if(DATE_FORMAT =="") DATE_FORMAT = 'MMM dd,yyyy';
if(DATE_STANDAR_FORMAT =="") DATE_STANDAR_FORMAT = 'M/d/y';

var NEW_CHAR ="\"";
var TARGET_REXP = /_/gi;

var today_	= formatDate(new Date(), DATE_STANDAR_FORMAT);

function Hide(id){
	changeVisibility(false, id);
}
	
function Show(id){
	changeVisibility(true, id);
}

function f(id){
	var d = document.getElementById(id);
		
	d.style.display = (d.style.display == "none")?"":"none";
}

function f1(){
	var t1 = document.getElementById(".pkupeven");
	var t2 = document.getElementById(".pkupodd");
		
	t1.style.display = (t1.style.display == "none")?"block":"none";
	t2.style.display = (t1.style.display != "none")?"block":"none";
}

function f2(val){
	var d = val.split("|");
	
	if((d.length != null) || (d.length == 1)){
		changeVisibility((d[1] == 2), '.cg2')
	}
}

function f3(id1,id2,img_id){
	var d1 = document.getElementById(id1);
	var d2 = document.getElementById(id2);
		
	d1.style.display = (d1.style.display == "none")?"":"none";
	d2.style.display = d1.style.display;
	
	var img_ =document.getElementById(img_id);	
	img_.setAttribute('src', (d1.style.display == "")?"/images/top1.gif":"/images/other_dest1.gif");
}

function showMyPrices(room, age, count){
	var bindex	= document.getElementById(room + '_bindex');
	
	if(bindex != null && bindex.getAttribute('value') != ""){
		for(i=0; i <= count; i++) changeVisibility(false, room + bindex.getAttribute('value') + '_' + i);
	}
	
	bindex.setAttribute('value', age);

	for(i=0; i <= count; i++)
		changeVisibility(true, room + age + '_' + i);	
}

function validate(f, result_page){
	var rdg	= f['flocnrdid'];
/*	
	if(rdg[rdg.length -1].checked){		
		changeValue('.fln_', f['.odeparture'].value);
	}
	
	rdg	= f['glocnrdid'];
	
	if(rdg[rdg.length -1].checked){		
		changeValue('.gln_', f['.ogoingto'].value);
	};
*/	
	f.action = result_page;
	f.submit();
	
	return true;
}

function openUrl(tour, cadena, other_params){
	var txt="/formularios/tour.asp?tour="+tour+"&cadena="+cadena;
	
	if(other_params	!= '')
		txt	+= '&' + other_params;
		
	win=window.open(txt,'LinkWin',"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=250,width=466");
	win.focus();
}

function touch_destinations(f, dests_){
	var arr_		= f['destinations'].value.split(',');
	var max_vta		= eval(f['max_vta'].value);
	var dests_count	= eval(f['glocnrdid_count'].value);	
	var shw_all		= false;	
	var fdest_		= f['glocval'].value;
	var img_		= document.getElementById('.gimg');
	
	for(j=0; j< dests_count; j++)
		changeVisibility((j <max_vta), 'tdg_' +j);

	if(img_ !=null){
		img_.setAttribute('src', '/images/buttons/see-other.gif');
		
		if(arguments.length >2)
			changeContent('.gimgtxt', arguments[2], 'html');			
	}
	
	if(fdest_ !="")	changeVisibility(false, 'gmapp_' +fdest_);
	
	fdest_ ="";
	
	for(j=0; j<arr_.length; j++){
		var enabled_ = (dests_.indexOf('[' +arr_[j] +']') !=-1);
	
		changeVisibility(!enabled_, 'dest_' +arr_[j] +'_0');
		changeVisibility(enabled_, 'dest_' +arr_[j] +'_1');
		changeVisibility(enabled_, 'dest_' +arr_[j] +'_2');
		
		if(enabled_ && (fdest_ =="")){			
			fdest_ = arr_[j];
			shw_all= (j >=max_vta);
		}
	}
	
	checkFormRdinGrpFieldByval(f, 'glocnrdid', fdest_);
	
	seeMapLnk(f, 'glocnrdid', 'glocval', 'gmapp_', fdest_);
		
	changeContent('glocn_', f['dest_' +fdest_ +'_n'].value, 'text');
	changeValue('.gln_', f['dest_' +fdest_ +'_n'].value);

	changeGrpIntvVisibility(shw_all, 'tdg_', max_vta, arr_.length);

	var img_ =document.getElementById('.fimg');
			
	if(img_ !=null){
		img_.setAttribute('src', (shw_all)?'/images/buttons/see-top.gif':'/images/buttons/see-other.gif');
		
		if(arguments.length >2)
			changeContent('.gimgtxt', (shw_all)?arguments[3]:arguments[2], 'html');					
	}
}

