function goToAnchor(slink) {
	if(slink != "0")
	{
		document.location.replace('#' + slink); 
		//location.href = "#" + slink;
	}
}

// Change an element's css class
//
function classSwapper (obj,cssClass) {
    if (obj)  
    {
      if (obj.className) {
        obj.className = cssClass;
     }
    }
}
 

// Private function for creating functions that change an element's css class
//
 function _ChangeCSSClass (css) {
    return function (id) {
        if (document.getElementById) {
            var element = document.getElementById(id);
	    classSwapper(element,css);
        }
    }
}



// Create functions for manipulating css classes
//

 var show    = _ChangeCSSClass('Visible');   // make an element visible
var unshow  = _ChangeCSSClass('Hidden');    // make an element invisible


// Private function for creating functions that control tabs
//
function _TabController (numOfTabs,elementPrefix) 
{
	var aa;
    return function (element) 
	{

			iconName = "icon_" + element;
			
			var a = document.getElementById(iconName).src.split("/");
			var a_length = a.length-1;
			aa = a[a_length];
			
	        if (document.getElementById(iconName))
			{

					if (aa=="node_open.gif")
					{
						document.getElementById(element).style.display = 'block';
						document.getElementById(iconName).src = "/center/images/node_expanded.gif";
					}
					else if (aa=="node_expanded.gif")
					{
						document.getElementById(element).style.display = 'none';
						document.getElementById(iconName).src = "/center/images/node_open.gif";
					}
					else if (aa=="node_premium_open.gif")
					{
						document.getElementById(element).style.display = 'block';
						document.getElementById(iconName).src = "/center/images/node_premium_expanded.gif";
					}
					else if (aa=="node_premium_expanded.gif")
					{
						document.getElementById(element).style.display = 'none';
						document.getElementById(iconName).src = "/center/images/node_premium_open.gif";
					}
				} 
   		return;    
    }
}

