var whitespace =" \t\n\r "; 
 
// function for checking empty filed 
 
function isEmpty(str) 
{   
	return ((str == null) || (str.length == 0)) 
} 
 
// end of function 
	 
// function to check the whitespace 
 
function isWhitespace(str) 
{    var i; 
	 var flag 
 
 	  // Is s empty? 
 	  if (isEmpty(str)) return true;		 
 	   // Search through string's characters one by one 
 	   // until we find a non-whitespace character. 
 	   // When we do, return false; if we don't, return true. 
 	   for (i = 0; i < str.length; i++) 
 	   {    
 	       // Check that current character isn't whitespace. 
 	       var c = str.charAt(i); 
 
		   if (whitespace.indexOf(c) == -1) 
		   		return false 
 	   }	 
 	   // All characters are whitespace. 
		    return true; 
} 
 
// end of function 
 
// function to check the maxlength of the textarea 
 
function checkMaxLength(val,maxlength) 
{ 
	var val1 
	val1 = val.length 
	if (parseInt(val1)>parseInt(maxlength)) 
	{ 
		lflag=false 
		return lflag; 
		//return true; 
	} 
	else 
	{ 
		lflag=true 
		return lflag; 
		//return false; 
	} 
} 
 
// end of function 
 
// function for special charachteres (",%) 
	function isSpecialCharPresnt(objValue) 
	{ 
 
		var characters="$,#" 
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{		 
			tmp=objValue.substring(i,i+1) 
			if(characters.indexOf(tmp)>=0) 
			{				 
				lTag = 1 
				break; 
			} 
		} 
		if(lTag == 1) 
			return true 
		else 
			return false 
	} 
// end of function 
	 
	 
// function for checking if inputed value is a valid number 
// @param objValue - string  
 
function isAllNumeric(objValue) 
{	 
			lTempLength = objValue.length 
			lTempCounter = 0  
			lTempString = trim(objValue) 
			flag = false 
			 
			do 
			{ 
			if(lTempString.charAt(lTempCounter) == " ") 
			{ 
				flag = false 
				break 
			} 
			else if(lTempString.charAt(lTempCounter) > 0 || lTempString.charAt(lTempCounter) < 9) 
				flag = true 
			else 
				{ 
					flag = false 
					break 
				} 
				lTempCounter = lTempCounter + 1 
			} 
			while(lTempCounter <= lTempLength)			 
			 
			if(flag == true) 
				return true 
			else 
				return false 
} 
 
// end of function 
 
// function for checking all entered valuea are numbers only with decimal values 
 
function isWholePositiveNumber(obj) 
{ 
		flag = 0 
		if(isNaN(obj)) 
		{ 
			flag=1; 
		} 
		 
		if(flag==0) 
		{ 
			for(i=0;i<obj.length;i++) 
			{ 
				//if(obj.charAt(i)=="-" || obj.charAt(i)==".") 
				if(obj.charAt(i)=="-") 
				{ 
					flag=1; 
				} 
			} 
		} 
		 
		if(flag==1) 
		{ 
			return false 
		}	 
		else if(flag==0) 
		{ 
			return true 
		} 
} 
 
// end of function 
 
// function for checking all entered valuea are numbers only with decimal values 
 
function isNegativeNumber(obj) 
{ 
		flag = 0 
		if(isNaN(obj)) 
		{ 
			flag=1; 
		} 
		 
		if(flag==0) 
		{ 
			for(i=0;i<obj.length;i++) 
			{ 
				//if(obj.charAt(i)=="-" || obj.charAt(i)==".") 
				if(obj.charAt(i)==".") 
				{ 
					flag=1; 
				} 
			} 
		} 
		 
		if(flag==1) 
		{ 
			return false 
		}	 
		else if(flag==0) 
		{ 
			return true 
		} 
} 
 
// end of function 
 
// function to check all the entered values are characters only 
 
function isAllCharacters(objValue) 
{ 
		var characters=" 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ." 
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=objValue.substring(i,i+1) 
			if (characters.indexOf(tmp)==-1) 
			{ 
				lTag = 1 
			} 
		} 
		if(lTag == 1) 
			return false 
		else 
			return true 
} 
	 
// end of function 
 
// function to check all the entered values are characters only 
 
