function onsubmitSearchField(id){
	if (document.getElementById(id).value == 'Enter Destination'){
		document.getElementById(id).value = '';
	}
}

function onclickSearchField(id){
	if ($("#"+id).val() == 'Enter Destination')$("#"+id).val('');
	$("#"+id).css('color','#000000');
}

function onblurSearchField(id){

	if ($("#"+id).val() == '') $("#"+id).val('Enter Destination');
	if ($("#"+id).val() == 'Enter Destination') $("#"+id).css('color','#808080');

}

function onloadSearchField(id){
	if ($("#"+id).val() != 'Enter Destination') $("#"+id).css('color','#000000');
}

function emailSignupRedirect(newsletter_str){

	var expiredays=7;
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	var cookie_val="newsletters=-"+newsletter_str+";expires="+(exdate.toUTCString())+";path=/";
	document.cookie=cookie_val;
	window.location.href='/LL/email_signup_thankyou.php';
	return;

}

function get_element_by_id(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	}
	else if (document.all) {
		return document.all[id];
	}
	else if (document.layers) {
		return document.layers[id];
	}
}

function gebi(id) {
	if (document.getElementById) {
		return document.getElementById(id);
	}
	else if (document.all) {
		return document.all[id];
	}
	else if (document.layers) {
		return document.layers[id];
	}
}

function change_style(id, element, value) {
	if (document.getElementById) {
		document.getElementById(id).style[element] = value;
	}
	else if (document.all) {
		document.all[id].style[element] = value;
	}
	else if (document.layers) {
		document.layers[id].style[element] = value;
	}
}

function get_style(id, element) {
	if (document.getElementById) {
		return document.getElementById(id).style[element];
	}
	else if (document.all) {
		return document.all[id].style[element];
	}
	else if (document.layers) {
		return document.layers[id].style[element];
	}
}

function get_scroll_height() {
	if (document.compatMode && document.compatMode != "BackCompat") {
	   return document.documentElement.scrollHeight;
	} else {
	   return document.body.scrollHeight;
	}
}

function get_scroll_width() {
	if (document.compatMode && document.compatMode != "BackCompat") {
	   return document.documentElement.scrollWidth;
	} else {
	   return document.body.scrollWidth;
	}
}

function get_body_property(property) {
	if (document.compatMode && document.compatMode != "BackCompat") {
	   return document.documentElement[property];
	} else {
	   return document.body.scrollTop[property];
	}
}

function center_floating_div(id) {
	var div = get_element_by_id(id);
	var div_width = div.offsetWidth;
	var div_height = div.offsetHeight;
	var dim = get_browser_height();
	var new_left = (dim.width - div_width) / 2;
	var new_top = (dim.height - div_height) / 2;
	change_style(id, 'left', parseInt(new_left + get_body_property('scrollLeft')) + 'px');
	change_style(id, 'top', parseInt(new_top + get_body_property('scrollTop')) + 'px');
}

function get_browser_height() {
	var intH = 0;
	var intW = 0;
	if (typeof window.innerWidth  == 'number') {
		intH = window.innerHeight;
		intW = window.innerWidth;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		intH = document.documentElement.clientHeight;
		intW = document.documentElement.clientWidth;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		intH = document.body.clientHeight;
		intW = document.body.clientWidth;
	}
	return {width: parseInt(intW), height: parseInt(intH)};
}

function toggle_collapse(id) {
	if (get_style(id, 'display') == 'none') {
		change_style(id, 'display', '');
	} else {
		change_style(id, 'display', 'none');
	}
}

function fade_in(elementId) {
	change_opacity(gebi(elementId), 0);
	change_style(elementId, 'display', '');
	
	var this_obj = this;
	var fadeTimer1 = new Array(), opacity1, delay;
	for (var i = 1; i <= 100; i++) {
		opacity1 = parseInt(i);
		delay = parseInt(i*15);
		fadeTimer1[i] = setTimeout('change_opacity(gebi("' + elementId + '"), ' + opacity1 + ')', delay);
	}
	// fadeTimer1[i] = setTimeout(function(){change_style(fromId, 'display', 'none'); this_obj.mClickable=true; this_obj.Debug();}, delay + 1);
}

function change_opacity(object, opacity) {
	object = object.style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")"; 
}

var xmlHttp;

