
browser = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 )) || 
		  ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))

//--------------------------------------------------------------------------------------//
// File Name			: Valid.js														//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This file contains the functions that check the forms for		//
//						  the entries in the not null fields if the entries are not made//
//						  then a message flashed and the focus returns to that			//
//						  particular field.												//
//																						//
// Procedures Invoked	:               												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

//------------------------------------------------------------------------//
// These arrays define the fields that are not null and messaging is given//
// accourding to values in the array, the numbers given along the side	  //
// of the array gives the number supplied when the function is called	  //
// so that each array is identified seperately							  //
//				THESE ARE FOR REGISTRATION FORMS						  //
//------------------------------------------------------------------------//
//		new User array Registration   "0"                                 //
//------------------------------------------------------------------------//
var newUser_arr = new Array("First Name",0,"Last Name",0,0,"Street Address",
					"City",0,0,0,"Phone No",0,"E-Mail",0,"User Name",
					"Password","Confirm Password","Secret Question",
					"Secret Question(Answer)")

var newUser_nn = new Array(0,2,5,6,10,12,14,15,16,17,18)
//------------------------------------------------------------------------//
//	new company Registration     "1"                                      //
//------------------------------------------------------------------------//
var compReg_arr = new Array("User Name","Password","Organization Name",
					"Street Address",0,"City",0,0,0,"Phone",0,"Email","Website")
				  
var compReg_nn = new Array(0,1,2,3,5,9,11,12)
//------------------------------------------------------------------------//
//  calendar Of Events  Registration    "2"                               //
//------------------------------------------------------------------------//
var calOfEvents_arr = new Array("User Name","Password","Name Of Event",0,0,0,0,0,0,0,
					  "Location")

var calOfEvents_nn = new Array(0,1,2,10)

var calOfEvents_dt = new Array(6,9)
//------------------------------------------------------------------------//
//  Jobs  Available  Registration      "3"                                //
//------------------------------------------------------------------------//
var jobAvailable_arr = new Array("User Name","Password","Confirm Password",
					   "Company Name",0,"E-Mail",0,"Phone No",0,"Address",
					   "City","State",0,"Zip Code","Type of Job","Job Description")

var jobAvailable_nn = new Array(0,1,2,3,5,7,9,10,11,13,14,15)
//------------------------------------------------------------------------//
//  Jobs  Wanted Registration     "4"                                     //
//------------------------------------------------------------------------//
var jobWanted_arr = new Array("User Name","Password","Confirm Password",
					"Name","Email",0,0,"Address",0,"City",0,0,0,"Type of Job",
					"Job Description")

var jobWanted_nn = new Array(0,1,2,3,4,7,9,13,14)
//------------------------------------------------------------------------//
//  Picture Submission Registration    "5"                                //
//------------------------------------------------------------------------//
var pictSub_arr = new Array("User Name","Password","Picture Title","Author",
				  0,0,"Picture URL")

var pictSub_nn = new Array(0,1,2,3,6)
//------------------------------------------------------------------------//
//  Picture Modification Registration    "6"                              //
//------------------------------------------------------------------------//
var pictMod_arr = new Array("User Name","Password","Caption Number")

var pictMod_nn = new Array(0,1,2)
//------------------------------------------------------------------------//
//		new User who is who Registration     "7"                          //
//------------------------------------------------------------------------//
var newUserWhW_arr = new Array("User Name","Password","Secret Question",
					 "Answer(Secret Question)","First Name",0,"Last Name",
					 "Title",0,"E-Mail","Street Address","City")

var newUserWhW_nn = new Array(0,1,2,3,4,6,7,9,10,11)
//------------------------------------------------------------------------//
//		Consultants  Registration    "8"                                  //
//------------------------------------------------------------------------//
var consultant_arr = new Array("User Name","Password","Consultant Name",0,
					"Street Address",0,"City",0,0,0,"Phone No")

var consultant_nn = new Array(0,1,2,4,6,10)
//------------------------------------------------------------------------//
//		Education main Registration "9"                                   //
//------------------------------------------------------------------------//
var eduMain_arr = new Array("User Name","Password",0,"Website","Title","Description")

var eduMain_nn = new Array(0,1,3,4,5)
//------------------------------------------------------------------------//
//		continuing education Registration "10"                            //
//------------------------------------------------------------------------//
var contEdu_arr = new Array("User Name","Password","Course Name","Address",
					0,0,0,0,0,0,"City")