function isDomainName(objValue) 
{ 
		var characters="_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789." 
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=objValue.substring(i,i+1) 
			if (characters.indexOf(tmp)==-1) 
			{ 
				lTag = 1 
			} 
		} 
		if(lTag == 1) 
			return false 
		else 
			return true 
} 
	 
// end of function 
 
 
// function2 to check all the entered values are characters only 
 
function isAllCharacters2(objValue) 
{ 
		var characters="'- abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=objValue.substring(i,i+1) 
			if (characters.indexOf(tmp)==-1) 
			{ 
				lTag = 1 
			} 
		} 
		if(lTag == 1) 
			return false 
		else 
			return true 
} 
// end of function2	 
 
//function3 to check if all characters only  
function isGroupName(objValue) 
{ 
		var characters="'-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 " 
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=objValue.substring(i,i+1) 
			if (characters.indexOf(tmp)==-1) 
			{ 
				lTag = 1 
			} 
		} 
		if(lTag == 1) 
			return false 
		else 
			return true 
} 
// end of function2	 
 
 
function specialnum(field,name,R)  
{ 
	missinginfo = ""	; 
	if(R=="R") 
	{ 
	if(field.value==""){ 
	missinginfo+="\n"+name+" m�fylles ut"; 
	return missinginfo; 
	 } 
	} 
	 
	var valid = "0123456789"; 
	var ok = "yes"; 
	var temp; 
	for (var i=0; i<field.value.length; i++)  
	{ 
	temp = "" + field.value.substring(i, i+1); 
	if (valid.indexOf(temp) == "-1") ok = "no"; 
	} 
	if (ok == "no") 
	{ 
	missinginfo += "\n"+ name + "(Bare taller tillatt)"; 
	return missinginfo; 
	field.focus(); 
	field.select(); 
	} 
	else return ""; 
  } 
   
// function to check all the entered values are characters only 
 
function isAlphaNumeric(objValue) 
{	 
			var characters="'-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 
			var tmp 
			var lTag 
			lTag = 0 
			temp = (objValue.length) 
			for (var i=0;i<temp;i++) 
			{ 
				tmp=objValue.substring(i,i+1) 
				if (characters.indexOf(tmp)==-1) 
				{ 
					lTag = 1 
				} 
			} 
			if(lTag == 1) 
				return false 
			else 
				return true 
	 
} 
	 
// end of function 
// function to check the valid Email Prefix 
function isEmailPrefix(objValue) 
{	 
			var characters="-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._" 
			var tmp 
			var lTag 
			lTag = 0 
			temp = (objValue.length) 
			for (var i=0;i<temp;i++) 
			{ 
				tmp=objValue.substring(i,i+1) 
				if (characters.indexOf(tmp)==-1) 
				{ 
					lTag = 1 
				} 
			} 
			if(lTag == 1) 
				return false 
			else 
				return true 
	 
} 
// function for checking blank value as wee as white space but allowes space between two characters  
 
function checkEmpty(objValue) 
{ 
   	if(isWhitespace(objValue)==true) 
    { 
	    return(true) 
	} 
	else 
   	{ 
    	return(false)			 
	}			 
}		 
 
// end of function 
 
 
// check alpha numeric  
function checkAlphaNumeric(objValue,objName,checkForNull) 
{	 
	err="" 
	 
	if (checkForNull.toUpperCase()=="Y") 
	{	 
		 
		if (checkEmpty(objValue)==true) 
		{  
			err =objName +" can not contain only space or can not be blank"  
			 
		}  
	}	 
	else 
	{			 
			var characters="-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 
			var tmp 
			var lTag 
			lTag = 0 
			temp = (objValue.length) 
			for (var i=0;i<temp;i++) 
			{ 
				tmp=objValue.substring(i,i+1) 
				if (characters.indexOf(tmp)==-1) 
				{ 
					err = objName+"Can not contains special characters" 
				 
				} 
			} 
							 
	}		 
	return err  
} 
// end of function 
 
// function for triming 
 
function trim(pstrString) 
{ 
	var intLoop=0; 
 
	for(intLoop=0; intLoop<pstrString.length; ) 
	{ 
		if(pstrString.charAt(intLoop)==" ") 
			pstrString=pstrString.substring(intLoop+1, pstrString.length); 
		else 
			break; 
	} 
 
	for(intLoop=pstrString.length-1; intLoop>=0; intLoop=pstrString.length-1) 
	{ 
		if(pstrString.charAt(intLoop)==" ") 
			pstrString=pstrString.substring(0,intLoop); 
		else 
			break; 
	} 
	return pstrString; 
} 
 
