function popUp(page, name, details) {
	var newWin = window.open(page, name, details);
	newWin.focus();
	return false;
}

function showPanofull(mapid,pid) {
	var codestr;
	var swidth = screen.width;
	if (mapid <= 0)
	{
		var win = window.open('http://delivery.vrxstudios.com/25/Frame.htm?id=' + pid ,'vrxmapviewer','height=720,width=600,menubar=no,top=5,scrollbars=yes,resizable=no,left=0');
	}
	else
	{
		var win = window.open('http://display.maxvr.com/vrxstudios/integration.asp?mapid=' + mapid ,'vrxmapviewer','height=720,width=567,menubar=no,top=5,scrollbars=no,resizable=no,left=0');
	}
	
	win.focus();
}

function setURL(page, qs) {
    var url;
    if (qs == "") {
        url = page;
    }
    else {
        url = page + "?" + qs;
    }
    
	window.navigate(url);
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		canmap_01_ImageMap_13_over = newImage("images/Map/canmap_01-ImageMap_13_over.gif");
		canmap_01_ImageMap_10_over = newImage("images/Map/canmap_01-ImageMap_10_over.gif");
		canmap_01_ImageMap_11_over = newImage("images/Map/canmap_01-ImageMap_11_over.gif");
		canmap_01_ImageMap_09_over = newImage("images/Map/canmap_01-ImageMap_09_over.gif");
		canmap_01_ImageMap_08_over = newImage("images/Map/canmap_01-ImageMap_08_over.gif");
		canmap_01_ImageMap_07_over = newImage("images/Map/canmap_01-ImageMap_07_over.gif");
		canmap_01_ImageMap_06_over = newImage("images/Map/canmap_01-ImageMap_06_over.gif");
		canmap_01_ImageMap_05_over = newImage("images/Map/canmap_01-ImageMap_05_over.gif");
		canmap_01_ImageMap_04_over = newImage("images/Map/canmap_01-ImageMap_04_over.gif");
		canmap_01_ImageMap_03_over = newImage("images/Map/canmap_01-ImageMap_03_over.gif");
		canmap_01_ImageMap_02_over = newImage("images/Map/canmap_01-ImageMap_02_over.gif");
		canmap_01_ImageMap_01_over = newImage("images/Map/canmap_01-ImageMap_01_over.gif");
		preloadFlag = true;
	}
}

function layer(id){
	var res;
	if(document.getElementById) {
		res = document.getElementById(id);
	}
	if(document.all) {
		res = document.all[id];
	}
	if (res) {
		return res.style;
	} else {
		return null;
	}
}

var nsx;
var nsy;

if (!document.all) {
	document.captureEvents(Event.MOUSEMOVE);	
	document.onmousemove = get_mouse;
}

function get_mouse(e) {
	nsx = e.pageX - 10;
	nsy = e.pageY + 5;
}

function ShowToolTip(myID) {
	var hlp=layer("TIP" + myID);
	if (hlp) {
		if (document.all) {
			nsy=event.y+document.body.scrollTop;
			nsx=event.x+document.body.scrollLeft;
		}
		hlp.top=nsy+10;
		hlp.left=(nsx>710?nsx-150:440);
		hlp.visibility='visible';
	}
}

function HideToolTip(myID) {
	var hlp=layer("TIP" + myID);
	if(hlp) {
		hlp.visibility='hidden';
	}
}

