


function input_value (el,val) {
	
	if ($(el).value == val) $(el).value = '';
	else if ($(el).value == '') $(el).value = val;
}
function getRadioButtonSelectedValue(ctrl)
{
	for(i=0;i<ctrl.length;i++)
        	if(ctrl[i].checked) return ctrl[i].value;
	return false;
}

function MAIL(email){
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; 
	    var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; 
				
		if(email=='' || (reg1.test(email)) || !(reg2.test(email)) )
		   {			
			 return 1
		   }
		else return 0
}

function ajaxError ()	{
	alert ("Ajax: Error");
	}



function tool_tip () {
['face_head_toolt','tw_head_toolt','rss_head_toolt','share_head_toolt','skype_head_toolt','gay_friendly','english_head_toolt','spanish_head_toolt','port_head_toolt',
'face_foot_toolt','tw_foot_toolt','rss_foot_toolt','share_foot_toolt','skype_foot_toolt','english_foot_toolt','spanish_foot_toolt','port_foot_toolt','print_toolt','send_friend_toolt','share_face_toolt','share_tw_toolt','inc_txt_toolt','dec_txt_toolt'].each(function(s) {
  if ($(s))
  	new Tooltip($(s), {backgroundColor: '#333', borderColor: '#333', textColor: '#FFF', textShadowColor: '#000'});
});
}
Event.observe(window, 'load', tool_tip, false);

function tool_tip_featured () {
$$("#featured_travels_in a.featured_travels_imgs").each( function(s) {
	 if ($(s))
  		new Tooltip($(s), {backgroundColor: '#333', borderColor: '#333', textColor: '#FFF', textShadowColor: '#000'});
});
}
Event.observe(window, 'load', tool_tip_featured, false);






//Muestra captcha
function showRecaptcha(element) {
	if ($(element))
	{
	Recaptcha.destroy();
	Recaptcha.theme = "clean";
	Recaptcha.create("6LcNQL4SAAAAADTSLVd8unDDpj2yN4jjIeMtngIQ", element, {
	theme: "clean",
	callback: Recaptcha.focus_response_field
	});
	}
}
function showRecaptcha_custom(element) {
	if ($(element))
	{
	Recaptcha.destroy();
	Recaptcha.theme = "custom";
	Recaptcha.create("6LcNQL4SAAAAADTSLVd8unDDpj2yN4jjIeMtngIQ", element, {
	theme: "custom",
	custom_theme_widget: element,
	callback: Recaptcha.focus_response_field
	});
	}
}
//Valida el captcha
function captcha (form_id,el,el1)	{
		var resp = false
		var a = new Ajax.Request(url_sitio+'include/processAjax/check_captcha.php', {
  		method: 'post',
  		asynchronous: true,
  		parameters: {recaptcha_response_field:$F(el),recaptcha_challenge_field: $F(el1)},
		onSuccess:function(transport){
				if ((transport.responseText) == "OK")
					{
					if ($('captcha_msg')) $('captcha_msg').style.display="none";
					try
						{
						eval('send_'+form_id+'();');
						}
						catch(err)
						{
						//alert (err);
						$(form_id).submit();
						}
					}
				else 
					{
					Recaptcha.reload();
					if ($('captcha_msg'))$('captcha_msg').style.display="";
					if ($('captcha_msg'))$('captcha_msg').style.visibility="visible";
					}
			},
  		onFailure: ajaxError
		});
		
	}
function captcha_reload () {
	for(i=0;i<=5;i++)
		{
		showRecaptcha('frm_captcha_cont'+i);
		if ($('captcha_msg'))$('captcha_msg').style.display="none";
		if ($('captcha_msg'))$('captcha_msg').style.visibility="visible";
		
		}
		showRecaptcha_custom('frm_captcha_cont');
		if ($('captcha_msg'))$('captcha_msg').style.display="none";
		if ($('captcha_msg'))$('captcha_msg').style.visibility="visible";
}