function toggleFeatured(element, elementtoshow) 
{
	var myValue = element.value;
	var myIdArray = new Array("subSection", "moreSection");
	
	if(myValue.charAt(0)== "~")
	{
		for (i=0; i<myIdArray.length; i++)
		{
			document.getElementById(myIdArray[i]).style.display = 'none';
		}
	
		myValue = myValue.substr(1);
		document.getElementById(myValue).style.display = 'block';
	}
	else
	{
		location.href = element.options[element.selectedIndex].value;
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Begin Window Popup
function winpop(url,w,h){
	var winfeatures = "width=" + w + ",height=" + h + ",scrollbars=no,resizable=no,status=no";
	window.open(url,"",winfeatures);
}
// End Window Popup


//search section dhtml design scripts
tab_Flight_Date = "Exact";
tab_Hotel_Country = "Country";
breakstate = true; //added 12/07/2006 - to tell if someone clicks on the tabs before the page loads.


function MM_showHideLayers() 
{ //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  	if ((obj=MM_findObj(args[i]))!=null) 
	{ 
		v=args[i+2];
    	if (obj.style) 
		{	 
			obj=obj.style; 
			v=(v=='show')?'block':(v=='hide')?'none':v; 
		}
    	obj.display=v; 
	}
}

function initPage() {
    if (breakstate) {	
		document.book.mode[0].checked = true;
		document.book.module[0].checked = true;
		document.book.trip_option[0].checked = true;

        //added 12/07/2006 - if breakstate = true; switch radio buttons back to default selections. 
        changeMode("Flights");
        changeFlightDate("Exact");
    }
}

function changeMode(strMode) {
	var arrModes = new Array("Flights", "Hotels");
        
        //added 12/07/2006 - breakstate turns false if someone clicks on the tabs after the page is loaded.
        breakstate=false; 

	for (var i = 0; i < arrModes.length; i++) {
		if (arrModes[i] == strMode) {
			document.getElementById('span'+arrModes[i]).className = "selected";
			document.getElementById('header'+arrModes[i]).className = "modeheader_selected";
		}
		else {
			document.getElementById('span'+arrModes[i]).className = "deselected";
			document.getElementById('header'+arrModes[i]).className = "modeheader_deselected";
		}
	}

	// 6/6/06 Added tab_cars_searchbtn to hide searchbutton for Simple Cars Tab
	switch (strMode) {
		case "Flights": 
			MM_showHideLayers('flight','','show','hotel','','hide');
			//changeFlightDate(tab_Flight_Date);
			break;
		case "Hotels": 
			MM_showHideLayers('flight','','hide','hotel','','show'); 
			//changeHotelDestDetails(tab_Hotel_Country);
			break;
	}
}

function changeFlightDate(strFlightDate) {

        //added 12/07/2006 - breakstate turns false if someone clicks on the tabs after the page is loaded.
        breakstate=false; 

	if (strFlightDate == 'Flexible') {
		document.getElementById('td_Flight_Exact').bgColor='#B3E1F0';
		document.getElementById('td_Flight_Flexible').bgColor='#DFF2F9';
		document.getElementById('flight_tabcorner').src = "http://www.zuji.com/Image_Library/Website_images/tabcorner_left.gif";
		MM_showHideLayers('tab_flight_exact','','hide','tab_flight_flexible','','show');
	} else {
		document.getElementById('td_Flight_Exact').bgColor='#DFF2F9';
		document.getElementById('td_Flight_Flexible').bgColor='#B3E1F0';
		document.getElementById('flight_tabcorner').src = "http://www.zuji.com/Image_Library/Website_images/tabcorner_right.gif";
		MM_showHideLayers('tab_flight_exact','','show','tab_flight_flexible','','hide');
	}
	tab_Flight_Date = strFlightDate;
}

function changeHotelDestDetails(strCountry) {
	if (strCountry == "US") {
		MM_showHideLayers('tab_hotel_countries','','hide', 'tab_hotel_us','','show', 'tab_hotel_ca','','hide'); 
	} else if (strCountry == "CA") {
		MM_showHideLayers('tab_hotel_countries','','hide', 'tab_hotel_us','','hide', 'tab_hotel_ca','','show'); 
	} else {
		MM_showHideLayers('tab_hotel_countries','','show', 'tab_hotel_us','','hide', 'tab_hotel_ca','','hide'); 
	}
	tab_Hotel_Country = strCountry;
}


function setdate(i_zuji){
	zuji_d=new Date();
	zuji_tom=new Date(zuji_d.getFullYear(),zuji_d.getMonth(),zuji_d.getDate()+i_zuji);
	return zuji_tom;
}
function setup(){
	if(document.getElementById){
		d_zuji_f=setdate(1);
		d_zuji_t=setdate(2);
		//document.getElementById("select_flightdepart_month").selectedIndex=d_zuji_f.getMonth();
		//document.getElementById("select_flightdepart_day").selectedIndex=d_zuji_f.getDate()-1;
		//document.getElementById("select_flightreturn_month").selectedIndex=d_zuji_t.getMonth();
		//document.getElementById("select_flightreturn_day").selectedIndex=d_zuji_t.getDate()-1;
		
		//document.getElementById("select_depart_month").selectedIndex=d_zuji_f.getMonth();
		//document.getElementById("select_depart_day").selectedIndex=d_zuji_f.getDate()-1;
		//document.getElementById("select_return_month").selectedIndex=d_zuji_t.getMonth();
		//document.getElementById("select_return_day").selectedIndex=d_zuji_t.getDate()-1;		
	}
}

setup();

// display top deal list depends on what the deals options that the users select
var maxList = 3;
function dealSelect(dropdown)
{
	var myindex  = dropdown.selectedIndex;
	var SelValue = dropdown.options[myindex].value;
	
	for (var i=1; i <= maxList; i++)
	{
	    	var displayList  = eval(document.getElementById('topdeallist' + i)); 
	    	if (displayList != null) {
			if (i == SelValue)
				displayList.style.display = 'block';
			else
				displayList.style.display = 'none';
		}
   	}
    //return true;
}

var maxSubPromo = 3;
function rotate(){
	if (document.images){

		for (var i=0; i < maxSubPromo; i++)
		{
			var currsubpromoimg = eval(document.getElementById(aryimg[i]));
			if (currsubpromoimg != null)
			{
			    	if (currsubpromoimg.complete){
					arycurrimg[i]++;
					if (arycurrimg[i]==(arysubpromolength[i])){
						arycurrimg[i]=0;
					}
					
					var j=i+1
					switch(j)
					{
						case 1:
						 currsubpromoimg.src=arysubpromoimg1[arycurrimg[i]];
						 currsubpromoimg.alt=arysubpromoalt1[arycurrimg[i]];
						  break;    
						case 2:
						  currsubpromoimg.src=arysubpromoimg2[arycurrimg[i]];
						  currsubpromoimg.alt=arysubpromoalt2[arycurrimg[i]];
						  break;
						case 3:
						  currsubpromoimg.src=arysubpromoimg3[arycurrimg[i]];
						  currsubpromoimg.alt=arysubpromoalt3[arycurrimg[i]];
						  break;
					}
				}
			}
	   	}
		setTimeout('rotate()',5*1000);		
	}
}

function clickthru(id){
	
	var currimg;
	var redirectUrl;
	var redirectTarget;

	switch(id)
	{
		case 1:
		  redirectUrl = arysubpromourl1[arycurrimg[0]][0];
		  redirectTarget = arysubpromourl1[arycurrimg[0]][1];
		  break;    
		case 2:
		  redirectUrl = arysubpromourl2[arycurrimg[1]][0];
		  redirectTarget = arysubpromourl2[arycurrimg[1]][1];
		  break;
		case 3:
		  redirectUrl = arysubpromourl3[arycurrimg[2]][0];
		  redirectTarget = arysubpromourl3[arycurrimg[2]][1];
		  break;
	}

	if (redirectTarget=="")
	{
		document.location.href=redirectUrl;
	}
	else
	{		
		window.open(redirectUrl);
	}

}