function setChildList(aListBoxChild, aListBoxParent, aArray, aShowAllDefault, aDefaultText, aDefaultValue) {
	var parentSelected = aListBoxParent.options[aListBoxParent.selectedIndex].value;
	var index = 0;
	var indexOffset = 0;

	for(x = aListBoxChild.options.length; x >= 0; x--) {
		aListBoxChild.options[x] = null;
	}
	
	if (aListBoxParent.selectedIndex > 0) {
		aListBoxChild.options[indexOffset] = new Option(aDefaultText, aDefaultValue);
		indexOffset++;
	}
	
	if (aShowAllDefault == 1 && aListBoxParent.selectedIndex == 0) {
	
		for(x = 0; x<aArray.length; x++) {
			aListBoxChild.options[index + indexOffset] = new Option(aArray[x][1],aArray[x][1]);
			index++;
		}
		
	} else if (aShowAllDefault == 1 && parentSelected == "Both") {
		
		for(x = 0; x<aArray.length; x++) {
			if (aArray[x][0] == "Celebrity Cruises" || aArray[x][0] == "Royal Caribbean International") {
				aListBoxChild.options[index + indexOffset] = new Option(aArray[x][1],aArray[x][1]);
				index++;
			}
		}		
	
	} else {
	
		for(x = 0; x<aArray.length; x++) {
			if (parentSelected == aArray[x][0]) {
				aListBoxChild.options[index + indexOffset] = new Option(aArray[x][1],aArray[x][1]);
				index++;
			}
		}
	}
}

//Section - Cruise Search dropdowns functionality
function populateDestination(setDefault) {
    var ddlDestination;
    var index = 0;
    var itemExists;
    
	ddlDestination = document.forms[0].ddlDestination;  
	
	ddlDestination.options.length = 0; 	
	
    ddlDestination.options[index] = new Option(aArray[index][0],"");
	index++;
		
	for(x = 2; x<aArray.length; x++) {
	    itemExists = 0;			    
        for(j = ddlDestination.options.length; j >= 0; j--) {
		    if (ddlDestination.options[j]!=null){
		        if (ddlDestination.options[j].value == aArray[x][0]){
		            itemExists = 1;	
		            break;
		        }
		    }
	    }
        if (itemExists == 0 ) {
            ddlDestination.options[index] = new Option(aArray[x][0],aArray[x][0]);
	        index++;
	    }


	} 
	if (aDefaults[0][0]!="" && setDefault == 1){
	    ddlDestination.value = aDefaults[0][0];
	   
	}

	document.forms[0].hiddenDestination.value = ddlDestination.value;
	
}


function populateSubdestination(setDefault) {	
	var index = 0;
	var j = 0;
	
	var ddlDestination;
	var ddlSubdestination;
	
	var itemExists;
	var arrSubDest = new Array();
	
    ddlDestination = document.forms[0].ddlDestination;   
	ddlSubdestination = document.forms[0].ddlSubDestination;   		    		
	if (ddlSubdestination!=null)
	{
	    ddlSubdestination.options.length = 0; 
    	
	    if (ddlDestination.selectedIndex==0){
            ddlSubdestination.options[index] = new Option(aArray[0][1],"");   	    
	    }
        else
        { 
            ddlSubdestination.options[index] = new Option(aArray[1][1],"");         
            
            for(x = 2; x<aArray.length; x++) {      
                if (ddlDestination.value == aArray[x][0]) {  
		            itemExists = 0;			    
                    for(j = 0; j < arrSubDest.length; j++) {
			            if (arrSubDest[j]!=null){
		                    if (arrSubDest[j] == aArray[x][1]){
		                        itemExists = 1;	
		                        break;	                    
		                    }
			            }
	                }			    
		            if (itemExists == 0) {		       		            
			            arrSubDest[index] = aArray[x][1];
			            index++;		             
		            }	                	                    
                }
            }	        
           
            arrSubDest.sort();
            for(j = 0; j < arrSubDest.length; j++) {	        
	            ddlSubdestination.options[j+1] = new Option(arrSubDest[j],arrSubDest[j]);			
            }	
        }
	    if (aDefaults[0][1]!="" && setDefault == 1){
	        ddlSubdestination.value = aDefaults[0][1];
	    }	
	    document.forms[0].hiddenSubDestination.value=ddlSubdestination.value;	
	}	
}