function executeAjax(file_name, state_change_func) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url = file_name;
	
	xmlHttp.onreadystatechange = state_change_func;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {xmlHttp=new XMLHttpRequest();}
	catch (e){ 
		try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e){ 
			xmlHttp=new
			ActiveXObject("Microsoft.XMLHTTP");
	    }
	}
	return xmlHttp;
}

function is_valid_email(str) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,10})$/;
	if(reg.test(str) == false) {
		return false;
	} else {
		return true;
	}
}

function validate_email(id) {
	var email = gebi(id).value;
	if (!is_valid_email(email)) {
		alert('The email address you have provided is invalid.');
        return false;
	}
}

function getEmailRegex(){

	var re = /^([a-zA-Z0-9_\-\+])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/
	return re;

}

//this is one of several email validation scripts. which one to keep?
function validateEmailForm() {
	var frm = document.email_signup;

	// Check E-mail ----------------------------------------------------
	if (frm.email_insert.value == "")	{
		alert ("Email is a required field. Please enter your email.");
		frm.email_insert.focus();
		return false;
	}
	var str = frm.email_insert.value;
	var re = /^\w+.+@\w+(\.\w+)+$/;
	var re = getEmailRegex();
	//var re = /^([a-zA-Z0-9_\-\+])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$/
	if (str != "") {
		if (!re.test(str)) {
			//alert("" + str + " is an invalid email address. Please enter a valid format.");
            alert("Please enter a valid email address");
			frm.email_insert.select();
			frm.email_insert.focus();
			return false;
		}
	}
	//------------------------------------------------------------------
	
	frm.submit();
}

function window_open(link_url, window_name, window_width, window_height, scrollbar) {
	var pref = "width=" + window_width + ",height=" + window_height + ",scrollbars=" + scrollbar;
	new_window = window.open(link_url, window_name, pref);
	if (window.focus) {
		new_window.focus();
	}
}

function clearInput(f, val) {
	if (f.value == val) {
		f.value = '';
	}
}

//form validation function for all fields in login form
function validateForm() {
	var frm = document.mylogin;

	if (frm.user.value == "") {
		alert ("You must enter a username to log in.");
		frm.form_username.focus();
		return false;
	}

	if (frm.pass.value == "") {
		alert ("You must enter a password to log in.");
		frm.pass.focus();
		return false;
	}
	frm.submit();
}

// for kid approved module -- scrolling
var kid_total = 4;
var kid_previous = 0;
var kid_current = 0;
var kid_timer;
var kid_tabs = new Array('babies', 'toddlers', 'school', 'teens');

function kid_scroll() {
	$("div.kid_approved li.off").removeClass("hide");
	$("div.kid_approved li.on, div.kid_approved div").addClass("hide");
	kid_current = (kid_current >= kid_total - 1) ? 0 : ++kid_current;
	$("div.kid_approved li." + kid_tabs[kid_current]).addClass("hide");
	$("div.kid_approved li." + kid_tabs[kid_current] +"On, div.kid_approved div." + kid_tabs[kid_current]).removeClass("hide");
	kid_previous = kid_current;
	kid_timer = setTimeout('kid_scroll()', 5000);
}
function kid_start_scroll() {
	kid_timer = setTimeout('kid_scroll()', 2000);
}
function kid_pause() {
	clearTimeout(kid_timer);
}

function doubleclickCheckTextAds(adContainer) {
    var adCount = 0;
    var topClassNeeded = true;
    var ads = $(adContainer).find('div.textads_right_ad');
    for (var i = 0; i < ads.length; i++) {
	var thisAd = ads[i];
	// empty first link means it's off at doubleclick
	//if ($(thisAd).find('a:first').text() == '') {
	if (doubleclickTextAdIsEmpty(thisAd)) {
	    $(thisAd).hide();
	} else {
	    // remove top border on first link 
	    if (topClassNeeded) {
		$(thisAd).addClass('textads_right_ad_top');
		topClassNeeded = false;
	    }
	    adCount++;
	}
    }
    // show text ad container
    if (adCount > 0) {
	$(adContainer).show();
    }
}

function doubleclickTextAdIsEmpty(adDiv) {
    if ($(adDiv).find('a:first').text() == '') {
	return true;
    } else {
	return false;
    }
}

//cookies for page views and overlay pop up