// function for valid file to be upload 
// @ param : val = value , msg = for which, typ = for which type - A = All files(.htm,.html,.jpg,.gif,.bmp,.jpeg)  
// H - .htm, .html 
// I - .jpg, .jpeg, .gif, .bmp 
// Att - all fileas are valid and only length is validated for 50 characters 
 
function IsValidFile(val,msg,typ) 
{ 
		var value=val;
		val = trim(val) 
		strlen = val.length 
		strcnt = val.lastIndexOf("\\") 
		newstr = val.substr(strcnt+1,strlen) 
		tempval = val.toUpperCase() 
		val = tempval.substr(val.lastIndexOf("."),val.length) 
		var flg= 0 
		var err = "" 
 		
 
		if( (typ=='A')&&( ( ((val.length==5)&&((val!='.JPEG')&&(val!='.HTML')))|| ((val.length==4)&&((val!='.HTM')&&(val!='.JPG')&&(val!='.GIF')&&(val!='.BMP')&&(val!='.TXT'))))||(val.length>5) )) 
		{ 
			err = "Only .gif/.jpg/.jpeg/.bmp/.html/.htm/.txt can be selected for "+msg;
		}	 
		else if( (typ=='H')&&( ( ((val.length==5)&&(val!='.HTML'))|| ((val.length==4)&&(val!='.HTM')))||(val.length>5) )) 
		{ 
			err = "Only .html/.htm files can be selected for "+msg; 
		} 
		else if( (typ=='I')&&( ( ((val.length==5)&&(val!='.JPEG'))|| ((val.length==4)&&((val!='.JPG')&&(val!='.GIF')&&(val!='.BMP'))))||(val.length>5) )) 
		{ 
			err = "Only .gif/.jpg/.jpeg/.bmp files can be selected for "+msg; 
		} 
		/* 
		else if((typ=='T')&&(((val.length==4)&&(val!='.TXT')))) 
		{ 
			err = "Only .txt file can be selected for "+msg+".<br>" 
		} 
		*/ 
		else if ( (newstr.indexOf(".") == 0)|| (val.indexOf('.') == -1) || (val.length <4) )  
			err = "File selected for "+msg+" is invalid"; 
		else if(newstr.indexOf("'") != -1) 
			err = "File selected for "+msg+" contains invalid character"; 
		else if (newstr.length > 255) 
			err = "Length of file name selected for "+msg+" must be less then or equal to 255"; 
	    if(value!="")
		return err 
}	 
 
// end of function 
 
// this is the same function for checking the valid file extension except it returns true or false 
 
function isInValidFile(val,msg,typ) 
{ 
		val = trim(val) 
		strlen = val.length 
		strcnt = val.lastIndexOf("\\") 
		newstr = val.substr(strcnt+1,strlen) 
		tempval = val.toUpperCase() 
		val = tempval.substr(val.lastIndexOf("."),val.length) 
		var flg= 0 
		var err = "" 
		 
		if( (typ=='A')&&( ( ((val.length==5)&&((val!='.JPEG')&&(val!='.HTML')))|| ((val.length==4)&&((val!='.HTM')&&(val!='.JPG')&&(val!='.GIF')&&(val!='.TXT'))))||(val.length>5) )) 
		{ 
			return true; 
		}	 
		else if( (typ=='H')&&( ( ((val.length==5)&&(val!='.HTML'))|| ((val.length==4)&&(val!='.HTM')))||(val.length>5) )) 
		{ 
			return true; 
		} 
		else if( (typ=='I')&&( ( ((val.length==5)&&(val!='.JPEG'))|| ((val.length==4)&&((val!='.JPG')&&(val!='.GIF'))))||(val.length>5) )) 
		{ 
			return true; 
		} 
		if( (typ=='HI')&&( ( ((val.length==5)&&((val!='.JPEG')&&(val!='.HTML')))|| ((val.length==4)&&((val!='.HTM')&&(val!='.JPG')&&(val!='.GIF'))))||(val.length>5) )) 
		{ 
			return true; 
		} 
		/* 
		else if((typ=='T')&&(((val.length==4)&&(val!='.TXT')))) 
		{ 
			err = "Only .txt file can be selected for "+msg+".<br>" 
		} 
		*/ 
		else if((typ=='X')&&(((val.length==4)&&(val!='.XLS')))) 
		{ 
			return true; 
		} 
		else if((typ=='K')&&((((val.length==3)&&((val!='.KW')))||(val.length>3)))) 
		{ 
			return true; 
		} 
		else if ( (newstr.indexOf(".") == 0)|| (val.indexOf('.') == -1) || (val.length <4) )  
			return true; 
		else if(newstr.indexOf("'") != -1) 
			return true; 
		else if (newstr.length > 50) 
			return true; 
	    		 
}	 
 