function populatePort(setDefault) {	
	var index = 0;
	var j = 0;
		
	var ddlDestination;	
	var ddlSubdestination;	
	var ddlDeparturePort;
	
	var itemExists;  
    var arrPorts = new Array();
        
    ddlDeparturePort = document.forms[0].ddlDeparturePort;   		   
    if (ddlDeparturePort!=null)	{
        ddlDestination = document.forms[0].ddlDestination;   
	    ddlSubdestination = document.forms[0].ddlSubDestination;   		

	    ddlDeparturePort.options.length = 0; 
    	    	
	    if (ddlDestination.selectedIndex==0 ){
            ddlDeparturePort.options[index] = new Option(aArray[0][2],"");
	    }
	    else{
	        ddlDeparturePort.options[index] = new Option(aArray[1][2],"");       
            
            for(x = 2; x<aArray.length; x++) {      
                if ((ddlDestination.value == aArray[x][0]) && (ddlSubdestination.value == aArray[x][1] || ddlSubdestination.selectedIndex == 0)) {
                
		            itemExists = 0;			    
                    for(j = 0; j < arrPorts.length; j++) {
			            if (arrPorts[j]!=null){
		                    if (arrPorts[j] == aArray[x][2]){
		                        itemExists = 1;	
		                        break;	                    
		                    }
			            }
	                }			    
		            if (itemExists == 0) {		       		            
			            arrPorts[index] = aArray[x][2];
			            index++;		             
		            }	                	                    
                }
            }	               
    	    
            arrPorts.sort();
            for(j = 0; j < arrPorts.length; j++) {	        
	            ddlDeparturePort.options[j+1] = new Option(arrPorts[j],arrPorts[j]);			
            }	
	    }
        
        if (aDefaults[0][2]!=""  && setDefault == 1){
	        ddlDeparturePort.value = aDefaults[0][2]
	    }	
	    document.forms[0].hiddenDeparture.value=ddlDeparturePort.value;   
	}
}

function populateCruiseline(setDefault) {	
	var index = 0;
	var j = 0;
	
    var ddlDestination;
    var ddlSubdestination;
    var ddlDeparturePort;
	var ddlCruiseline;		
	
	var arrCruiseline = new Array();	
	
	var itemExists;
    
    ddlDestination = document.forms[0].ddlDestination;   	
    ddlSubdestination = document.forms[0].ddlSubDestination;   	    
    ddlDeparturePort = document.forms[0].ddlDeparturePort;
    ddlCruiseline = document.forms[0].ddlCruiseLine;
	ddlCruiseline.options.length = 0; 	   	
    ddlCruiseline.options[index] = new Option(aArray[index][3],"");
	
    for(x = 2; x<aArray.length; x++) {      
        if (ddlSubdestination!=null && ddlDeparturePort!=null) {
            if (((ddlDestination.value == aArray[x][0] || ddlDestination.selectedIndex == 0) && (ddlSubdestination.value == aArray[x][1] || ddlSubdestination.value == "") && (ddlDeparturePort.value == aArray[x][2] || ddlDeparturePort.value=="")) ||  x==0 || ddlDestination.options.length == 0) {			   		    
            
		        itemExists = 0;			    
                for(j = 0; j < arrCruiseline.length; j++) {
			        if (arrCruiseline[j]!=null){
		                if (arrCruiseline[j] == aArray[x][3]){
		                    itemExists = 1;	
		                    break;	                    
		                }
		            }
	            }			    
		        if (itemExists == 0) {		       		            
			        arrCruiseline[index] = aArray[x][3];
			        index++;		             
		        }	                	                    
            }        
        }
        else{
            if (((ddlDestination.value == aArray[x][0] || ddlDestination.selectedIndex == 0) ) ||  x==0 || ddlDestination.options.length == 0) {			   		    
            
		        itemExists = 0;			    
                for(j = 0; j < arrCruiseline.length; j++) {
			        if (arrCruiseline[j]!=null){
		                if (arrCruiseline[j] == aArray[x][3]){
		                    itemExists = 1;	
		                    break;	                    
		                }
		            }
		            
	            }			    
		        if (itemExists == 0) {		       		            
			        arrCruiseline[index] = aArray[x][3];
			        index++;		             
		        }	                	                    
            }            
        }
        
        
    }	               
	    
    arrCruiseline.sort();
    for(j = 0; j < arrCruiseline.length; j++) {
        ddlCruiseline.options[j + 1] = new Option(arrCruiseline[j], arrCruiseline[j]);
    }		

    if (aDefaults[0][3]!=""  && setDefault == 1){
	    ddlCruiseline.value = aDefaults[0][3];
	}

	document.getElementById('hiddenCruiseline').value = ddlCruiseline.value;
}

