﻿var clickedControl;
function callfireCallBack(control, tourCode)
{
var theObjsrc=control.innerHTML.toLowerCase();
 if (theObjsrc.indexOf('add') > -1) {
 control.innerHTML='Remove from MyTourabout';
     fireCallBack(control, 'AddMyHoliday', tourCode);
    } 
 else {
 control.innerHTML='Add to MyTourabout';
     fireCallBack(control, 'DeleteMyHoliday', tourCode);
}
} 
function fireCallBack(control, Action, tourCode)
{
Cbo4.DoCallBack(control.id + '|' + Action  , tourCode, '/components/AJAX/AjaxHandler.aspx', false);
} 
var Cbo4 = new CallBackObject();
Cbo4.OnComplete = Cbo_Complete;
Cbo4.OnError    = Cbo_Error;
function Cbo_Complete(responseText, responseXML)
{
var str = responseText; 
var payload = responseText.split(':'); 
var sSideBarText = payload[6]; 
if (str != '')
{
if (payload[1]=='HTML') {
} else {
if (payload[4]=='TRUE') {
//var replaceImage=document.getElementById(payload[0]);
//if (replaceImage) {
//replaceImage.src=payload[5];
// } 
if (document.getElementById('ctl00_CHdr1_lnkTours')) {
if (payload[1]>'0') 
document.getElementById('ctl00_CHdr1_lnkTours').innerHTML='My Shortlist (' + payload[1] + ')';
else 
document.getElementById('ctl00_CHdr1_lnkTours').innerHTML='My Shortlist';
} 
 else 
{ 
if (document.getElementById('cHdr_lnkTours')) {
if (payload[1]>'0') 
document.getElementById('cHdr_lnkTours').innerHTML='My Shortlist (' + payload[1] + ')';
else 
document.getElementById('cHdr_lnkTours').innerHTML='My Shortlist';
} 
} 
if (document.getElementById('ctl00_SideBar_ctl01_lblMyShortList')) {
if (payload[6]!='') 
document.getElementById('ctl00_SideBar_ctl01_lblMyShortList').innerHTML=payload[6];
} 
if (document.getElementById('ctl01_lblMyShortList')) {
if (payload[6]!='') 
document.getElementById('ctl01_lblMyShortList').innerHTML=payload[6];
} 
} 
} 
} 
}
function Cbo_Error(status, statusText, responseText)
{
alert(statusText);
alert(responseText);
}

function getTStamp(){
var currentTime = new Date()
var tstamp = null;
tstamp =  'T' + currentTime.getHours() + currentTime.getMinutes() + currentTime.getSeconds();  
return tstamp;
}
 


function popMoreWindow(sPayload){
var TourWin = null;
TourWin = window.open('/transfer.aspx?pld=' + sPayload ,'TourWin' + getTStamp(),'width=850,height=550,left=100,top=60,status=1, menubar=1, navigation=1, toolbar=1, scrollbars=1, resizable=1, location=1');
if (TourWin && !TourWin.closed) TourWin.focus(); 
TourWin.focus(); 
}

function popSupplierContacts(sPayload){
var SupplierContact = null;
SupplierContact = window.open('/suppliercontact.aspx?pld=' + sPayload ,'SupplierContact' + getTStamp(),'width=850,height=550,left=100,top=60,status=1, menubar=1, navigation=1, toolbar=1, scrollbars=1, resizable=1, location=1');
if (SupplierContact && !SupplierContact.closed) SupplierContact.focus(); 
SupplierContact.focus(); 
}

function popEmailSupplier(sPayload){
var EmailSupplier = null;
EmailSupplier = window.open('/emailsupplier.aspx?pld=' + sPayload ,'EmailSupplier' + getTStamp(),'width=850,height=550,left=100,top=60,status=1, menubar=1, navigation=1, toolbar=1, scrollbars=1, resizable=1, location=1');
if (EmailSupplier && !EmailSupplier.closed) EmailSupplier.focus(); 
EmailSupplier.focus(); 
}

