/*
Description: Hotel Reservations JavaScript
Author: Antonio Trejo 
Version: 1.0.1
*/

/*BROWSER START*/
/*BROWSER START*/
/*BROWSER START*/
/*BROWSER START*/

function knowbrowser(){
	var browser;
	browser = navigator.appName;
	b_version = navigator.appVersion;
	//Microsoft Internet Explorer
}


/*BROWSER END*/
/*BROWSER END*/
/*BROWSER END*/
/*BROWSER END*/


/* TOP FORM */
/* TOP FORM */
/* TOP FORM */
/* TOP FORM */
/* TOP FORM */
function resizeerror(){
	window.scroll(0,75);
	
}
function changeCSS(){
document.getElementById('topform').href = "/wp-content/plugins/hotelReservation/jgrowl-1.1.1/topform/jquery.jgrowl.css";
	if (typeof(document.forms['formDisp2']) != 'undefined' )  
	{
	document.getElementById('form2').href = "/wp-content/plugins/hotelReservation/jgrowl-1.1.1/topform/jquery.jgrowl.css";
	}
}
//Top checkin and check out top
function anotherDDM()
{
			var numOut = parseInt(document.formDisp1.checkIn.value) + 1;
			document.formDisp1.checkOut.value = numOut.toString(); 
			document.formDisp1.monthOut.value = document.formDisp1.monthIn.value;
			errorDates();
			
			if (typeof(document.forms['formDisp2']) != 'undefined')  {
			document.formDisp2.checkIn.value = document.formDisp1.checkIn.value;
			document.formDisp2.checkOut.value = numOut.toString(); 
			}
			
		
}
//change values days out
function outForm()
{
	if (typeof(document.forms['formDisp2']) != 'undefined' )  
	{
	document.formDisp2.checkOut.value = document.formDisp1.checkOut.value;
	errorDates();
	}
}
function errorDates(){
			var errors = '';
			var flag = 0;
	if((parseInt(document.formDisp1.checkIn.value) >= parseInt(document.formDisp1.checkOut.value)) && (document.formDisp1.monthIn.value == document.formDisp1.monthOut.value ))
			{
				errors = errors + "<br/>La fecha de entrada no puede ser mayor a la fecha de salida";
				flag++;
			}
						
			if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Fechas incorrectas:' });
				return false;
			}
				else
			{
				return true;
			}
}

//change values months
function monthsCheck1()
{
	var errors = '';
	var flag = 0;
	document.formDisp1.monthOut.value = document.formDisp1.monthIn.value;
	
	if (typeof(document.forms['formDisp2']) != 'undefined')  {
	document.formDisp2.monthIn.value = document.formDisp1.monthIn.value;
	document.formDisp2.monthOut.value = document.formDisp1.monthOut.value;
	}
	if((parseInt(document.formDisp1.checkIn.value) >= parseInt(document.formDisp1.checkOut.value)) && (document.formDisp1.monthIn.value == document.formDisp1.monthOut.value ))
			{
				errors = errors + "<br/>La fecha de entrada no puede ser mayor a la fecha de salida";
				flag++;
			}
	if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Fechas incorrectas:' });
				return false;
			}
				else
			{
				return true;
			}
	
}
//change values months
function monthsCheckOut()
{
	var errors = '';
	var flag = 0;
	
	if (typeof(document.forms['formDisp2']) != 'undefined')  {
	document.formDisp2.monthIn.value = document.formDisp1.monthIn.value;
	document.formDisp2.monthOut.value = document.formDisp1.monthOut.value;
	}
	if((parseInt(document.formDisp1.checkIn.value) >= parseInt(document.formDisp1.checkOut.value)) && (document.formDisp1.monthIn.value == document.formDisp1.monthOut.value ))
			{
				errors = errors + "<br/>La fecha de entrada no puede ser mayor a la fecha de salida";
				flag++;
			}
	if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Fechas incorrectas:' });
				return false;
			}
				else
			{
				return true;
			}
	
}

//change adults values 
function adultschecks1()
{
	if (typeof(document.forms['formDisp2']) != 'undefined')  {
	document.formDisp2.adults.value = document.formDisp1.adults.value;
	}
}

//change rooms values
function roomschecks1()
{
	if (typeof(document.forms['formDisp2']) != 'undefined')  {
	document.formDisp2.rooms.value = document.formDisp1.rooms.value;
	}
}
//change arrival time values
function arrivaltime1()
{
if (typeof(document.forms['formDisp2']) != 'undefined')  {
	document.formDisp2.timeArrival.value = document.formDisp1.timeArrival.value;
	}
}
	
//Top children select
function childrens(){
if (typeof(document.forms['formDisp2']) != 'undefined')  {
	document.formDisp2.children.value = document.formDisp1.children.value;
}
								if (document.formDisp1.children.value != 'No children') {
									document.getElementById('note').style["visibility"] = "visible";
								//	document.getElementById('submitBtn').style["top"] = "-3px";
									
									if (typeof(document.forms['formDisp2']) != 'undefined')  {
										document.getElementById('note3').style["visibility"] = "visible";
								//		document.getElementById('submitBtn').style["top"] = "-3px";
									}
								}
								else {
									document.getElementById('note').style["visibility"] = "hidden";
								//	document.getElementById('submitBtn').style["top"] = "7px";
									
									if (typeof(document.forms['formDisp2']) != 'undefined')  {
										document.getElementById('note3').style["visibility"] = "hidden";
								//		document.getElementById('submitBtn').style["top"] = "7px";
									}
								}
							}
							
