// JavaScript Document
var TimeId
var a = ''
var x = 0
var t = 0

var rmvctySel
var rmvctyNum
var rmvctyNam
var rmvctyFin

function createCookie(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 readCookie(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 null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function findObj(elemID){
	var obj=false;
	if(document.all){
		obj=document.all(elemID);
	}
	else{
		if(document.getElementById){
			obj=document.getElementById(elemID);
		}
		else{
			if(document.laers){
				obj=document.laers[elemID];
			}
		}
	}
	return obj;	
}

function displayDiv(divID,display){
	//alert(divID)
	oDiv=findObj(divID);
	if (display){
		oDiv.style['display'] = "";
	}
	else{
		//alert(divID)
		oDiv.style['display'] = "none";
	}
}
function HiddenPK(g,f,d){
	displayDiv('PK'+g,false);
	displayDiv('td'+g,true);
	findObj('ImgPK'+g).src = '';
}
function ShowPK(p,q,r){
//alert(p + ' - ' + q)
displayDiv('PK'+p,true);
displayDiv('td'+p,false);
//findObj('td'+p).className = 'Editor_Package_Includes';
findObj('ImgPK'+p).src = 'http://pictures.solardestinations.com/Thumbnail/'+ r +'.jpg';

var i = 1
	for (i=1;i<=q;i++){
		if (i!=p){
			displayDiv('PK'+i,false);
			findObj('td'+i).className = 'Package_Title1';
			findObj('ImgPK'+i).src = '';
			displayDiv('td'+i,true);
		}
	}
}
function PKgoToShow(r){
if (r==1){
displayDiv('CityPK',true);
displayDiv('PKgoshow',false);
displayDiv('PKgoNshow',true);
}
if (r==0){
displayDiv('CityPK',false);
displayDiv('PKgoshow',true);
displayDiv('PKgoNshow',false);
}
}
function jFindInterest(intVal,intNam){

	var xClean = document.getElementById('divCty1').className
	if (xClean == 'div-Select1' || xClean == 'div-Select2'){
		document.getElementById('tdPacks').className = '';
		for (i=1;i<8;i++){
		 document.getElementById('divCty' + i).className = '';
		 document.getElementById('divCty' + i).style.display = 'none'
		}
		 document.getElementById('divCty0').style.display='block';
		 document.getElementById('divCty10').style.display='none';
		 document.getElementById('divCty11').style.display='none';
		 CtyFind = findObj('IDCTY').value;
		 findObj('ctysIds').value = CtyFind;
		 showCombineCtyLD(CtyFind,0);
	}

if (intVal >= 0){
	document.getElementById('selecInt').className = 'divSelect1';
	document.getElementById('showCalendars').style.display='none';
		if (intVal == 0){
			document.getElementById('showCalendars').style.display='block';
		}
	createCookie('LDCtyInt',intVal +'|'+ intNam,-1)
	showCitiesPackLD(iProducID,intVal,iPlaceName,intNam,iCountry)
	//eval("document.frmpackfilters.FindInt.value = intVal");
	//document.frmpackfilters.submit()
}
}

// <!--  Show Packages on City page
function showCitiesPackLD(ctyID,ctyInt,ctyName,intName){
	
	var url="/Get-PackXCitiesInterest.asp?iPlaceID=" + ctyID + "&iInterest=" + ctyInt + "&iPlaceTitle=" + ctyName +"&iInterestName=" + intName +"&iCountry=" + iCountry
	//alert(url)
	xmlHttp=GetXmlHttpObject(stateChangedIntLD)
	xmlHttp.open("GET", url , true)
	xmlHttp.send(null)
	}
	
	function stateChangedIntLD(){ 
			ShowWait()
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
			
			if (xmlHttp.responseText == ''){
		
			}
			else{
			document.getElementById('divPacksInt').style.display='block';
			document.getElementById('divPacksInt').innerHTML=xmlHttp.responseText;
			}
		   HideWait()
		}
	}
//--> end show packages 

//<!-- Show Drop down combination

function PassValueLD(iCtySel,iCtyNam,iCtyNum){
	//alert(iCtySel +'|'+ iCtyNam +'|'+ iCtyNum)
	document.getElementById('tdPacks').className = '';
	if (iCtySel < 0){
		if (iCtySel == -1){
			alert(iCtyNam +' is a Region Name, please select a City Name')
		}
		if (iCtySel == -2){
			alert(iCtyNam +' is a Country Name, please select a City Name')
		}
	}
	
	else{
		rmvctySel = iCtySel
	    rmvctyNum = iCtyNum
		rmvctyNam = iCtyNam
		rmvctyFin = document.getElementById('ctysIds').value
	  	x = document.getElementById('CountTitle').value;
		
		if (x == 1){
				document.getElementById('divCty' + iCtyNum).style.display='block';
				document.getElementById('CityName' + iCtyNum).value = iCtyNam;
			    document.getElementById('divCty0').style.display='none';
				document.getElementById('divCty10').style.display='block';
				//alert(location.href)
				
		}
		
		else{
		a = document.getElementById('ctysIds').value +',' + iCtySel
		document.getElementById('ctysIds').value = a
		CtyFind = a
		document.getElementById('showCalendars').style.display='none';
		document.getElementById('divCty' + iCtyNum).style.display='block';
		document.getElementById('divCty11').style.display='block';
		document.getElementById('CityName' + iCtyNum).value = iCtyNam;
		showCombineCtyLD(CtyFind,iCtyNum)
		}
	}
	
	document.getElementById('tdPacks').className = 'TB-Border_Orange1';
	
	if (iCtyNum == 2){
		document.getElementById('divCty1').className = 'div-Select2';
	}
	if (iCtyNum > 2){
		var idivClass = iCtyNum - 1
		document.getElementById('divCty' + idivClass).className = 'div-Select4';
	}
				
}

function remove(){
	a = rmvctyFin
	CtyFind = a
	document.getElementById('ctysIds').value = a
	document.getElementById('CityName' + rmvctyNum).value = '';
	document.getElementById('divCty' + rmvctyNum).style.display='none';
	showCombineCtyLD(rmvctyFin,rmvctyNum)
	
}

function showCombineCtyLD(ctyIDs,Numcty){
	
	//alert(CtyFind + ' inside function')
	var url="/Get_CombineCities_V1.asp?CtyFind=" + ctyIDs + "&CtyNum=" + Numcty
	xmlHttpC=GetXmlHttpObjectC(stateCombineLDC)
	xmlHttpC.open("GET", url , true)
	xmlHttpC.send(null)
		
}

function stateCombineLDC(){ 
	if (xmlHttpC.readyState==4 || xmlHttpC.readyState=="complete"){
		if (xmlHttpC.responseText == ''){
		}
		else{
		document.getElementById('divCty0').style.display='block';
		document.getElementById('divCty0').innerHTML=xmlHttpC.responseText;
		
			if (a != ''){
				showCitiesPackLD(CtyFind,0,'','')
			}
			
			t = document.getElementById('CountTitle1').value;
			
			if (t == 1){
				document.getElementById('divCty0').style.display='none';
				document.getElementById('divCty10').style.display='block';
				//alert(location.href)
				
			}
		}
	}
}

// --> end show drop down combination

/*function ChangeConTitle(z){
	alert(z)
	document.getElementById('CountTitle').value = z;
}*/
// <!-- Operations

function GetXmlHttpObjectC(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var strNameC="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				strNameC="Microsoft.XMLHTTP"
			}
			try{
				objXmlHttpC=new ActiveXObject(strNameC)
				objXmlHttpC.onreadystatechange=handler
				return objXmlHttpC
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	objXmlHttpC=new XMLHttpRequest()
	objXmlHttpC.onload=handler
	objXmlHttpC.onerror=handler
	return objXmlHttpC
	}
}
function GetXmlHttpObject(handler){
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This City selector doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0){
		var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
				strName="Microsoft.XMLHTTP"
			}
			try{
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler
				return objXmlHttp
			}
			catch(e){
				alert("Error. Scripting for ActiveX might be disabled")
				return
			}
	}
	if (navigator.userAgent.indexOf("Firefox")>=0){
	objXmlHttp=new XMLHttpRequest()
	objXmlHttp.onload=handler
	objXmlHttp.onerror=handler
	return objXmlHttp
	}
}

function gotoURL(){
	location.replace(location.href)
}
// --> end operations
function ShowWait(){
        document.getElementById('pleaseWait').style.display='block';return true;
    }
    function HideWait(){
        document.getElementById('pleaseWait').style.display='none';return true;
    }