function usetCookie(c_name,value,exdays) {
    //alert("usetCookie called with: " + c_name + " / " + value + " / " + exdays);
    var exdate=new Date();
    //exdate.setDate(exdate.getDate() + (exdays * 24 * 60 * 60 * 1000));
    exdate.setDate(exdate.getDate() + (exdays));
    var thishost = location.hostname;
    //var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()+ "; path=/; domain=" + thishost.substring(thishost.lastIndexOf(".",(thishost.length-5)),thishost.length) + ";");
    var v = 
            c_name + "=" +
            value +
            
            (
            exdays ?
              (
              "; expires=" + 
              exdate.toGMTString()              
               ) : ""
            )
            +
            "; path=/; domain=" +
             thishost.substring(thishost.lastIndexOf(".",(thishost.length-5)),thishost.length)
             + ";"
            ;

    //alert("setting cookie: " + v);
    document.cookie=v;
}

function getCookie(c_name) {
    var cc,ARRcookies=document.cookie.split("; ");
    var answer = null;
    for (cc=0;(cc<ARRcookies.length) && !answer;cc++) {
        var arr_kvpair = ARRcookies[cc].split("=");
        if (c_name == arr_kvpair[0]) {
            answer = window.decodeURIComponent(arr_kvpair[1]);
        } else {
            answer = null;
        }
    }//loop thru cookies
    return answer;
}//getCookie

function checkCookie() {

    var newsletterscookie = getCookie("newsletters");
    var newsletter_overlay_viewed=getCookie("newsletteroverlayviewed");    
    var page_viewed=getCookie("pagebrowsed");
    //var show_subscriber_overlay=getCookie("showsubscriberoverlay");

    //if (newsletter_overlay_viewed==null && newsletter_overlay_viewed=="") {
    
    if (!newsletterscookie) {        
    if (!newsletter_overlay_viewed || isNaN(parseInt(newsletter_overlay_viewed))) {    
        if (!page_viewed || isNaN(parseInt(page_viewed))) {
            //alert("i am not a number!!");
            usetCookie("pagebrowsed",1,1);             
        } else {            
            usetCookie("pagebrowsed",parseInt(page_viewed)+1,1);                             
        }
    }
	}//if newsletterscookie
            
            
} 
            
    //}
    
   
//}
//
////------------------------------------------------------
//// JQuery Onload scripts
////------------------------------------------------------
//
//
$(document).ready(function(){

	$('#link-question').hover(
		function () {
			 $('#question-div').show();
		},
		function () {
			$('#question-div').hide();
		}
	); 

  if (location.protocol.indexOf("https") == -1) {
  	checkCookie();
  }
    
	$('.openHelp').live('click', function() {
		var helpwindow = window.open('/LL/home_help.php','helpwindow','width=680,height=530,resizable=0');
		helpwindow.focus();
	});
    
    $('img#llTab').hover(function() {
        $(this).attr('src', '/images/shared/site_tabs/tab_ll_over.gif'); 
        },
        function() {
            $(this).attr('src', '/images/shared/site_tabs/tab_ll_off.gif');
        }
    ); 
    
    $('img#vacationistTab').hover(function() {
        $(this).attr('src', '/images/shared/site_tabs/vac_over.gif'); 
        },
        function() {
            $(this).attr('src', '/images/shared/site_tabs/vac.gif');
        }
    ); 	
    
	// Kid-Approved JS -- move to module-specific file if necessary to speed up load time
	function kidClickAll() {
		$("div.kid_approved li.off").removeClass("hide");
		$("div.kid_approved li.on, div.kid_approved div").addClass("hide");
	}
	if ($("div.kid_approved")) {
		$("div.kid_approved li.babies a").click(function(){
			kidClickAll();
			kid_pause();
			$("div.kid_approved li.babies").addClass("hide");
			$("div.kid_approved li.babiesOn, div.kid_approved div.babies").removeClass("hide");
			return false;
		});

		$("div.kid_approved li.toddlers a").click(function(){
			kidClickAll();
			kid_pause();
			$("div.kid_approved li.toddlers").addClass("hide");
			$("div.kid_approved li.toddlersOn, div.kid_approved div.toddlers").removeClass("hide");
			return false;
		});

		$("div.kid_approved li.school a").click(function(){
			kidClickAll();
			kid_pause();
			$("div.kid_approved li.school").addClass("hide");
			$("div.kid_approved li.schoolOn, div.kid_approved div.school").removeClass("hide");
			return false;
		});

		$("div.kid_approved li.teens a").click(function(){
			kidClickAll();
			kid_pause();
			$("div.kid_approved li.teens").addClass("hide");
			$("div.kid_approved li.teensOn, div.kid_approved div.teens").removeClass("hide");
			return false;
		});
		kid_start_scroll();
	}  
	
    	  
});