//True or false breakfast
	function checkBreakfast1()
	{
		if (typeof(document.forms['formDisp2']) != 'undefined')  {
			if(document.formDisp1.breakfast.checked == true)
			document.formDisp2.breakfast.checked = true;
			else
			document.formDisp2.breakfast.checked = false;
		}
	}
//Check months and days corrects
function checkDayMonth()
{
	var errors;
	/*months*/
		month_array = new Array();
		month_array['Jan'] = 0; month_array['Feb'] = 1; month_array['Mar'] = 2; month_array['Apr'] = 3; month_array['May'] = 4; month_array['Jun'] = 5; month_array['Jul'] = 6; month_array['Aug'] = 7;
		month_array['Sep'] = 8; month_array['Oct'] = 9; month_array['Nov'] = 10; month_array['Dec'] = 11;
	/*months Spanish*/	
		month_spa_array = new Array(); 		month_spa_array['Enero'] = 0;		month_spa_array['Febrero'] = 1;		month_spa_array['Marzo'] = 2;		month_spa_array['Abril'] = 3;
		month_spa_array['Mayo'] = 4;		month_spa_array['Junio'] = 5;		month_spa_array['Julio'] = 6;		month_spa_array['Agosto'] = 7;		month_spa_array['Septiembre'] = 8;
		month_spa_array['Octubre'] = 9;		month_spa_array['Noviembre'] = 10;		month_spa_array['Diciembre'] = 11;
		
	/*CHECK DATE IN START*/
		var day = document.formDisp1.checkIn.value;
		var month_year_String = document.formDisp1.monthIn.value;
		var splitString = month_year_String.split(" ");
		var checkdate = new Date(splitString[1], month_array[splitString[0]], day) ;
		var checkDay = checkdate.getDay();
		var checkMonth = checkdate.getMonth();
		var checkYear = checkdate.getYear();
		//alert(checkMonth);
		//alert(month_array[splitString[0]]);
	/*CHECK DATE IN END*/
	
	/*CHECK DATE OUT START*/
		var day2 = document.formDisp1.checkOut.value;
		var month_year_String2 = document.formDisp1.monthOut.value;
		var splitString2 = month_year_String2.split(" ");
		
		var checkdate2 = new Date(splitString2[1], month_array[splitString2[0]], day2) ;
		var checkDay2 = checkdate2.getDay();
		var checkMonth2 = checkdate2.getMonth();
		var checkYear2 = checkdate2.getYear();
	
	/*CHECK DATE OUT END*/
	
	/*CHECK ACTUAL DAY*/
	
	var todayisString = document.getElementById("todaysDate").firstChild.nodeValue;
	var todaySplit = todayisString.split(" ");
	var dayToday = todaySplit[1];
	var monthToday = month_spa_array[todaySplit[3]];
	   
	 var checkDayInt = parseInt(day); 
	 var checkDayOut = parseInt(day2); 
	 var dayTodayInt = parseInt(dayToday); 
	 
	var monthIN_INT = parseInt(month_array[splitString[0]]);
	var monthOUT_INT = parseInt(month_array[splitString2[0]]);
	
	/*CHECK ACTUAL DAY*/
	
	if (checkMonth != month_array[splitString[0]]) 
	{
		return 1;
	}
	else if (checkMonth2 != month_array[splitString2[0]]) 
	{
		return 2;
	}
	else if (monthToday == month_array[splitString[0]] && checkDayInt <= dayTodayInt)
	{
		return 3;
	}
	else if (monthIN_INT > monthOUT_INT)
	{
		return 4;
	}
	else
	{
	return 0;
	}
	
}

/*
if($("#Child1_Select0").length > 0 && $("#Adult1_Select0").length > 0){
			$("#Child1_Select0").change(function() {
				manyforRoom($("#Child1_Select0").attr("value"), $("#Adult1_Select0").attr("value"), 1);
			});
			$("#Adult1_Select0").change(function() {
				manyforRoom($("#Child1_Select0").attr("value"), $("#Adult1_Select0").attr("value"), 1);
			});
}
*/
function manyforRoom(children, adults, room){
	var roomCap = parseInt(children) + parseInt(adults);
	var errors = '<br />- Sobrecupo en el cuarto n&uacute;mero ' + room;
	if( roomCap > 4) return errors;
	else return '';
}

