		
		
		function Email_Check (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="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			/* 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. "jiminy 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. joe@[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 john.doe@somewhere.com, john and doe 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), 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;
		}
				
		function Character_Check(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || (c==" ")||(c==",") || (c==".")|| (c=="-")))
					return false;
			}
			return true;
		}
		
		function Names_Check(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || (c==" ") || (c=="-")  || (c==".") || (c==",")))
					return false;
			}
			return true;
		}
		
		function Only_CharacterCheckandSlash(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!(((c>='A' && c<='Z') || (c>='a' && c<='z')||(c=='/')||(c==' '))))
					return false;
			}
			return true;
		}
		
		function Only_CharacterCheck(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!(((c>='A' && c<='Z') || (c>='a' && c<='z')||(c==' '))))
						return false;
			}
			return true;
		}
		
		
		function Only_NumberCheck(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!(c>='0' && c<='9'))
					return false;
			}
			return true;
		}
		
		function Number_Check(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='0' && c<='9') || (c==" ") || (c==".")))
					return false;
			}
			return true;
		}
		
		function Numeric_Check(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='0' && c<='9') || (c==".")))
					return false;
			}
			return true;
		}
		
		function Pincode_Check(strCharacter)
		{			
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='0' && c<='9') || (c == " ")))
					return false;	
			}				
			return true;
		}
		
		function Phone_Check(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='0' && c<='9') || (c == " ") || (c == ",") || (c == "+") || (c == "-") || (c == "(") || (c == ")")))
					return false;
			}
			return true;
		}
		function Time_Check(strCharacter)
		{
		
			if (strCharacter.length != 5)
			{return false;}
			
			var part=strCharacter.split(".");
			
			if (part[0] >24 )
				{ return false;}
			else if (part[1] > 59 )
				{return false;}
			else if (part[0] ==24 && part[1] >1 )
				{return false;}
			else
				{return true}
		}	
		function Langauges(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='A' && c<='Z') || (c>='a' && c<='z')  || (c==" ") || (c==",") ))
					return false;
			}
			return true;
		}
		function FOpen(strFile)
		{
			window.open(strFile,"","width=610 ,height=440 ,toolbar=0,status=0,scrollbars=1,top=200,left=250"); 				
		}
		function HOpen(strFile)
		{
			window.open(strFile,"","width=710 ,height=400 ,toolbar=0,status=0,scrollbars=1,top=100,left=150"); 				
		}
		function ROpen(strFile)
		{
			window.open(strFile,"","width=610 ,height=300 ,toolbar=0,status=0,scrollbars=1,top=100,left=150"); 				
		}
		function FMapOpen(strFile)
		{
			window.open(strFile,"","width=750 ,height=600,resizable=yes ,toolbar=0,status=0,scrollbars=1,top=50,left=150"); 				
		}
		function OpenWin(strFile)
		{
			window.open(strFile,"","width=300,height=280,toolbar=0,status=0,scrollbars=0,top=300,left=400"); 				
		}
		function OpenAdvertisement(strFile)
		{
			window.open(strFile,"Advertisement","width=400,height=400,toolbar=0,status=0,scrollbars=0,top=300,left=400"); 				
		}
		
		function NavigatePage(strFile)
		{
			window.location.href = strFile;
		}		
				
		function ChangeTextDecoration(ctlName)
		{
			document.getElementById(ctlName).style.textDecoration = "underline";
		}
		
		function GetBackTextDecoration(ctlName)
		{
			document.getElementById(ctlName).style.textDecoration = "none";
		}
		
		function ChangeRowColor()
		{
			if (this.style.backgroundColor == "#99ccff")
				this.style.backgroundColor == "white"
			else
				this.style.backgroundColor == "#99ccff"	
		}
		
		function GotoPage(pageName,navType)
		{
			if ((document.getElementById("txtGoto").value == "") || (document.getElementById("txtGoto").value == 0))
			{
				alert("Please enter the page number");
				document.getElementById("txtGoto").focus();
			}
			else if (! Only_NumberCheck(document.getElementById("txtGoto").value))
			{
				alert("Please enter valid page no.");
				document.getElementById("txtGoto").focus();
			}
			else if (parseInt(document.getElementById("txtGoto").value) < 0)
			{
				alert("Page number should not contain negative values");
				document.getElementById("txtGoto").focus();
			}		
			else if ( parseInt(document.getElementById("txtGoto").value) > parseInt(document.getElementById("hidTotalIndexes").value))
			{
				alert("Page number should not exceed " + document.getElementById("hidTotalIndexes").value);
				document.getElementById("txtGoto").focus();
			}				
			else
			{	
				if (navType == "4")			
					window.location.href = pageName + ".aspx?PID=" + document.getElementById("txtGoto").value;
				else if (navType == "3")
					window.location.href = pageName + ".aspx?Alp="+ document.getElementById("hidAlp").value +"&PNo=" + document.getElementById("txtGoto").value;
				else if (navType == "2")			
					window.location.href = pageName + ".aspx?CID="+ document.getElementById("hidCID").value +"&PNo=" + document.getElementById("txtGoto").value;
				else 
					window.location.href = pageName + ".aspx?PNo=" + document.getElementById("txtGoto").value;
			}
		}
		
		
		
		function GotoYPPage(pageName,searchType)
		{
			if ((document.getElementById("txtGoto").value == "") || (document.getElementById("txtGoto").value == 0))
			{
				alert("Please enter the page number");
				document.getElementById("txtGoto").focus();
			}
			else if (! Only_NumberCheck(document.getElementById("txtGoto").value))
			{
				alert("Please enter valid page no.");
				document.getElementById("txtGoto").focus();
			}
			else if (parseInt(document.getElementById("txtGoto").value) < 0)
			{
				alert("Page number should not contain negative values");
				document.getElementById("txtGoto").focus();
			}
			else if ( parseInt(document.getElementById("txtGoto").value) > parseInt(document.getElementById("hidTotalIndexes").value))
			{
				alert("Page number should not exceed " + document.getElementById("hidTotalIndexes").value);
				document.getElementById("txtGoto").focus();
			}			
			else
			{	
				/* Q - Quick search
				   D - Detailed search
				   A - Alphabetical search		
				   C - Category-wise search
				 */
				if (searchType == "Q")
				{	
					if ((document.getElementById("hidKeyword").value != "") && (document.getElementById("hidBusinessName").value != ""))
						window.location.href = pageName + ".aspx?KW=" + document.getElementById("hidKeyword").value + "&BN=" + document.getElementById("hidBusinessName").value +"&PNo=" + document.getElementById("txtGoto").value;
					else if	((document.getElementById("hidKeyword").value != "") && (document.getElementById("hidBusinessName").value == ""))
						window.location.href = pageName + ".aspx?KW=" + document.getElementById("hidKeyword").value +"&PNo=" + document.getElementById("txtGoto").value;
					else if	((document.getElementById("hidKeyword").value == "") && (document.getElementById("hidBusinessName").value != ""))
						window.location.href = pageName + ".aspx?BN=" + document.getElementById("hidBusinessName").value +"&PNo=" + document.getElementById("txtGoto").value;														
				}
				if (searchType == "D")
				{	
					var qString, sFlag;
					
					qString = "";
					sFlag = 0;
					
					if (document.getElementById("hidKeyword").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "KW=" + document.getElementById("hidKeyword").value;
							sFlag = 1;
						}
						else
							qString = qString + "&KW=" + document.getElementById("hidKeyword").value;	
					}
					if (document.getElementById("hidBusinessName").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "BN=" + document.getElementById("hidBusinessName").value;
							sFlag = 1;
						}
						else
							qString = qString + "&BN=" + document.getElementById("hidBusinessName").value;	
					}					
					if (document.getElementById("hidCity").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "CI=" + document.getElementById("hidCity").value;
							sFlag = 1;
						}
						else
							qString = qString + "&CI=" + document.getElementById("hidCity").value;	
					}
					if (document.getElementById("hidState").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "SE=" + document.getElementById("hidState").value;
							sFlag = 1;
						}
						else
							qString = qString + "&SE=" + document.getElementById("hidState").value;	
					}
					if (document.getElementById("hidCountry").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "CO=" + document.getElementById("hidCountry").value;
							sFlag = 1;
						}
						else
							qString = qString + "&CO=" + document.getElementById("hidCountry").value;	
					}
					if (document.getElementById("hidZipcode").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "ZC=" + document.getElementById("hidZipcode").value;
							sFlag = 1;
						}
						else
							qString = qString + "&ZC=" + document.getElementById("hidZipcode").value;	
					}
					if (document.getElementById("hidPhoneNo").value != "")
					{
						if (sFlag == 0)
						{
							qString = qString + "PN=" + document.getElementById("hidPhoneNo").value;
							sFlag = 1;
						}
						else
							qString = qString + "&PN=" + document.getElementById("hidPhoneNo").value;	
					}					
					window.location.href = "DetailedSearchResults.aspx?" + qString + "&PNo=" + document.getElementById("txtGoto").value;						
				}
				
				if (searchType == "A")
					window.location.href = pageName + ".aspx?Alp=" + document.getElementById("hidAlphabet").value + "&PNo=" + document.getElementById("txtGoto").value;					
				
				if (searchType == "C")
				{
					if (document.getElementById("hidAlp").value == "")
						window.location.href = pageName + ".aspx?Id=" + document.getElementById("hidCID").value + "&PNo=" + document.getElementById("txtGoto").value;					
					else	
						window.location.href = pageName + ".aspx?Id=" + document.getElementById("hidCID").value + "&PNo=" + document.getElementById("txtGoto").value + "&Alp=" + document.getElementById("hidAlp").value;					
				}
				
			}
		}
		
		
		function GotoMPPage(service,typ)
		{
			if ((document.getElementById("txtGoto").value == "") || (document.getElementById("txtGoto").value == 0))
			{
				alert("Please enter the page number");
				document.getElementById("txtGoto").focus();
			}
			else if (! Only_NumberCheck(document.getElementById("txtGoto").value))
			{
				alert("Please enter valid page no.");
				document.getElementById("txtGoto").focus();
			}
			else if (parseInt(document.getElementById("txtGoto").value) < 0)
			{
				alert("Page number should not contain negative values");
				document.getElementById("txtGoto").focus();
			}
			else if ( parseInt(document.getElementById("txtGoto").value) > parseInt(document.getElementById("hidTotalIndexes").value))
			{
				alert("Page number should not exceed " + document.getElementById("hidTotalIndexes").value);
				document.getElementById("txtGoto").focus();
			}		
			else
			{
				var loc = "";
				
				if (typ == "Alp")
					loc = "MarriageServiceAlpSearch.aspx?PNo=" + document.getElementById("txtGoto").value + "&Alp=" + document.getElementById("hidKey").value + "&Ser=" + service;
				else if (typ == "Area")
				{
					if (document.getElementById("hidKey").value != "") // Search type - 'Both'
						loc = "MarriageServiceAreaSearch.aspx?PNo=" + document.getElementById("txtGoto").value + "&AId=" + document.getElementById("hidAId").value + "&Alp=" + document.getElementById("hidKey").value + "&Ser=" + service;
					else	
						loc = "MarriageServiceAreaSearch.aspx?PNo=" + document.getElementById("txtGoto").value + "&AId=" + document.getElementById("hidAId").value + "&Ser=" + service;
				}
				else
					loc = "MarriageService.aspx?PNo=" + document.getElementById("txtGoto").value + "&Ser=" + service;
				
				window.location.href = loc;
			}
		}
		
			function GoPage(pageName,typ)
			{
				if ((document.getElementById("txtGoto").value == "") || (document.getElementById("txtGoto").value == 0))
				{
					alert("Please enter the page number");
					document.getElementById("txtGoto").focus();
				}
				else if (! Only_NumberCheck(document.getElementById("txtGoto").value))
				{
					alert("Please enter valid page no.");
					document.getElementById("txtGoto").focus();
				}
				else if (parseInt(document.getElementById("txtGoto").value) < 0)
				{
					alert("Page number should not contain negative values");
					document.getElementById("txtGoto").focus();
				}
				else if ( parseInt(document.getElementById("txtGoto").value) > parseInt(document.getElementById("hidTotalIndexes").value))
				{
					alert("Page number should not exceed " + document.getElementById("hidTotalIndexes").value);
					document.getElementById("txtGoto").focus();
				}			
				else
				{	
					var loc = "";
				if (typ == "Alp")
					loc = pageName + "AlpSearch.aspx?PNo=" + document.getElementById("txtGoto").value + "&Alp=" + document.getElementById("hidKey").value;
				else if (typ == "Area")
				{
					if (document.getElementById("hidKey").value != "") // Search type - 'Both'
						loc = pageName + "AreaSearch.aspx?PNo=" + document.getElementById("txtGoto").value + "&AId=" + document.getElementById("hidAId").value + "&Alp=" + document.getElementById("hidKey").value;
					else	
						loc = pageName + "AreaSearch.aspx?PNo=" + document.getElementById("txtGoto").value + "&AId=" + document.getElementById("hidAId").value;
				}
				else
					loc = pageName + ".aspx?PNo=" + document.getElementById("txtGoto").value;
				
				window.location.href = loc;				
				}
			}
			
			function Go(pageName)
			{
				if ((document.getElementById("txtGoto").value == "") || (document.getElementById("txtGoto").value == 0))
				{
					alert("Please enter the page number");
					document.getElementById("txtGoto").focus();
				}		
				else if (! Only_NumberCheck(document.getElementById("txtGoto").value))
				{
					alert("Please enter valid page no.");
					document.getElementById("txtGoto").focus();
				}
				else if (parseInt(document.getElementById("txtGoto").value) < 0)
				{
					alert("Page number should not contain negative values");
					document.getElementById("txtGoto").focus();
				}
				else if ( parseInt(document.getElementById("txtGoto").value) > parseInt(document.getElementById("hidTotalIndexes").value))
				{
					alert("Page number should not exceed " + document.getElementById("hidTotalIndexes").value);
					document.getElementById("txtGoto").focus();
				}
				else				
				{						
					window.location.href = pageName + ".aspx?Type="+ document.getElementById("hidType").value + "&PNo=" + document.getElementById("txtGoto").value;
				}
			}
			
			
			
			
			function IsValidImageFile(path)
			{				
				if(path.length > 0)
				{			
					lastIndex = path.lastIndexOf(".");
					fname = path.substring(lastIndex+1);							
					if( !((fname == "gif") || (fname == "jpg")) )
						return false;
					else
						return true;				
				}				
			}
			
			function CheckCharacter(strCharacter)
	{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!((c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || (c==" ") || (c=="-") || (c==13)))
					return false;
			}
			return true;
	}		
		
		function IsValidType(value)
	{
		
		if(value.length > 0)
		{
			fname = value.split(".");
				     
			if(fname[1] != "gif" && fname[1] != "jpg")			
				return false;
		 }		
			
			return true;
	}	