function populateShip(setDefault) {	
	var index = 0;
	var j = 0;
	
    var ddlDestination;
    var ddlSubdestination;
    var ddlDeparturePort;
	var ddlCruiseline;	
	var ddlShip;	
		
	var arrShip = new Array();
	var itemExists;
   
    ddlDestination = document.forms[0].ddlDestination;   	
    ddlSubdestination = document.forms[0].ddlSubDestination;   	    
    ddlDeparturePort = document.forms[0].ddlDeparturePort;
    ddlCruiseline = document.forms[0].ddlCruiseLine;   
    ddlShip = document.forms[0].ddlShip;   
  
	ddlShip.options.length = 0; 
	
	if (ddlCruiseline.selectedIndex <=0){
    	ddlShip.options[index] = new Option(aArray[0][4],"");	
	}
	else{
	   ddlShip.options[index] = new Option(aArray[1][4],"");	
        
       for(x = 0; x<aArray.length; x++) {    
           if (ddlSubdestination!=null && ddlDeparturePort!=null){
                if ((ddlDestination.value == aArray[x][0] || ddlDestination.value == "") && (ddlSubdestination.value == aArray[x][1] || ddlSubdestination.value == "") && (ddlDeparturePort.value == aArray[x][2] || ddlDeparturePort.value == "") && ddlCruiseline.value == aArray[x][3]) {			   	

	                itemExists = 0;			    
                    for(j = 0; j < arrShip.length; j++) {
		                if (arrShip[j]!=null){
		                    if (arrShip[j] == aArray[x][4]){
		                        itemExists = 1;	
		                        break;	                    
		                    }
		                }
	                }			    
	                if (itemExists == 0) {		       		            
		                arrShip[index] = aArray[x][4];
		                index++;		             
	                }	               	                    
                }
           }
           else{ 
            
            if ((ddlDestination.value == aArray[x][0] || ddlDestination.value == "")  && ddlCruiseline.value == aArray[x][3]) {			   	

	                itemExists = 0;			    
                    for(j = 0; j < arrShip.length; j++) {
		                if (arrShip[j]!=null){
		                    if (arrShip[j] == aArray[x][4]){
		                        itemExists = 1;	
		                        break;	                    
		                    }
		                }
	                }			    
	                if (itemExists == 0) {		       		            
		                arrShip[index] = aArray[x][4];
		                index++;		             
	                }	               	                    
                }
            }
        }	     
    	arrShip.sort();
        for(j = 0; j < arrShip.length; j++) {	        
	        ddlShip.options[j+1] = new Option(arrShip[j],arrShip[j]);			
        }			
	
	    if (aDefaults[0][4]!="" && setDefault == 1){	   
		    ddlShip.value = aDefaults[0][4];
	    }			
	    document.forms[0].hiddenShip.value=ddlShip.value;
   }      	
}