//Check if the user choose a option					
function checkDate(){
		
	var checkingIn = $("#input_checkIn1").attr("value");
	var arraycheckingIn = ($("#input_checkIn1").attr("value")).split('/');
	var cdIn = arraycheckingIn[0].replace(/^\s*|\s*$/g,'');
	var cmIn = arraycheckingIn[1].replace(/^\s*|\s*$/g,'');
	var cyIn = arraycheckingIn[2].replace(/^\s*|\s*$/g,'');
	var checkingOut = $("#input_checkOut1").attr("value");
	var arrival = $("#timeArrival1").attr("value");
	var currentTime = new Date();
	var currentmonth = currentTime.getMonth() ;
	var currentday = currentTime.getDate();
	var currentyear = currentTime.getFullYear();
	var m_names = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre","Diciembre");
		
		/*manyforRoom($("#Child1_Select1").attr("value"), $("#Adult1_Select1").attr("value"), 2);
		manyforRoom($("#Child1_Select2").attr("value"), $("#Adult1_Select2").attr("value"), 3);
		manyforRoom($("#Child1_Select3").attr("value"), $("#Adult1_Select3").attr("value"), 4);*/
		var errorsTitle1 = '<br />Por favor verifica los siguientes campos:<br />'; 
		var errorsTitle2 = '<br />Por favor verifica el siguiente campo:<br />'; 
		var errors = '';
		var flag = 0;	
		
		if($("#Child1_Select0").length > 0 && $("#Adult1_Select0").length > 0){
			var room1;
			room1 = manyforRoom($("#Child1_Select0").attr("value"), $("#Adult1_Select0").attr("value"), 1);
			if(room1 != ''){
				errors += room1;
				flag++;
			}
		}
		if($("#Child1_Select1").length > 0 && $("#Adult1_Select1").length > 0){
			var room2;
			room2 = manyforRoom($("#Child1_Select1").attr("value"), $("#Adult1_Select1").attr("value"), 2);
			if(room2 != ''){
				errors += room2;
				flag++;
			}
		}
		if(cmIn == m_names[currentmonth] && currentyear == cyIn){
			if(cdIn == currentday){
				errors += "<br/>- No es posible reservar por este medio el dia actual, si deseas realizar la reservaci&oacute;n para esta fecha por favor comunicate con nosotros a los telefonos: <br />  <br /><center style='font-size:10px;'> +52 (55) 1107 1790    |   01 800 640 5211 </center>";
				flag++;
			}
		}

		if($("#Child1_Select2").length > 0 && $("#Adult1_Select2").length > 0){
			var room3;
			room3 = manyforRoom($("#Child1_Select2").attr("value"), $("#Adult1_Select2").attr("value"), 3);
			if(room3 != ''){
				errors += room3;
				flag++;
			}
		}
		if($("#Child1_Select3").length > 0 && $("#Adult1_Select3").length > 0){
			var room4;
			room4 = manyforRoom($("#Child1_Select3").attr("value"), $("#Adult1_Select3").attr("value"), 4);
			if(room4 != ''){
				errors += room4;
				flag++;
			}
		}
		errors += checkYear(checkingIn , checkingOut, '') ? checkYear(checkingIn , checkingOut, '') : '';
		errors += checkMonth(checkingIn , checkingOut, '') ? checkMonth(checkingIn , checkingOut, '') : '';
		//errors += checkDay(checkingIn, checkingOut, '') ? checkDay(checkingIn , checkingOut, '') : '';
		errors += validateActualDayandInDay(checkingIn) ? validateActualDayandInDay(checkingIn) : '';
		
		if(!checkingIn){
			errors += "<br/>- Fecha de entrada incorrecta";
			flag++;
		}
		if(!checkingOut){
			errors += "<br/>- Fecha de salida incorrecta";
			flag++;
		}
		if(!arrival){
			errors += "<br/>- Hora de llegada incorrecta";
			flag++;
		}
		if(flag > 0)	{
			if(flag > 2) $.jGrowl(errorsTitle1 + errors, { header: 'Error en el formulario' });
			else $.jGrowl(errorsTitle2 + errors, { header: 'Error en el formulario' });
			return false;
		}
}


/* SECOND FORM  START*/							
/* SECOND FORM  START*/
/* SECOND FORM  START*/
/* SECOND FORM  START*/
function errorresize2(){
	//window.scroll(0,240);
}

function overbutton(){
document.getElementById('topform').href = "../wp-content/plugins/hotelReservation/jgrowl-1.1.1/jquery.jgrowl.css";
document.getElementById('form2').href = "../wp-content/plugins/hotelReservation/jgrowl-1.1.1/jquery.jgrowl.css"	
}