var contEdu_nn = new Array(0,1,2,3,10)

var contEdu_dt = new Array(6,9)
//------------------------------------------------------------------------//
//		Directory of Publication Registration "11"                        //
//------------------------------------------------------------------------//
var dirOfPub_arr = new Array("User Name","Password",0,"Title")

var dirOfPub_nn = new Array(0,1,3)
//------------------------------------------------------------------------//
//		Professional Organization Registration    "13"                    //
//------------------------------------------------------------------------//
var profOrg_arr = new Array("User Name","Password","Organization Name",0,0,0,0,0,0,0,0,0,0,
					"Website")

var profOrg_nn = new Array(0,1,2,13)
//------------------------------------------------------------------------//
//		Research Labs Registration "14"                                   //
//------------------------------------------------------------------------//
var resLabs_arr = new Array("User Name","Password",0,"Name of Lab","Department","Location",
					"City")

var resLabs_nn = new Array(0,1,3,4,5,6)
//------------------------------------------------------------------------//
//		University  Registration "15"                                     //
//------------------------------------------------------------------------//
var univ_arr = new Array("User Name","Password","Department","University",
				  "Location","City")

var univ_nn = new Array(0,1,2,3,4,5)
//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
// The following array is for messaging and not null field numbers Arrays //
//	for Edit Forms														  // 
//							THESE ARE FOR EDIT FORMS					  //
//------------------------------------------------------------------------//
//		new User Edit       "16"                                          //
//------------------------------------------------------------------------//
var newUserEdit_arr = new Array("First Name",0,"Last Name",0,0,"Street Address",
					"City",0,0,0,"Phone No",0,"E-Mail")

var newUserEdit_nn = new Array(0,2,5,6,10,12)
//------------------------------------------------------------------------//
//		new User Edit       "17"                                          //
//------------------------------------------------------------------------//
var compEdit_arr = new Array("Organization Name","Street Address",0,"City",0,0,0,"Phone No",0,"E-Mail","Website");

var compEdit_nn = new Array(0,1,3,7,9,10)

//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//		new User Edit       "18"                                          //
//------------------------------------------------------------------------//
var consEdit_arr = new Array("Consultant Name",0,"Street Address",0,"City",0,0,0,"Phone");

var consEdit_nn = new Array(0,2,4,8)

//------------------------------------------------------------------------//
//------------------------------------------------------------------------//
//		new User Edit       "19"                                          //
//------------------------------------------------------------------------//
var univEdit_arr = new Array("Department","University","Location","City");

var univEdit_nn = new Array(0,1,2,3)

//------------------------------------------------------------------------//

//------------------------------------------------------------------------//
//		Research Lab Edit        "20"			                          //
//------------------------------------------------------------------------//
var resLabEdit_arr = new Array(0,"Name of the Lab","Department","Location","City")

var resLabEdit_nn = new Array(1,2,3,4)
//------------------------------------------------------------------------//

//------------------------------------------------------------------------//
//		Education Edit       "21"                                         //
//------------------------------------------------------------------------//
var eduEdit_arr = new Array(0,"Web Site","Title","Description");

var eduEdit_nn = new Array(1,2,3)


//------------------------------------------------------------------------//
//		new User Edit       "22"                                          //
//------------------------------------------------------------------------//
var conEduEdit_arr = new Array("Course Name","Address",0,0,0,0,0,0,0,"City");

var conEduEdit_nn = new Array(0,1,8)


//------------------------------------------------------------------------//
//		new User Edit       "23"                                          //
//------------------------------------------------------------------------//
var jobWanEdit_arr = new Array("Name","E-Mail",0,0,"Address",0,"City",0,0,0,"Type Of Job","Description");

var jobWanEdit_nn = new Array(0,1,4,6,10,11)

//------------------------------------------------------------------------//
//		new User Edit       "24"                                          //
//------------------------------------------------------------------------//
var jobAvaEdit_arr = new Array("Company Name",0,"E-Mail",0,"Phone No",0,
							"Address","City","State",0,"Zip Code","Type Of Job","Description");

var jobAvaEdit_nn = new Array(0,2,4,6,7,8,10,11,12)

//------------------------------------------------------------------------//