function populateMonth(setDefault) {
	var index = 0;	
	var x;
	var j;
    var ddlDestination;
    var ddlSubDestination;
    var ddlMonth;
    var ddlMonthTo;
    
    var arrMonth = new Array();
    
    var itemExists;
    
    ddlDestination = document.forms[0].ddlDestination;   	
    ddlSubDestination = document.forms[0].ddlSubDestination;   	
    ddlMonth = document.forms[0].ddlMonth;   
    ddlMonthTo = document.forms[0].ddlMonthTo;   
    
	if (ddlMonth!=null){	
	    ddlMonth.options.length = 0; 
	    if (ddlMonthTo!=null){ddlMonthTo.options.length = 0;}	    
    	
	    ddlMonth.options[0] = new Option(aMonth[0][2],"");
        if (ddlMonthTo!=null){ddlMonthTo.options[0] = new Option(aMonth[0][2],"");}              

        for(x = 1; x<aMonth.length; x++) {
            if (ddlSubDestination!=null){
                if ((ddlDestination.value == aMonth[x][0] || ddlDestination.selectedIndex == 0) && (ddlSubDestination.value == aMonth[x][1] || ddlSubDestination.selectedIndex == 0)) {	        
		            itemExists = 0;			    
                    for(j = 0; j < arrMonth.length; j++) {
			            if (arrMonth[j]!=null){
		                    if (arrMonth[j] == aMonth[x][2]){
		                        itemExists = 1;	
		                        break;	                    
		                    }
			            }
	                }			    
		            if (itemExists == 0) {		                		            
			            arrMonth[index] = aMonth[x][2];			    
			            index++;		             
		            }	                	                    
                }            
        }
        
         else{
                if (ddlDestination.value == aMonth[x][0] || ddlDestination.selectedIndex == 0 ) {	        
		            itemExists = 0;			    
                    for(j = 0; j < arrMonth.length; j++) {
			            if (arrMonth[j]!=null){
		                    if (arrMonth[j] == aMonth[x][2]){
		                        itemExists = 1;	
		                        break;	                    
		                    }
			            }
	                }			    
		            if (itemExists == 0) {		                		            
			            arrMonth[index] = aMonth[x][2];			    
			            index++;		             
		            }	                	                    
                }                        
            }            
        }	     
         
        for(j = 0; j < arrMonth.length; j++) {	        
	        ddlMonth.options[j+1] = new Option(arrMonth[j],arrMonth[j]);	    	 
	         if (ddlMonthTo!=null){ddlMonthTo.options[j+1] = new Option(arrMonth[j],arrMonth[j]);}
	     }
	     var monthYear = aDefaults[0][5];
	     var year = monthYear.substring(monthYear.indexOf(",") + 1);
	     var month = monthYear.substring(0, monthYear.indexOf(" "));
	     if (month + year != "" && setDefault == 1) {
	         ddlMonth.value = month + year;
	     }
	    document.forms[0].hiddenMonthYearFrom.value=ddlMonth.value;      
	     if (ddlMonthTo!=null){document.forms[0].hiddenMonthYearTo.value=ddlMonthTo.value;}
	}   
}


function populateDay(setDefault) {
	var x;
    var ddlDay;
    var ddlMonth;    
    var daysInMonth;
    ddlMonth = document.forms[0].ddlMonth;   
    ddlDay = document.forms[0].ddlDay;   
    if (ddlDay!=null){
    
	    ddlDay.options.length = 0;
    	
        ddlDay.options[0] = new Option(aMonth[0][3],"");
        
        if (ddlMonth.selectedIndex > 0){       
            for(x = 0; x<aMonth.length; x++) {
		        if (ddlMonth.value == aMonth[x][2]) {	
		            daysInMonth = aMonth[x][3];
		            break;				   			
		        }    				   			
	        }
	        for(x = 1; x<=daysInMonth; x++) {		
                ddlDay.options[x] = new Option(x,x);
	        }
        }
        var date = aDefaults[0][5];
        var day = date.substring(date.indexOf(" ") + 1, date.indexOf(","));
        if (day != "" && setDefault == 1) {
            ddlDay.value = day;
        }
        document.forms[0].hiddenDayFrom.value = ddlDay.value;

       
    }
}