// end of function 
 
// function to put the comma in between the validation fileds 
 
function putcomma(msg) 
{ 
	if((msg!="")) 
	{ 
		msg = msg+"," ; 
	} 
	return (msg); 
} 
	 
// end of function	 
 
 
//checking whether date is valid or not ie no of days are correct or not as per the month 
 
function isValidDate(tempDate, tempMonth, tempYear) 
{   
	 	// check weather the date is selected or not 
	    if ((tempDate =="Day") || (tempMonth == "Month") || (tempYear == "Year" )) 
	    { 
		 return false; 
	    } 
	    else if((tempDate !="") && (tempMonth != "") && (tempYear != "" )) 
		{  
		 
			var tempNoOfDays 
			var lArrMonthDays = new Array(2) 
			var dateFlag 
				 
			dateFlag = false 
				 
			lArrMonthDays[0] = new Array(12) 
			lArrMonthDays[1] = new Array(12) 
							 
			lArrMonthDays[0][0] = "1" 
			lArrMonthDays[1][0] = "31" 
				 
			lArrMonthDays[0][1] = "2" 
			lArrMonthDays[1][1] = "28" 
				 
			lArrMonthDays[0][2] = "3" 
			lArrMonthDays[1][2] = "31" 
				 
			lArrMonthDays[0][3] = "4" 
			lArrMonthDays[1][3] = "30" 
				 
			lArrMonthDays[0][4] = "5" 
			lArrMonthDays[1][4] = "31" 
				 
			lArrMonthDays[0][5] = "6" 
			lArrMonthDays[1][5] = "30" 
				 
			lArrMonthDays[0][6] = "7" 
			lArrMonthDays[1][6] = "31" 
				 
			lArrMonthDays[0][7] = "8" 
			lArrMonthDays[1][7] = "31" 
				 
			lArrMonthDays[0][8] = "9" 
			lArrMonthDays[1][8] = "30" 
				 
			lArrMonthDays[0][9] = "10" 
			lArrMonthDays[1][9] = "31" 
				 
			lArrMonthDays[0][10] = "11" 
			lArrMonthDays[1][10] = "30" 
				 
			lArrMonthDays[0][11] = "12" 
			lArrMonthDays[1][11] = "31"						 
				 
			if(tempMonth == 2) 
			{			 
				if(tempYear % 4 == 0 || tempYear % 400 == 0) 
				{ 
					//change the days of Feb to 29 b'coz LEAP YEAR 
					lArrMonthDays[1][1] = "29"							 
				} 
			}			 
			 
			tempNoOfDays = lArrMonthDays[1][tempMonth-1]			 
		 
			// check for the no of days for the selected month 
			if(parseInt(tempDate) > parseInt(tempNoOfDays)) 
			{ 
				dateFlag = false 
			} 
			else				 
			{ 
				dateFlag = true 
			} 
					 
			return dateFlag 
		} 
		else 
		{ 
			return false;	 
		} 
} 
 
// end of function 
 
// function for comparison of date 
 
