
// Function to check space at the beginning only but allows 
	function isBlank(obj, msg)
	{
		if(obj.value=="")
		{
				alert(msg);			
				obj.focus();
				return false;
		}
		return true;
	}
// End of function check

//	check blank
		function validateBlank(obj, msg)
		{
			//if (obj.value == "") 
			if ( (obj.value == "") ||(obj.value == " ") )			
			{
				alert(msg);			
				obj.focus();
				return false;
			}
			return true;
		}
//	end check blank



// Check for selection from dropdown listbox
		function validateSelect(obj, msg)
		{
			if(obj.value == "")
			{
				if(msg != "")
					alert(msg);
				obj.focus();
				return false;	
			}
				return true;
		}
// end selection function

//	check string
		function validateString(obj, msg)
		{
			var validStr = /^[a-zA-Z]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}

//	check string with numbers
		function validateStringWithNumber(obj, msg)
		{
			var first = obj.value.charAt(0);
			var validNum =  /^[0-9]{1,}$/;
			if (validNum.test(first) == true)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}

		function validatePassword(obj, msg)
		{
			var validStr = /^[a-zA-Z0-9]{6,15}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
		}
	
//	end check string
		
		// function to check numbers with  minimun (6) n maximum (15) length
		function validateNumberLength(obj, msg)
		{
			var validStr = /^[0-9]{5,15}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
		}
		//end function
		
		// function to check with Dash -
		function validateAlphaNumericDash(obj, msg)
		{
			var validStr = /^[a-zA-Z0-9\s-]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();				
				return false;
			}
			return true;
		}
		
		// function to check with Dash -
		function validateAlphaNumericComma(obj, msg)
		{
			var validStr = /^[a-zA-Z0-9\s,]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();				
				return false;
			}
			return true;
		}

		function validateAlphaNumeric(obj, msg)
		{
			var validStr = /^[a-zA-Z0-9\s]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();				
				return false;
			}
			return true;
		}

		function validateAddress(obj, msg)
		{
			var validStr = /^[a-zA-Z0-9\s,-\/#]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}


		function validNumber(obj, msg)
		{
			
			var validStr = /^[0-9]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
		function isNumeric(obj, msg)
		{
			
			if (isNaN(obj.value))
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
		
//	check space
		function validateSpace(obj, msg)
		{
			var validSpace = /\s/;
			if (validSpace.test(obj.value) == true)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return true;
			}
			return false;
		}
//	end check space

//	check space
		function validateSpacenew(obj, msg)
		{
			var validSpace = /\s/;			
			if (validSpace.test(obj.value) == true)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}			
		}
//	end check space

//	check string
		function validateLength(obj, msg, len)
		{
			if (obj.value.length > len )
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
//	end check string

//	check numeric
		function validateNumeric(obj, msg)
		{
			var validNum =  /^[0-9]{1,}$/;
			if (validNum.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
//	end check numeric

//	check ccno
		function validateCCno(obj, msg)
		{
			var validNum =  /^[0-9]{13,16}$/;
			if (validNum.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
//	end check ccno


//	check float value with 2 decimal places
		function validateFloat(obj, msg)
		{
			var validNum =  /^([0-9]{1,})|([0-9]+)\.[0-9]{1,2}$/;
			if (validNum.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
//	end float value with 2 decimal places

// 	email validation
		function validateEmail(obj,msg)
		{
			//var emailStr = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z]$/;
			var emailStr = /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
			if (emailStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
// 	end email validation

// 	email validation
		function validateMultipleEmail(obj,msg)
		{
			//var emailStr = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z]$/;
			var emailStr = /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
			if (emailStr.test(obj) == false)
			{
				alert(msg);
				return false;
			}
			return true;
		}
// 	end email validation

// 	email validation
		function validateEmailMore(obj,msg)
		{
			//var emailStr = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z]$/;
			var emailStr = /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
			
			var strmail = obj.value;
			var temp = new Array();
			temp = strmail.split(',');
			for(var i=0; i<temp.length; i++)
			{
				if (emailStr.test(temp[i]) == false)
				{
					alert(msg);
					obj.focus();
					obj.select();
					return false;
				}
			}
			return true;
		}
// 	end email validation

//	check video file type
// Date : 10th July 2006.
		function validateVDOFile(obj)
		{
			validformFile = /(.wmv|.WMV)$/;
			if (obj.value != "")
			{
				if(!validformFile.test(obj.value)) 
				{
		
					alert("Only WMV files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
//	end check Video file type

// 	url validation
		function validateUrl(obj)
		{
			var urlStr = /^\http\:\/\/[a-zA-Z]{3,}\.[a-zA-Z0-9]{2,}(\.[a-zA-Z]{2,3}|\.[a-zA-Z]{2,3}\.[a-zA-Z]{2})$/;
			if (urlStr.test(obj.value) == false)
			{
				alert("Please enter valid URL");
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
// 	end url validation

//	check image file type
		function validateImgFile(obj)
		{
			validformFile = /(.jpg|.JPG|.gif|.GIF|.JPEG|.jpeg)$/;
			if (obj.value != "")
			{
				if(!validformFile.test(obj.value)) 
				{
		
					alert("Only JPG, GIF, JPEG files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
//	end check image file type

//	check file type
		function validatePDFFile(obj)
		{
			validFile = /(.pdf|.PDF)$/;
			if (obj.value != "")
			{
				if(!validFile.test(obj.value)) 
				{		
					alert("Only PDF files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
//	end check file type
//	check file SQL type
		function validateSQLFile(obj)
		{
			validFile = /(.sql|.SQL)$/;
			if (obj.value != "")
			{
				if(!validFile.test(obj.value)) 
				{		
					alert("Only SQL files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
//	end check file SQL type

//	check file type
		function validatePDFFile(obj)
		{
			validFile = /(.pdf|.PDF)$/;
			if (obj.value != "")
			{
				if(!validFile.test(obj.value)) 
				{		
					alert("Only PDF files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
//	end check file type

//	check file type VDO
		function validateFile(obj)
		{
			validFile = /(.pdf|.PDF)$/;
			if (obj.value != "")
			{
				if(!validFile.test(obj.value)) 
				{		
					alert("Only PDF files supported for questionnaries, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
//	end check file type

//	check list box validation
		function validateListCheck(fieldName, msg)
		{
			var arr = document.getElementById(fieldName);
			var choice = false;
			
			for(r=0;r<arr.length;r++)
			{
				if (arr[r].selected == true)
					choice = true;
			}
			if (!choice)
			{
				alert(msg);
				arr[0].focus();
				return false;
			}
		}
//	end check list box validation

//	check radio button validation
		function validateRadioCheck(fieldName, msg)
		{
			var arr = document.getElementsByName(fieldName);
			var choice = false;
			//alert(arr.length);
			for(r=0;r<arr.length;r++)
			{
				if (arr[r].checked == true)
					choice = true;
			}
			if (!choice)
			{
				alert(msg);
				arr[0].focus();
				return false;
			}
		}
//	end check radio button validation


		function validateRadioCheckGroup(fieldName,fieldName2, msg)
		{
			var arr = document.getElementsByName(fieldName);
			var arr2 = document.getElementsByName(fieldName2);
			
			var choice = false;
			for(r=0;r<arr.length;r++)
			{
				if (arr[r].checked == true)
					choice = true;
			}
			
			if (!choice)
			{
			var choice2 = false;
				for(r=0;r<arr2.length;r++)
				{
					if (arr2[r].checked == true)
						choice2 = true;
				}
			}
			
			if (!choice && !choice2)
			{
				alert(msg);
				return false;
			}
		}
//	check all checkboxes
		function checkAll(fieldName, checkval)
		{
			var chkarr = document.getElementsByName(fieldName);
			for(r=0;r<chkarr.length;r++)
			{
				if (checkval == true)
					chkarr[r].checked = true;					
				else
					chkarr[r].checked = false;
			}
		}
//	end check all checkboxes

	function checkRad(id)
	{
		var obj = document.getElementsByName(id); 
		var choice = false;
		for(i=0;i<obj.length;i++)
		{
			if (obj[i].checked == true)
				choice = true;
		}
		if (choice == false)
		{
			alert("Please select atleast one option");
			return false;
		}
		return true;
	}

	function check_value(fld,obj)
	{
		var field = document.getElementById(fld);
		if(obj.checked==true)
		{
			if(field.value=="")
			{
				field.value = obj.value+",";  
			} 
			else
				field.value=field.value + obj.value+",";
		}   	
		else
		{
			var col_array=field.value.split(",");
			var part_num=0;
			while (part_num < col_array.length)
			{
				if(col_array[part_num] == obj.value)
				{
					var str = col_array[part_num]+",";
					field.value = field.value.replace(str,"");
				}
				part_num+=1;
			}
		}
	}

//	confirm to
		function confirmTo(msg)
		{
			var ans = confirm(msg);
			if (ans == true)
				return true;
			else
				return false;
		}
//	end confirm to

//	confirm password
		function confirmValue(obj1, obj2, msg)
		{
			if (obj1.value != obj2.value)
			{
				alert(msg);
				obj2.focus();
				obj2.select();				
				return false;
			}
			return true;
		}
//	end confirm to

// checking text with space
		function stringwithSpace(obj, msg)
		{
			var validStr = /^\S[a-zA-Z\s]{1,}$/; 
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
// end of stringwithSpace


// checking text with space
		function alphanumercwithSpace(obj, msg)
		{
			var validStr = /^\S[a-zA-Z0-9\s]{1,}$/; 
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
// end of stringwithSpace

		function validatecsvFile(obj)
		{
			validFile = /(.csv|.CSV)$/;											 
			if (obj.value != "")
			{
				if(!validFile.test(obj.value)) 
				{		
					alert("Only CSV files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
		
		function validateMdbFile(obj)
		{
			validFile = /(.mdb|.MDB)$/;											 
			if (obj.value != "")
			{
				if(!validFile.test(obj.value)) 
				{		
					alert("Only MDB files supported, Please try again.");
					obj.focus();
					obj.select();
					return false;
				}
				return true;
			}
		}
		
		function openwindow(url, width, height)
		{
			window.open(url, 'newwnd', 'width='+width+', height='+height+', nemubar=0, toolbar=0, titlebar=0');
		}
		
		function closewindow()
		{
			self.close();
		}
		
		function isNotblank(obj)
		{
			if (obj.value != "")
				return true;
			else
				return false;
		}
		
		
	 	function replaceAll(str, strFind, strReplace)
 		{
			while (str.indexOf(strFind) > -1)
  			{
			   str = str.replace(strFind, strReplace);
			}
			return str;
 		}
		function retVoid()
		{
			return false;
		}
		function changeImage(timg,limg,id)
		{
			var obj = document.getElementById('memberPhoto'+id);
			obj.src = timg;
			return false;
		}
		function changeImage1(timg,limg)
		{
			var obj = document.getElementById('memberPhoto');
			obj.src = timg;
			return false;
		}

// end upto here		