function populateDayTo(setDefault) {
	var x;
    var ddlDayTo;
    var ddlMonthTo;
    var daysInMonth;
    
    ddlMonthTo = document.forms[0].ddlMonthTo;   
    ddlDayTo = document.forms[0].ddlDayTo;      

	ddlDayTo.options.length = 0;	
    ddlDayTo.options[0] = new Option(aMonth[0][3],"");



    var date = aDefaults[0][6];
    var year = date.substring(date.indexOf(",") + 1);
    var month = date.substring(0, date.indexOf(" "));
    var day = date.substring(date.indexOf(" ") + 1, date.indexOf(","))

    
    if ((month + year != "") && (day != "") && setDefault == 1) {
        ddlMonthTo.value = month + year;

        ddlDayTo.value = day;
    }

    if (ddlMonthTo.selectedIndex > 0) {
        for (x = 0; x < aMonth.length; x++) {
            if (ddlMonthTo.value == aMonth[x][2]) {
                daysInMonth = aMonth[x][3];
                break;
            }
        }
        for (x = 1; x <= daysInMonth; x++) {
            ddlDayTo.options[x] = new Option(x, x);
        }
    }
    if (day != "" && setDefault == 1 && window.location.href.search("dtr=1") > 0) {
       

        ddlDayTo.value = day;
    }
    document.forms[0].hiddenMonthYearTo.value = ddlMonthTo.value;
    document.forms[0].hiddenDayTo.value=ddlDayTo.value;
}

function populateDuration() {
	var index = 0;	
	var j;
	var x;
    var ddlDuration;    
    
    ddlDuration = document.forms[0].ddlDuration;          		
    if (ddlDuration!=null){
        
	    ddlDuration.options.length = 0;
    	
        ddlDuration.options[index] = new Option(aDuration[index][0],aDuration[index][1]);
	    index++;
    	
	    for(x = 0; x<aDuration.length; x++) {	
	        ddlDuration.options[x] = new Option( aDuration[x][0], aDuration[x][1]);						   			
	    }      
        document.forms[0].hiddenDuration.value=ddlDuration.value;
    }
}
 

//Section - Cruise Search dropdowns - Cascading refresh of dropdowns with dependencies
function RefreshDestination(setdefault) {       
    
    populateDestination(setdefault);
    populateSubdestination(setdefault);    
    populatePort(setdefault);
   
    populateDuration();

    populateMonth(setdefault);
    if(window.location.href.search("CruiseSearchResult")>-1)
        populateDay(setdefault);
    else
        populateDay(setdefault, "");

    populateCruiseline(setdefault);

    populateShip(setdefault);  
}

function RefreshSubDestination() {
   
    populateSubdestination();
    populatePort();
        
    populateCruiseline();
    populateShip();

    
}

function RefreshPort() {
    
    populatePort();
    populateCruiseline();
    populateShip();

    //populateMonth(setdefault);
    //populateDay(setdefault);   
}

function RefreshCruiseline() {    
    populateCruiseline();
    populateShip();    
}


//

function HideShowRange(query) {
    var lblFrom;
    var lblTo;
    
    lblFrom = document.getElementById("lblFrom"); 
    lblTo = document.getElementById("lblTo");
    //lblFrom.style.display = 'none';
    //lblTo.style.display = 'none';
    if (document.forms[0].rblDate[1].checked || query.search("dtr=1") > 0) {
       
        document.forms[0].ddlMonthTo.style.display = '';
        document.forms[0].ddlDayTo.style.display = '';
        document.forms[0].hiddenRange.value = "1"	   	   
	       
	    lblFrom.style.display='';	    
	    lblTo.style.display='';
	    populateDayTo(1);
	    document.getElementById("rangeFrom").style.display = "block";
	    document.getElementById("rangeTo").style.display = "block";
	    document.forms[0].rblDate[1].checked=true;
    } else {
	    document.forms[0].ddlMonthTo.style.display = 'none';
	    document.forms[0].ddlDayTo.style.display = 'none';
	    document.forms[0].hiddenRange.value = "0";

	    document.getElementById("rangeFrom").style.display = "none";
	    document.getElementById("rangeTo").style.display = "none";




	    document.forms[0].hiddenMonthYearTo.value = "";
	    document.forms[0].hiddenDayTo.value ="";
	    	   
    }
    return 1;
}
    