function fnDateComp(frmNm,Day1,Month1,Year1,Day2,Month2,Year2) 
{	 
 
	var Day1	=	eval("document."+frmNm+"."+Day1+"[document."+frmNm+"."+Day1+".selectedIndex].value") 
	var Day2	=	eval("document."+frmNm+"."+Day2+"[document."+frmNm+"."+Day2+".selectedIndex].value") 
	var Month1	=	eval("document."+frmNm+"."+Month1+"[document."+frmNm+"."+Month1+".selectedIndex].value") 
	var Month2	=	eval("document."+frmNm+"."+Month2+"[document."+frmNm+"."+Month2+".selectedIndex].value") 
	var Year1	=	eval("document."+frmNm+"."+Year1+"[document."+frmNm+"."+Year1+".selectedIndex].value") 
	var Year2	=	eval("document."+frmNm+"."+Year2+"[document."+frmNm+"."+Year2+".selectedIndex].value") 
 
	if(parseFloat(Year1) > parseFloat(Year2)) 
	{ 
		return true; 
	} 
	 
	if(parseFloat(Year1)==parseFloat(Year2)) 
	{ 
		if(parseFloat(Month1) > parseFloat(Month2)) 
		{  	 
			 
			return true; 
		} 
		else if(parseFloat(Month1)==parseFloat(Month2)) 
		{  
			if((parseFloat(Day1)>parseFloat(Day2))) 
			{   
				return true; 
			} 
			else 
			{ 
				return false; 
			} 
		} 
		else 
		{ 
			return false; 
		} 
	} 
	 
	if (parseFloat(Year1) < parseFloat(Year2)) 
	{ 
		return false; 
	} 
}	 
 
// end of function 
 
 
 
//-------------- email validation ------- 
 
function isValidEmail(emailStr) 
{ 
			/* The following pattern is used to check if the entered e-mail address 
			   fits the user@domain format.  It also is used to separate the username 
			   from the domain. */ 
			var emailPat=/^(.+)@(.+)$/ 
			/* The following string represents the pattern for matching all special 
			   characters.  We don't want to allow special characters in the address.  
			   These characters include ( ) < > @ , ; : \ " . [ ]    */ 
			//var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 
			var specialChars="\\(\\)<>@,`';:~!#$%^&*+=|{}?\\\\\\\"\\.\\[\\]" 
			 
			/* The following string represents the range of characters allowed in a  
			   username or domainname.  It really states which chars aren't allowed. */ 
			var validChars="\[^\\s" + specialChars + "\]" 
			/* The following pattern applies if the "user" is a quoted string (in 
			   which case, there are no rules about which characters are allowed 
			   and which aren't; anything goes).  E.g. "sg cricket"@disney.com 
			   is a legal e-mail address. */ 
			var quotedUser="(\"[^\"]*\")" 
			/* The following pattern applies for domains that are IP addresses, 
			   rather than symbolic names.  E.g. sg@[123.124.233.4] is a legal 
			   e-mail address. NOTE: The square brackets are required. */ 
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ 
			/* The following string represents an atom (basically a series of 
			   non-special characters.) */ 
			var atom=validChars + '+' 
			/* The following string represents one word in the typical username. 
			   For example, in sg.sg@somewhere.com, sg and sg are words. 
			   Basically, a word is either an atom or quoted string. */ 
			var word="(" + atom + "|" + quotedUser + ")" 
			// The following pattern describes the structure of the user 
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$") 
			/* The following pattern describes the structure of a normal symbolic 
			   domain, as opposed to ipDomainPat, shown above. */ 
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") 
 
 
			/* Finally, let's start trying to figure out if the supplied address is 
			   valid. */ 
 
			/* Begin with the coarse pattern to simply break up user@domain into 
			   different pieces that are easy to analyze. */ 
			var matchArray=emailStr.match(emailPat) 
			if (matchArray==null) { 
			  /* Too many/few @'s or something; basically, this address doesn't 
			     even fit the general mould of a valid e-mail address. */ 
				//alert("Email address seems incorrect (check @ and .'s)") 
				return false 
			} 
			var user=matchArray[1] 
			var domain=matchArray[2] 
			// See if "user" is valid  
			if (user.match(userPat)==null) { 
			    // user is not valid 
			    //alert("The username doesn't seem to be valid.") 
			    return false 
			} 
 
			/* if the e-mail address is at an IP address (as opposed to a symbolic 
			   host name) make sure the IP address is valid. */ 
			var IPArray=domain.match(ipDomainPat) 
			if (IPArray!=null) { 
			    // this is an IP address 
				  for (var i=1;i<=4;i++) { 
				    if (IPArray[i]>255) { 
				        //alert("Destination IP address is invalid!") 
					return false 
				    } 
			    } 
			    return true 
			} 
 
			// Domain is symbolic name 
			var domainArray=domain.match(domainPat) 
			if (domainArray==null) { 
			//alert("The domain name doesn't seem to be valid.") 
			    return false 
			} 
 
			/* domain name seems valid, but now make sure that it ends in a 
			   three-letter word (like com, edu, gov) or a two-letter word, 
			   representing country (uk, nl, no), and that there's a hostname preceding  
			   the domain or country. */ 
 
			/* Now we need to break up the domain to get a count of how many atoms 
			   it consists of. */ 
			var atomPat=new RegExp(atom,"g") 
			var domArr=domain.match(atomPat) 
			var len=domArr.length 
			if (domArr[domArr.length-1].length<2 ||  
			    domArr[domArr.length-1].length>3) { 
			   // the address must end in a two letter or three letter word. 
			   //alert("The address must end in a three-letter domain, or two letter country.") 
			   return false 
			} 
 
			// Make sure there's a host name preceding the domain. 
			if (len<2) { 
			   var errStr="This address is missing a hostname!" 
			   //alert(errStr) 
			   return false 
			} 
 
			// If we've gotten this far, everything's valid! 
			return true; 
} 
 