//------------------------------------------------------------------------//
//		new User Edit       "25"                                          //
//------------------------------------------------------------------------//
var evtCalEdit_arr = new Array("Name of Event",0,0,0,0,0,0,0,"Location");

var evtCalEdit_nn = new Array(0,8)

var evtCalEdit_dt = new Array(4,7)

//------------------------------------------------------------------------//
//		new User Edit       "25"                                          //
//------------------------------------------------------------------------//
var profOrgEdit_arr = new Array("Organization Name","Website")

var profOrgEdit_nn = new Array(0,1)
//------------------------------------------------------------------------//

//------------------------------------------------------------------------//
// 			FUNCTIONS													  //
//------------------------------------------------------------------------//  
// browser check checks for the version of the browser and the type       //
//------------------------------------------------------------------------//

netBrowser = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 )) 
ieBrowser = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))


//--------------------------------------------------------------------------------------//
// Function Name		: browserChk()													//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function calls the browserChk1(arrCount,me) for both		//
//						  IE AND NETSCAPE but only in the case of new user Registration	//
//						  the checkFieldNUser(me) function is called					//
//																						//
// Procedures Invoked	: browserChk1(arrCount,me),checkFieldNUser(me)					//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function browserChk(arrCount,me)
{
	validFlag = true
	if(netBrowser)
	{
		if(arrCount==0)
		{
			validFlag = checkFieldNUser(me)
		}
		else if(arrCount==1)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==2)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==3)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==4)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==5)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==6)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==7)
		{
			//validFlag = checkFieldsNewUserWhW(me)
		}
		else if(arrCount==8)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==9)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==10)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==11)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==13)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==14)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==15)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==16)
		{
			validFlag = checkFieldNUserEdit(me)
			//validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==17)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==18)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==19)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==20)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==21)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==22)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==23)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==24)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==25)
		{
			validFlag = browserChk1(arrCount,me)
		}
		else if(arrCount==26)
		{
			validFlag = browserChk1(arrCount,me)
		}
	}
	else if(ieBrowser)
	{
		validFlag=browserChk1(arrCount,me)
	}
	return validFlag
}

