// JavaScript Document
function zoomPic(gid,cid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 800;
	winHeight = 600;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showZoom.php?galleryid=" + gid + "&category=" +cid, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function checkPassword() {
	document.forms[0].password.value = trimSpaces(document.forms[0].password.value);
	if(document.forms[0].password.value.length <= 0) {
		alert("Please enter the current password");
		document.forms[0].password.focus();
		return false;
	}
	document.forms[0].newPassword.value = trimSpaces(document.forms[0].newPassword.value);
	if(document.forms[0].newPassword.value.length <= 0) {
		alert("Please enter the new password");
		document.forms[0].newPassword.focus();
		return false;
	}
	document.forms[0].retypePassword.value = trimSpaces(document.forms[0].retypePassword.value);
	if(document.forms[0].newPassword.value != document.forms[0].retypePassword.value) {
		alert("Passwords does not match");
		document.forms[0].retypePassword.focus();
		return false;
	}
}
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 checkContact()
{
	visitorName =  trimSpaces(document.feedbackForm.visitorName.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(visitorEmail == "")
	{
		alert("Please enter your email");
		document.feedbackForm.visitorEmail.focus();
		return false;
	}
	if(!checkEmail(visitorEmail))
	{
		document.feedbackForm.visitorEmail.select();
		return false;
	}
	if(visitorPhone == "")
	{
		alert("Please enter your phone number");
		document.feedbackForm.visitorPhone.focus();
		return false;
	}
	if(visitorComments == "")
	{
		alert("Please enter your comments");
		document.feedbackForm.visitorComments.focus();
		return false;
	}
	
	document.feedbackForm.frmAction.value="send";
	return true;
}
function checkLinks() {
	if(trimSpaces(document.feedbackForm.linkname.value).length <= 0) {
		alert("Please provide the Link Name name");
		document.feedbackForm.linkname.focus();
		return false;
	}
	if(trimSpaces(document.feedbackForm.linkurl.value).length <= 0) {
		alert("Please provide the Link URL name");
		document.feedbackForm.linkurl.focus();
		return false;
	}
document.feedbackForm.frmAction.value = "update";
document.feedbackForm.passLinkid.value = document.feedbackForm.elements["linkid[]"].options[document.feedbackForm.elements["linkid[]"].selectedIndex].value;
document.feedbackForm.parentlinkid.value = document.feedbackForm.elements["linkid[]"].options[document.feedbackForm.elements["linkid[]"].selectedIndex].value;
return true	
}
function submitThis()
{
	document.forms[0].passLinkid.value="0";
	document.forms[0].submit();
}

//function to open in custom window 
function openWindow(url,window_name,winWidth,winHeight,fscroll,position) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;

	if(!position || position.length <= 0) {
		sLeft = (sWidth - winWidth) / 2;
		sTop = (sHeight - winHeight) / 2;
	}else if(position == 'TL') { //Top left
		sLeft = 0;
		sTop = 0;
	}else if(position == 'TR') { //Top right
		sLeft = (sWidth - winWidth) - 30;
		sTop = 0;
	}else if(position == 'BL') { //Bottom left
		sLeft = 0;
		sTop = (sHeight - winHeight) - 50;
	}else if(position == 'BR') { //Bottom left
		sLeft = (sWidth - winWidth) - 30;
		sTop = (sHeight - winHeight) - 50;
	}

	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 checkLen(limit,what) {
  if(what=="name"){
	   if(document.forms[0].name.value.length > limit) {
		 alert('Only 30 Characters allowded!');
		document.forms[0].name.value='';
		 return false;
		 
	   }
	}
	  if(what=="email"){
	   if(document.forms[0].email.value.length > limit) {
		 alert('Only 50 Characters allowded!');
		document.forms[0].email.value='';
		 return false;
		 
	   }
	}

		   
} 

function A_val(frmObj,modifier)
{
	 
	 var fname=document.regis.fname;
	 var lname=document.regis.lname;
	 var course=document.regis.course;	
	 var grad=document.regis.grad;
	 var radd1=document.regis.radd1; 
	 var city=document.regis.city;
	 //var zip=document.regis.zip;
	 var email=document.regis.email;


	 var uname=document.regis.uname;
	 var pwd=document.regis.pwd;
	 var repwd=document.regis.repwd;


	 var question=document.regis.question;
	 var answer=document.regis.answer;
	 var chapter=document.regis.chapter;
	var frmAction = document.regis.frmAction;
	if(fname.value=="")
	{
		
		 alert("Please enter your First Name");
		 fname.focus();
		return false;
	}

	 if(lname.value=="")
	{
		alert("Please enter your Last Name"); 
		lname.focus();
		 return false;
	}

	 if(course.value=="Select")
	{
		alert("Please specify the Programme you underwent in the College"); 
		course.focus();
		 return false;
	}
		
	
	 if(grad.value=="Select")
	{
		alert("Please enter the Year of Graduation....");
		 grad.focus();
		 return false;
	}

	 if(radd1.value=="")
	{
		alert("Please enter your Residential Address"); 
		radd1.focus();
		 return false;
	}
			
	 if(city.value=="")
	{
		alert("Please enter the name of the city you are in"); 
		city.focus();
		 return false;
	}
		
	 if(!checkEmail(email.value))
	{
		email.focus();
		 return false;
	}
	
	if(modifier=='add')
	{
	
		 if(uname.value=="")
		{
			alert("Please enter the User Name, which you will require to login ");
			 uname.focus(); 
			return false;
		}
		else if(checkIfValueExists(frmObj,'checkUserNames',uname.value))
		{
			alert("The username:'" + uname.value + "' already exists");
			frmObj.uname.focus();
			return false;
		}
	}
	 if(pwd.value=="")
	{
		alert("Please enter the Password, which you will require to login ");
		 pwd.focus();
		 return false;
	}
	if(repwd.value=="")
	{
		alert("Please reenter the Password, which you will require to login ");
		 repwd.focus();
		 return false;
	}
	if(pwd.value!=repwd.value)
	{
		alert("Your Passwords dont match. Please ReEnter your password"); 
		pwd.select();
		repwd.select();
		pwd.focus(); 
		return false;
	}
	 if(question.value=="")
	{
		alert("Please enter the secret question");
		 question.focus(); 
		return false;
	}	
	 if(answer.value=="")
	{
		alert("Please enter the secret answer"); 
		answer.focus();	
		 return false;
	}
	
	
	 if(chapter.value=="Unspecified")
	{
		alert("Please specify the Chapter you want to associate yourself with.... "); 			chapter.focus();
		return false;
	}
	
	frmAction.value = "yes";
}

function checkLogin() {
	document.loginFrm.loginName.value = trimSpaces(document.loginFrm.loginName.value);
	if(document.loginFrm.loginName.value.length <= 0) {
		alert("Please enter the username");
		document.loginFrm.loginName.focus();
		return false;
	}
	document.loginFrm.loginPassword.value = trimSpaces(document.loginFrm.loginPassword.value);
	if(document.loginFrm.loginPassword.value.length <= 0) {
		alert("Please enter password");
		document.loginFrm.loginPassword.focus();
		return false;
	}
}
function searchFromHome(){

	searchKey = trimSpaces(document.searchForm.searchKey.value);
	
	if(searchKey == '') {
		alert("Enter search string");
		document.searchForm.searchKey.focus();
		return false;
	}

	document.searchForm.submit();
}

function checksubscribe(){

	newsname = trimSpaces(document.newsletterForm.newsname.value);
	newsemail = trimSpaces(document.newsletterForm.newsemail.value);
	
	if(newsname == '') {
		alert("Enter your name");
		document.newsletterForm.newsname.focus();
		return false;
	}
	if(newsemail == '') {
		alert("Enter your email");
		document.newsletterForm.newsemail.focus();
		return false;
	}
	if(!checkEmail(newsemail)){
		document.newsletterForm.newsemail.focus();
		return false;
	}

	document.newsletterForm.submit();
}

function checkEnquiry()
{
	custName = trimSpaces(document.enqFrm.custName.value);
	if(custName.length<=0){
		alert("Enter your name");
		document.enqFrm.custName.focus();
		return false;
	}
	email = trimSpaces(document.enqFrm.email.value);
	if(email.length<=0){
		alert("Enter the email address");
		document.enqFrm.email.focus();
		return false;
			
	}
	else if(! checkEmail(email)){
		document.enqFrm.email.focus();
		return false;
	}	
	custComments = trimSpaces(document.enqFrm.custComments.value);
	if(custComments.length<=0){
		alert("Enter your comments");
		document.enqFrm.custComments.focus();
		return false;
			
	}
	document.enqFrm.frmAction.value="yes";	
	return true;	
}
function showRiser() {
	sWidth = 800;
	sHeight = 615;
	
	sTop = 50
	sLeft = 50
	
	window.open("php/showRiserContent.php?linkid=108", "downLoadFile", "width=" + sWidth + ",height=" + sHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=1,scrollbars=1,resizable=1");
	return;
}

function checkResearchEnquiry() {
	frmObject = document.researchEnquiry;
	
	frmObject.institution.value = trimSpaces(frmObject.institution.value);
	frmObject.address1.value = trimSpaces(frmObject.address1.value);
	frmObject.phone.value = trimSpaces(frmObject.phone.value);
	frmObject.email.value = trimSpaces(frmObject.email.value);
	frmObject.contactperson.value = trimSpaces(frmObject.contactperson.value);
	frmObject.researchArea.value = trimSpaces(frmObject.researchArea.value);
	
	institution = trimSpaces(frmObject.institution.value);
	address1 = trimSpaces(frmObject.address1.value);
	phone = trimSpaces(frmObject.phone.value);
	email = trimSpaces(frmObject.email.value);
	contactperson = trimSpaces(frmObject.contactperson.value);
	researchArea = trimSpaces(frmObject.researchArea.value);
	
	if(institution.length <= 0) {
		alert("Please provide the name of institution");
		frmObject.institution.focus();
		return false;
	}
	if(address1.length <= 0) {
		alert("Please provide the address");
		frmObject.address1.focus();
		return false;
	}
	if(phone.length <= 0) {
		alert("Please provide the phone number");
		frmObject.phone.focus();
		return false;
	}
	if(email.length <= 0) {
		alert("Please provide your email");
		frmObject.email.focus();
		return false;
	}
	if(!checkEmail(email)) {
		frmObject.email.focus();
		return false;
	}
	if(contactperson.length <= 0) {
		alert("Please provide the name of contact person");
		frmObject.contactperson.focus();
		return false;
	}
	if(researchArea.length <= 0) {
		alert("Please provide the area of research");
		frmObject.researchArea.focus();
		return false;
	}
}