// end of function 
 
 
// function to get the file name 
 
function getFileName(fileName) 
{ 
	// get the file name 
	 
	// find the length 
	strlen = fileName.length; 
	// find out the location of last back slash(\) 
	strcnt =fileName.lastIndexOf("\\"); 
	// find the name of the file 
	nameOfFile = fileName.substr(strcnt+1,strlen) 
	// return the file name		 
	return nameOfFile; 
	 
} 
 
 
//************code for validation of same file name not allowed for  Left Column and reading reference 
 
function isDuplicatFileNameCheck(fileName,fileControlName,formName) 
{	 
	tempflag = true 
	errMsg ="" 
	 
	if(tempflag==true) 
	{	 
		val = fileName 
		 
			if (trim(val) != "") 
			{		 
					// assign the file to variable which will check for duplicate 
					FixedFileName = fileName 
					 
					// loop through the form elements for checking all the file elements 
					for(i=1;i<=eval("document."+formName+".elements.length") - 1;i++) 
					{ 
						// get the currnet control name  
						CurControlname= eval("document."+formName+".elements["+i+"].name") 
						 
						// compare the current control name with the passed control name if not equal then 
						// check for the duplicate name						 
						if (fileControlName.toUpperCase() != CurControlname.toUpperCase()) 
						{	 
							// check form element of type "FILE"	 
							if (eval("document."+formName+".elements["+i+"].type.toUpperCase()")=="FILE") 
							{	 
								// get the current form control file value 
								CurControlValue = getFileName("document."+formName+".elements["+i+"].value") 
								 
								// comapre the Fixed file name with the others 
								if (FixedFileName.toUpperCase() == CurControlValue.toUpperCase()) 
								{ 
									tempflag=false 
									break; 
								 
								} 
							} 
						} 
					} 
			} 
			if(tempflag==false) 
			{	 
				errMsg = errMsg  + "Please select different files/fine name for uploading" 
				return errMsg; 
			} 
			else 
			{ 
				return errMsg + "File  is not duplicate" 
			} 
	} 
} 
	 
// function for combo box selectd 
function isComboSelected(frmNm,objName,valueForCompare) 
{ 
   	var objName	=	eval("document."+frmNm+"."+objName+"[document."+frmNm+"."+objName+".selectedIndex].value") 
 
   	if (objName.toUpperCase() == valueForCompare.toUpperCase()) 
   	  return true 
   	else 
   	  return false	   
}  	 
 
// function to check special characters in course Id 
function isSpecialCharactersCourseId(objValue) 
	{ 
		tmp = 0 
		var characters="`<>?/,.=~!@$%^[]{}&*\;+|\'\"\\" 
		ltag = false 
		temp = characters.length 
 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=characters.substring(i,i+1) 
			if (objValue.indexOf(tmp) != -1) 
			{ 
				ltag = true  
				break  
			} 
		} 
		return ltag 
	} 
//end function	 
 