//--------------------------------------------------------------------------------------//
// Function Name		: browserChk1()													//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function calls the browserChk1(arrCount,me) for both		//
//						  IE AND NETSCAPE but only in the case of new user Registration	//
//						  the chkNullFieldSpec() function is called in the case of		//
//						  forms containing dates										//
//																						//
// Procedures Invoked	: browserChk1(arrCount,me),chkNullFieldSpec()					//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function browserChk1(arrCount,me)
{
	validFlag = true
	if(arrCount==0)
	{
		//function call for NewUser Registration
		validFlag = chkNullField(newUser_arr,newUser_nn,me)
	}
	else if(arrCount==1)
	{
		//function call for Company Registration
		validFlag = chkNullField(compReg_arr,compReg_nn,me)
	}
	else if(arrCount==2)
	{
		//function call for Event Calendar Registration
		validFlag = chkNullFieldSpec(calOfEvents_arr,calOfEvents_nn,calOfEvents_dt,me)
	}
	else if(arrCount==3)
	{
		//function call for Jobs Available Registration
		validFlag = chkNullField(jobAvailable_arr,jobAvailable_nn,me)
	}
	else if(arrCount==4)
	{
		//function call for Jobs Wanted Registration
		validFlag = chkNullField(jobWanted_arr,jobWanted_nn,me)
	}
	else if(arrCount==5)
	{
		//function call for Picture Submition Registration
		validFlag = chkNullField(compReg_arr,compReg_nn,me)
	}
	else if(arrCount==6)
	{
		//function call for Picture Modification Registration
		validFlag = chkNullField(compReg_arr,compReg_nn,me)
	}
	else if(arrCount==7)
	{
		//validFlag = checkFieldsNewUserWhW(me)
	}
	else if(arrCount==8)
	{
		//function call for Consultants Registration
		validFlag = chkNullField(consultant_arr,consultant_nn,me)
	}
	else if(arrCount==9)
	{
		//function call for Education Main Registration
		validFlag = chkNullField(eduMain_arr,eduMain_nn,me)
	}
	else if(arrCount==10)
	{
		//function call for Continuing Education Registration
		validFlag = chkNullFieldSpec(contEdu_arr,contEdu_nn,contEdu_dt,me)
	}
	else if(arrCount==11)
	{
		//function call for Directory of Publication Registration
		validFlag = chkNullField(compReg_arr,compReg_nn,me)
	}
	else if(arrCount==13)
	{
		//function call for Professional Organization Registration
		validFlag = chkNullField(profOrg_arr,profOrg_nn,me)
	}
	else if(arrCount==14)
	{
		//function call for Research Labs Registration
		validFlag = chkNullField(resLabs_arr,resLabs_nn,me)
	}
	else if(arrCount==15)
	{
		//function call for University Registration
		validFlag = chkNullField(univ_arr,univ_nn,me)
	}
	else if(arrCount==16)//form here the edit form validations start
	{
		//function call for New User Edit
		validFlag = chkNullField(newUserEdit_arr,newUserEdit_nn,me)
	}
	else if(arrCount==17)
	{
		//function call for Company Edit
		validFlag = chkNullField(compEdit_arr,compEdit_nn,me)
	}
	else if(arrCount==18)
	{
		//function call for Consultant Edit
		validFlag = chkNullField(consEdit_arr,consEdit_nn,me)
	}
	else if(arrCount==19)
	{
		//function call for University Edit
		validFlag = chkNullField(univEdit_arr,univEdit_nn,me)
	}
	else if(arrCount==20)
	{
		//function call for Research Labs
		validFlag = chkNullField(resLabEdit_arr,resLabEdit_nn,me)
	}
	else if(arrCount==21)
	{
		//function call for Education Main
		validFlag = chkNullField(eduEdit_arr,eduEdit_nn,me)
	}
	else if(arrCount==22)
	{
		//function call for Continuing Education
		validFlag = chkNullField(conEduEdit_arr,conEduEdit_nn,me)
	}
	else if(arrCount==23)
	{
		//function call for Consultant Edit
		validFlag = chkNullField(jobWanEdit_arr,jobWanEdit_nn,me)
	}
	else if(arrCount==24)
	{
		//function call for Company Edit
		validFlag = chkNullField(jobAvaEdit_arr,jobAvaEdit_nn,me)
	}
	else if(arrCount==25)
	{
		//function call for Event Cal Edit
		validFlag = chkNullFieldSpec(evtCalEdit_arr,evtCalEdit_nn,evtCalEdit_dt,me)
	}
	else if(arrCount==26)
	{
		//function call for Prof Org Edit
		validFlag = chkNullField(profOrgEdit_arr,profOrgEdit_nn,me)
	}
	return validFlag
}

