function popupShareSubmit()
{
var emailReg =  "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
var regex = new RegExp(emailReg);
var emailo = document.popupshareform.share_email.value.split(',');
var invalidemails="", validemails="";
var cnt = 0;
for (k=0; k<emailo.length; k++)
{
emailo[k] = emailo[k].replace(/^\s+|\s+$|\r|\n|\r\n/g,"");
if (!regex.test(emailo[k]))
{
if (invalidemails!="") invalidemails += ", ";
invalidemails += emailo[k];
}
else
{
if (validemails!="") validemails += ",";
validemails += emailo[k];
cnt++;
}
}
if (invalidemails!="")
{
alert("Invalid Email:\r\n" + invalidemails);
return false;
}
else if (cnt==0)
{
alert("Please enter email address.");
return false;
}
else if (cnt>15)
{
alert("You can send up to 15 emails at a time, but you have entered" + cnt + "");
return false;
}
else
{
xlocationmenu.onClose();
var obj = xGetElementById("popupsharetable");
if (obj) obj.style.display="none";
obj = xGetElementById("popupsharewait");
obj.style.display="block";
xlocationmenu.onOpen(xWidth(xGetElementById("tb001")), xHeight(xGetElementById("tb001")), xlocationmenu.triggerObj(), xlocationmenu.getCurrentDisp());
var query = "s=" + document.popupshareform.sessionid.value +
(document.popupshareform.sid!=null ? "&i=" + document.popupshareform.sid.value : "&ti=" + document.popupshareform.ti.value) +
"&e=" + encodeURIComponent(validemails) +
"&c=" + encodeURIComponent(document.popupshareform.share_message.value) +
"&t=" + document.popupshareform.t.value +
"&u=" + document.popupshareform.u.value +
"&cc=" + (document.popupshareform.email_copy.checked ? "Y" : "N");
makeRequest('/com/share.jsp', shareHandler, query);
}
}
function showShareForm()
{
xlocationmenu.onClose();
var obj = xGetElementById("popupsharetable");
if (obj) obj.style.display="block";
obj = xGetElementById("popupsharewait");
obj.style.display="none";
xlocationmenu.onOpen(xWidth(xGetElementById("tb001")), xHeight(xGetElementById("tb001")), xlocationmenu.triggerObj(), xlocationmenu.getCurrentDisp());
}
function shareHandler()
{
try
{
if (ajax_abort || http_request.readyState == 4)
{
xlocationmenu.onClose();
var obj = xGetElementById("popupsharewait");
if(!ajax_abort && http_request.status == 200)
{
if(http_request.responseText != null)
{
obj.innerHTML = http_request.responseText;
return;
}
}
obj.innerHTML = "Cannot execute request, please try again later. <a href=\"javascript:showShareForm(); void(0);\">Back</a>";
}
}
finally
{
xlocationmenu.onOpen(xWidth(xGetElementById("tb001")), xHeight(xGetElementById("tb001")), xlocationmenu.triggerObj(), xlocationmenu.getCurrentDisp());
http_request = null;
}
}
function publishFBSpot(parent_folder_path, spot_guid, pids)
{
var link = "http://www.otineri.com/sv/" + spot_guid;
var ary = new Array();
for (var k=1; k<=3; k++)
{
if (pids.indexOf(k)!=-1)
{
var o = new Object();
o.src = "http://www.otineri.com/user/" + parent_folder_path + "/s_" + k + ".jpg";
o.href = link;
ary[ary.length] = o;
}
}
FB.Connect.showFeedDialog(227985045303, {"images": ary, "o_type":"<a href=\"" + link + "\" target=\"_blank\">" + xGetElementById("share_title" + spot_guid).innerHTML + "</a>", "o_title":"<a href=\"" + link + "\" target=\"_blank\">" + xGetElementById("share_title" + spot_guid).innerHTML + "</a>", "o_content":xGetElementById("spotname_viewer" + spot_guid).innerHTML + ": " + xGetElementById("spot_country_name" + spot_guid).innerHTML + getSpotContentLead(link, spot_guid)}, null, null, null, FB.RequireConnect.promptConnect, function(){xlocationmenu.onClose();});
}
function getSpotContentLead(link, spot_guid)
{
var o = xGetElementById("spot_exp" + spot_guid);
var o2 = xGetElementById("spot_desc" + spot_guid);
var content="";
if (o!=null)
{
content = o.innerHTML;
}
if (o2!=null)
{
content += " " + o2.innerHTML;
}
if (content=="")
{
o = xGetElementById("spot_exp" + spot_guid + "_span");
o2 = xGetElementById("spot_desc" + spot_guid + "_span");
if (o!=null)
{
content = o.innerHTML;
}
if (o2!=null)
{
content += " " + o2.innerHTML;
}
}
content.replace("/\r\n/g", " ").replace("/\n/g", " ").replace("\"", "&quot;");
if (content.length>100) content = content.substring(0, 100) + "... ";
content += "<a href=\"" + link + "\" target=\"_blank\">more[+]</a>" ;
if (content!="") content = "<br><br>" + content;
return content;
}
function publishFBTrip(parent_folder_path, trip_guid, has_photo)
{
var link = "http://www.otineri.com/tv/" + trip_guid;
var ary = new Array();
if (has_photo)
{
var o = new Object();
o.src = "http://www.otineri.com/user/" + parent_folder_path + "/1.jpg";
o.href = link;
ary[ary.length] = o;
}
FB.Connect.showFeedDialog(227985045303, {"images": ary, "o_type":"<a href=\"" + link + "\" target=\"_blank\">" + xGetElementById("share_title").innerHTML + "</a>", "o_title":"<a href=\"" + link + "\" target=\"_blank\">" + xGetElementById("share_title").innerHTML + "</a>", "o_content":xGetElementById("trip_loc_name").innerHTML + getTripContentLead(link)}, null, null, null, FB.RequireConnect.promptConnect);
}
function getTripContentLead(link)
{
var o = xGetElementById("myexp_txt");
var content="";
if (o!=null)
{
content = o.innerHTML;
}
content.replace("/\r\n/g", " ").replace("/\n/g", " ").replace("\"", "&quot;");
if (content.length>100) content = content.substring(0, 100) + "... ";
content += "<a href=\"" + link + "\" target=\"_blank\">more[+]</a>" ;
if (content!="") content = "<br><br>" + content;
return content;
}