//Function to check Code eg:- Course Code 
function isAlphaNumericSpecialCharsForCourse(objValue) 
{	 
			var characters="-_()#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 
			var tmp 
			var lTag 
			lTag = 0 
			temp = (objValue.length) 
			for (var i=0;i<temp;i++) 
			{ 
				tmp=objValue.substring(i,i+1) 
				if (characters.indexOf(tmp)==-1) 
				{ 
					lTag = 1 
				} 
			} 
			if(lTag == 1) 
				return true 
			else 
				return false 
	 
} 
//end of function  
 
 
//Function to check Code eg:- Subject Code and Class Code 
function isAlphaNumericSpecialChars(objValue) 
{	 
			var characters="-'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&()" 
			var tmp 
			var lTag 
			lTag = 0 
			temp = (objValue.length) 
			for (var i=0;i<temp;i++) 
			{ 
				tmp=objValue.substring(i,i+1) 
				if (characters.indexOf(tmp)==-1) 
				{ 
					lTag = 1 
				} 
			} 
			if(lTag == 1) 
				return true 
			else 
				return false 
	 
} 
//end of function  
 
//function to validate city,state 
function fnIsAlphaNumericSpecial(objValue) 
{	 
	var characters=", -abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&'()[]+" 
	var tmp 
	var lTag 
	lTag = 0 
	temp = (objValue.length) 
	for (var i=0;i<temp;i++) 
	{ 
		tmp=objValue.substring(i,i+1) 
		if (characters.indexOf(tmp)==-1) 
		{ 
			lTag = 1 
		} 
	} 
	if(lTag == 1) 
		return false 
	else 
		return true 
} 
//end function 
 
// function to reset the form values 
 function fnReset(frmName) 
 { 
    eval("document."+frmName+".reset()") 
 } 
// end function 
 
 
 
function isValidDomain(emailStr) 
{ 
			/* The following pattern is used to check if the entered e-mail address 
			  fits the user@domain format.  It also is used to separate the username 
			   from the domain. */ 
			var emailPat=/^(.+)@(.+)$/ 
			/* The following string represents the pattern for matching all special 
			   characters.  We don't want to allow special characters in the address.  
			   These characters include ( ) < > @ , ; : \ " . [ ]    */ 
			//var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 
			var specialChars="\\(\\)<>@,`';:~!#$%^&*+=|{}?\\\\\\\"\\.\\[\\]" 
			 
			/* The following string represents the range of characters allowed in a  
			   username or domainname.  It really states which chars aren't allowed. */ 
			var validChars="\[^\\s" + specialChars + "\]" 
			/* The following pattern applies if the "user" is a quoted string (in 
			   which case, there are no rules about which characters are allowed 
			   and which aren't; anything goes).  E.g. "sg cricket"@disney.com 
			   is a legal e-mail address. */ 
			var quotedUser="(\"[^\"]*\")" 
			/* The following pattern applies for domains that are IP addresses, 
			   rather than symbolic names.  E.g. sg@[123.124.233.4] is a legal 
			   e-mail address. NOTE: The square brackets are required. */ 
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ 
			/* The following string represents an atom (basically a series of 
			   non-special characters.) */ 
			var atom=validChars + '+' 
			/* The following string represents one word in the typical username. 
			   For example, in sg.sg@somewhere.com, sg and sg are words. 
			   Basically, a word is either an atom or quoted string. */ 
			var word="(" + atom + "|" + quotedUser + ")" 
			// The following pattern describes the structure of the user 
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$") 
			/* The following pattern describes the structure of a normal symbolic 
			   domain, as opposed to ipDomainPat, shown above. */ 
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") 
 
 
			/* Finally, let's start trying to figure out if the supplied address is 
			   valid. */ 
 
			/* Begin with the coarse pattern to simply break up user@domain into 
			   different pieces that are easy to analyze. */ 
			var matchArray=emailStr.match(domainPat) 
			if (matchArray==null) { 
				  /* Too many/few @'s or something; basically, this address doesn't 
			     even fit the general mould of a valid e-mail address. */ 
				//alert("Email address seems incorrect (check @ and .'s)") 
				return false 
			} 
//			var user=matchArray[0] 
			var domain=matchArray[0] 
 
			// See if "user" is valid  
	/*		if (user.match(userPat)==null) { 
			    // user is not valid 
			    //alert("The username doesn't seem to be valid.") 
			 alert("hi1"); 
				return false 
			} 
 
			/* if the e-mail address is at an IP address (as opposed to a symbolic 
			   host name) make sure the IP address is valid. */ 
			//alert(user); 
			var IPArray=domain.match(ipDomainPat) 
			if (IPArray!=null) { 
			    // this is an IP address 
				  for (var i=1;i<=4;i++) { 
				    if (IPArray[i]>255) { 
				        //alert("Destination IP address is invalid!") 
					 return false 
				    } 
			    } 
			    return true 
			} 
 
			// Domain is symbolic name 
			var domainArray=domain.match(domainPat) 
			if (domainArray==null) { 
			//alert("The domain name doesn't seem to be valid.") 
			    return false 
			} 
 
			/* domain name seems valid, but now make sure that it ends in a 
			   three-letter word (like com, edu, gov) or a two-letter word, 
			   representing country (uk, nl, no), and that there's a hostname preceding  
			   the domain or country. */ 
 
			/* Now we need to break up the domain to get a count of how many atoms 
			   it consists of. */ 
			var atomPat=new RegExp(atom,"g") 
			var domArr=domain.match(atomPat) 
			var len=domArr.length 
			if (domArr[domArr.length-1].length<2 ||  
			    domArr[domArr.length-1].length>3) { 
			   // the address must end in a two letter or three letter word. 
			   //alert("The address must end in a three-letter domain, or two letter country.") 
			   return false 
			} 
 
			// Make sure there's a host name preceding the domain. 
			if (len<2) { 
			   var errStr="This address is missing a hostname!" 
			   //alert(errStr) 
			   return false 
			} 
 
			// If we've gotten this far, everything's valid! 
			return true; 
}


 
// isFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is an unsigned floating point (real) number. 
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isInteger, then call isFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isFloat (s)

