// JavaScript Document
var xmlHttp
var email;

/*function PostcodeFinderForm()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="postcode_finder.php";
	xmlHttp.onreadystatechange=disPostcodeFinder;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function disPostcodeFinder()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("disPostcodeFinder").innerHTML=xmlHttp.responseText;
		
	}
}

function PostcodeFinder(form)
{
	$state = form.cboState.value;
	$location = form.txtLocation.value;
	$opt1 = form.opt1.value;
	$opt2 = form.opt2.value;
	$opt3 = form.opt3.value;
	
	
}*/

function DisplayCity(addtype,city_id)
{
	//alert("asdfasdfasd");
	if (addtype == "main")
	{
		state_id = document.frmRegPub.cboState.value;
	}
	else
	{
		state_id = document.frmRegPub.cboPState.value;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="pub_city_list.php?state_id="+state_id+"&addtype="+addtype+"&edt_city="+city_id;
	  if (addtype == "main")
	  {
		xmlHttp.onreadystatechange=disCitySelection;
	  }
	  else
	  {
		  xmlHttp.onreadystatechange=disPCitySelection;
	  }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function disCitySelection()
{
	if (xmlHttp.readyState==4)
	{
		
			
		document.getElementById("disCity").innerHTML = xmlHttp.responseText
		
		
	}
}

function disPCitySelection()
{
	if (xmlHttp.readyState==4)
	{
		
			
		document.getElementById("disPCity").innerHTML = xmlHttp.responseText
		
		
	}
}


function DisplayCityAdx(act)
{
	//alert("asdfasdfasd");
	
	state_id = document.frmConsole2.cboState.value;
	city_list = document.frmConsole2.txtSelectedCity.value;
	city_count= document.frmConsole2.txtCountCity.value;
	if (city_count != "" || city_count != 0)
	{
		document.frmConsole2.txtSelectedCityGroup.value += city_list;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="list_city.php?state_id="+state_id+"&ads_city="+city_list+"&act="+act;
	 document.frmConsole2.txtSelectedCity.value = "";
	xmlHttp.onreadystatechange=disCitySelectionAdx;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function disCitySelectionAdx()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("disCityAdx").innerHTML = xmlHttp.responseText	
	}
}
function chkEmailAdv()
{
	email = document.frmRegAdv.txtEmail.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chkadv.php?email="+email+"&level=advertiser";
	xmlHttp.onreadystatechange=disChkEmailAdv;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
function disChkEmailAdv()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText != 0)
		{
			alert("this e-mail already been used. Please use other email");
			document.frmRegAdv.txtEmail.focus();
			//document.getElementById("txtGotoIndex").disabled=false;
		}
		
	}
}

function chkEmailBizAdv()
{
	email = document.frmRegBizAdv.txtEmail1.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chkadv.php?email="+email+"&level=bizadvertiser";
	xmlHttp.onreadystatechange=disChkEmailBizAdv;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
function disChkEmailBizAdv()
{
	if (xmlHttp.readyState==4)
	{
		//alert(xmlHttp.responseText);
		if (xmlHttp.responseText != 0)
		{
			alert("this e-mail already been used. Please use other email");
			document.frmRegBizAdv.txtEmail1.focus();
			//document.getElementById("txtGotoIndex").disabled=false;
		}
		
	}
}

function chkMobile()
{

	MobilePrefix = document.frmRegPub.cboMobilePrefix.value;
	MobileNumber = document.frmRegPub.txtMobileNumber.value;
	
	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="mobile_chk.php?prefix="+MobilePrefix+"&number=" + MobileNumber;
	xmlHttp.onreadystatechange=disChkMobile;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}
	
function disChkMobile()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText == 1)
		{
			alert("this Mobile Number has already been used. Please use other Mobile Number");
			document.frmRegPub.cboMobilePrefix.focus();
			//document.getElementById("txtGotoIndex").disabled=false;
		}
		
	}
}

function chkEmail()
{
	email = document.frmRegPub.txtEmail.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chk.php?email="+email;
	xmlHttp.onreadystatechange=disChkEmail;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
function disChkEmail()
{
	if (xmlHttp.readyState==4)
	{
		if (xmlHttp.responseText == 1)
		{
			alert("this e-mail already been used. Please use other email");
			document.frmRegPub.txtEmail.focus();
			//document.getElementById("txtGotoIndex").disabled=false;
		}
		
	}
}


//tell a friend email chk
function chkEmailFriend1()
{
	email = document.form1.txtEmail1.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chk.php?email="+email+"&no=1";
	xmlHttp.onreadystatechange=disChkEmailFriend;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function chkEmailFriend2()
{
	email = document.form1.txtEmail2.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chk.php?email="+email+"&no=2";
	xmlHttp.onreadystatechange=disChkEmailFriend;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function chkEmailFriend3()
{
	email = document.form1.txtEmail3.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chk.php?email="+email+"&no=3";
	xmlHttp.onreadystatechange=disChkEmailFriend;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function chkEmailFriend4()
{
	email = document.form1.txtEmail4.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chk.php?email="+email+"&no=4";
	xmlHttp.onreadystatechange=disChkEmailFriend;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function chkEmailFriend5()
{
	email = document.form1.txtEmail5.value;
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	  var url="email_chk.php?email="+email+"&no=5";
	xmlHttp.onreadystatechange=disChkEmailFriend;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function disChkEmailFriend()
{
	var txtEmail;
	if (xmlHttp.readyState==4)
	{
		get_info = xmlHttp.responseText.split("|");
		
		if (get_info[0] == 1)
		{
			alert("this e-mail already been used. Please invite new friends!");

			if (get_info[1] == 1)
			{
				
				document.form1.txtEmail1.focus();
			}
			else if (get_info[1] == 2)
			{
				document.form1.txtEmail2.focus();
			}
			else if (get_info[1] == 3)
			{
				document.form1.txtEmail3.focus();
			}
			else if (get_info[1] == 4)
			{
				document.form1.txtEmail4.focus();
			}
			else if (get_info[1] == 5)
			{
				document.form1.txtEmail5.focus();
			}
			//document.getElementById("txtGotoIndex").disabled=false;
		}
		
		
	}
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
	    {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e)
	    {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	  }
	return xmlHttp;
}