function validate_form(form_id) {
	
	var valid = new Validation(form_id);
	Validation.add([
		['required',idioma[idioma_sitio]['required']],
		['validate-alpha',idioma[idioma_sitio]['validate-alpha']],
		['validate-email',idioma[idioma_sitio]['validate-email']],
		['validate-number',idioma[idioma_sitio]['validate-number']],
		['validate-selection',idioma[idioma_sitio]['validate-selection']],
		['validate-one-required',idioma[idioma_sitio]['validate-one-required']]
	]);
	Validation.addAllThese([
		['validate-email-confirm', idioma[idioma_sitio]['validate-email-confirm'], {
			equalToField : 'email'
		}],
		['validate-comment', idioma[idioma_sitio]['required'], {
			notOneOf : ['',idioma[idioma_sitio]['comments']]
		}]
	]);
	
	return 	valid.validate();
	}

function validate_captcha_form(form_id,el,el1) {
	
	if(validate_form(form_id))
		captcha (form_id,el,el1);
}

function send_form (form_id) {
	new Ajax.Request(url_sitio+'include/processAjax/send_'+form_id+'.php', {
	method: 'post',
  	asynchronous: true,
  	parameters: $(form_id).serialize(true)
	});
}
/*Contact*/
function send_frm_contact_light() {
	var form_id = 'frm_contact_light';
	send_form (form_id);
	var params = encodeURI('template=Contact');
	J.colorbox(
		{
		href:url_sitio+"_light_thanks.php?"+params,
			onOpen:function(){ 
				setTimeout('J.colorbox.close()', 1000);
				},
			onClosed:function(){ 
				captcha_reload ();
				}
			 
		});
}

/*Share*/
function send_frm_share_light() {
	var form_id = 'frm_share_light';
	send_form (form_id);
	var params = encodeURI('template=Share');
	J.colorbox(
		{
		href:url_sitio+"_light_thanks.php?"+params,
			onOpen:function(){ 
				setTimeout('J.colorbox.close()', 1000);
				},
			onClosed:function(){ 
				captcha_reload ();
				}
			 
		});
}

/*travel in*/

/*Contact*/
function send_frm_inquire_travel() {
	
	var form_id = 'frm_inquire_travel';
	send_form (form_id);
	$(form_id).update('<div class="blog_box_post_txt">'+idioma[idioma_sitio]['inquire_msg']+'</div><br /><div class="blog_box_post_txt right">Vamos Adventure Travel</div><div class="fix"></div>');
	
}


function change_font_size (o)	{
	var _min = 10;
	var _max = 40;
	var op = o; //op es la la operacion, si es 0 resto (achico) si es 1 sumo (agrando)
	
	var els = new Array();
	/*els[0] = 'h2.travel_tit_cont';
	els[1] = 'h2.travel_duration_cont';
	els[2] = 'h2.travel_tit_wrapper';
	els[3] = 'h2.text_cont';
	els[4] = 'h2.content_intro';
	els[5] = 'h2.content_text';
	els[6] = 'h2.left_col_cont_tit';
	els[7] = 'h2.left_col_cont_txt';
	els[8] = 'h3.travel_tit_cont';
	els[9] = 'h3.travel_duration_cont';
	els[10] = 'h3.travel_tit_wrapper';
	els[11] = 'h3.text_cont';
	els[12] = 'h3.content_intro';
	els[13] = 'h3.content_text';
	els[14] = 'h3.left_col_cont_tit';
	els[15] = 'h3.left_col_cont_txt';
	els[16] = 'div span.txt_copy';
	els[17] = 'div span.head_phonesi';
	els[18] = 'h1.left_col_cont_tit';
	els[19] = 'h1.txt_titles';
	*/
	
	els[0] = 'h2.travel_tit_cont *';
	els[1] = 'h2.travel_duration_cont *';
	els[2] = 'h2.travel_tit_wrapper *';
	els[3] = 'h2.text_cont *';
	els[4] = 'h2.content_intro *';
	els[5] = 'h2.content_text *';
	els[6] = 'h2.left_col_cont_tit *';
	els[7] = 'h2.left_col_cont_txt *';
	els[8] = 'h3.travel_tit_cont *';
	els[9] = 'h3.travel_duration_cont *';
	els[10] = 'h3.travel_tit_wrapper *';
	els[11] = 'h3.text_cont *';
	els[12] = 'h3.content_intro *';
	els[13] = 'h3.content_text *';
	els[14] = 'h3.left_col_cont_tit *';
	els[15] = 'h3.left_col_cont_txt *';
	els[16] = 'div span.txt_copy *';
	els[17] = 'div span.head_phonesi *';
	els[18] = 'h1.left_col_cont_tit *';
	els[19] = 'h1.txt_titles *';
	els[20] = 'h1.left_col_cont_tit';
	els[21] = 'h1.txt_titles';
	els[22] = 'span.head_phonesi';
			
	
	
	
	
	for(i=0;i<els.length;i++) {
	
	$$(els[i]).each(function(s) {
				
		//valor actual del font-size ej: 13px
		var font =	s.getStyle('font-size');
		//le saco el 'px' ej:13
		var new_font = parseInt(font.substring(0,font.length-2));
		if (op == 0 && (new_font < _min)) //si quiero seguir achicando y el tama�o de la letra es menor al minimo, termino.
			return;
		if (op == 1 && (new_font > _max)) //si quiero seguir agrandando y el tama�o de la letra es mayor al max, termino.
			return;
		//sumo 2
		if (op == 0)
			new_font = new_font - 2;
		else
			new_font = new_font + 2;
		//agrego 'px'
		new_font = new_font +'px';
		//valor actual del line-height ej: 13px
		var line =	s.getStyle('line-height');
		//le saco el 'px' ej:13
		var new_line = parseInt(line.substring(0,line.length-2));
		//sumo 2
		if (op == 0)
			new_line = new_line - 2;
		else
			new_line = new_line + 2;
		//agrego 'px'
		new_line = new_line +'px';
		
		if (new_font == 'NaNpx')
			new_font = '13px';
		if (new_line == 'NaNpx')
			new_line = '21px';
		
		
		s.setStyle({
  			fontSize: new_font,
			lineHeight: new_line
			});
		
		
		
		});
	}
	
	
	
	

}