{   
	var i;
    var seenDecimalPoint = false;
	var decimalPointDelimiter=".";
    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
	
        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isAllNumeric(c)) return false;
    }

    // All characters are numbers.
    return true;
}

// function for validating URL:
function fnValidateURL(strURL)
{
	var result;
	re = /^(file|http):\/\/\S+\.(com|net|org|info|biz|ws|us|tv|cc|in|au|uk|htm|php|edu|asp|aspx|html|jsp)(\/(\S+\/)*)*$/i
	/*re = /^(file|http):\/\/\S+\.(com|net|org|info|biz|ws|us|tv|cc|in|au|uk|htm|php|edu|asp|aspx|html|jsp)$/i*/
	result=re.test(strURL);
	if(!result) 
	{
		return false;
	}
	return true;
}

function isValidAmericanPhone(objValue) 
{ 
		var characters="-.0123456789 " 
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=objValue.substring(i,i+1) 
			if (characters.indexOf(tmp)==-1) 
			{ 
				lTag = 1 
			} 
		} 
		if(lTag == 1) 
			return false 
		else 
			return true 
} 

function isAlphaNumeric2(objValue) 
{	 
			var characters="'- abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.," 
			var tmp 
			var lTag 
			lTag = 0 
			temp = (objValue.length) 
			for (var i=0;i<temp;i++) 
			{ 
				tmp=objValue.substring(i,i+1) 
				if (characters.indexOf(tmp)==-1) 
				{ 
					lTag = 1 
				} 
			} 
			if(lTag == 1) 
				return false 
			else 
				return true 
	 
} 

function isValid(characters,objValue) 
{ 
		//var characters=" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ."
//		alert(characters);
//		alert(objValue);
		var tmp 
		var lTag 
		lTag = 0 
		temp = (objValue.length) 
		for (var i=0;i<temp;i++) 
		{ 
			tmp=objValue.substring(i,i+1) 
			if (characters.indexOf(tmp)==-1) 
			{ 
				lTag = 1 
			} 
		} 
		if(lTag == 1) 
			return false 
		else 
			return true 
} 


/*function fnChecked(val,obj,frmObj,hidObj)
	{
	
		var tcount; 
		alert("Hi");
		alert(document.frmObj.hidObj.value);
		tcount = document.frmObj.hidObj.value;
		alert(tcount);
		if (obj.checked == true)
		{
			tcount = tcount + val+",";
		}
		else
		{
			tarray = new Array(100)
			var i
			var tempval
			tempval=""
			delval = val;
			tarray = tcount.split(",")
			for(i=0;i<tarray.length-1;i++)
			{
				if(eval((tarray[i])) != eval((delval)))
				{
					tempval = tempval+tarray[i]+",";
				}
			}
				
			tcount = tempval;
		}	
		window.document.frmObj.hidObj.value = tcount;
	alert(window.document.frmObj.hidObj.value);
}*/