function popAgentQuote(sPayload){
var AgentQuote = null;
AgentQuote = window.open('/agentquote.aspx?pld=' + sPayload ,'AgentQuote' + getTStamp(),'width=850,height=550,left=100,top=60,status=1, menubar=1, navigation=1, toolbar=1, scrollbars=1, resizable=1, location=1');
if (AgentQuote && !AgentQuote.closed) AgentQuote.focus(); 
AgentQuote.focus(); 
}
 

function popMapWindow(Payload){
htmlstring = "<html><head><title>Map</title>" +
"</head><body style='margin: 0px; padding: 0px;'>" +
"<div id='imagediv' style='BORDER:#9999cc 1px solid; PADDING: 4px; BACKGROUND-COLOR: #ebebf7\'>" + 
"<a href='javascript:void(0)'  onclick=\"popMoreWindow('" + Payload + "')\" ><img SRC='/components/MapImage.aspx?pl=" + Payload + "' BORDER=0 NAME=image " +
" title='Click map to go to supplier website' onload=\"window.resizeTo(document.image.width+20, document.image.height+84);imagediv.width=document.image.width+20;imagediv.height=document.image.height+20;\">" +
"</a> " + 
"<br /> " + 
"</" + 
"div>" + 
"<script type='text/javascript'>" + 
"function popMoreWindow(sPayload){" + 
"var TourWin = null;" + 
"TourWin = window.open('/transfer.aspx?pld=' + sPayload ,'TourWin','width=850,height=550,left=100,top=60,status=1, menubar=1, navigation=1, toolbar=1, scrollbars=1, resizable=1, location=1');" + 
"window.opener.focus(); " + 
"window.close(); " + 
"if (TourWin && !TourWin.closed) TourWin.focus(); " + 
"TourWin.focus(); " + 
"}" + 
"</" + 
"script>" + 
"</BODY></html>";
popup = window.open
('','image','left=100,top=60,width=1,height=1,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
popup.document.open();
popup.document.write(htmlstring);
popup.focus();
//popup.close()
}

var clickedControl;
function fireRelevancyCallBack(controlid, tourCode)
{
if (document.getElementById(controlid + '_DIVrelevancy')) 
{
if (document.getElementById(controlid + '_lblRelevancy')) {
document.getElementById(controlid + '_lblRelevancy').innerHTML='Getting details...';
var replaceImage=document.getElementById(controlid + '_imgRelevancy');
if (replaceImage) {
replaceImage.src='/i/spinner.gif';
} 
document.getElementById(controlid + '_DIVrelevancy').style.display="";
} 
 fireCallBackRelevancy(controlid + '_lnkRelevancyDetail', 'getRelevancyDetails', tourCode);
} 
} 
function fireCallBackRelevancy(controlid, Action, tourCode)
{
Cbo5.DoCallBack(controlid + '|' + Action  , tourCode, '/components/AJAX/AjaxHandler.aspx', false);
} 
var Cbo5 = new CallBackObject();
Cbo5.OnComplete = Cbo_Complete2;
Cbo5.OnError    = Cbo_Error2;
function Cbo_Complete2(responseText, responseXML)
{
var str = responseText; 
if (str != '')
{
var payload = str.split('|'); 
var controlid = payload[0]; 
var textstr = payload[1]; 
if (document.getElementById(controlid + '_DIVrelevancy')) 
{
if (document.getElementById(controlid + '_lblRelevancy')) {
document.getElementById(controlid + '_lblRelevancy').innerHTML=textstr;
var replaceImage=document.getElementById(controlid + '_imgRelevancy');
if (replaceImage) {
replaceImage.src='/i/pad.gif';
} 
} 
} 
} 
}
function Cbo_Error2(status, statusText, responseText)
{
alert(statusText);
alert(responseText);
}

function popAboutSupplierDiv(BrandID){
var DivName='DivAbout' + BrandID;
if (document.getElementById(DivName))
{
document.getElementById(DivName).style.display="";
center(DivName);
}
}
function hideAboutSupplierDiv(BrandID){
var DivName='DivAbout' + BrandID;
if (document.getElementById(DivName))
{
document.getElementById(DivName).style.display="none";
}
}


function pl(index, iButton){
var payload=plarr[index];
if (iButton>-1)
 payload = payload + '|' + plbarr[iButton]; 
return payload;
}

function fbs_click(uloc, utitle) 
{
u=uloc;
t=utitle;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