function checkDateDayMonth(){
			var errors = '<br/>Fechas incorrectas:<br/><br/>';
			var flag = 0;
			document.formDisp1.checkIn.value = document.formDisp2.checkIn.value;
			document.formDisp1.checkOut.value = document.formDisp2.checkOut.value;
			
			
			var numOut = parseInt(document.formDisp2.checkIn.value) + 1;
			document.formDisp2.checkOut.value = numOut.toString(); 
			document.formDisp1.checkOut.value = numOut.toString(); 
			document.formDisp2.monthOut.value = document.formDisp2.monthIn.value;
					
								
			if((parseInt(document.formDisp2.checkIn.value) >= parseInt(document.formDisp2.checkOut.value)) && (document.formDisp2.monthIn.value == document.formDisp2.monthOut.value ))
			{
				errors = errors + "La fecha de entrada no puede ser mayor o igual a la fecha de salida";
				flag++;
			}
			
			
			if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Error en el formulario' });
				return false;
			}
				else
			{
				return true;
			}

}	
function dayOut2(){
		document.formDisp1.checkOut.value = document.formDisp2.checkOut.value;
		errorDates2();
}
function errorDates2(){
			var errors = '';
			var flag = 0;
	if((parseInt(document.formDisp2.checkIn.value) >= parseInt(document.formDisp2.checkOut.value)) && (document.formDisp2.monthIn.value == document.formDisp2.monthOut.value ))
			{
				errors = errors + "<br/>La fecha de entrada no puede ser mayor a la fecha de salida";
				flag++;
			}
						
			if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Fechas incorrectas:' });
				return false;
			}
				else
			{
				return true;
			}
}
//change values months
function monthsCheck2()
{
	var errors = 'Fechas incorrectas:';
	var flag = 0;
	document.formDisp1.monthIn.value = document.formDisp2.monthIn.value;
	document.formDisp1.monthOut.value = document.formDisp2.monthIn.value;
	document.formDisp2.monthOut.value = document.formDisp2.monthIn.value;
	if((parseInt(document.formDisp2.checkIn.value) >= parseInt(document.formDisp2.checkOut.value)) && (document.formDisp2.monthIn.value == document.formDisp2.monthOut.value ))
			{
				errors = errors + "<br/>La fecha de entrada no puede ser mayor o igual a la fecha de salida";
				flag++;
			}
	if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Error en el formulario' });
				return false;
			}
				else
			{
				return true;
			}	
}

function monthsCheckOutTwo()
{
	var errors = 'Fechas incorrectas:';
	var flag = 0;
	document.formDisp1.monthIn.value = document.formDisp2.monthIn.value;
	document.formDisp1.monthOut.value = document.formDisp2.monthOut.value;
	
	if((parseInt(document.formDisp2.checkIn.value) >= parseInt(document.formDisp2.checkOut.value)) && (document.formDisp2.monthIn.value == document.formDisp2.monthOut.value ))
			{
				errors = errors + "<br/>La fecha de entrada no puede ser mayor o igual a la fecha de salida";
				flag++;
			}
	if(flag > 0)
			{
				$.jGrowl(errors, { header: 'Error en el formulario' });
				return false;
			}
				else
			{
				return true;
			}	
}
//change adults values 
function adultschecks2()
{
	document.formDisp1.adults.value = document.formDisp2.adults.value;
}

//change rooms values
function roomschecks2()
{
	document.formDisp1.rooms.value = document.formDisp2.rooms.value;
}
//change arrival time values
function arrivaltime2()
{
	document.formDisp1.timeArrival.value = document.formDisp2.timeArrival.value;
}
//children select
function childrens2(){
	document.formDisp1.children.value = document.formDisp2.children.value;
	//var browser = knowbrowser();
								if (document.formDisp2.children.value != 'No children') {
									document.getElementById('note3').style["visibility"] = "visible";
									//$.jGrowl('Primer ni&ntilde;o menor a 12 a&ntilde;os no paga habitaci&oacute;n', { header: 'Nota:' });
									//document.getElementById('submitBtn').style["top"] = "-3px";
									document.getElementById('note').style["visibility"] = "visible";
									//document.getElementById('submitBtn').style["top"] = "-3px";
								}
								else {
									document.getElementById('note3').style["visibility"] = "hidden";
									//document.getElementById('submitBtn').style["top"] = "7px";
									document.getElementById('note').style["visibility"] = "hidden";
									//document.getElementById('submitBtn').style["top"] = "7px";
								}
							}

//Check months and days corrects
function checkDayMonth2()
{
	var errors;
	/*months*/
		month_array = new Array();
		month_array['Jan'] = 0; month_array['Feb'] = 1; month_array['Mar'] = 2; month_array['Apr'] = 3; month_array['May'] = 4; month_array['Jun'] = 5; month_array['Jul'] = 6; month_array['Aug'] = 7;
		month_array['Sep'] = 8; month_array['Oct'] = 9; month_array['Nov'] = 10; month_array['Dec'] = 11;
	
	/*months Spanish*/	
		month_spa_array = new Array(); 		month_spa_array['Enero'] = 0;		month_spa_array['Febrero'] = 1;		month_spa_array['Marzo'] = 2;		month_spa_array['Abril'] = 3;
		month_spa_array['Mayo'] = 4;		month_spa_array['Junio'] = 5;		month_spa_array['Julio'] = 6;		month_spa_array['Agosto'] = 7;		month_spa_array['Septiembre'] = 8;
		month_spa_array['Octubre'] = 9;		month_spa_array['Noviembre'] = 10;		month_spa_array['Diciembre'] = 11;
		
	/*CHECK DATE IN START*/
		var day = document.formDisp2.checkIn.value;
		var month_year_String = document.formDisp2.monthIn.value;
		var splitString = month_year_String.split(" ");
		var checkdate = new Date(splitString[1], month_array[splitString[0]], day) ;
		var checkDay = checkdate.getDay();
		var checkMonth = checkdate.getMonth();
		var checkYear = checkdate.getYear();
		//alert(checkMonth);
		//alert(month_array[splitString[0]]);
	/*CHECK DATE IN END*/
	
	/*CHECK DATE OUT START*/
		var day2 = document.formDisp2.checkOut.value;
		var month_year_String2 = document.formDisp2.monthOut.value;
		var splitString2 = month_year_String2.split(" ");
		var checkdate2 = new Date(splitString2[1], month_array[splitString2[0]], day2) ;
		var checkDay2 = checkdate2.getDay();
		var checkMonth2 = checkdate2.getMonth();
		var checkYear2 = checkdate2.getYear();
		//alert(checkMonth2);
		//alert(month_array[splitString2[0]]);
	/*CHECK DATE OUT END*/
	
	/*CHECK ACTUAL DAY*/
	
	var todayisString = document.getElementById("todaysDate").firstChild.nodeValue;
	var todaySplit = todayisString.split(" ");
	var dayToday = todaySplit[1];
	var monthToday = month_spa_array[todaySplit[3]];
	   
	 var checkDayInt = parseInt(day); 
	 var checkDayOut = parseInt(day2); 
	 var dayTodayInt = parseInt(dayToday); 
	 
	var monthIN_INT = parseInt(month_array[splitString[0]]);
	var monthOUT_INT = parseInt(month_array[splitString2[0]]);
	
	/*CHECK ACTUAL DAY*/
	
	if (checkMonth != month_array[splitString[0]]) 
	{
		return 1;
	}
	else if (checkMonth2 != month_array[splitString2[0]]) 
	{
		return 2;
	}
	else if (monthToday == month_array[splitString[0]] && checkDayInt <= dayTodayInt)
	{
		return 3;
	}
	else if (monthIN_INT > monthOUT_INT)
	{
		return 4;
	}
	else
	{
	return 0;
	}
	
}