// 2011-10-10 event tracking + lltg framework
/*
	Compress with:
	http://closure-compiler.appspot.com/home
*/
var i=null;
(function(c){function I(){z("$",function(){f&&alert("Registering clients handler");c.$(document).ready(function(){var a="default";for(t in j){var b=j[t];if(b[0]&&A.match(b[0])||b[4]&&b[4]()){a=t;break}}f&&alert("This page is a: "+a);p=a;b=j[p][3]();b.ids?(a=q(b.ids),b=q(b.names),f&&alert("Found 2 client batches: \n"+a+"\n"+b),m(a),m(b)):(a=q(b),f&&alert("Found clients: "+a+" - logging impressions"),m(a))})})}function z(a,b){c[a]?b&&typeof b==="function"?b.apply():b?eval(b):c[a].apply():c.setTimeout(function(){LL.w(a,
b)},5);return g}function q(a){var b=[];for(k in a)b.push(k);return b}function r(a){var b=c.document.cookie.split("; "),d=null,s,e;for(s=0;b&&!d&&b[s]&&(e=b[s].split("="));s++){var f=e[1];a===e[0]&&(d=f)}return d}function B(a,b){document.cookie=a+"="+b+"; path=/; domain="+J;return g}function K(a){return u(a,1,i)}function L(a){return u(a,null,null)}function u(a,b,d){var b=b===1?{tag:"link",rel:"stylesheet",type:"text/css",href:a}:{tag:"script",type:"text/javascript",src:a},a=c.document.createElement(b.tag),f;for(f in b)f!==
"tag"&&a.setAttribute(f,b[f]);d?d.insertBefore(a,d.firstChild):(d=c.document.getElementsByTagName("script")[0],d.parentNode.insertBefore(a,d));return g}function C(a){return function(b){M.apply(c,[b,a])}}function M(a,b){for(var d=a?a:c.event,d=d.srcElement?d.srcElement:d.target?d.target:d.currentTarget;d;){var g=d.className?d.className.split(" "):null,e;if(g)for(var h=0;e=g[h];h++)e.indexOf(b+"track")!==-1?(e=e.split(b+"track_")[1].split("|"),v(b.toUpperCase(),e[0],e[1]),b==="click"&&e[0]==="client"&&
e[1].match(/^[^_]+$/gi)&&D([e[1]],false)):b==="click"&&e.indexOf("converttrack")!==-1&&(e=e.split("converttrack_")[1].split("|"),B("lltg-clickconvert",e[0]+"|"+e[1]),f&&alert("convert-track: "+r("lltg-clickconvert")));d=d.parentNode}}function m(a){D(a,true);return g}function D(a,b){f&&alert("logging event: "+a+": "+(b?"IMPRESSION":"CLICK"));if(a&&a.length>0){var c="/t/hpr.php?"+(!isNaN(parseInt(a[0],10))?N?"vci":"ci":"cn")+"="+E(a.join("|"))+"&e="+E(j[p][b?2:1]);f&&alert("requesting: "+c);(new Image(1,
1)).src=c}}function E(a){return c.encodeURIComponent?c.encodeURIComponent(a):escape(a)}function v(a,b,d){a=["_trackEvent",a+"_"+b,d,n+" | "+c.document.referrer];f&&alert("evt: "+a);c._gaq&&c._gaq.push&&c._gaq.push(a);return g}function w(a,b,c){a.addEventListener?a.addEventListener(b,c,false):a.attachEvent&&a.attachEvent("on"+b,c);return g}function F(a,b){c.LL[a]||(c.LL[a]=b);return g}function o(a){return a&&(a.substring(a.indexOf(l)+l.length).match(j.pdp[0])||a.indexOf("clid=")!==-1)}function x(a){var b=
this.href.split("/"),b=b[b.length-1],c=b.indexOf("?");(b=c!==-1?b.substring(0,c):b)&&y(this,a,b)}function G(a){var b=parseInt(this.href.split("/id/")[1],10);isNaN(b)||y(this,a,b)}function h(a){var b=parseInt(this.href?this.href.split("clid=")[1]:this.content?this.content.split("clid=")[1]:null,10);isNaN(b)||y(this,a,b)}function y(a,b,d){b[d]=true;b="clicktrack_client|"+d;c.$(a).hasClass(b)||c.$(a).addClass(b)}c.LL||(c.LL={});var n=c.location.href,l=c.location.hostname,A=c.location.pathname,J=l.substring(l.lastIndexOf(".",
l.length-5)),N=l.indexOf("vacationist")!==-1,f=n.indexOf("isdebug")!==-1,H={fp_confirm:"fixed-price-confirm",fp_review:"fixed-price-complete",auc_confirm_bid:"auction-bid-confirm",auc_bid_complete:"auction-bid-complete"},j={home:[/^(\/|\/\?.*)$/gi,35,41,function(){var a={};c.$&&(c.$("#leftBox a").each(function(){h.apply(this,[a])}),c.$("#rightBox a").each(function(){h.apply(this,[a])}));return a}],listings:[/^\/(fivestar|vacations)\/(deals|hotel-deals).*$/gi,36,42,function(){var a={};c.$&&c.$("#listing_properties a").each(function(){o(this.href)&&
x.apply(this,[a])});return a},function(){return!A.match(j.proptypes[0])&&c.$("#listing_properties a.property_name").length>0}],"listings-vcom":[/^\/membersonly\/?\??[^\/]*$/gi,36,42,function(){var a={};c.$&&(c.$("#content dl.sale p.prop-visit a").each(function(){G.apply(this,[a])}),c.$("#list-sale-bar-comming li a").each(function(){G.apply(this,[a])}));return a}],destination:[/^\/fivestar\/[^\/]+\/(hotels|hotel-guide|articles|itineraries|attractions|photos).*$/gi,37,43,function(){var a={ids:{},names:{}};
if(c.$){c.$("div.bestsellers ul li a").each(function(){o(this.href)&&h.apply(this,[a.ids])});var b=function(){o(this.href)&&x.apply(this,[a.names])};c.$("div.containerContentLeft ul li a").each(b);c.$("div.containerContentRight ul li a").each(b)}return a}],"destination-fg":[/^\/vacations\/[^\/]+$/gi,37,43,function(){var a={};c.$&&c.$("div.bestsellers ul li a").each(function(){h.apply(this,[a])});return a}],interests:[/^\/(vacation-ideas|fivestar)\/[^\/]+\/best$/gi,38,44,function(){var a={};c.$&&(c.$("table.marginBottomLarge tr td.bgLightSilver div div div a").each(function(){h.apply(this,
[a])}),c.$("table.topAlign tr td div div a").each(function(){h.apply(this,[a])}));return a}],proptypes:[/^\/(fivestar|vacation)\/[^\/]+\/deals$/gi,39,45,function(){var a={};c.$&&c.$("#listing_properties a").each(function(){o(this.href)&&x.apply(this,[a])});return a}],pdp:[/^\/(fivestar|vacation)\/(hotels|lodges|inn|all-inclusive-resorts|tour-packages|estates-villas)\/[^\/]*\/[^\/]+$/gi,40,46,function(){var a={};c.$&&c.$("meta[property='og:url']").each(function(){h.apply(this,[a])});return a}],"pdp-vcom":[/^\/(membersonly|visitors)\/hotels\/id.*$/gi,
40,46,function(){var a={};a[parseInt(n.split("/id/")[1],10)]=true;return a}],"default":[null,47,48,function(){return{}}]},p=null,g=c.LL;(function(){if(!c.LLFLoaded){c.LLFLoaded=1;for(var a in H)if(n.indexOf(a)!==-1){var b=r("lltg-clickconvert");b&&(b=b.split("|"),v("CLICK",b[0],b[1]+" | convert: "+H[a]))}I();a={lci:m,ssc:B,gcv:r,ls:L,lc:K,lr:u,w:z,extend:F,domreg:w,evt:v};for(k in a)F(k,a[k]);w(c.document,"click",C("click"));f&&(w(c.document,"mouseover",C("hover")),alert("done with init"))}})()})(window);


