/* ***************************************************
AvilaBeach.com  - Main general-purpose Javascript routines for this site. 

**************************************************** */
	
function goto(sLocArg){
//Redirects to a different location
    window.href.location=sLocArg;	
}	
	
function popup(sLocArg,iHeight,iWidth,bScrolling,windowName) {
//Open a child window.
    if (iHeight==null) {iHeight=550}
    if (iWidth==null) {iWidth=550}	
    if (bScrolling=='false' || bScrolling==false) {sScroll="no"}	
    else{sScroll="yes"}
	if (windowName==null){windowName='me'}
    sProps = "height="+iHeight+",width="+iWidth+",scrollbars="+sScroll;
    window.open(sLocArg,windowName,sProps);
}

function clearsearch(field){
	if (field.value=="Search Avila Beach") field.value="";
}

function search(){
	var form = document.forms["searchform"];
	
	if (form.s.value=="Search Avila Beach" || form.s.value==""){
		alert("Please enter a phrase to search");
		return false;
	}
	form.action="/";
	form.submit();				
}

function webcam(){
	var url = "http://24.205.224.155/viewer/live/en/live.html";
	popup(url,500,500);
}

function hotelSearch(form){

	//Validation of data
	if (form.checkInDate.value=="" || form.checkOutDate.value==""){
		alert("Please provide valid checkin and checkout dates");
		return false;
	}else if (form.checkInDate.value=="mm/dd/yyyy" || form.checkOutDate.value=="mm/dd/yyyy"){
		alert("Please provide valid checkin and checkout dates");
		return false;
	}

	//Parsing of data 
	var cidSplit = form.checkInDate.value.split("/");
	var codSplit = form.checkOutDate.value.split("/");
	var arrMonth = cidSplit[0];
	var arrDay = cidSplit[1];
	var depMonth = codSplit[0];
	var depDay = codSplit[1];

	form.arrivalMonth.value = arrMonth;
	form.arrivalDay.value = arrDay;
	form.departureMonth.value = depMonth;
	form.departureDay.value = depDay;

	return true;
}