// This is Right bar validation
	
	function Check(control,str)
	{
	    if (document.getElementById(control).value == 0)
	    {
	        alert("Please enter " + str);
	        document.getElementById(control).value = "";
	        document.getElementById(control).focus();
	        return false;
	    }
	    return true;
	}
	
	function Only_CharacterCheck(strCharacter)
		{
			for (k=0;k<strCharacter.length;k++)
			{
				c = strCharacter.charAt(k);
				if (!(((c>='A' && c<='Z') || (c>='a' && c<='z')||(c==' ') ||(c=='.'))))
						return false;
			}
			return true;
		}
function Character_Check1(strCharacter)
{
	return true;
}
	function Validateon(val1,val2,val3,val4,val5)
		{
		var txtName=val1;
		var Text1=val2;
		var Text2=val3;
		var Text3=val4;
		var Text4=val5;
			
		if (Check("txtName","your name") == false)
	        return false;	    
	    else if (Only_CharacterCheck(document.getElementById("txtName").value) == false)
	    {
	        alert("Please enter valid character");
	        document.getElementById("txtName").value = "";
	        document.getElementById("txtName").focus();
	        return false;
	    }
	    if (Check("Text1","your company") == false)
	        return false;	    
	    else if (Character_Check1(document.getElementById("Text1").value) == false)
	    {
	        alert("Please enter valid character");
	        document.getElementById("Text1").value = "";
	        document.getElementById("Text1").focus();
	        return false;
	    }
	    if (Check("Text2","your address") == false)
	        return false;	    
	    else if (Character_Check1(document.getElementById("Text2").value) == false)
	    {
	        alert("Please enter valid character");
	        document.getElementById("Text2").value = "";
	        document.getElementById("Text2").focus();
	        return false;
	    }
	    
	    if (Check("Text3","your email") == false)
	        return false;	    
	    else if (Email_Check(document.getElementById("Text3").value) == false)
	    {
	        alert("Please enter valid Email");
	        document.getElementById("Text3").value = "";
	        document.getElementById("Text3").focus();
	        return false;
	    }
	    
	    if (Check("Text4","message") == false)
	        return false;	    
	    else if (Character_Check1(document.getElementById("Text4").value) == false)
	    {
	        alert("Please enter valid character");
	        document.getElementById("Text4").value = "";
	        document.getElementById("Text4").focus();
	        return false;
	    }
	    
    	window.location.href="../MailHelper.aspx?&N=" + val1 + "&E=" + val4 + "&C=" + val2 + "&A=" + val3 + "&M=" + val5;
}
