
var curSearchType = 'Travel';

function searchType(obj,searchType){
   if(curSearchType != obj.id){
	if(searchType == 'search'){
    		var inputObj = document.createElement("input");
    		inputObj.setAttribute("type","hidden");
    		inputObj.setAttribute("name","invocationType");
    		inputObj.setAttribute("value","hdtravel");
    		inputObj.setAttribute("id","invocationType");
    		var invocationTypeFld = document.getElementById('invocationTypeFld');
    		invocationTypeFld.appendChild(inputObj);
    	}else{
    		var invocationTypeFld = document.getElementById('invocationTypeFld');
		var elmInvo = document.getElementById('invocationType');
		if (elmInvo != null){
			var ie6 = (navigator.appVersion.indexOf('MSIE')!=-1)?true:false;
			if(ie6){
				if(elmInvo.id == 'invocationType')
					invocationTypeFld.removeChild(document.getElementById('invocationType'));	
			}else{
                                invocationTypeFld.removeChild(document.getElementById('invocationType'));           

			}
		}
    	}
        if(obj.id == 'Travel'){
            document.searchForm.action = "/travel/DestinationGuideServlet";
	     document.searchForm.target = "_self";
        }else{
            document.searchForm.action = 'http://search.aol.com/aol/'+searchType;
	     document.searchForm.target = "_blank";
        }
        obj.className="srchType tab_sel";
        document.getElementById(curSearchType).className = "srchType tab_clr";
        curSearchType = obj.id;
    }
}



if (staticDomain === undefined) {
    var staticDomain = "";
}

function saveInput(obj){

}

function menu(obj,eve,e)
{
    //if the browser is IE <6.0
    if(document.all){
        for(i=0;i<obj.childNodes.length;i++){
            child = obj.childNodes[i]
            if(child.tagName == 'UL'){
                if(e == 1){
                    child.className="drop"
                    for(j=0;j<obj.childNodes.length;j++){
                        grandchild = child.childNodes[j]
                        if(grandchild.tagName == 'IFRAME'){
                            grandchild.style.height = (child.offsetHeight)-4+'px';
                            grandchild.style.width  = (child.offsetWidth)-4+'px';
                            return;
                        }
                    }
                }
                else if(e == 2){
                child.className="hide"
                return;
                }
            }
            else if(child.tagName == 'A'){
                if(e == 1){
                         child.style.cssText="background-color:#606F94;color:#FFF;"
                }
                else if(e == 2){
                         child.style.cssText="background-color:#FFF;color:#606F94;"
                }
            }
        }
    }
}

function moreOption(name){
	document.getElementById('moreOptions').className = name;
}

function checkforAolClient(){
	var is_aol = navigator.userAgent.toLowerCase().indexOf("aol") != -1;
	if(is_aol){
		document.getElementById('logoutBtn').style.display = "none";
	}
}

function userLogin(){
	var url = window.location.toString();
	var list =  escape(url);
	var startUrl = "/_cqr/login/login.psp?mcState=initialized&sitedomain=travel.aol.com&authLev=1&seamless=y&lang=en&locale=us&siteState=OrigUrl%3d";
	var finalUrl = snsURL+ startUrl +list;
	window.location.href = finalUrl;
}

function userLogout(){
	var url = window.location.toString();
	var list =  escape(url);
	var startUrl = "/_cqr/logout/mcLogout.psp?mcState=initialized&sitedomain=travel.aol.com&authLev=1&seamless=y&lang=en&locale=us&siteState=OrigUrl%3d";
	var finalUrl = snsURL+ startUrl +list;
	window.location.href = finalUrl;
}


function validateQuery(frm){
	document.searchForm.query.value = RTrim(document.searchForm.query.value);
    if(typeof frm == 'undefined')frm='';
    var val = document.searchForm.query.value;

    if(val == ''){
	if(curSearchType == 'Travel'){
		return;
	} else if(curSearchType == 'Local'){
		window.open('http://sbgw.search.aol.com/kw/exec?lookupType=11&sourceType=416&text=&q='+document.searchForm.query.value);
		return;
	}else{
		document.searchForm.submit();
	}
    } else {
    	createCookieObj('searchTermDG',document.searchForm.query.value,1);
       if(curSearchType == 'Local'){
            window.open('http://sbgw.search.aol.com/kw/exec?lookupType=11&sourceType=416&text=&q='+document.searchForm.query.value);
            return;
       }
        document.searchForm.submit();
    }
}


/*FOOTER VALIDATE*/
function validateSearch(frmObj){
	frmObj.query.value = RTrim(frmObj.query.value);
	if (frmObj.query.value == ""){
		//alert("No Search Term! Please enter some query term; Example New York, Paris");
	}
	else{
		frmObj.submit();
	}
}

// Trims all spaces to the right of a specific string
function RTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            var i = s.length - 1;       
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            s = s.substring(0, i+1);
        }
        return s;
}

//cookie code
function createCookieObj(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
}

function readCookieVal(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return '';
}

function eraseCookieObj(name) {
        createCookie(name,"",-1);
}

function srchSub(ref){
  var queryval = document.searchForm.query.value.trim();
  if(queryval == 'Search Here'){
    queryval = '';
  }
  queryval = queryval.replace( /\+/, " ");
  newurl = ref.href + queryval;
  window.location = newurl;
  return false;

}
