
	function TermsCond(){
		window.open('http://www.smooch.com/free-online-dating/asp/rules.asp','popup','toolbar=no,location=no,directories=no,status=no,' + 
		'menubar=no,scrollbars=yes,resizable=yes,screenX=0,screenY=0,top=0,left=0,width=420,height=440');
	}

	function memberslogin(){
		document.entry.ENTER.value="ENTER";
		document.entry.submit();
	}
	
	function onEnter( evt, frm ) {
		var keyCode = null;
		if( evt.which ) {			//for Netscape,Firefox,Opera
			keyCode = evt.which;
		} else if( evt.keyCode ) {	//for IE
			keyCode = evt.keyCode;
		}
		
		if( 13 == keyCode ) {
			frm.ENTER.value="ENTER";
			frm.submit();
		return false;
		}
		return true;
	}	
	
	var xmlHttp;
	function CountryListOnChange() 
	{
		var countryList = document.JoinForm.Country;
		var countryName = countryList.options[countryList.selectedIndex].value;
		var locations="";

		//if(document.all["locations"] != null)
		if(document.JoinForm.locations != null)		
			locations=document.JoinForm.locations[document.JoinForm.locations.selectedIndex].value;		
		else
			locations="Choose";

		if(countryName!=165){
			document.getElementById("locid").style.display="block";				
			document.getElementById("sublocid").style.display="block";				
			if(countryName!=75){
				document.getElementById("locid").innerHTML=""
			}
			document.getElementById("sublocid").innerHTML=""		
			document.getElementById("postcode").style.display="none";				
		}else{
			document.getElementById("locid").innerHTML="";	
			document.getElementById("sublocid").innerHTML=""
			document.getElementById("locid").style.display="none";				
			document.getElementById("sublocid").style.display="none";											
			document.getElementById("postcode").style.display="block";																	
		}
		
		if(countryName!="Choose"){
			if(countryName==7 || countryName==25 || countryName==54 ||
				countryName==58 || countryName==75 || countryName==77 ||
				countryName==79|| countryName==112 || countryName==113 ||
				countryName==125 || countryName==129 || countryName==130 ||
				countryName==143 || countryName==145 || countryName==151 || countryName==166){
				//countryName==165 || countryName==166)	//commented for postcode change - 16/12/2009
				
				//	submit down as it is with level one passed to indicate that the next level down from the country	
				//	has been selected. Also pass country through
				
					document.JoinForm.countryLevel.value=1;
				}
				else{
					document.getElementById("locid").style.display="none";				//new change
					document.getElementById("sublocid").style.display="none";			//new change				
					if(document.JoinForm.countryLevel.value!=0){
						document.JoinForm.countryLevel.value=0;
					}
				}
			}
			if(countryName!="165"){	
		    	CreateXmlHttp();
		   		if(xmlHttp)
		   		{	
		       		xmlHttp.onreadystatechange = HandleResponse;
		       		if(locations!="" || locations.length!=0){
		       			xmlHttp.open("GET", "displayLocation.asp?countryName="+ encodeURIComponent(countryName)+"&countryLevel="+encodeURIComponent(document.JoinForm.countryLevel.value)+"&locations="+locations,  true);
		       		}else{
						xmlHttp.open("GET", "displayLocation.asp?countryName="+ encodeURIComponent(countryName)+"&countryLevel="+encodeURIComponent(document.JoinForm.countryLevel.value)+"&locations=Choose",  true);        			
					}	
		       		xmlHttp.send(null);           
		   		}
		   	}	
		}


		//Browser Support Code	
		function CreateXmlHttp()
		{
			if(window.XMLHttpRequest){ 
				xmlHttp = new XMLHttpRequest(); 
			} 
			else if (window.ActiveXObject){ 
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
				if (!xmlHttp){ 
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
				}	
			} 
			return xmlHttp; 			
		}

		function HandleResponse()
		{
			if(xmlHttp.readyState == 4)
			{
	        		if(xmlHttp.status == 200)
	        		{
						document.getElementById("locid").innerHTML=xmlHttp.responseText;
	        		}
	        		else
	        		{
	            			alert("There was a problem retrieving data from the server. "+xmlHttp.statusText );
	        		}
	    		}
		}
		
		function HandleResponse_Sub()
		{
			if(xmlHttp.readyState == 4)
			{
	        		if(xmlHttp.status == 200)
	        		{
						document.getElementById("sublocid").innerHTML=xmlHttp.responseText;
	        		}
	        		else
	        		{
	            			alert("There was a problem retrieving data from the server. "+xmlHttp.statusText );
	        		}
	    		}
		}
		
		function getSublocations1(){
				var countryList = document.JoinForm.Country;
				var countryName = countryList.options[countryList.selectedIndex].value;	
				var locations;
				if(document.JoinForm.locations[document.JoinForm.locations.selectedIndex].value!="Choose"){
					locations=document.JoinForm.locations[document.JoinForm.locations.selectedIndex].value;
					document.JoinForm.locations_new.value=locations;
					document.JoinForm.countryLevel.value=2;
		    		CreateXmlHttp();
	   				if(xmlHttp)
	   				{	
	       				xmlHttp.onreadystatechange = HandleResponse_Sub;
	   					xmlHttp.open("GET", "displaySubLocation.asp?countryName="+ encodeURIComponent(countryName)+"&countryLevel="+encodeURIComponent(document.JoinForm.countryLevel.value)+"&locations="+locations,  true);
	       				xmlHttp.send(null);           
	   				}		
				}else{
						locations=document.JoinForm.locations[document.JoinForm.locations.selectedIndex].value;
						document.JoinForm.locations_new.value=locations;
						document.getElementById("sublocid").innerHTML=""			
				//		if(countryName=="165")
				//			createSelect("sublocid");				
				}
				if(countryName=="165" && locations != "Choose")	document.getElementById("postcode").style.display="block";						
				else document.getElementById("postcode").style.display="none";
		}
	
	function createSelect(divId){
		var locDiv=document.getElementById(divId);
		var mySelect=document.createElement("select");
		var theOption=document.createElement("OPTION");
		var theText=document.createTextNode("Choose");
		theOption.appendChild(theText);
		theOption.setAttribute("value","Choose");
		mySelect.appendChild(theOption);
		locDiv.appendChild(mySelect); 	
	/*	if(divId=="sublocid"){
			locDiv.appendChild(document.createElement('br'));
			locDiv.appendChild(document.createElement('br'));		
		}
	*/	
	}	

	function usernameCheck1(x){
		if(x){
			if(document.JoinForm.username.value=="Choose a username")document.JoinForm.username.value="";
		}
		else{
			if(document.JoinForm.username.value=="")document.JoinForm.username.value="Choose a username";
		}
	}
	function emailCheck1(x){
		if(x){
			if(document.JoinForm.email.value=="Your email address")document.JoinForm.email.value="";
		}
		else{
			if(document.JoinForm.email.value=="")document.JoinForm.email.value="Your email address";
		}
	}
	function postcodeCheck1(x){
		if(x){
			if(document.JoinForm.postcode.value=="Enter postcode")document.JoinForm.postcode.value="";
		}
		else{
			if(document.JoinForm.postcode.value=="")document.JoinForm.postcode.value="Enter postcode";
		}
	}
	
		
	function usernameCheck(x){
		if(x){
			if(document.JoinForm.username.value==" Choose a username")document.JoinForm.username.value="";
		}
		else{
			if(document.JoinForm.username.value=="")document.JoinForm.username.value=" Choose a username";
		}
	}
	function emailCheck(x){
		if(x){
			if(document.JoinForm.email.value==" My email address")document.JoinForm.email.value="";
		}
		else{
			if(document.JoinForm.email.value=="")document.JoinForm.email.value=" My email address";
		}
	}
	function postcodeCheck(x){
		if(x){
			if(document.JoinForm.pcode.value==" Enter postcode")document.JoinForm.pcode.value="";
		}
		else{
			if(document.JoinForm.pcode.value=="")document.JoinForm.pcode.value=" Enter postcode";
		}
	}	

	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"=stored_"+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	
	var allCookies=document.cookie;
	var pos=allCookies.indexOf("referrer=stored_");
	if(pos==-1){
		createCookie("referrer",escape(document.referrer),1000)
	}
	
	function procFormOrig(){
		
		var dateLocal=new Date();
		
		document.JoinForm.localYea.value=dateLocal.getFullYear()+"";
		document.JoinForm.localMon.value=dateLocal.getMonth()+"";
		document.JoinForm.localDay.value=dateLocal.getDate()+"";
		document.JoinForm.localHou.value=dateLocal.getHours()+"";
		document.JoinForm.localMin.value=dateLocal.getMinutes()+"";
		document.JoinForm.localSec.value=dateLocal.getSeconds()+"";
		
		var refCookie = readCookie('referrer');
		if (refCookie) {
			refCookie=refCookie.replace(/stored_/,"");
			document.JoinForm.Referer.value=unescape(refCookie);
		}
		else{
			document.JoinForm.Referer.value="not found";
		}
		
		doAJAXCall();

	}	
		
	
	
	function procForm(){
		var dateLocal=new Date();
		
		document.JoinForm.localYea.value=dateLocal.getFullYear()+"";
		document.JoinForm.localMon.value=dateLocal.getMonth()+"";
		document.JoinForm.localDay.value=dateLocal.getDate()+"";
		document.JoinForm.localHou.value=dateLocal.getHours()+"";
		document.JoinForm.localMin.value=dateLocal.getMinutes()+"";
		document.JoinForm.localSec.value=dateLocal.getSeconds()+"";
		
		var refCookie = readCookie('referrer');
		if (refCookie) {
			refCookie=refCookie.replace(/stored_/,"");
			document.JoinForm.Referer.value=unescape(refCookie);
		}
		else{
			document.JoinForm.Referer.value="not found";
		}
		
		doAJAXCall();

	}	

	/** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        **
	 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
	 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/
	function XHConn()
	{
	  var xmlhttp, bComplete = false;
	  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
	  catch (e) { xmlhttp = false; }}}
	  if (!xmlhttp) return null;
	  this.connect = function(sURL, sMethod, sVars, fnDone)
	  {
	    if (!xmlhttp) return false;
	    bComplete = false;
	    sMethod = sMethod.toUpperCase();
	    try {
	      if (sMethod == "GET")
	      {
	        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
	        sVars = "";
	      }
	      else
	      {
	        xmlhttp.open(sMethod, sURL, true);
	        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
	        xmlhttp.setRequestHeader("Content-Type",
	          "application/x-www-form-urlencoded");
	      }
	      xmlhttp.onreadystatechange = function(){
	        if (xmlhttp.readyState == 4 && !bComplete)
	        {
	          bComplete = true;
	          fnDone(xmlhttp);
	        }};
	      xmlhttp.send(sVars);
	    }
	    catch(z) { return false; }
	    return true;
	  };
	  return this;
	}
	
	// doAJAXCall : Generic AJAX Handler, used with XHConn
	// Author : Bryce Christensen (www.esonica.com)
	// PageURL : the server side page we are calling
	// ReqType : either POST or GET, typically POST
	// PostStr : parameter passed in a query string format 'param1=foośm2=bar'
	// FunctionName : the JS function that will handle the response

	var doAJAXCall = function () {
		// create the new object for doing the XMLHTTP Request
		var myConn = new XHConn();
		// check if the browser supports it
		
		if (myConn)	{
		    // XMLHTTPRequest is supported by the browser, continue with the request    
		    var pc;
			var pcValue;
		    var locations;
		    var slocations;
		    
		    var uname=document.JoinForm.username.value;
			uname=(uname+"").replace(/ /ig,"%20");
			uname=(uname+"").replace(/&/ig,"%26");
		    var gs = document.JoinForm.GenderAndSexuality;
		    var gands = gs.options[gs.selectedIndex].value;
			var lt = document.JoinForm.LookingType;
			var lktyp = lt.options[lt.selectedIndex].value;
			var d = document.JoinForm.Day;
			var jday = d.options[d.selectedIndex].value;
			var m = document.JoinForm.Month;
			var jMonth = m.options[m.selectedIndex].value;
			var y = document.JoinForm.Year;
			var jYear = y.options[y.selectedIndex].value;
			var e=document.JoinForm.email.value;
			e=(e+"").replace(/ /ig,"%20");			
			var c = document.JoinForm.Country;
			var ctry = c.options[c.selectedIndex].value;
			var loc = document.JoinForm.locations;
			if(typeof(loc) != "undefined")
			{
				locations = loc.options[loc.selectedIndex].value;			
				locations=(locations+"").replace(/ /ig,"%20");							
			}	
			var sloc = document.JoinForm.subLocations;
			if(typeof(sloc) != "undefined")
			{
				slocations = sloc.options[sloc.selectedIndex].value;			
				slocations=(slocations+"").replace(/ /ig,"%20");											
			}	
			var ctryLevel=document.JoinForm.countryLevel.value			

			if(ctry==165)
			{
				pc = document.JoinForm.pcode.value;
				pc=(pc+"").replace(/ /ig,"%20");				
				
				locations="";
				slocations="";			
			}else if(ctry+""=="Choose" || ctryLevel==0){
				locations="";
				slocations="";							
			}

			//Have to figure out if country should have 1,2 or 3 tiers
			/*
			else
			{
				var l = document.JoinForm.locations;
				var locs = l.options[l.selectedIndex].value;		
			}
			*/
			
			var PostStr='username='+uname;
			PostStr=PostStr+'&GenderAndSexuality='+gands;
			PostStr=PostStr+'&lookingType='+lktyp;
			PostStr=PostStr+'&day='+jday;
			PostStr=PostStr+'&month='+jMonth;
			PostStr=PostStr+'&year='+jYear;
			PostStr=PostStr+'&email='+e;			
			PostStr=PostStr+'&country='+ctry;				
			if(typeof(locations) != "undefined") PostStr=PostStr+'&locations='+locations;				
			if(typeof(slocations) != "undefined") PostStr=PostStr+'&subLocations='+slocations				
			if(ctry+""=="165") PostStr=PostStr+'&pcode='+pc;	
			PostStr=PostStr+'&ctryLevel='+ctryLevel;								
