var selectedcheckin = new Date();
var checkinoffset = 1;				
var yearoffset = 1;
var now = new Date();
var calinselect;

var invalids="/:,;!~$";			//lists the characters that shouldn't be included 

function isValid(string){
	for(var i=0; i<string.length; i++){
	  if(invalids.indexOf(string.charAt(i)) != -1)
		return false;
	}
	return true;
}
function validateMailFm(){

	var errmsg = "";
	
	// Check Name
	var tmpname = document.mailform.fname.value;
	if(tmpname=="") errmsg += "Please provide your name\n";
	if(!isValid(tmpname)) errmsg += "\"" + invalids + "\" characters are invalid for name";
	// Check email
	var tmpemail=document.mailform.femail.value;
	if (tmpemail=="") errmsg += "Please provide your email address\n";
	if(!isValid(tmpemail)) errmsg += "The email you provided is not in valid format\n";
	if(tmpemail.indexOf("@") == -1) errmsg += "The valid email format is name@domain.ext \n";
	if(tmpemail.indexOf(".") == -1) ;
	// Check Subject
	var tmpsub = document.mailform.fsubject.value;
	if(tmpsub=="") errmsg += "Please provide the subject of your inquiry\n";
	if(!isValid(tmpsub)) errmsg += "\"" + invalids + "\" characters are invalid in subject field";
	// Check message
	var tmpmsg = document.mailform.fmessage.value;
	if(tmpmsg=="") errmsg += "Please provide the message of your inquiry\n";
	//if(!isValid(tmpmsg)) errmsg += "Please remove \"" + invalids + "\" characters";
	
	// Display error message if any	
	if(errmsg!=""){
		alert(errmsg);
		return false;
	}else{
		document.mailform.submit();
	}
}



function validateMemberfm(){

	var errmsg = "";
	
	// Check Name
	var tmpname = document.memberform.checkuser.value;
	if(tmpname=="") errmsg += "Please provide your name\n";
	if(!isValid(tmpname)) errmsg += "\"" + invalids + "\" characters are invalid for name";
	// Check Password
	var tmpcheckpass = document.memberform.checkpass.value;
	if(tmpcheckpass=="") errmsg += "Please provide your password\n";
	if(!isValid(tmpcheckpass)) errmsg += "\"" + invalids + "\" characters are invalid for password";
	
	// Display error message if any	
	if(errmsg!=""){
		alert(errmsg);
		return false;
	}else{
		document.memberform.submit();
	}
}
function checkeditprofile(){

	var errmsg = "";
	
	// Check Name
	var tmpname = document.addtodb.addrprov.value;
	if(tmpname=="") errmsg += "Please provide your province\n";
	
	// Display error message if any	
	if(errmsg!=""){
		alert(errmsg);
		return false;
	}else{
		document.addtodb.submit();
	}
}
//delete 
function delbrach(id)
{
	if (confirm("Are you sure you want to delete ID '" + id  + "'"))
	{
		window.location.href = 'mem_add_branches.php?del=' + id;
	}
}