function srch_validate(f, result_page){
	if((f['chk4n_'][1].checked) && emptyField(f['.n'].value)){
		alert(f['err_n'].value.replace(TARGET_REXP, NEW_CHAR));
				 
		return false;
	}
	
	if((f['chk4p_'][1].checked) && (emptyField(f['.lp'].value) || emptyField(f['.up'].value) || isNaN(f['.lp'].value) || isNaN(f['.up'].value) || (eval(f['.lp'].value) >eval(f['.up'].value)))){
		alert(f['err_p'].value.replace(TARGET_REXP, NEW_CHAR));
				 
		return false;
	}
	
	if(result_page !=''){
		f.action = result_page;
		f.submit();
	}

	return true;
}

function shopping_validate(f, url){
	var onehour		= 1000 * 60 * 60;
	var oneday		= onehour * 24;
	
   if(emptyField(f['name'].value)){
    alert(f['err_name'].value.replace(TARGET_REXP, NEW_CHAR));
		 
    return false;
   }	
	
	if((f['email'] !=null) && emptyField(f['email'].value)){
	 alert(f['err_email'].value.replace(TARGET_REXP, NEW_CHAR));
		 
	 return false;
	}
		
   if(emptyField(f['.tchi'].value)){
    alert(f['err_.tchi'].value.replace(TARGET_REXP, NEW_CHAR));
		 
    return false;
   }

   if(isNaN(Date.parse(f['.tchi_standar'].value)) || (Math.floor(Date.parse(f['.tchi_standar'].value)/oneday) <Math.floor(Date.parse(today_)/oneday))){
	alert(f['err_.tchiv'].value.replace(TARGET_REXP, NEW_CHAR));
					
	return false;
   }
	
   var tchi_		= formatDate(new Date(f['.tchi_standar'].value), DATE_FORMAT);
   var grn_tchi_	= formatDate(new Date(f['.grn.tchi'].value), DATE_FORMAT);

   var grn_ = ((f['.grn.tadlts'].value!=getFval(f, '.tadlts', 's')) || (f['.grn.tinfs'].value!=getFval(f, '.tinfs', 's')) || (f['.grn.tchs'].value!=getFval(f, '.tchs', 's')) || (tchi_!=grn_tchi_));
		
   if(!grn_)
	goTo(f, url);
   else
   	alert(f['err_.grn'].value.replace(TARGET_REXP, NEW_CHAR));
}

// Iframe functions

function ifr_srch_validate(f){	
	if(getFval(f, '.from', 's') =="-"){
	 alert(f['err_frompattern'].value.replace(TARGET_REXP, NEW_CHAR));
			 
	 return false;
	}

	if(getFval(f, '.go', 's') =="-"){
	 alert(f['err_gopattern'].value.replace(TARGET_REXP, NEW_CHAR));
			 
	 return false;
	}
	
	var onehour		= 1000 * 60 * 60;
	var oneday		= onehour * 24;
	
	if(!emptyField(f['.tchi'].value) && ((isNaN(Date.parse(f['.tchi_standar'].value))) || (Math.floor(Date.parse(f['.tchi_standar'].value)/oneday) <Math.floor(Date.parse(today_)/oneday)))){
		alert(f['err_.tchi'].value.replace(TARGET_REXP, NEW_CHAR));
					
		return false;
	}
							
	f.submit();
			
	return true;
}
		
function ifr_touch_caption(captionid, myval){
	if(myval !="-"){
		var parts	= myval.split('.');
				
		changeContent(captionid, parts[1], 'html');
	}else
		changeContent(captionid, '', 'html');
}
		
function ifr_touch_goin(f, captionid, myval){
	var dcapstr	= "";
	var gcapstr	= "";
			
	f['.go'].length = 0;

	if(myval !="-"){
		var dests	= f['dest.' +myval].value.split(',');
				
		var parts	= myval.split('.');
		for(j=0; j<dests.length ; j++){
			var go_ = f['go.' +dests[j]].value.split('.');
					
			f['.go'].options[f['.go'].length] = new Option(' ' +go_[1], f['go.' +dests[j]].value);
					
			if(gcapstr =="") gcapstr =go_[1];
		};
				
		f['.go'].selectedIndex =0;
				
		dcapstr	= parts[1];

	}else
		f['.go'].options[0] = new Option(f['gcaption'].value, 'wwww');
			
	changeContent(captionid, dcapstr, 'html');
	changeContent('go_caption', gcapstr, 'html');
			
	changeEnable((myval =="-"), ".go");
}

function validate_travelinfo(f){
	var onehour		= 1000 * 60 * 60;
	var oneday		= onehour * 24;
	
	if(emptyField(f['.tchi'].value) || (((isNaN(Date.parse(f['.tchi_standar'].value))) || (Math.floor(Date.parse(f['.tchi_standar'].value)/oneday) <Math.floor(Date.parse(today_)/oneday))))){
		alert(f['err_.tchi'].value.replace(TARGET_REXP, NEW_CHAR));
					
		return false;
	}
		
	if(f['.a'] != null)
		f['.a'].value = "/s";
	return true;
}