//Check if the user choose a option					
function checkDate2()	{
		var checkingIn = $("#input_checkIn2").attr("value");
		var checkingOut = $("#input_checkOut2").attr("value");
		var arrival = $("#timeArrival2").attr("value");
		
		var errorsTitle1 = '<br />Por favor verifica los siguientes campos:<br />'; 
		var errorsTitle2 = '<br />Por favor verifica el siguiente campo:<br />'; 
		var errors = '';
		var flag = 0;	
		
		var arraycheckingIn = ($("#input_checkIn2").attr("value")).split('/');
		var cdIn = arraycheckingIn[0].replace(/^\s*|\s*$/g,'');
		var cmIn = arraycheckingIn[1].replace(/^\s*|\s*$/g,'');
		var cyIn = arraycheckingIn[2].replace(/^\s*|\s*$/g,'');
		var currentTime = new Date();
		var currentmonth = currentTime.getMonth() ;
		var currentday = currentTime.getDate();
		var currentyear = currentTime.getFullYear();
		var m_names = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre","Diciembre");	
			
		if($("#Child2_Select0").length > 0 && $("#Adult2_Select0").length > 0){
			var room1;
			room1 = manyforRoom($("#Child2_Select0").attr("value"), $("#Adult2_Select0").attr("value"), 1);
			if(room1 != ''){
				errors += room1;
				flag++;
			}
		}
		if($("#Child2_Select1").length > 0 && $("#Adult2_Select1").length > 0){
			var room2;
			room2 = manyforRoom($("#Child2_Select1").attr("value"), $("#Adult2_Select1").attr("value"), 2);
			if(room2 != ''){
				errors += room2;
				flag++;
			}
			
		}
		if($("#Child2_Select2").length > 0 && $("#Adult2_Select2").length > 0){
			var room3;
			room3 = manyforRoom($("#Child2_Select2").attr("value"), $("#Adult2_Select2").attr("value"), 3);
			if(room3 != ''){
				errors += room3;
				flag++;
			}
		}
		if($("#Child2_Select3").length > 0 && $("#Adult2_Select3").length > 0){
			var room4;
			room4 = manyforRoom($("#Child2_Select3").attr("value"), $("#Adult2_Select3").attr("value"), 4);
			if(room4 != ''){
				errors += room4;
				flag++;
			}
		}
		
		errors += checkYear(checkingIn , checkingOut, '') ? checkYear(checkingIn , checkingOut, '') : '';
		errors += checkMonth(checkingIn , checkingOut, '') ? checkMonth(checkingIn , checkingOut, '') : '';
		//errors += checkDay(checkingIn, checkingOut, '') ? checkDay(checkingIn , checkingOut, '') : '';
		errors += validateActualDayandInDay(checkingIn) ? validateActualDayandInDay(checkingIn) : '';
		
		if(cmIn == m_names[currentmonth] && currentyear == cyIn){
			if(cdIn == currentday){
				errors += "<br/>- No es posible reservar por este medio el dia actual, si deseas realizar la reservaci&oacute;n para esta fecha por favor comunicate con nosotros a los telefonos: <br />  <br /><center> +52 (55) 1107 1790    |   01 800 640 5211 </center>";
				flag++;
			}
		}
		
		if(!checkingIn){
			errors += "<br/>- Fecha de entrada incorrecta";
			flag++;
		}
		if(!checkingOut){
			errors += "<br/>- Fecha de salida incorrecta";
			flag++;
		}
		if(!arrival){
			errors += "<br/>- Hora de llegada incorrecta";
			flag++;
		}
		if(flag > 0)	{
			if(flag > 2) $.jGrowl(errorsTitle1 + errors, { header: 'Error en el formulario' });
			else $.jGrowl(errorsTitle2 + errors, { header: 'Error en el formulario' });
			return false;
		}
								
			/*var errors = '<br />Selecciona una opci&oacute;n en los siguientes campos: <br />';
			var flag = 0;
			var cheking = checkDayMonth2();
								if( cheking == 1) {
										errors = errors + "<br/>- Fecha de entrada incorrecta";
										flag++;
								}
								else if( cheking == 2) {
										errors = errors + "<br/>- Fecha de salida incorrecta";
										flag++;
								}
								else if( cheking == 3) {
										errors = "<br/>- Tu reservacion contiene fechas anteriores a la fecha actual";
										flag++;
								}
								else if( cheking == 4) {
										errors = "<br/>- El mes de entrada es posterior al mes de salida";
										flag++;
								}
								else
								{
									if (document.formDisp2.checkIn.value == '') {
											errors = errors + "<br/>- DÃ­a de entrada";
											flag++;
									}
									if(document.formDisp2.monthIn.value == ''){
											errors = errors + "<br/>- Mes de entrada";
											flag++;
											
										}
									if(document.formDisp2.checkOut.value == ''){
											errors = errors + "<br/>- DÃ­a de salida";
											flag++;
											
										}
									if(document.formDisp2.monthOut.value == ''){
											errors = errors + "<br/>- Mes de salida";
											flag++;
											
										}
									
									if(document.formDisp2.timeArrival.value == ''){
											errors = errors + "<br/>- Hora de llegada";
											flag++;
										}
								}
								if(flag > 0)
									{
										$.jGrowl(errors, { header: 'Error en la reservacion' });
										
										return false;
									}
								else{
										if((parseInt(document.formDisp2.checkIn.value) >= parseInt(document.formDisp2.checkOut.value)) && (document.formDisp2.monthIn.value == document.formDisp2.monthOut.value ))
										{
											errors = errors + "<br/>La fecha de entrada no puede ser mayor o igual a la fecha de salida";
											$.jGrowl(errors, { header: 'Elije correctamente las fechas de entrada y salida:' });
											return false;
										}						
										else
										{
											return true;
										}
												
									}*/



}
	//True or false breakfast
	function checkBreakfast2()
	{
			if(document.formDisp2.breakfast.checked == true)
			document.formDisp1.breakfast.checked = true;
			else
			document.formDisp1.breakfast.checked = false;
	}

	/* SECOND FORM  END*/
	/* SECOND FORM  END*/
	/* SECOND FORM  END*/
	/* SECOND FORM  END*/
	
	
	/* USER FORM  START*/
	/* USER FORM  START*/	
	/* USER FORM  START*/
	/* USER FORM  START*/