function ClearCTLVKey()
 {
     if (window.event.ctrlKey && window.event.keyCode == 86)
         {    
           window.event.keyCode=0;            
         }   
 }
 
 function ClearRightMouseKey(ctrlID)
 {
     if (event.button == 2)
         {   
            
           var txt;           
           txt = document.getElementById(ctrlID);   
         
           if (txt!=null){
            txt.oncontextmenu=new Function('return false;');           
           }          
           
         }   
}
 
function setHiddenProvince() {
	if (document.forms[0].ucPersonal_ddlState.style.display == "") {
		document.forms[0].ucPersonal_hiddenProvince.value = document.forms[0].ucPersonal_ddlState.options[document.forms[0].ucPersonal_ddlState.selectedIndex].value;
		document.forms[0].ucPersonal_txtState.value = document.forms[0].ucPersonal_ddlState.options[document.forms[0].ucPersonal_ddlState.selectedIndex].value;
	} else {
		document.forms[0].ucPersonal_hiddenProvince.value = document.forms[0].ucPersonal_txtState.value;
	}
}

function setHiddenProvinceJoin() {
	if (document.forms[0].ucJoinPersonal_ddlState.style.display == "") {
		document.forms[0].ucJoinPersonal_hiddenProvince.value = document.forms[0].ucJoinPersonal_ddlState.options[document.forms[0].ucJoinPersonal_ddlState.selectedIndex].value;
		document.forms[0].ucJoinPersonal_txtState.value = document.forms[0].ucJoinPersonal_ddlState.options[document.forms[0].ucJoinPersonal_ddlState.selectedIndex].value;
	} else {
		document.forms[0].ucJoinPersonal_hiddenProvince.value = document.forms[0].ucJoinPersonal_txtState.value;
	}
}

function setChildListProvince(aListBoxChild, aListBoxParent, aTextBoxChild, aArray) {
	var parentSelected = aListBoxParent.options[aListBoxParent.selectedIndex].text;
	var index = 0;
	
	// Clear the list
	for(x = aListBoxChild.options.length; x >= 0; x--) {
		aListBoxChild.options[x] = null;
	}
	
	// "Canada" or "United States" is selected
	if (aListBoxParent.options[aListBoxParent.selectedIndex].text == "Canada" || aListBoxParent.options[aListBoxParent.selectedIndex].text == "United States") {

		aListBoxChild.style.display = "";
		aTextBoxChild.style.display = "none";
		
		for(x = 0; x<aArray.length; x++) {
			if (parentSelected == aArray[x][0]) {
				aListBoxChild.options[index] = new Option(aArray[x][2],aArray[x][1]);
				index++;
			}
		}
	// Any other country is selected.  Hide the list, show the textbox
	} else {
		aTextBoxChild.value = "";
		aListBoxChild.style.display = "none";
		aTextBoxChild.style.display = "";
	}
}

function CreateCheckList(chkControl,hiddenCounter,hiddenCheckedIDs,varProduct_ID,errorMessage) {
    var varDelimiter = ',';
    var returnCode;   
  
    if (chkControl.checked == true) {    
        if (Number(hiddenCounter.value)+1 > 5){
            alert(errorMessage);
            chkControl.checked = false;
            returnCode = false;            
        } else {
            if(hiddenCheckedIDs.value == ''){varDelimiter = '';} 
            hiddenCheckedIDs.value = hiddenCheckedIDs.value + varDelimiter + varProduct_ID;
            hiddenCounter.value = Number(hiddenCounter.value) + 1;
            returnCode = true;            
        }
    } else {        	
        var ProdIds = hiddenCheckedIDs.value;
        var len = String(varProduct_ID).length;
        var i = ProdIds.indexOf(varProduct_ID); 
        var leftString = ProdIds.substr(ProdIds, i-1)
        var rightString = ProdIds.substr(i+len+1) 

        if  (leftString == '' || rightString == ''){varDelimiter='';}               
        ProdIds = leftString + varDelimiter + rightString;
        hiddenCheckedIDs.value = ProdIds;
        hiddenCounter.value = Number(hiddenCounter.value) - 1;
        returnCode = true;  
    }    
    return returnCode; 
 }
 
 function ShowToolTipAbsoluteRelative(myID, myTop, myLeft) {
	var hlp=layer("TIP" + myID);
	if (hlp) {
		if (document.all) {
	        if(document.documentElement.scrollTop > 0){
		        nsx = event.x + document.documentElement.scrollLeft;
		        nsy = event.y + document.documentElement.scrollTop;
	        }else if(document.body.scrollTop > 0){
		        nsx = event.x + document.body.scrollLeft;
		        nsy = event.y + document.body.scrollTop;
	        }else{
		        nsx = event.x + 0;
		        nsy = event.y + 0;
	        }
		}
		hlp.top=nsy+myTop;
		hlp.left=nsx+myLeft;
		hlp.visibility='visible';
	}
}


