function changeInputContent(element, value) {
	if(element.value == value)
		return '';
	if(element.value == '')
		return value;
	return element.value;
}

function openCalendar (url)
{
//  var the_width=screen.availWidth - 10, the_height=screen.availHeight - 30;
  var the_width=250, the_height=388;
  var the_left=Math.round((screen.availWidth - 10 - the_width) / 2), the_top=Math.round((screen.availHeight - 30 - the_height) / 2);
//  var the_left=0, the_top=0;
  if (url != "") {
  /*  NewWindow = window.open(url,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=0,resizable=0,width=' + the_width + ',height=' + the_height + ',top=' + the_top + ',left=' + the_left);*/
  NewWindow = window.open(url,'','toolbar=no,location=no,status=yes,menubar=no,scrollbars=0,resizable=0,width=' + the_width + ',height=' + the_height + ',top=' + the_top + ',left=' + the_left);
	NewWindow.focus();
  }
}

function OpenWindow (url)
{
  if (url != "") {
    NewWindow = window.open(url,'WAConditions','toolbar=no,location=no,status=no,menubar=no,scrollbars=1,resizable=0,width=500,height=400');
	NewWindow.focus();
  }
}

function dateDifference(strDate1,strDate2){
	
	lala1 = strDate1.split("-");
	lala2 = strDate2.split("-");
	strDate1 = lala1[1]+"/"+lala1[0]+"/"+lala1[2];
	strDate2 = lala2[1]+"/"+lala2[0]+"/"+lala2[2];

     datDate1= Date.parse(strDate1);

     datDate2= Date.parse(strDate2);

     return Math.round((datDate2-datDate1)/(24*60*60*1000));
}

function CalcularTotal(cant,price,field) {
	//alert(cant * price);
	var val = cant * price;
	var roundedVal = Math.round(val*Math.pow(10,2))/Math.pow(10,2);
	var toEval = 'document.ApplicationForm.'+field+'.value = roundedVal;';
	eval(toEval);
	updateTotal();
}
function applyCharge(cant,field) {
	var toEval;
	if(cant>0)
		toEval = 'document.ApplicationForm.'+field+'.value = 10';
	else
		toEval = 'document.ApplicationForm.'+field+'.value = 0';
	eval(toEval);
	updateTotal();
}
function updateTotal() {
	var suma;
	document.ApplicationForm.Total_Costing.value = 0;
	suma = document.ApplicationForm.Accommodation_T.value*1 +
			document.ApplicationForm.Fee_T.value*1 +
			document.ApplicationForm.Bond_T.value*1 +
			document.ApplicationForm.Linen_Single_T.value*1 +
			document.ApplicationForm.Linen_Double_T.value*1 +
			document.ApplicationForm.Highchair_T.value*1 +
			document.ApplicationForm.Highchair_Charge.value*1 +
			document.ApplicationForm.Port_T.value*1 +
			document.ApplicationForm.Port_Charge.value*1 +
			document.ApplicationForm.Fold_T.value*1 +
			document.ApplicationForm.Fold_Charge.value*1;
	document.ApplicationForm.Total_Costing.value = suma;
}
function isNumberKey(evt) {
     var charCode = (evt.which) ? evt.which : event.keyCode
     if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

     return true;
}

$(document).ready(function(){
    $("#ApplicationForm").formToWizard({ submitButton: 'SaveAccount' });
    $("#ApplicationForm").validate();
    //$("#arrivalDate").datepicker({dateFormat: 'dd-mm-yy'});
    //$("#departureDate").datepicker({dateFormat: 'dd-mm-yy'});
    //$("#Prefered_Date").datepicker({dateFormat: 'dd-mm-yy'});
});

function PetType(option) {
	if(option == '1')
		document.ApplicationForm.Type_of_Pet.disabled = false;
	else
		document.ApplicationForm.Type_of_Pet.disabled = true;
}
function VehicleDetails(option) {
	if(option == '1') {
		document.ApplicationForm.Make.disabled = false;
		document.ApplicationForm.Model.disabled = false;
		document.ApplicationForm.Registration_Number.disabled = false;
	} else {
		document.ApplicationForm.Make.disabled = true;
		document.ApplicationForm.Model.disabled = true;
		document.ApplicationForm.Registration_Number.disabled = true;
	}
}
