// JavaScript Document
//To Check whether the user is valid or not
function showBranch(state,type) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 600;
	winHeight = 600;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	if(type == "S"){
		window.open("showImBranchList.php?state=" + state,"branchCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}else{
		window.open("showImBranchList.php?dist=" + state,"branchCategory","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	}
}
function checkSearchBranch(){
	if(trimSpaces(document.form1.searchFor.value == "")){
		alert("Please specify the search word");
		document.form1.searchFor.focus();
		return false;
	}
	document.form1.txtSearch.value ="search";
}
function checkLogin() {
	document.forms[1].uname.value = trimSpaces(document.forms[1].uname.value);
	if(document.forms[1].uname.value.length <= 0) {
		alert("Please enter the email address");
		document.forms[1].uname.focus();
		return false;
	}
	if(!checkEmail(document.forms[1].uname.value))
	{
		return false;
	}
	document.forms[1].password.value = trimSpaces(document.forms[1].password.value);
	if(document.forms[1].password.value.length <= 0) {
		alert("Please enter password");
		document.forms[1].password.focus();
		return false;
	}
	document.forms[1].sbm.value="Y";
}
function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() 
{
	window.print();
}

function showCalendar(frmElement, dispElement) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 375;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCalendar.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}

function checkFeedBack() {
	document.forms[0].visitorName.value = trimSpaces(document.forms[0].visitorName.value);
	if(document.forms[0].visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.forms[0].visitorName.focus();
		return false;
	}

	document.forms[0].emailAddress.value = trimSpaces(document.forms[0].emailAddress.value);
	if(document.forms[0].emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[0].emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.forms[0].emailAddress.value)) {
		document.forms[0].emailAddress.focus();
		document.forms[0].emailAddress.select();
		return false;
	}

	document.forms[0].visitorComments.value = trimSpaces(document.forms[0].visitorComments.value);
	if(document.forms[0].visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].frmAction.value = "update";
}
function checkBooking()
{
	name =  trimSpaces(document.feedbackForm.name.value);
	email =  trimSpaces(document.feedbackForm.email.value);
	phone =  trimSpaces(document.feedbackForm.phone.value);
	dob =  trimSpaces(document.feedbackForm.dob.value);
	address =  trimSpaces(document.feedbackForm.address.value);
	if(name == "")
	{
		alert("Please enter your name");
		document.feedbackForm.name.focus();
		return false;
	}
	if(dob == "")
	{
		alert("Please enter Date of birth");
		document.feedbackForm.dob.focus();
		return false;
	}
	if(address == "")
	{
		alert("Please enter Address");
		document.feedbackForm.address.focus();
		return false;
	}
	if(email == "")
	{
		alert("Please enter Email Address");
		document.feedbackForm.email.focus();
		return false;
	}
	if(!checkEmail(email))
	{
		document.feedbackForm.email.select();
		return false;
	}
	if(phone == "")
	{
		alert("Please enter Phone number");
		document.feedbackForm.phone.focus(); 
		return false;
	}
	document.feedbackForm.frmAction.value="send";
}

function checkContact()
{
	visitorName =  trimSpaces(document.feedbackForm.visitorName.value);
	visitorAddress=trimSpaces(document.feedbackForm.visitorAddress.value);
	visitorEmail =  trimSpaces(document.feedbackForm.visitorEmail.value);
	visitorPhone =  trimSpaces(document.feedbackForm.visitorPhone.value);
	visitorComments =  trimSpaces(document.feedbackForm.visitorComments.value);
	
	if(visitorName == "")
	{
		alert("Please enter your name");
		document.feedbackForm.visitorName.focus();
		return false;
	}
	if(visitorAddress =="")
	{
		alert("Please enter your address");
		document.feedbackForm.visitorAddress.focus();
		return false;
	}
	if(visitorPhone == "")
	{
		alert("Please enter your phone number");
		document.feedbackForm.visitorPhone.focus();
		return false;
	}
	if(visitorEmail == "")
	{
		alert("Please enter your email");
		document.feedbackForm.visitorEmail.focus();
		return false;
	}
	if(!checkEmail(visitorEmail))
	{
		document.feedbackForm.visitorEmail.select();
		return false;
	}
	
	if(visitorComments == "")
	{
		alert("Please enter your queries/complaints/suggestions ");
		document.feedbackForm.visitorComments.focus();
		return false;
	}
	
	document.feedbackForm.frmAction.value="send";
	return true;
}
function checkLinks() {
	if(trimSpaces(document.forms[0].linkname.value).length <= 0) {
		alert("Please provide the Link Name name");
		document.forms[0].linkname.focus();
		return false;
	}
	if(trimSpaces(document.forms[0].linkurl.value).length <= 0) {
		alert("Please provide the Link URL name");
		document.forms[0].linkurl.focus();
		return false;
	}
document.forms[0].frmAction.value = "update";
document.forms[0].passLinkid.value = document.forms[0].elements["linkid[]"].options[document.forms[0].elements["linkid[]"].selectedIndex].value;
document.forms[0].parentlinkid.value = document.forms[0].elements["linkid[]"].options[document.forms[0].elements["linkid[]"].selectedIndex].value;
return true	
}
function submitThis()
{
	document.forms[0].passLinkid.value="0";
	document.forms[0].submit();
}
function downloadFile(file_id)
{
	document.downLoadForm.file_id.value=file_id;
	document.downLoadForm.toDo.value="download";
	document.downLoadForm.submit();
}
