/*
 Copyright (c) 2008  Wise Owl Technology Ltd.
 All Rights Reserved.
*/
function common()
{$("img.travelSite").click(fixIeImgLabelBug);$("#tellMeMore").click(tellMeMorePopup);setupCommonHideShow();setupCluetip();clearFilteredSites();}
function filterResponse(responseText,statusText){if(responseText.length!=0)
{if($.trim(responseText)=="invalidLoc")
{return;}
var optArray=new Array();optArray=responseText.split(";");var showOptDiv=false;var optPresent=false;for(var i=0;i<optArray.length;i++)
{if(optArray[i].length!=0)
{var optName=new Array();optName=optArray[i].split("^");if(optName.length!=4)
{alert("Invalid filter response returned by server: "
+optName.length+" "+responseText);continue;}
var rc=filterOptionalSite(optName[0],optName[1],optName[2],optName[3]);if(rc=="notOpt")
{continue;}
else
{optPresent=true;if(rc=="showOpt")
{showOptDiv=true;}}}}
if(showOptDiv)
{$("#optionalSitesDiv").show();}
else if(optPresent)
{$("#optionalSitesDiv").hide();}}}
function filterOptionalSite(site,directive,text,checked)
{var id="#"+$.trim(site.replace(/\./g,""));var div=$(id).parent("div");if(directive==="hide")
{if(div.hasClass("optional"))
{if(!div.hasClass("hidden"))
{div.addClass("hidden");if($(id).attr('checked'))
{$(id).removeAttr('checked');}}
return"hideOpt";}
makeUnselectable(div,text);return"notOpt";}
else
{if(div.hasClass("optional"))
{if(div.hasClass("hidden"))
{div.removeClass("hidden");if(checked=="true")
{$(id).attr('checked','checked');}}
return"showOpt";}
makeSelectable(div);return"notOpt";}}
function makeSelectable(div)
{affCb=div.children("input");affImg=div.find("img");if(affImg.hasClass("siteNotSelectable"))
{affImg.removeClass("siteNotSelectable");affCb.removeAttr('disabled');id="#ctExtra-"+affCb.attr('id');$(id).hide();}}
function makeUnselectable(div,text)
{affCb=div.children("input");affImg=div.find("img");if(!affImg.hasClass("siteNotSelectable"))
{affImg.addClass("siteNotSelectable");affCb.attr('disabled','disabled');if(affCb.attr('checked'))
{affCb.removeAttr('checked');}}
id="#ctExtra-"+affCb.attr('id');$(id).text(text).show();}
function setupCommonHideShow()
{hideShowMoreOptions();$("#moreOptionsLink").click(function(){$("#moreOptions").attr('checked','checked');hideShowMoreOptions();return false;});$("#fewerOptionsLink").click(function(){$("#moreOptions").removeAttr('checked');hideShowMoreOptions();return false;});hideShowMoreSites();$("#moreSitesLink").click(function(){$("#moreSites").attr('checked','checked');hideShowMoreSites();return false;});$("#fewerSitesLink").click(function(){$("#moreSites").removeAttr('checked');hideShowMoreSites();return false;});}
function hideShowMoreOptions()
{if($('#moreOptions').attr('checked'))
{$("#moreOptionsDiv").hide();$('#additionalOptionsDiv').show();}
else
{$("#moreOptionsDiv").show();$('#additionalOptionsDiv').hide();}}
function hideShowMoreSites()
{if($("div.additional").size()==0)
{$("#moreSitesDiv").hide();$('#additionalSitesDiv').hide();return;}
if($('#moreSites').attr('checked'))
{$("#moreSitesDiv").hide();$('#additionalSitesDiv').show();}
else
{$("#moreSitesDiv").show();$('#additionalSitesDiv').hide();}}
function setupCluetip()
{$('img.travelSite').cluetip({hoverIntent:{sensitivity:3,interval:500,timeout:50},local:true,arrows:true,cursor:'pointer'});}
function fixIeImgLabelBug()
{if(document.all&&navigator.appVersion.indexOf("MSIE")>-1&&navigator.appVersion.indexOf("Windows")>-1)
{var $imgInput=$(this).parent().prev("input");if($imgInput.attr('checked'))
{$imgInput.removeAttr('checked');}
else
{$imgInput.attr('checked','checked');}}}
function tellMeMorePopup()
{var text="<div id='tellMeMoreDiv'>";text+="<h1>What does this site do?</h1>";text+="<p>WiseTravelSearch simplifies the task of finding the best travel deal for the best price:</p>";text+="<ol>";text+="<li>Enter your travel information just once</li>";text+="<li>Select which sites you want to search (or search them all)</li>";text+="<li>Click search... your selected travel sites will be searched (a new window will open for each site that you have selected).</li>";text+="</ol>";text+="<p>This saves you the repetitive task of entering (and re-entering) your travel search details multiple times.  Want to make a change?  Change your travel details, and update your search at multiple travel sites with one easy click.  See our <a href='/Info/faq.php'>FAQ</a> for further details.</p>";text+="</div>";$.prompt(text).children('#jqi').corner();return false;}
function clearFilteredSites()
{$("input.sites").each(function(){if($(this).attr('disabled'))
{$(this).removeAttr('disabled');}});}
function loadBannerAds(cookieName)
{$(".popupWarning").hide();if(isIndCookieSet(cookieName))
{$("#recentSearchesDiv").show();}
else
{$("#recentSearchesDiv").hide();}}