/*	function cssuserform()
	{
	document.getElementById('topform').href = "/wp-content/plugins/hotelReservation/jgrowl-1.1.1/contactform/jquery.jgrowl.css";
	}
*/	function cssemail(){
	document.getElementById('formUser').href = "../wp-content/plugins/hotelReservation/jgrowl-1.1.1/email/jquery.jgrowl.css"	
	}
	
	function formcss(){
	document.getElementById('formUser').href = "../wp-content/plugins/hotelReservation/jgrowl-1.1.1/contactform/jquery.jgrowl.css"	
	}
	function caracter()
	{
		var name =  document.userformReservation.client.value;
		var lastname =  document.userformReservation.lastname.value;
		var char_Caracter = "1234567890@#$%/()=?¡\'/*-+.¬|°!\"\¿'";
		var stringName = name.toLowerCase();
		var error = "";
		var headers;
		var stringLastname = lastname.toLowerCase();
			for(var i=0; i < stringName.length; i++)
			{
				if(char_Caracter.indexOf(stringName.charAt(i),0) != -1)
				{
					error += "- Introduce un nombre correcto";
					headers = "Error en nombre";
					document.userformReservation.client.value = "";
					break;
				}
			}
			for(var j=0; j < stringLastname.length; j++)
			{
				if(char_Caracter.indexOf(stringLastname.charAt(j),0) != -1)
				{
					error += "- Introduce un apellido correcto";
					headers = "Error en apellido";
					document.userformReservation.lastname.value = "";
					break;
				}
			}
		if(error !="")
		{
			$.jGrowl(error, { header: headers});	
		}
	}
	function emails()
	{
	texto =  document.userformReservation.email.value;
    var mailres = true;            
    var cadena = "abcdefghijklmnÃ±opqrstuvwxyzABCDEFGHIJKLMNÃ‘OPQRSTUVWXYZ1234567890@._-";
    var errors;
	
    var arroba = texto.indexOf("@",0);
    if ((texto.lastIndexOf("@")) != arroba) 
	{
		arroba = -1;
	}
	    
    var punto = texto.lastIndexOf(".");
                
     for (var contador = 0 ; contador < texto.length ; contador++)
	 {
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1)
		{
            mailres = false;
            break;
     	}
			
     }

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
     mailres = true;
    else
     mailres = false;
    
	if(mailres == false){
		if(texto !='')
			errors = '<br />' + texto + '<br />- Por favor verifica que sea correcto<br />';
		else
			errors = '<br />- Por favor verifica que sea correcto<br />';
	 	$.jGrowl(errors, { header: 'Email incorrecto' });		
		return false;
	}
	   
    return mailres;
	}
	
	function emails2()
	{
	texto =  document.userformReservation.email.value;
    var mailres = true;            
    var cadena = "abcdefghijklmnÃ±opqrstuvwxyzABCDEFGHIJKLMNÃ‘OPQRSTUVWXYZ1234567890@._-";
    var errors;
	
    var arroba = texto.indexOf("@",0);
    if ((texto.lastIndexOf("@")) != arroba) 
	{
		arroba = -1;
	}
	    
    var punto = texto.lastIndexOf(".");
                
     for (var contador = 0 ; contador < texto.length ; contador++)
	 {
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1)
		{
            mailres = false;
            break;
     	}
			
     }

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
     mailres = true;
    else
     mailres = false;
    
	if(mailres == false){
		errors = '<br />' + texto + '<br />Ejemplo: <br /> prueba@ejemplo.com';
		//$.jGrowl(errors, { header: 'Email incorrecto por favor verifica que sea correcto' });		
	}
	
    return mailres;
	}
	
	
	
	function validator()
	{
		var errors = '';
		var flag = 0;
		var client, clientLenght, credit, errorCredit;
		client = document.userformReservation.client.value;
		clientLenght = client.length;
		credit = 0;
		
		var name =  document.userformReservation.client.value;
		var lastname =  document.userformReservation.lastname.value;
		var char_Caracter = "1234567890@#$%/()=?¡\'/*-+.¬|°!\"\¿'";
		var stringName = name.toLowerCase();
		var error = "";
		var headers;
		var stringLastname = lastname.toLowerCase();
			for(var i=0; i < stringName.length; i++)
			{
				if(char_Caracter.indexOf(stringName.charAt(i),0) != -1)
				{
					error += "- Introduce un nombre correcto";
					headers = "Error en nombre";
					document.userformReservation.client.value = "";
					break;
				}
			}
			for(var j=0; j < stringLastname.length; j++)
			{
				if(char_Caracter.indexOf(stringLastname.charAt(j),0) != -1)
				{
					error += "- Introduce un apellido correcto";
					headers = "Error en apellido";
					document.userformReservation.lastname.value = "";
					break;
				}
			}
			
		
		if(error != '')
		{
			errors = errors + error;
			flag++;
		}
		
		if(document.userformReservation.client.value == '' || clientLenght < 3)
		{
			errors = errors + "<br />Nombre";
			flag++;
		}
		
		var lastname, lastnameLenght;
		lastname = document.userformReservation.lastname.value;
		lastnameLenght = lastname.length;
		
		if(document.userformReservation.lastname.value == '' || lastnameLenght < 3)
		{
			errors = errors + "<br />Apellido";
			flag++;
		}
			
		if(document.userformReservation.email.value == '')
		{
			errors = errors + "<br />Email";
			flag++;
		}	
		
		var phone, phoneLenght;
		phone = document.userformReservation.phone.value;
		phoneLenght = phone.length;
		
		
		if(document.userformReservation.phone.value == '' || phoneLenght < 5 || stringPhone(phone) == 0)
		{
			errors = errors + "<br />Telefono incorrecto";
			flag++;
		}
		
//		
		//if(!document.userformReservation.pay[0].checked && !document.userformReservation.pay[1].checked && !document.userformReservation.pay[2].checked)
		if(!document.userformReservation.pay[0].checked && !document.userformReservation.pay[1].checked && !document.userformReservation.pay[2].checked && !document.userformReservation.pay[3].checked){
			errors = errors + "<br />Forma de Pago";
			flag++;						
		}
		/*if(document.userformReservation.pay[0].checked)
		{
			errorCredit = "<br />Por el momento no esta disponible el pago con tarjeta de credito";
			credit++;						
		}*/
		if(emails2() == false)
		{
					//alert(emails2());
					errors = errors + "<br />Email incorrecto";
					flag++;
		
		}
		if(flag > 0)	{
				if(flag > 1)	$.jGrowl(errors, { header: 'Por favor completa correctamente los siguientes campos del formulario:' });
				else	$.jGrowl(errors, { header: 'Por favor completa correctamente el siguiente campo del formulario:' });
			return false;
		}else{
			/*	if(credit > 0){
				$.jGrowl(errorCredit, { header: 'Lo sentimos:' });
				return false;
				}else{*/
			return true;
			//	}
		}
		
	
	}
	function stringPhone(phone)
	{
		var stringPhone;
		var abc="abcdefghyjklmnñopqrstuvwxyz{}[]@#$%&/()=?¡\'/*-+.¬|°";
		stringPhone = phone.toLowerCase();
		for(var i=0; i < stringPhone.length; i++)
			{
			if(abc.indexOf(stringPhone.charAt(i),0) != -1)
				return 0;
			else
				return 1;
			}
	}
	function lenghtPhone()
	{
	var errors, phone;
	errors = '';
	phone = document.userformReservation.phone.value;
	phoneLenght = phone.length;
		if(phoneLenght < 5)
		{
			errors = '- Inserta un numero telefonico correcto';
			document.getElementById('phone').value='2';//document.getElementById('formUser')
			errorsFunction(errors);
			//alert(errors);
		}else{
			if(stringPhone(phone) == 0)
			{
				errors = errors + '- Inserta numero telefonico sin letras, ni otros caracteres<br />';
				errorsFunction(errors);
				//	alert(errors);
			}
		}
		
		
	}
	function errorsFunction(errors)
	{
	var error = errors;
		$.jGrowl('<br />'+error, { header: 'Error en numero Telefonico' });	
	}