/*registration*/
var step = 1; //en que paso estoy
J(document).ready(function() {
	//botones del paso 1
	J("#regist_bar_btn1,#reg_back_step_1").bind('click', function() {
		show_reg_step (1);
		
	});
	//botones del paso 2
	J("#regist_bar_btn2,#reg_next_step_2,#reg_back_step_2").bind('click', function() {
		if (step < 2)	{
			if(validate_form('frm_registration_step_1') )	{
				show_reg_step (2);
				step = 2;
			}
		}
		else	{
			show_reg_step (2);
			
		}
		
	});
	//botones del paso 3
	J("#regist_bar_btn3,#reg_next_step_3").bind('click', function() {
		if (step < 3)	{
			if(validate_form('frm_registration_step_2') && validate_form('frm_registration_step_1') && J("#step_2").css( 'display') != 'none'  ){
				show_reg_step (3);
				step = 3;
			}
		}
		else	{
			show_reg_step (3);
			
		}
	});
	//botones enviar paso 3
	J("#buttons_big_submit_reg").bind('click', function() {
		if(validate_form('frm_registration_step_2') && validate_form('frm_registration_step_1') && validate_form('frm_registration_step_3') )	{
			captcha ('frm_registration_step_3','recaptcha_response_field','recaptcha_challenge_field');
		}
			
	});


	

});

function show_reg_step (step) {
	//muestro formularios
	for (i=1; i<=3; i++){
		if (i == step)J("#step_"+i).css( 'display', '' );
		else J("#step_"+i).css( 'display', 'none' );
	}

	//saco clases de los botones
	for (i=3; i>=0; i--)
		J("#regist_bar_btn"+i).removeClass();
	//pongo clases correspondientes
	var selected_btn = 0;
	for (i=3; i>=0; i--){
		if (i == step){
			J("#regist_bar_btn"+i).addClass("regist_bar_btn regist_bar_btn_white_arrow");
			selected_btn = i;
		}
		else {
			if (i>selected_btn)J("#regist_bar_btn"+i).addClass("regist_bar_btn");
			if (i<selected_btn)J("#regist_bar_btn"+i).addClass("regist_bar_btn regist_bar_btn_white");
		}
	}
}




 //test
