// JavaScript Document
var num
var cookVal

function setCookie(c_name,value,expiredays){
 	var exdate=new Date();
	exdate.setTime(exdate.getTime()+(expiredays*24*60*60*1000));
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());	
}
function getCookie(c_name){
	if (document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=")
	  	if (c_start!=-1){ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1){
				c_end=document.cookie.length
			}
			return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return null
}
function ObjectPosition(obj) {
      var curleft = 0;
      var curtop = 0;
      if (obj.offsetParent) {
            do {
                  curleft += obj.offsetLeft;
                  curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
      }
	   return [curleft,curtop];
}
function packInit(){
	cookVal = getCookie('addAir');
	if (cookVal == 'False'){
		var bradio = document.all('addFlight');
		bradio(1).checked = true;
		setCookie('addAir','',-1);
		flightadd('False','woair');
	}
}
var chg = 0
function changeTab(idn){
	chg = 0 
	var ntab = 'tab'+idn
	var ndiv = 'divInfo'+idn
	var nclass
	var nclaso
	for(i=1;i<=4;i++){
		if (i==1){
			 nclass = 'Tab_L_Active'
			 nclaso = 'Tab_L_Out'
		}
		else{
			nclass = 'Tab_Active'
			nclaso = 'Tab_Out'
		}
		if ($('#tab'+i+'').length){
			if ('tab'+i == ntab){
				$('#'+ntab+'').attr('class', nclass);
				$('#'+ndiv+'').show();
			}
			else{
				$('#tab'+i+'').attr('class', nclaso);
				$('#divInfo'+i+'').hide();
			}
		}
	}
}
function tabOver(thclass,thid){
	switch(thclass){
		case 'Tab_L_Active':
			chg = 0 
			break;
		case  'Tab_Active':
			chg = 0
			break;
		case  'Tab_L_Out':
			$('#tab1').attr('class','Tab_L_Active');
			chg = 1
			break;
		case 'Tab_Out':
			$('#'+ thid +'').attr('class','Tab_Active');
			chg = 1
			break;
	}
}
function tabOut(thclass,thid){
	if (chg == 1) {
		switch(thclass){
			case 'Tab_L_Active':
				$('#tab1').attr('class','Tab_L_Out');
				chg = 0
			break;
			case  'Tab_Active':
				$('#'+ thid +'').attr('class','Tab_Out');
				chg = 0
			break;
		}
	}
}
function flightadd(z,y){
	if(z == 'True'){
		$('#AirParam').show();
		$('#wair').attr('class','Text_Arial12_BlueBold');
		$('#woair').attr('class','Text_Arial12_Blue');
		
	}
	if(z =='False'){
		$('#AirParam').hide();
		$('#wair').attr('class','Text_Arial12_Blue');
		$('#woair').attr('class','Text_Arial12_BlueBold');
		$('#iDepCity').val('US city airport');
	}
}
function showInfo(infid){
	var shwdiv = 'info'
	$('#'+ infid +'').attr('src','/images/infomouseover.gif'); 
	objPos = ObjectPosition(document.getElementById(infid))
	objL = objPos[0] - 110 +'px'
	objT = objPos[1] - 70 +'px'
	switch(infid){
			case 'idest':
			$('#info').html('<b>Destination:</b><br>First city may be different than arrival airport.');
			document.getElementById(shwdiv).style.width = '250px';
			break;
			case 'iarr':
			$('#info').html('<b>Arrival Date:</b><br>Hotel check-in date for your selected city. May be different than flight departure date.');
			document.getElementById(shwdiv).style.width = '250px';
			break;
			case 'iflex':
			$('#info').html('<b>Flex Stay:</b><br>Adjust number of nights as you wish.');
			document.getElementById(shwdiv).style.width = '200px';
			objL = objPos[0] - 150 +'px'
			objT = objPos[1] - 70 +'px'
			break;
	}
	document.getElementById(shwdiv).style.left = objL;
	document.getElementById(shwdiv).style.top = objT;
	$('#info').show();
}
function hideInfo(infid){
	$('#'+ infid +'').attr('src','/images/info.gif'); 
	$('#info').hide();
	$('#info').html();
}
function showChild(qty){
	for (i=0;i<=2;i++){
		if (i<=qty){
			$('#divChild'+ i +'').show();
		}
		else{
			$('#divChild'+ i +'').hide();
		}
	}
}
function backward(){
	if (num>0){
		window.status=''
		num--
		if (num==0){
			num = 1
		}
		$('#photoslider').attr('src',picture[num]);
		$('#PicName').html(picname[num]);
		$('#picNo').html(num);
	}
}
function forward(){
	if (num == 0){
		num = 1
	}
	if (num<picture.length-1){
		num++
		$('#photoslider').attr('src',picture[num]);
		$('#PicName').html(picname[num]);
		$('#picNo').html(num);
	}
	else window.status='End of gallery'
}

function priceIt(){
	var iRet
	myOption = -1;
	for (i=formP.addFlight.length-1; i > -1; i--){
		if (formP.addFlight[i].checked){
		myOption = i; i = -1;
		}
	}
	
	p = formP.addFlight[myOption].value;
	
	if (p == 'True'){
		
		if ($('#iDepCity').val() == -1){
			alert('Please Select a Departure City   ')
			return;
		}
		$('#iRetCity').val($('#iDepCity').val());
		//document.formP.iRetCity.value = document.formP.iDepCity.value
		setCookie('addAir','True',1)
	}
	if (p == 'False'){
		$('#iRetCity').val(-1);
		$('#iDepCity').val(-1);
		//document.formP.iRetCity.value = -1
		//document.formP.iDepCity.value = -1
		setCookie('addAir','False',1)
	}
	//alert($('#iRetCity').val())
	var sele = $('#InDate1').val()
	if (sele.indexOf('Select') == 0)
	{
		alert('Please Select a Valid Date   ')
		return;
	}
	
	var ziCabin
		ziCabin = $('#Cabin').val(); //document.formP.Cabin.value // findObj('Cabin').value;
		if (ziCabin=='C' || ziCabin=='F'){
			//findObj('AirVendorAPI').value
			//document.formP.AirVendorAPI.value = '3|6-7-26-17-53-55';
			$('#Cabin').val('3|6-7-26-17-53-55');
		}
	
	if ($('#iChildren').val() != 0){
				var aChld = $('#iChildren').val();
				for (c=0;c<=aChld;c++){
					
					if ($('#iChild'+c+'').val() == ''){
						alert('Please type a Child '+c+' age')
						return;
					}
					
				}
			}
			
	var pckType
	var booProcess = 'javascript:alert("Type Of Packages is not difine");return false;'
	pckType = $('#PackType').val(); //document.formP.PackType.value
	var pckID
	pckID = $('#Pkgid').val(); //document.formP.Pkgid.value
	//alert(pckType)
	switch (pckType)
			{
			case 'TP3':
				bookProcess="http://solartours.bookingprocess.com/TVLAPI/TourPackage3/TP_ComponentList.ASP?" + pckID 
			break;
			case 'MC':
				bookProcess="http://solartours.bookingprocess.com/TVLAPI/Multicity3/MC_ComponentList.ASP?" + pckID 
			break;
			}
			
	document.formP.action=bookProcess
	document.formP.submit()
	//__utmLinkPost(bookProcess)

	/*var stringQuery = ''
    stringQuery = $('#formP').formSerialize(); 
    alert(stringQuery)
   $.ajax({
		url: 'http://latindestinations.bookingprocess.com/TVLAPI/Multicity3/MC_ComponentList.ASP', //bookProcess, 
		data: stringQuery,
		type: "POST",
		success: function(html){
			alert(html)
				//processResponse (html)
				//setCookie('calContAS',stringQuery,1)
  		},
		error: function (xhr, desc, exceptionobj) {
			//$('#content').html(xhr.responseText);
    		alert(xhr.responseText +' = error');
  		}
	});*/
 }
 var pObj
 var idPlc;
 var clsDiv;
 var scrrT
 function showFilter(plcid,filt,pg,rdNo,pobj,bCom){
	//alert(plcid +' | '+ filt+' | '+pg+' | '+rdNo+' | '+pobj+' | '+bCom)
	idPlc = plcid
	pObj = pobj
	var hotpg = pg
	var hotty = filt 
	clsDiv = ('<div style="padding:3px 15px" align="right" onclick="hideINFO()">close</div>')
	$('#hotSS').html('<div style="height:300px; padding: 50px 50px;" align="center"><img src="/images/ajax-loader-related.gif"></div>');
	
	if (bCom != 'NO'){
		var objPos = ObjectPosition(document.getElementById(pobj))
		objL = objPos[0] + 80 +'px'
		objT = objPos[1] + 10 +'px'
		document.getElementById('hotSS').style.left = objL;
		document.getElementById('hotSS').style.top = objT;
		$('#hotSS').show()
		scrrT = objPos[1] - 150;
	}
		
	$.ajax({
		url: "/GET_HotsOnPlace.aspx", 
		data: 'plcID='+plcid+'&hotTY='+hotty+'&hotPG='+hotpg, //"name="+obj+"&ship="+shipNa+"&imag0="+imag+"",
		type: "GET",
		success: function(html){
		   $('#hotSS').html(clsDiv + html);
		   window.scroll(0,scrrT);
		   
  		},
		error: function (xhr, desc, exceptionobj) {
			$('#hotSS').html(xhr.responseText);
    		alert(xhr.responseText +' = error');
  		}
	});
	
		
	/*$.get("/GET_HotsOnPlace.aspx", {plcID: ''+plcid+'',hotTY:''+hotty+'' , hotPG:''+hotpg+''},
			function(data){
				//alert(data)
				$('#hotSS').html(clsDiv + data);
				
			//if (data == "false"){
				$('#showHotels').html('No data');
				return false;
			}
			else{
				$('#showHotels').html(data);
			//}
		});*/
}

function selectPG(pg){
	var idplc = idPlc 
	var tyhot = 'Recomended' 
	var pghot = pg
	pObj = pObj
	showFilter(idplc,tyhot,pghot,2,pObj,'NO')
}
function showRooms(hotC){
	$('#shwh'+hotC+'').show();
}
function showPics(obj,shipNa,imag){
	//alert(obj)
	jShow(obj)
	
	$.ajax({
		url: "/GET_ImagForProducts.aspx", 
		data: "name="+obj+"&ship="+shipNa+"&imag0="+imag+"",
		type: "GET",
		success: function(html){
			//alert(html)
    	    processResponse (html)
  		},
		error: function (xhr, desc, exceptionobj) {
			$('#content').html(xhr.responseText);
    		alert(xhr.responseText +' = error');
  		}
	});
	//alert("que pasa")
}
function processResponse(result){
	if (window.ActiveXObject){
		$('#content').html(result);
	}
	else if (document.implementation && document.implementation.createDocument)	{
		$('#content').html(result);
	}
	else{
		alert('Your browser cannot handle this script');
	}
}
 
  function PlaceINFO(ctyID,typQ,obj){
   //alert(ctyID +' | '+ typQ)
	objPos = ObjectPosition(document.getElementById(obj))
	objL = objPos[0] + 80 +'px'
	objT = objPos[1] -100 +'px'
	document.getElementById('hotSS').style.left = objL;
	document.getElementById('hotSS').style.top = objT;
	$('#hotSS').html('<div style="height:300px; padding: 50px 50px;" align="center"><img src="/images/ajax-loader-related.gif"></div>');
	$('#hotSS').show();
	$.get("/GET_PlaceInfo.aspx", { plcid: ''+ctyID+'', infotype: ''+typQ+'' },
	
	function(data){
			$('#hotSS').html(data);
			winT = objPos[1] + 250
			//alert(winT)
			winL = objPos[0] + 80
			//window.scroll(0,winT);
	});
 }
 function hideINFO(){
	$('#hotSS').html('');
	$('#hotSS').hide();
 }
 
 /* CHECK BOX STYLE */
function init(){
	$(document).ready(function(){
		// check for what is/isn't already checked and match it on the fake ones
		$("input:checkbox").each( function() {
			(this.checked) ? $("#false"+this.id).addClass('falsecheckeddop') : $("#false"+this.id).removeClass('falsecheckeddop');
		});
		// function to 'check' the fake ones and their matching checkboxes
		$(".falsecheckdop").click(function(){
			($(this).hasClass('falsecheckeddop')) ? $(this).removeClass('falsecheckeddop') : $(this).addClass('falsecheckeddop');
			$(this.hash).trigger("click");
			return false;
		});
	});
}

$(document).ready(function(){
		// check for what is/isn't already checked and match it on the fake ones
		$("input:checkbox").each( function() {
			(this.checked) ? $("#false"+this.id).addClass('falsechecked') : $("#false"+this.id).removeClass('falsechecked');
		});
		// function to 'check' the fake ones and their matching checkboxes
		$(".falsecheck").click(function(){
			($(this).hasClass('falsechecked')) ? $(this).removeClass('falsechecked') : $(this).addClass('falsechecked');
			$(this.hash).trigger("click");
			return false;
		});
	});

function changeClass(chkid){
	alert(chkid)
	var check = chkid.replace('false','');
	alert(check)
}
/* TO TAKE ID FROM FORM TO FIND PACKAGES */
function findPacks(formID){
	//alert(formID)
	var idForm = formID
	var idString = $('#'+ idForm +'').formSerialize();
	var idStrParts
	var idxOf
	var idValP
	var idVal
	var idToFind = ''
	//alert(idString)
	idStrParts = idString.split('&');
	for (i = 0;i<idStrParts.length;i++){
		if (idForm == 'frmFindPack'){
			idxOf = idStrParts[i].indexOf('dot')
		}
		else{
			idxOf = idStrParts[i].indexOf('dop')
		}
		//alert(idxOf)
		//alert(idStrParts[i])
		if (idxOf != -1){
			idValP = idStrParts[i].split('=')
			idVal = idValP[1]
			idToFind = idToFind + idVal +','
		}
	}
	idToFind = idToFind.substring(0,idToFind.length - 1); 
	//alert(idToFind)
	if (idForm == 'frmFindPack'){
		$('#allIDs').val(idToFind);
	}
	else{
		$('#allIDsdp').val(idToFind);
	}
	//alert($('#allIDsdp').val(idToFind))
	$('#'+ idForm +'').attr('action','/Find_Packages.aspx');
	$('#'+ idForm +'').submit();
}
function closeInfo(id){
	$('#info').hide();
	
}
var imgSrc;
var imgVal;
function openInfo(id){
	var reID = id.replace('pic','');
	divInf = 'desc'+reID;
	divShw = 'pkInf'+reID;
	divtxt = 'txt'+reID;
	divBut = 'butt'+reID
	divReHtml = '<div style="padding: 15px 5px" align="center"><img src="/images/ajax-loader.gif" align="absmiddle"><br><br><span class="Text_Arial11_Blue">Loading...</span></div>'
	
	imgSrc = $('#'+id+'').attr("src");
	imgVal = imgSrc.indexOf("Plus");
	if (imgVal != -1){
		$('#'+id+'').attr("src","/images/Minus.jpg");
		$('#'+divInf+'').attr("class","Text_Arial12");
		$('#rel'+reID+'').html(divReHtml);
		$('#rel'+reID+'').show();
				if(document.getElementById(divtxt) != null){
			$('#'+divtxt+'').html('Hide details');
		}
		infoAjax(reID);
		return false
	}
	else{
		$('#'+id+'').attr("src","/images/Plus.jpg");
		$('#'+divInf+'').attr("class","Text_12_Gray");
		$('#'+divShw+'').hide();
		if(document.getElementById(divtxt) != null){
			$('#'+divtxt+'').html('More details');
		}
		$('#rel'+reID+'').html(divReHtml);
		$('#rel'+reID+'').hide();
		$('#'+divBut+'').hide();
	}
}
function infoAjax(reID){
	$.ajax({
		url: "/GET_PackRelatedInfo.aspx", 
		//data: {PackID: ""+reID+""}, //stringQuery, if is GET
		data: {'PackID': ''+ reID +''},
		type: "POST",
		success: function(html){
				pasteResult(reID,html)
		},
		error: function (xhr, desc, exceptionobj) {
			$('#rel'+reID+'').html(xhr.responseText);
    		alert(xhr.responseText +' = error');
  		}
	});
}
function pasteResult(rID,tml){
	$('#pkInf'+rID+'').show();
	$('#rel'+rID+'').html(tml);
	$('#butt'+rID+'').show();
	init()
}


function openInfo111(id){
	var imgSrc;
	var imgVal;
	var divShw = id;
	var divInfo
	var divInfoH
	var reID = divShw.replace('pic','');
	divShw = divShw.replace('pic','');
	divInfo = 'desc'+divShw;
	divInfoH = 'desch'+divShw;
	divtxt = 'txt'+divShw;
	divShw = 'pkInf'+divShw;
	imgSrc = $('#'+id+'').attr("src");
	imgVal = imgSrc.indexOf("Plus");
	if (imgVal != -1){
		$('#'+id+'').attr("src","/images/Minus.jpg");
		$('#'+divInfo+'').hide();
		$('#'+divInfoH+'').show();
		$('#'+divShw+'').show();
		if(document.getElementById(divtxt) != null){
			$('#'+divtxt+'').html('Hide details');
		}
		
		$.ajax({
		url: "/GET_PackRelatedInfo.aspx", 
		//data: {PackID: ""+reID+""}, //stringQuery, if is GET
		data: {'PackID': ''+ reID +''},
		type: "POST",
		success: function(html){
				$('#rel'+reID+'').html(html);
				$('#butt'+reID+'').show();
  				},
		error: function (xhr, desc, exceptionobj) {
			$('#rel'+reID+'').html(xhr.responseText);
    		alert(xhr.responseText +' = error');
  		}
	});
		/*$.get("/GET_PackRelatedInfo.aspx", { PackID: ""+reID+""},
			function(data){
			if (data == "false"){
				$('#rel'+reID+'').html("<div id='message'></div>");
				return false;
			}
			else{
				$('#rel'+reID+'').html(data);
				init()
				$('#butt'+reID+'').show();
			}
		});*/
	}
	else{
		$('#'+id+'').attr("src","/images/Plus.jpg");
		$('#'+divInfo+'').show()
		$('#'+divInfoH+'').hide();
		$('#'+divShw+'').hide();
		if(document.getElementById(divtxt) != null){
			$('#'+divtxt+'').html('More details');
		}
		$('#rel'+reID+'').html('');
		$('#butt'+reID+'').hide();
	}
}

/* ************  POP UP PICS AND MAP ********** */
function jShow(obj) { 
       var aryPosition = ObjectPosition(document.getElementById(obj));
	   document.getElementById("divPics").style.left = aryPosition[0] + 50 + "px";
	   document.getElementById("divPics").style.top = aryPosition[1] - 135 + "px";
	   document.getElementById("divPics").style.display="block";
	    $('#divPics').show() ;
}  
function jHide() {  

        $('#divPics').hide() ; //style.display="none";
		$('#dclosex').hide()
		$('#content').html('');
		$('#contentmap').html('');
		$('#contentmap').hide()
		map = ""
		
}
function showPics(obj,shipNa,imag){
	//alert(obj)
	$('#contentmap').hide()
	$('#dclosex').hide()
	$('#content').show()
	map = ""
	jShow(obj)
	
	$.ajax({
		url: "/GET_ImagForProducts.aspx", 
		data: "name="+obj+"&ship="+shipNa+"&imag0="+imag+"",
		type: "GET",
		success: function(html){
			//alert(html)
    	    processResponse (html)
  		},
		error: function (xhr, desc, exceptionobj) {
			$('#content').html(xhr.responseText);
    		alert(xhr.responseText +' = error');
  		}
	});
	//alert("que pasa")
}
function showMap(propID,pTitl,pLat,pLong,pAddr){
	//alert(obj)
	$('#content').hide()
	$('#contentmap').show()
	$('#dclosex').show()
	var mobj = 'amap'+propID
	jShow(mobj)
	var lat = pLat;
	var long = pLong;
	var addr = pAddr;
	var titl = pTitl;
	if (GBrowserIsCompatible()) {
		//var map = new GMap2(document.getElementById("map_canvas"));//
		map = new GMap2(document.getElementById("contentmap"));
		map.setCenter(new GLatLng(lat, long), 14);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
	
		var marker = new GMarker(new GLatLng(lat, long));
		GEvent.addListener(marker, "click", function() {
		var html ='<div class="Text_Arial12_BlueBold" align="left" >' + titl + '<br></div>'
		html = html + '<div class="Text_Arial12_Blue" align="left">'+ addr +'</div>'
		marker.openInfoWindowHtml(html);
		});
		map.addOverlay(marker);
		GEvent.trigger(marker, "click");
	}
/*

		var lat = <%=hotLat%>
		var long = <%=hotLong%>
		var addr = "<%=replace(hotAdd,vbcrlf,"")%>"
		var titl = "<%=hotNa%>"
     	//function initialize() {
		function buildMap() {
			if (GBrowserIsCompatible()) {
         		var map = new GMap2(document.getElementById("map_canvas"));
         		map.setCenter(new GLatLng(lat, long), 14);
        		map.addControl(new GLargeMapControl());
		 		map.addControl(new GMapTypeControl());

         		var marker = new GMarker(new GLatLng(lat, long));
        		GEvent.addListener(marker, "click", function() {
		 		var html ='<div class="Blue-Arial12" align="left" >' + titl + '<br></div>'
		 		html = html + '<div class="Text_11" align="left">'+ addr +'</div>'
		 		marker.openInfoWindowHtml(html);
         		});
         		map.addOverlay(marker);
        		GEvent.trigger(marker, "click");
       		}
    	}
		var gmap = 1
	if (gmap == 1){
		builMap()
		//initialize();
	}





*/
	//alert("que pasa")
}