
// 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();
//				obj.select();
				return false;
			}
			return true;
		}
//	end check blank




//	check blank
		function validateNumber(obj, msg)
		{
			//if (obj.value == "") 
			if ((obj.value != ""))			
			{
				if (isNaN(obj.value) || obj.value <= 0 )
				{
					alert(msg);
					obj.focus();
					obj.select();
					return false;
				}
			}
			return true;
		}
//	end check blank

//	check blank
		function validateSelect(obj, msg)
		{
			//if (obj.value == "") 
			if (obj.value == "")			
			{
				alert(msg);			
				obj.focus();
//				obj.select();
				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 validPhoneNumber(obj, msg)
		{
			
			var validStr = /^[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,4}x[0-9]{1,4}$/;
			if (validStr.test(obj.value) == false)
			{
				alert(msg);
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}


		function validNumberFrom1(obj, msg)
		{
			
			var validStr = /^[1-9]{1,}$/;
			if (validStr.test(obj.value) == false)
			{
				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 string
		function validatePincode(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;
		}
		function validateFloatFrom1(obj, msg)
		{
			var validNum =  /^([1-9]{1,})|([0-9]+)\.[1-9]{1,}|([1-9]+)\.[0-9]{1,}$/;
			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 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(id, msg)
		{
			var arr = document.getElementById(id);
			var choice = false;
			for(r=0;r<arr.length;r++)
			{
				if (arr[r].selected == true && arr[r].value != "")
					choice = true;
			}
			if (choice != true)
			{
				alert(msg);
				arr.focus();
				return false;
			}
		}
//	end check list box validation

//	check radio button validation
		function validateRadioCheck(fieldName, msg)
		{
			var arr = document.getElementsByName(fieldName);
			var choice = false;
			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, chked)
		{
			var chkarr = document.getElementsByName(fieldName);
			for(r=0;r<chkarr.length;r++)
			{
				if (chked == true)
					chkarr[r].checked = true;					
				else
					chkarr[r].checked = false;
			}
		}
		
		function checkAllWithText(fieldName, chked, id)
		{
			var chkarr = document.getElementsByName(fieldName);
			var obj = document.getElementById(id);
			for(r=0;r<chkarr.length;r++)
			{
				if (chked == true)
				{
					chkarr[r].checked = true;					
					obj.innerHTML = "Uncheck All";
				}
				else
				{
					chkarr[r].checked = false;
					obj.innerHTML = "Check All";
				}
			}
		}
//	end check all checkboxes

//	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

// written by vaibhavi 
		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 openwindow(url, width, height)
		{
			window.open(url, 'newwnd', 'width='+width+', height='+height+', nemubar=0, toolbar=0, titlebar=0');
			return false;
		}
		
		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 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;
			}
			else
			{
				var ans = confirm("Are you sure want to delete?");
				if (ans == true)
					return true;		
				else
					return false;		
			}
			
		}

		function check(id, msg)
		{
			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;
			}
			else
			{
				var ans = confirm(msg);
				if (ans == true)
					return true;		
				else
					return false;		
			}
			
		}

		function NewWindow(page, name, w, h, location, scroll, resizable, menubar, titlebar, taskbar)
		{
        	var winl = (screen.width - w) / 2;
	        var wint = (screen.height - h) / 2;
    	    winprops = 'height='+h+',width='+w+',location='+location+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+',menubar='+menubar+',titlebar='+titlebar+',taskbar='+taskbar
        	win = window.open(page, name, winprops)
        	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
    	}
		
		function validateTextArr(id,msg)
		{
			var obj1 = document.getElementsByName(id);
			f = 0;
			for(i=0;i<obj1.length;i++)
			{
				if (obj1[i].value != "")
				{
					f = 1;
				}
			}
			if (!f == 1)
			{
				alert(msg);
				obj1[0].focus();
				return false;	
			}
			return true;
		}
		function validateTextArr1(id,msg)
		{
			var obj1 = document.getElementsByName(id);
			f = 0;
			for(i=0;i<obj1.length;i++)
			{
				if (obj1[i].value != "")
				{
					f = 1;
				}
			}
			if (!f == 1)
			{
				return false;	
			}
			return true;
		}
		
		function validateDate(obj)
		{
			var validStr = /^[0-9]{1,2}-[0-9]{1,2}-[0-9]{1,4}$/;  // format: "d-m-Y"  separator: "/"
			if (validStr.test(obj.value) == false)
			{
				alert("Please enter valid date");
				obj.focus();
				obj.select();
				return false;
			}
			return true;
		}
		
		
		// ajax oject 
		function getHTTPObject() 
		{ 
			var xmlhttp; 
			/*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/  
			if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
			{ 
				try { 
					xmlhttp = new XMLHttpRequest(); 
				} 
				catch (e) { 
					xmlhttp = false; 
				} 
			} 
			return xmlhttp;
		}
		var http = getHTTPObject(); // We create the HTTP Object 
		
		function clearBox(ObjselBox)	
		{
			for(i=ObjselBox.length-1; i>=0; i--)
			{
				deleteOption(ObjselBox, i);
			}
		}
		
		function deleteOption(theSel, theIndex)
		{	
			var selLength = theSel.length;
			if(selLength > 0)
			{
				theSel.options[theIndex] = null;
			}
		}
		
		// end ajas object
		
		
		function trimString(str)
		{
			return str.replace(/^\s+|\s+$/g, '');
		}
		
			
		function changeYSrc(obj,Ysrc)
		{
			obj.src = Ysrc;
		}
		function changeRSrc(obj,Rsrc)
		{
			obj.src = Rsrc;
		}
// end upto here		