//--------------------------------------------------------------------------------------//
// Function Name		: chkNullField(msgArr,nnArr,me)									//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks for the not null fields according to the //
//						  defined above and flashes the corresponding message			//
//																						//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function chkNullField(msgArr,nnArr,me)
{
	var num = me.length    //number of control elements in the form
	Flag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<nnArr.length;i++)
		{
			if(n==nnArr[i])
			{
				// the null field checking block//
				if(me.elements[nnArr[i]].type == "text" || me.elements[nnArr[i]].type == "password" ||
					me.elements[nnArr[i]].type == "textarea"  || me.elements[nnArr[i]].type == "file")
				{
					if ((me.elements[nnArr[i]].value == null || me.elements[nnArr[i]].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
/*				else if(me.elements[nnArr[i]].type == "select-one")
				{
					if ((me.elements[nnArr[i]].selectedIndex == 0 ) && 
					(me.elements[nnArr[i]].type != 'submit' || me.elements[nnArr[i]].type != 'reset'))
	 				{ 
						Flag = 2
						break 
					}
				}*/
			}
		}
		if(Flag == 1 || Flag == 2)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		
		alert("The " + msgArr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[nnArr[i]].focus()
		return false
	}
	if(Flag == 2)
	{

		alert("Please select a value in " + msgArr[n] + " field.")
		me.elements[nnArr[i]].focus()
		return false
	}
}
//------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------//
// Function Name		: chkNullFieldSpec(msgArr,nnArr,dtArr,me)						//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks for the not null fields according to the //
//						  defined above and flashes the corresponding message, it also	//
//						  checks for the valid dates									//
//																						//
// Procedures Invoked	: checkDate(me,n)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function chkNullFieldSpec(msgArr,nnArr,dtArr,me)
{
	var num = me.length    //number of control elements in the form
	Flag = 0
	tdDateFlag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<nnArr.length;i++)
		{
			if(n==nnArr[i])
			{
				// the null field checking block//
				if(me.elements[nnArr[i]].type == "text" || me.elements[nnArr[i]].type == "password" ||
					me.elements[nnArr[i]].type == "textarea")
				{
					if ((me.elements[nnArr[i]].value == null || me.elements[nnArr[i]].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
				/*else if(me.elements[nnArr[i]].type == "select-one")
				{
					if ((me.elements[nnArr[i]].selectedIndex == 0 ) && 
					(me.elements[nnArr[i]].type != 'submit' || me.elements[nnArr[i]].type != 'reset'))
	 				{ 
				
						Flag = 2
						break 
					}
				}*/
			}
		}

		if(me.elements[n].type == "select-one")
		{
			/*if(dtArr[0]==n)
			{	
				tdDateFlag = todayDate(me,n)
				if(tdDateFlag==30 || tdDateFlag==31 || tdDateFlag==32)
				{
					break
				}
			}*/
			if(dtArr[1] == n)
			{
				
				tdDateFlag = checkDate(me,n)
				if(tdDateFlag == 33 || tdDateFlag==34 || tdDateFlag==35)
				{
					break
				}
			}
		}
		if(Flag == 1 || Flag == 2 || Flag == 3)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		alert("The " + msgArr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[nnArr[i]].focus()
		return false
	}
	/*if(Flag == 2)
	{
		alert("Please select a value in " + msgArr[n] + " field.")
		me.elements[nnArr[i]].focus()
		return false
	}*/
	//alert(tdDateFlag);
	if(tdDateFlag == 30 || tdDateFlag == 33)
	{
		me.elements[n].focus()
		return false
	}
	if(tdDateFlag == 31 || tdDateFlag == 34)
	{
		me.elements[n-2].focus()
		return false
	}
	if(tdDateFlag == 32 || tdDateFlag == 35)
	{
		me.elements[n-1].focus()
		return false
	}
	return validFlag
}
//------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Function Name		: checkDate(me,n)												//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks for the starting date to be greater then	//
//						  ending date and flashes a message if so						//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function checkDate(me,n)
{
	if(parseInt(me.elements[n].options[me.elements[n].selectedIndex].value) < parseInt(me.elements[n-3].options[me.elements[n-3].selectedIndex].value))
	{
		alert("Invalid End Date")
		return 33
	}	
	else if(parseInt(me.elements[n].options[me.elements[n].selectedIndex].value) == parseInt(me.elements[n-3].options[me.elements[n-3].selectedIndex].value))
	{
		if(me.elements[n-2].selectedIndex < me.elements[n-5].selectedIndex)
		{
			alert("Invalid End Date");
			return 34
		}
		else if(me.elements[n-2].selectedIndex == me.elements[n-5].selectedIndex)
		{
			if(parseInt(me.elements[n-1].options[me.elements[n-1].selectedIndex].value) < parseInt(me.elements[n-4].options[me.elements[n-4].selectedIndex].value))
			{
				
				alert("Invalid End Date");
				return 35
			}
		}		
	}
}
//------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Function Name		: checkConPass(fieldVal,me)										//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks for the confirm password to be same as	//
//						  the password given, if not smae it flashes a message and puts //
//						  focus back on the confirm password field						//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function checkConPass(fieldVal,me)
{
	if(!(me.value == null || me.value == "") && !(fieldVal==null || fieldVal==""))
	{
		if(!(fieldVal == me.value))
		{
			// messaging block for the valid email and returning focus to the email field //
			alert("The confirm password and password field values do not match.!Please verify")
			me.focus();
			me.select();
		}
	}
	else if(me.value == null || me.value == "")
	{
		validFlag = false
	}
}

//--------------------------------------------------------------------------------------//
// Function Name		: editFormChkNull(me)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks for the username and password field of	//
//						  ordinary user edit form if not present it flashes a message	//
//						  focuses on the particular field								//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
var edit_arr = new Array("UserName","Password")
var edit_nn = new Array(0,1)

function editFormChkNull(me)
{
	var num = me.length    //number of control elements in the form
	Flag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<edit_nn.length;i++)
		{
			if(n==edit_nn[i])
			{
				// the null field checking block//
				if(me.elements[edit_nn[i]].type == "text" || me.elements[edit_nn[i]].type == "password")
				{
					if ((me.elements[edit_nn[i]].value == null || me.elements[edit_nn[i]].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
			}
		}
		if(Flag == 1)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		alert("The " + edit_arr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[edit_nn[i]].focus()
		return false
	}
}
//--------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------//
// Function Name		: chkNum(me)													//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks for the entries in the field to be		//
//						  numbers only if any other character is entered it clears it	//
//						  dynamically													//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function chkNum(me)
{
	var flag=0	//flag value indicating the presence or 
			//absence of a particular character flag=1 
			//not present flag=0 present(default)

	field = new String(me.value)
	for(var j=0;j<field.length;j++)
	{
		//check for the restricted characters and break if they are encountered
		if(!(field.substring(j,j+1)>="0" && field.substring(j,j+1)<="9"))
		{
			flag=1
			break
		}
	}
	//checking the flag condition and eliminating the particular character 	
	if(flag==1)
	{
		me.value = field.substring(0,j) + field.substring(j+1,field.length)
	}
}
//------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------//
// Function Name		: checkFieldNUser(me)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks not null fields in the new user form and //
//						  also the number only field in it and flashes a message		//
//						  accordingly the function message1(Flag) is called to flash	//
//						  the message													//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function checkFieldNUser(me) 
{
	var validFlag = true
	var Flag = 0	
	var num=me.elements.length    //number of control elements in the form
	for (var n=0; n<num; n++) 
	{
		if(n==0 || n==2 || n==5 || n==6 || n==10 || n==12 || n==14 || n==15 || 
		   n==16 || n==17 || n==18)
		{
			if ((me.elements[n].value == null || me.elements[n].value == "") && 
			   (typeof me.elements[n] != 'submit' || typeof me.elements[n] != 'reset'))
		 	{ 
				Flag = 1
				break 
			}
		}
		else
		{
			if(n==22)
			{
				field = new String(me.elements[n].value) //string into which the textbox value is first passed
				for(var k=0; k<field.length;k++)
				{
					if(!((field.charAt(k)>="0" && field.charAt(k)<="9")))
					{	
						Flag=79
						break	
					}
				}
			}
		}
		if(Flag==79)
		{
			break
		}
	}

	if(Flag==1)
	{
		validFlag = false 
		alert("The " + newUser_arr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[n].focus();
		return validFlag 
	}
	if(Flag==79)
	{
		validFlag=message1(Flag)	
		me.elements[n].select();
		me.elements[n].focus();
		return validFlag 
	}
} 
//--------------------------------------------------------------------------------------//
// Function Name		: message1(Flag)												//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function gives the message								//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function message1(Flag)
{
	if(Flag==79)
	{
		alert("Invalid entry in No.Of Publication Field! Please enter numerics only.")
	}	 
	return false
}


//--------------------------------------------------------------------------------------//
// Function Name		: checkFieldNUser(me)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 03-05-2001													//
// Version				: 2.0															//
// Synopsis				: This function checks not null fields in the new user form and //
//						  also the number only field in it and flashes a message		//
//						  accordingly the function message1(Flag) is called to flash	//
//						  the message													//
// Procedures Invoked	: message2(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function checkFieldNUserEdit(me) 
{
	var validFlag = true
	var Flag = 0	
	var num=me.elements.length    //number of control elements in the form

	for (var n=0; n<num; n++) 
	{
		if(n==0 || n==2 || n==5 || n==6 || n==10 || n==12)
		{
			if ((me.elements[n].value == null || me.elements[n].value == "") && 
			   (typeof me.elements[n] != 'submit' || typeof me.elements[n] != 'reset'))
		 	{ 
				Flag = 1
				break 
			}
		}
		else
		{
			if(n==15)
			{
				field = new String(me.elements[n].value) //string into which the textbox value is first passed
				for(var k=0; k<field.length;k++)
				{
					if(!((field.charAt(k)>="0" && field.charAt(k)<="9")))
					{	
						Flag=80
						break	
					}
				}
			}
		}
		if(Flag==80)
		{
			break
		}
	}

	if(Flag==1)
	{
		validFlag = false 
		alert("The " + newUser_arr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[n].focus();
		return validFlag 
	}
	if(Flag==80)
	{
		validFlag=message2(Flag)	
		me.elements[n].select();
		me.elements[n].focus();
		return validFlag 
	}
} 
//--------------------------------------------------------------------------------------//
// Function Name		: message1(Flag)												//
// Author Name			: Dilip M P														//
// Date of Creation		: 03-05-2001													//
// Version				: 2.0															//
// Synopsis				: This function gives the message								//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
function message2(Flag)
{
	if(Flag==80)
	{
		alert("Invalid entry in No.Of Publication Field! Please enter numerics only.")
	}	 
	return false
}

//--------------------------------------------------------------------------------------//
// Function Name		: forgotPwdFormChkNull(me)										//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function gives the message when no entries are made into //
//						  the not null fields of forgot password form					//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
var forgotpwd_arr = new Array("UserName")
//var edit_nn = new Array(0,1)

function forgotPwdFormChkNull(me)
{
	var num = me.length    //number of control elements in the form
	Flag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<forgotpwd_arr.length;i++)
		{
			if(n==0)
			{
				// the null field checking block//
				if(me.elements[0].type == "text" || me.elements[0].type == "password")
				{
					if ((me.elements[0].value == null || me.elements[0].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
			}
		}
		if(Flag == 1)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		alert("The " + forgotpwd_arr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[0].focus()
		return false
	}
}
//--------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------//
// Function Name		: chgPwdFormChkNull(me)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function gives the message when no entries are made into //
//						  the not null fields of change password form					//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
var chgpwd_arr = new Array("Old Password","New Password","Confirm New Password")
var chgpwd_nn = new Array(0,1,2)

function chgPwdFormChkNull(me)
{
	var num = me.length    //number of control elements in the form
	Flag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<chgpwd_nn.length;i++)
		{
			if(n==chgpwd_nn[i])
			{
				// the null field checking block//
				if(me.elements[chgpwd_nn[i]].type == "text" || me.elements[chgpwd_nn[i]].type == "password")
				{
					if ((me.elements[chgpwd_nn[i]].value == null || me.elements[chgpwd_nn[i]].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
			}
		}
		if(Flag == 1)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		alert("The " + chgpwd_arr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[chgpwd_nn[i]].focus()
		return false
	}
}

//--------------------------------------------------------------------------------------//
// Function Name		: forgotPwdHChkNull(me)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function gives the message when no entries are made into //
//						  the not null fields of forgot password hint ans form			//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
var forgotpwdH_arr = new Array("Hint Answer")
//var chgpwd_nn = new Array(0,1,2)

function forgotPwdHChkNull(me)
{
	var num = me.length    //number of control elements in the form
	Flag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<forgotpwdH_arr.length;i++)
		{
			if(n==1)
			{
				// the null field checking block//
				if(me.elements[1].type == "text" || me.elements[1].type == "password")
				{
					if ((me.elements[1].value == null || me.elements[1].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
			}
		}
		if(Flag == 1)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		alert("The " + forgotpwdH_arr[i] + " field cannot be blank. Please enter a value.") 
		me.elements[1].focus()
		return false
	}
}

//--------------------------------------------------------------------------------------//
// Function Name		: regNewAdminChkNull(me)										//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function gives the message when no entries are made into //
//						  the not null fields of Admin registration form				//
// Procedures Invoked	: message1(Flag)												//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//
var regNewAdmin_arr = new Array("Username","Password","Hint Queatiin","Hint Answer")
var regNewAdmin_nn = new Array(0,1,2,3)

function regNewAdminChkNull(me)
{
	
	var num = me.length    //number of control elements in the form
	Flag = 0
	for (var n=0; n<num; n++) 
	{
		for(var i=0;i<regNewAdmin_nn.length;i++)
		{
			if(n==regNewAdmin_nn[i])
			{
				// the null field checking block//
				if(me.elements[regNewAdmin_nn[i]].type == "text" || me.elements[regNewAdmin_nn[i]].type == "password")
				{
					if ((me.elements[regNewAdmin_nn[i]].value == null || me.elements[regNewAdmin_nn[i]].value == "")) 
				   	{ 
						Flag = 1
						break 
					}
				}
			}
		}
		if(Flag == 1)
		{
			validFlag = false 
			break
		}
	}
	// the messaging block in case of null field focus returned to the null field //
	if(Flag == 1)
	{
		alert("The " + regNewAdmin_arr[n] + " field cannot be blank. Please enter a value.") 
		me.elements[regNewAdmin_nn[i]].focus()
		return false
	}
}

//--------------------------------------------------------------------------------------//
// Function Name		: conEduSDate(form1)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function adjusts the numser of days in month bsaed on	//
//						  the months and year selected									//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function conEduSDate(form1) 
{
	timeA = new Date(form1.conEduSyear.options[form1.conEduSyear.selectedIndex].value,form1.conEduSmonth.options[form1.conEduSmonth.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < form1.conEduSday.length; i++) 
	{
		abval = form1.conEduSday.options[form1.conEduSday.selectedIndex].text
	}
	for (var i = 0; i < form1.conEduSday.length; i++) {
		form1.conEduSday.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++) {
		form1.conEduSday.options[i] = new Option(i+1);
	}
	if ((abval != "") && (abval <= daysInMonth))
	{
		abval = (abval - 1)
		form1.conEduSday.options[abval].selected = true;
	}
	else
	{
		form1.conEduSday.options[0].selected = true;
	}
}   

//--------------------------------------------------------------------------------------//
// Function Name		: conEduEDate(form1)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function adjusts the numser of days in month bsaed on	//
//						  the months and year selected									//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function conEduEDate(form1) 
{
	timeA = new Date(form1.conEduEyear.options[form1.conEduEyear.selectedIndex].value,form1.conEduEmonth.options[form1.conEduEmonth.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < form1.conEduEday.length; i++) 
	{
		abval = form1.conEduEday.options[form1.conEduEday.selectedIndex].text
	}
	for (var i = 0; i < form1.conEduEday.length; i++) 
	{
		form1.conEduEday.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++) 
	{
		form1.conEduEday.options[i] = new Option(i+1);
	}
	if ((abval != "") && (abval <= daysInMonth))
	{
		abval = (abval - 1)
		form1.conEduEday.options[abval].selected = true;
	}
	else
	{
		form1.conEduEday.options[0].selected = true;
	}
}

//--------------------------------------------------------------------------------------//
// Function Name		: evtCalSDate(form1)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function adjusts the numser of days in month bsaed on	//
//						  the months and year selected									//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function evtCalSDate(form1) 
{
	timeA = new Date(form1.evtCalSYear.options[form1.evtCalSYear.selectedIndex].value,form1.evtCalSMonth.options[form1.evtCalSMonth.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < form1.evtCalSDay.length; i++) 
	{
		abval = form1.evtCalSDay.options[form1.evtCalSDay.selectedIndex].text
	}
	for (var i = 0; i < form1.evtCalSDay.length; i++) {
		form1.evtCalSDay.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++) {
		form1.evtCalSDay.options[i] = new Option(i+1);
	}
	if ((abval != "") && (abval <= daysInMonth))
	{
		abval = (abval - 1)
		form1.evtCalSDay.options[abval].selected = true;
	}
	else
	{
		form1.evtCalSDay.options[0].selected = true;
	}
}   

//--------------------------------------------------------------------------------------//
// Function Name		: evtCalEDate(form1)											//
// Author Name			: Dilip M P														//
// Date of Creation		: 27-03-2001													//
// Version				: 2.0															//
// Synopsis				: This function adjusts the numser of days in month bsaed on	//
//						  the months and year selected									//
// Procedures Invoked	:																//
//																						//
// Revision History		:																//
//																						//
// DATE			AUTHOR			VERSION					MODIFICATION					//
//--------------------------------------------------------------------------------------//

function evtCalEDate(form1) 
{
	timeA = new Date(form1.evtCalEYear.options[form1.evtCalEYear.selectedIndex].value,form1.evtCalEMonth.options[form1.evtCalEMonth.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < form1.evtCalEDay.length; i++) 
	{
		abval = form1.evtCalEDay.options[form1.evtCalEDay.selectedIndex].text
	}
	for (var i = 0; i < form1.evtCalEDay.length; i++) 
	{
		form1.evtCalEDay.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++) 
	{
		form1.evtCalEDay.options[i] = new Option(i+1);
	}
	if ((abval != "") && (abval <= daysInMonth))
	{
		abval = (abval - 1)
		form1.evtCalEDay.options[abval].selected = true;
	}
	else
	{
		form1.evtCalEDay.options[0].selected = true;
	}
}