
// 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;
			
			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;
		}
		/* start */ 
		
		function ufocusComm(obj, val, status)
		{	
			if ((status == 1) && (obj.value == val))
				obj.value = ""
			else if (status == 2)
			{
				if ((obj.value == val) || (obj.value == ""))
					obj.value = val
			}
		}
		function hideLoginBox(){
			document.getElementById('loginoverlay').style.display = 'none';
			document.getElementById('loginbar').style.display = 'none';
		}
		function showLoginBox()
		{
			var aleft   = (screen.availWidth  - 800)/2;
			var atop    = (screen.availHeight - 425)/2;
			 //alert(screen.availWidth  + " - " + screen.availHeight);
			//alert(document.getElementById('topbar').style.top);
			document.getElementById('loginbar').style.top = parseInt(atop,10) + 'px';
			document.getElementById('loginbar').style.left= parseInt(aleft,10) + 'px';
			document.getElementById('loginbar').style.display ='block';
			document.getElementById('loginoverlay').style.display = 'block';
		}
		function valideRegisterAction(obj)
		{
	//		alert(my.name);
	//		var obj = document.frmCommonLogin;
	
			if ((obj.txtfirst.value == "Name") || (obj.txtfirst.value == "")) 
			{
				alert("Please enter your Name");
				obj.txtfirst.focus()
				return false;
			}
			if ((obj.txtemail.value == "Email address") || (obj.txtemail.value == "")) 
			{
				alert("Please enter Email address");
				obj.txtemail.focus()
				return false;
			}
			if (validateEmail(obj.txtemail, "Please enter valid Email address")==false) return false;
			if ((obj.txtpasswd.value == "Password") || (obj.txtpasswd.value == "")) 
			{
				alert("Please enter Password");
				obj.txtpasswd.focus()
				return false;
			}
			if ((obj.txtcpasswd.value == "Password") || (obj.txtcpasswd.value == "")) 
			{
				alert("Please enter Confirm Password");
				obj.txtcpasswd.focus()
				return false;
			}
			
			if (obj.chkagree.checked == false)
			{
				alert("Please read & accept our Terms & Conditions");
				return false;
			}
	
			
//			obj.add.value = 1;
//			obj.submit();
			actionRegister(obj.txtfirst.value, obj.txtemail.value, obj.txtpasswd.value);
	//		obj.login_button.value = 1;
	//		obj.submit();
		}
		function actionRegister(first, email, pass, addr, zip, state, country, phone)
		{
			// for GET method start 
		
				var url = "actionRegister.php?txtfirst="+ first + "&txtemail=" + email+ "&txtpasswd=" + pass; // The server-side script 
				//alert(url);
				httpXML.open("GET", url, true); 
				httpXML.onreadystatechange = handleHttpResponseRegister; 
				httpXML.send(null);
			// for GET method end 
			
			
		}
		function handleHttpResponseRegister() 
		{ 
			if (httpXML.readyState == 4) 
			{ 
				// Split the comma delimited response into an array  
				var results = httpXML.responseText;
				//alert(results);
				
				
				if (parseInt(results.length, 10) > 0)
				{
					var results_line_arr = results.split(":");
					if (parseInt(results_line_arr.length, 10) > 0)
					{
						var sCode = results_line_arr[0];
						var sName = results_line_arr[1];
						if (sCode == 1)
						{
							alert(sName);
					//		$('div.loginErr').innerHTML = sName;
						//	$('loginErr').textContent(sName)
						//	document.getElementById('loginErr').innerHTML = sName;
						//	$('#loginErr').val(sName);
						//	$("#loginErr").html(sName);  
						//	$("#loginErr").innerText(sName);
						}
						else
							window.location = sName;
					}		
				}
				
				
			} 
		}
		function valideloginAction(doc)
		{
	//		alert(my.name);
	//		var obj = document.frmCommonLogin;
			var obj = doc.form;
			if ((obj.txtuser.value == "Email address") || (obj.txtuser.value == "")) 
			{
				alert("Please enter Email address");
				obj.txtuser.focus()
				return false;
			}
			if ((obj.txtpass.value == "Password") || (obj.txtpass.value == "")) 
			{
				alert("Please enter Password");
				obj.txtpass.focus()
				return false;
			}
			actionLogin(obj.txtuser.value, obj.txtpass.value);
	//		obj.login_button.value = 1;
	//		obj.submit();
		}
		function actionLogin(u, p)
		{
			// for GET method start 
		
				var url = "actionLogin.php?u="+ u + "&p=" + p; // The server-side script 
			//	alert(url);
				httpXML.open("GET", url, true); 
				httpXML.onreadystatechange = handleHttpResponseLogin; 
				httpXML.send(null);
			// for GET method end 
			
			
		}
		function handleHttpResponseLogin() 
		{ 
			if (httpXML.readyState == 4) 
			{ 
				// Split the comma delimited response into an array  
				var results = httpXML.responseText;
				//alert(results);
				
				
				if (parseInt(results.length, 10) > 0)
				{
					var results_line_arr = results.split(":");
					if (parseInt(results_line_arr.length, 10) > 0)
					{
						var sCode = results_line_arr[0];
						var sName = results_line_arr[1];
						if (sCode == 1)
						{
						//	alert(sName);
						//	$('loginErr').style.display = 'block';
					//		$('div.loginErr').innerHTML = sName;
						//	$('loginErr').textContent(sName)
							document.getElementById('loginErr').innerHTML = sName;
						//	$('#loginErr').val(sName);
						//	$("#loginErr").html(sName);  
						//	$("#loginErr").innerText(sName);
						}
						else
							window.location = sName;
					}		
				}
				
				
			} 
		}
		
		 function setHTTPObject() 
		{ 
			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 httpXML = setHTTPObject(); // We create the HTTP Object 
		//-->
	
		/* end */
// end upto here		