var test_step = 0; //en que paso estoy
J(document).ready(function() {
	J("#test_bar_btn0,#test_back_step_0").bind('click', function() {
		show_test_step (0);
		
	});
	J("#test_bar_btn1,#buttons_big_submit_test_start,#test_back_step_1").bind('click', function() {
		if (test_step < 1)	{
			if(validate_form('frm_test_step_0'))	{
				show_test_step (1);
				test_step = 1;
			}
		}
		else	{
			show_test_step (1);
			
		}
		
	});
	J("#test_bar_btn2,#test_next_step_2,#test_back_step_2").bind('click', function() {
		if (test_step < 2  )	{
			
			if(validate_form('frm_test_step_0') && 
			validate_form('frm_test_step_1') && J("#step_1").css( 'display') != 'none' 
			)	{
				show_test_step (2);
				test_step = 2;
			}
		}
		else 	{
			show_test_step (2);
			
		}
	});
	J("#test_bar_btn3,#test_next_step_3,#test_back_step_3").bind('click', function() {
	
		
		if (test_step < 3  )	{
			
			if(validate_form('frm_test_step_0') && 
			validate_form('frm_test_step_1') &&
			validate_form('frm_test_step_2') && J("#step_2").css( 'display') != 'none'
			)	{
				
				show_test_step (3);
				test_step = 3;
			}
		}
		else 	{
			show_test_step (3);
			
		}
	});
	J("#test_bar_btn4,#test_next_step_4,#test_back_step_4").bind('click', function() {
		if (test_step < 4  )	{
			
			if(validate_form('frm_test_step_0') && 
			validate_form('frm_test_step_1') && 
			validate_form('frm_test_step_2') && 
			validate_form('frm_test_step_3') && J("#step_3").css( 'display') != 'none'
			)	{
				show_test_step (4);
				test_step = 4;
			}
		}
		else 	{
			show_test_step (4);
			
		}
	});

	J("#test_bar_btn5,#test_next_step_5").bind('click', function() {
	if (test_step < 5  )	{
			
			if(validate_form('frm_test_step_0') && 
			validate_form('frm_test_step_1') && 
			validate_form('frm_test_step_2') && 
			validate_form('frm_test_step_3') && 
			validate_form('frm_test_step_4') && J("#step_4").css( 'display') != 'none'
				)	{
				show_test_step (5);
				test_step = 5;
			}
		}
		else 	{
			show_test_step (5);
			
		}
	});
	//botones enviar paso 5
	J("#buttons_big_submit_test").bind('click', function() {
		if(validate_form('frm_test_step_0') && 
		validate_form('frm_test_step_1') && 
		validate_form('frm_test_step_2') && 
		validate_form('frm_test_step_3') && 
		validate_form('frm_test_step_4') && J("#step_4").css( 'display') != 'none' &&
		validate_form('frm_test_step_5') 
		)	{
			captcha ('frm_test','recaptcha_response_field','recaptcha_challenge_field');
		}
			
	});

});

function show_test_step (step) {
	//muestro formularios
	for (i=0; i<=5; i++){
		if (i == step)J("#step_"+i).css( 'display', '' );
		else J("#step_"+i).css( 'display', 'none' );
	}
	
	//saco clases de los botones
	for (i=5; i>=0; i--)
		J("#test_bar_btn"+i).removeClass();
	//pongo clases correspondientes
	var selected_btn = 0;
	for (i=5; i>=0; i--){
		if (i == step){
			J("#test_bar_btn"+i).addClass("test_bar_btn_step test_bar_btn_step_arrow");
			selected_btn = i;
		}
		else {
			if (i>selected_btn)J("#test_bar_btn"+i).addClass("test_bar_btn_step");
			if (i<selected_btn)J("#test_bar_btn"+i).addClass("test_bar_btn_step test_bar_btn_step_white");
		}
	}
	
	
}

function arrival_inf(v) {
	if (v == "Yes")
		{
		$('airline').enable();
		$('flight_number').enable();
		$('arrival_date').enable();
		$('arrival_time').enable();
		$('departure_city').enable();
		}
	else
		{
		$('airline').disable();
		$('flight_number').disable();
		$('arrival_date').disable();
		$('arrival_time').disable();
		$('departure_city').disable();
		}
}

function popup(url,ancho,alto){
	if(navigator.userAgent.indexOf("Mac")>0){ancho=ancho+15;alto=alto+15;}
	var winl = (screen.availWidth-ancho)/2;
	var wint = (screen.availHeight-alto)/2;
	
	 winprops = 'height='+alto+',width='+ancho+',top='+wint+',left='+winl+'resizable=0,scrollbars=1, menubar=1,location=0';
		   window.open(url,"PRINT", winprops)
}


function JvalSearch(texto){
	f = document.frm_search;
	i = f.search_input;
	if ((i.value != texto) && (i.value !="")){
		url = f.action;
		url = url + "!" + i.value;
		
		window.location.href= url;
	}
}