/* USER FORM  END*/
/* USER FORM  END*/

/*ACCEPT CONDITTIONS STAR*/
	function agreeCondition(){
		var errors = "";
		var check;
		var flag = 0;
		if (typeof(document.forms['formAgree']) != 'undefined')  
		check = document.formAgree.agree.checked;
		else
		check = document.creditpayment.agree.checked;
		if( check == true)
		{
		
			return true;
		}else{
			errors = "Es necesario aceptar las condiciones para completar la reservaci&oacute;n";
			flag = flag + 1;
		}
		if(flag > 0){
			$.jGrowl(errors, { header: 'Error:' });
			return false;
		}
		
	}


/*ACCEPT CONDITTIONS END*/

/* PRINT */


function printMe() {
	window.print();
}

function printerFriendlyPage() {
 var popupStatus = 0;  
	
//request data for centering  
 var windowWidth = document.documentElement.clientWidth;  
 var windowHeight = document.documentElement.clientHeight;  
 var popupHeight = $("#infoprinting").height();  
 var popupWidth = $("#infoprinting").width();  
 //centering  
 $("#infoprinting").css({  
	"position": "fixed",  
	"top": 25 
	
 });  
 //only need force for IE6  
   $("#backgroundPopup").css({  
	"height": windowHeight  
 });  
 //$("#infoprinting").append(topContent);
 //$("#infoprinting").append(content);
	 $("#backgroundPopup").css({ "opacity": "0.7" });  
	 
	 if( popupStatus == 0 )
	 {
		$("#infoprinting").fadeIn("slow");  
		$("#backgroundPopup").fadeIn("slow"); 
		popupStatus = 1;
		window.print();
	}
	
	$("#backgroundPopup").click(function(){
	//topContent = '';
	//content = '';
		//$("#infoprinting").append(topContent);
		//$("#infoprinting").append(content);
		$("#infoprinting").fadeOut("slow");  
		$("#backgroundPopup").fadeOut("slow"); 
		popupStatus = 0;
	});  
} 

		