// Postal Code User Control support
function postalCodeCountryChange(aControl, aCountryCode)
{
    var valPostalCodeCanadian = document.getElementById(aControl + "_valPostalCodeCanadian");
    var valPostalCodeUS = document.getElementById(aControl + "_valPostalCodeUS");
    var valPostalCodeIntl = document.getElementById(aControl + "_valPostalCodeIntl");
    
    var hidPostalCodeCanadianEnabled = document.getElementById(aControl + "_hidPostalCodeCadEnabled");
    var hidPostalCodeUsEnabled = document.getElementById(aControl + "_hidPostalCodeUsEnabled");
    var hidPostalCodeIntlEnabled = document.getElementById(aControl + "_hidPostalCodeIntlEnabled");
    
    switch(aCountryCode)
    {
        case "CA":
            ValidatorEnable(valPostalCodeCanadian, true);
            hidPostalCodeCanadianEnabled.value = "true";
            ValidatorEnable(valPostalCodeUS, false);
            hidPostalCodeUsEnabled.value = "false";
            ValidatorEnable(valPostalCodeIntl, false);
            hidPostalCodeIntlEnabled.value = "false";
            break;
        case "US":
            ValidatorEnable(valPostalCodeCanadian, false);
            hidPostalCodeCanadianEnabled.value = "false"
            ValidatorEnable(valPostalCodeUS, true);
            hidPostalCodeUsEnabled.value = "true";
            ValidatorEnable(valPostalCodeIntl, false);
            hidPostalCodeIntlEnabled.value = "false";
            break;
        default:
            ValidatorEnable(valPostalCodeCanadian, false);
            hidPostalCodeCanadianEnabled.value = "false"
            ValidatorEnable(valPostalCodeUS, false);
            hidPostalCodeUsEnabled.value = "false";
            ValidatorEnable(valPostalCodeIntl, true);
            hidPostalCodeIntlEnabled.value = "true";
    }
}

function preSelectRateType(query) {
    var rateType = document.getElementById("ddlRateType");
    
    if (query.search("RateType") > -1) {
        var queryRateType = query.substring(query.indexOf("RateType="));
        if (queryRateType.indexOf("&") > -1)
            queryRateType = queryRateType.substring(queryRateType.indexOf("=")+1, queryRateType.indexOf("&"));
        for (var index = 0; index < rateType.options.length;index++ ) {
            if (rateType.options[index].value == queryRateType) {
                rateType.selectedIndex = index;
                break;
            }
        }
    }

}

function preSelectDayForAnyDay(query) {
    if ((query.search("dtf") > -1 && query.search("dtt") > -1) && (query.search("dtr=1") == -1)) {
        var ddlDay = document.forms[0].ddlDay;
        var dtf = query.substring(query.indexOf("dtf"));
        var dtt = dtf.substring(dtf.indexOf("dtt"));
        dtt = dtt.substring(dtt.indexOf("=")+1, dtt.indexOf("&"));
        dtf = dtf.substring(dtf.indexOf("=") + 1, dtf.indexOf("&"))
        if (dtf != dtt)
            ddlDay.selectedIndex = 0;
    }
}