//			alert(PostStr);
		    myConn.connect("frontPageValidation.asp", "Post","" + PostStr + "",showMessageResponse);   
		} 
		else {
		    // Not support by this browser, alert the user
		    alert("XMLHTTP not available. Try a newer/better browser, this application will not work!");   
		}
	}
	

	
	// The function for handling the response from the server
	var showMessageResponse = function (oXML) 
	{ 
		// get the response text, into a variable
    	var response = oXML.responseText;
    	//Show response from ajax call.	
//		alert(response);	
    	if(response.length==0){
    		//document.JoinForm.action="profiles.asp?formproc=form";
    		document.JoinForm.method="post"
    		document.JoinForm.submit();
    	}
    	else{
    		var str="";
    		str="<ul class='circle'>";
    		if(response.indexOf("1")==0) str=str+"<li>Username</li>";
    		if(response.indexOf("13")> 0) str=str+"<li>Username - That username is already taken. Please choose another.</li>";    		    		    		    		    		    		    		    		
    		if(response.indexOf("12")> 0) str=str+"<li>Email - You're already a member. If you have forgotten your password, please <a href='free-online-dating/password-reminder.asp' onClick='closePopup();return true;'>click here</a>.</li>";    		    		    		    		    		
    		//,3 or 1,3 and not ,13
    		if((response.indexOf("3")==1 || response.indexOf("3")==2) && (response.substring(1,2)!= "1")) str=str+"<li>Sexuality</li>";    		
    		if(response.indexOf("5")> 0) str=str+"<li>Using this site for</li>";    		    		
    		if(response.indexOf("6")> 0) str=str+"<li>Date of Birth</li>";    		    		
    		if(response.indexOf("7")> 0) str=str+"<li>Email Address</li>";    		    		
    		if(response.indexOf("8")> 0) str=str+"<li>Country</li>";    		    		
    		if(response.indexOf("9")> 0) str=str+"<li>Location</li>";    		    		    		
    		if(response.indexOf("10")> 0) str=str+"<li>Sublocation</li>";    		    		    		    		
    		if(response.indexOf("11")> 0) str=str+"<li>Postcode</li>";    		    		    		    		

    		str=str+"</ul>";

			try{
				//document.getElementById('mm_content').innerHTML=response;
				document.getElementById('mm_content').innerHTML=str;
			}
			catch(e)
			{
					var newdiv=document.createElement("div");
					newdiv.innerHTML="Hello world!";
					var container=document.getElementById("mm_content");
					container.appendChild(newdiv);					
			}
			mm_showMyPopUp();
		}
	}
	
	function mm_showMyPopUp() {
    	DarkenPage();	
    	
		mm_myPopupRelocate();
 		document.getElementById("mm_mypopup").style.display = "block";
 		document.body.onscroll = mm_myPopupRelocate;
 		window.onscroll = mm_myPopupRelocate;
	}
	

	function closePopup()
	{
    	// hide the popup panel
    	var popupDiv = document.getElementById('mm_mypopup');
    	document.getElementById('mm_content').innerHTML='';
    	popupDiv.style.display = 'none';
    	// lighten the page again
    	LightenPage();
	}	
	// this function puts the dark screen over the entire page
	function DarkenPage()
	{
		var str="";
    	var page_screen = document.getElementById('page_screen');		
		var browser=navigator.appName;
		var b_version=navigator.appVersion;
		var version=parseFloat(b_version);
		str=b_version;
		if((str.indexOf("MSIE 6")) > 0){
	    	getScrollXY();
	    	var xScroll=sX;
	    	var yScroll=sY;	    	
			
			//yScroll=0;
			if(xScroll==0 && yScroll==0){
	   			page_screen.style.height=screen.availHeight+'px';
				page_screen.style.width='100%';    			
			}else{
	   			page_screen.style.height=document.body.scrollHeight + 'px';
				page_screen.style.width=document.body.clientWidth + 'px';    
			}
				   		page_screen.style.position='absolute';			
		}else{

	   		page_screen.style.backgroundRepeat='repeat';	   	   
	   		page_screen.style.position='fixed';			
 			page_screen.style.height='100%'
 			page_screen.style.width='100%'
		}
   		page_screen.style.display = 'block';
    		    	
//		page_screen.style.width=document.body.clientWidth + 'px';    
//    	page_screen.style.display = 'block';
	}

		function getScrollXY() {
  			var scrOfX = 0, scrOfY = 0;
  			if( typeof( window.pageYOffset ) == 'number' ) {
    			//Netscape compliant
    			scrOfY = window.pageYOffset;
    			scrOfX = window.pageXOffset;
  			} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    			//DOM compliant
    			scrOfY = document.body.scrollTop;
    			scrOfX = document.body.scrollLeft;
  			} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    			//IE6 standards compliant mode
    			scrOfY = document.documentElement.scrollTop;
    			scrOfX = document.documentElement.scrollLeft;
  			}
  			sX=scrOfX;
  			sY=scrOfY;

  			//return [ scrOfX, scrOfY ];
		}
		
	// this function removes the dark screen and the page is light again
	function LightenPage()
	{
    	var page_screen = document.getElementById('page_screen');
    	page_screen.style.display = 'none';
	}
	
	function mm_myPopupRelocate()
	{
		var scrolledX, scrolledY;
		if( self.pageYOffset ) 
		{
  			scrolledX = self.pageXOffset;
  			scrolledY = self.pageYOffset;
		} 
		else if( document.documentElement && document.documentElement.scrollTop ) 
		{
  			scrolledX = document.documentElement.scrollLeft;
  			scrolledY = document.documentElement.scrollTop;
		} 
		else if( document.body ) 
		{
  			scrolledX = document.body.scrollLeft;
  			scrolledY = document.body.scrollTop;
		}
		
		//alert(scrolledY);
		
		// Determine the coordinates of the center of the page
		var centerX, centerY;
		if( self.innerHeight ) 
		{
  			centerX = self.innerWidth;
  			centerY = self.innerHeight;
		} else if( document.documentElement && document.documentElement.clientHeight ) {
  			centerX = document.documentElement.clientWidth;
  			centerY = document.documentElement.clientHeight;
		} 
		else if( document.body ) {
  			centerX = document.body.clientWidth;
  			centerY = document.body.clientHeight;
  		}
		
		var leftOffset = scrolledX + (centerX - 498) / 2;	//498 is the width of the window
		var topOffset = scrolledY + (centerY - 420) / 2;	//150 is the width of the window

		document.getElementById("mm_mypopup").style.top = topOffset + "px";
 		document.getElementById("mm_mypopup").style.left = leftOffset + "px";
	}	