/* PRINT */

/* COMPANY */
 
  /* Slide top-bottom */
  $(document).ready(function(){
    var button = document.getElementById("v_toggle");
    var elementHidden = document.getElementById("companyHidden");
      $(button).click(function () {
      $(elementHidden).slideToggle("slow");
    });

  });
  
/* COMPANY */

/*CREDIT CARD START*/


var globalName = '';
function validationCardSection(){
	/*var showerrors = checkinFields();
	if(showerrors != '')
	{
		$.jGrowl(showerrors, { header: 'Error en formulario' });
		return false;
	}else{*/
		if($("#agree").attr('checked')){
		//return true;
			return true;
		}else{
			$.jGrowl('<br />Es necesario aceptar las condiciones de pago', { header: 'Condiciones de pago' });
			return false;
		}
	//}
	
}

/*function cardHolder(){
	var errorHolder = $('#_cardId').val();
	if(errorHolder.length < 5){
		globalName = '<br /> - Inserta correctamente el nombre del titular de la tarjeta de credito';
		$.jGrowl(globalName, { header: 'Error en titular de tarjeta de credito' });
	}else{
		globalName = '';
	}
	//alert(errorCard.length);
}

var globalNumCard = '';
function cardNumber(){
	var errorCard = IsNumeric($('#_numberID').val());
	//alert(errorCard);
	if(!errorCard){
		globalNumCard = '<br /> - Inserta un numero correcto de tarjeta de credito';
		$.jGrowl(globalNumCard, { header: 'Error en numero de tarjeta de credito' });
	}else{
		globalNumCard = '';
	}
	//alert('1');
}



function checkinFields(){
	var errorCard = '';
	//alert();
	var text = '<br />Por favor completa correctamente el formulario: <br />';
	var fieldsCheck = new Array('_cardId', '_numberID', '_cardType', 'expirationMonth', 'expirationYear');
	var fieldsCheckError = new Array('Titular de la tarjeta de credito', 'Numero de la tarjeta de credito', 'Tipo de tarjeta de credito', 'Mes de expiracion', 'Año de expiracion');
	for(var i = 0; i < fieldsCheck.length; i++){
		if($('#'+fieldsCheck[i]).val() == '') errorCard += '<br />' + '- ' + fieldsCheckError[i];
	}
	if(errorCard != ''){ 
		errorCard = text + errorCard;
	}else{
		if(globalNumCard != '') errorCard += globalNumCard;
		if(globalName != '') errorCard += globalName;
	}
	//alert(errorCard);
	return errorCard;
	
}

function IsNumeric(sText){
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	if(sText.length == 16){
		for (i = 0; i < sText.length && IsNumber == true; i++) { 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) {
				IsNumber = false;
			}
		}
		return IsNumber;
	}else{
		return false;
	}
   
   }
*/



/*CREDIT CARD END*/
/*SAFETYPAY START*/
/*function showSafetyPay(){
	var content = null;
	$('').update('');
}*/


/*SAFETYPAY END*/