// JavaScript Document

function openWindow(url,window_name,winWidth,winHeight,fscroll) {
	sWidth 	= screen.availWidth;
	sHeight = screen.availHeight;

	sLeft 	= (sWidth - winWidth) / 2;
	sTop 	= (sHeight - winHeight) / 2;
	if(fscroll == ''){fscroll = 0}
	window.open(url,window_name,"width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=" + fscroll + ",resizable=0");
}

function checkLogin(objForm){
	username = trimSpaces(objForm.username.value);
	if(username.length <= 0) {
		alert("Please enter your username");
		objForm.username.focus();
		return false;
	}
	
	password = trimSpaces(objForm.password.value);
	if(password.length <= 0) {
		alert("Please enter your password");
		objForm.password.focus();
		return false;
	}

	return true;
}// checkLogin()

function checkUpdateClientsideUser(objForm) {
	username = trimSpaces(objForm.username.value);
	password = trimSpaces(objForm.password.value);
	email = trimSpaces(objForm.email.value);
	
	if(username == "") {
		alert("Please enter the User Name.");	
		objForm.username.focus();
		return false;
	}
	
	if(password == "") {
		alert("Please enter the Password.");	
		objForm.password.focus();
		return false;
	}
	
	if(email == "") {
		alert("Please enter the email.");	
		objForm.email.focus();
		return false;
	}
	else if(!checkEmail(email)){
		objForm.email.focus();
		return false;
	}
}// checkUpdateClientsideUser()

function checkSuggestion(objForm){
	sugg_title = trimSpaces(objForm.sugg_title.value);
	if(sugg_title == ""){
		alert("Please enter the Title of your suggesstion");
		objForm.sugg_title.focus();
		return false;
	}

	sugg_body = trimSpaces(objForm.sugg_body.value);
	if(sugg_body == ""){
		alert("Please enter your Suggesstion");
		objForm.sugg_body.focus();
		return false;
	}
	objForm.frmAction.value = "send";
}// checkSuggestion()

function checkQuickFinder(frm, txt) {
	
	if(txt == "searchbykeyword") {
		txtKey = trimSpaces(frm.txtKey.value);
		if(txtKey == "") {
			alert("Please enter the keyword");	
			frm.txtKey.focus();
			return false;
		}
	}else if(txt == "searchbydept") {
		cmbDept = trimSpaces(frm.cmbDept.value);
		if(cmbDept == "") {
			alert("Please select the department");	
			frm.cmbDept.focus();
			return false;
		}
		frm.action = "index.php";
	}else if(txt == "searchbydoc") {
		txtDoc = trimSpaces(frm.txtDoc.value);
		if(txtDoc == "") {
			alert("Please enter the doctor's name");	
			frm.txtDoc.focus();
			return false;
		}
	}
	frm.frmAction.value = txt;
	frm.submit();
}

function checkQuickFinderDoc(){
	txtDoc = trimSpaces(document.quickfinder.txtDoc.value);
	if(txtDoc == ""){
		alert("Please enter the doctor's name");	
		document.quickfinder.txtDoc.focus();
		return false;
	}
	document.quickfinder.frmAction.value = 'searchbydoc';
	document.quickfinder.submit();
}

function validate(){
	if(document.forms.employee_name.value == ""){
	 	alert("Please enter name ");
		document.forms.employee_name.focus();
		return false;
	}
	if(document.forms.employee_email.value == ""){
	 	alert("Please enter email ");
		document.forms.employee_email.focus();
		return false;
	}
	if(!checkEmail(document.forms.employee_email.value)){
		document.forms.employee_email.select();
		document.forms.employee_email.focus();
		return false;
	}
	if(document.forms.resume_text.value == ""){
	 	alert("Enter your skills ");
		document.forms.resume_text.focus();
		return false;
	}
	document.forms.frmAction.value = 'upload';
}

function Doctor(){
	id=document.form1.app_department.value;
	document.form1.deptID.value = id;
	document.form1.frmAction.value = 'departments';
	document.form1.submit();
}


function checkDFPost(objForm,postType) {
	if(postType == "post")  {
		subject = trimSpaces(objForm.subject.value);
		if(subject.length <= 0) {
			alert("Please enter the Subject.");	
			objForm.subject.focus();
			return false;
		}
	}
	
	messageBody = trimSpaces(objForm.messagebody.value);
	if(messageBody.length <= 0) {
		alert("Please enter the Message.");	
		objForm.messagebody.focus();
		return false;
	}
}// checkDFPost()
