// JavaScript Document

$(function()
{
	checkEmail();
});


function checkEmail()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		if(xmlHttp.responseText == 'valid')
		{
			document.getElementById("checkEmail").style.color='#00CC00';
			document.getElementById("checkEmail").innerHTML='&radic;';
			$("input[type='submit']").css('opacity','1');
			$("input[type='submit']").unbind('click',prevDef);
		}
		else
		{
			document.getElementById("checkEmail").innerHTML='!';
			document.getElementById("checkEmail").style.color='#990000';
			$("input[type='submit']").css('opacity','.5');
			$("input[type='submit']").bind('click',prevDef);
		}
      }
    }
  xmlHttp.open("POST","validateForm.php?i="+document.joinForm.email.value,true);
  xmlHttp.send(null);
  }



function checkPassword()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
		if(document.joinForm.confpassword.value == document.joinForm.password.value)
		{
			document.getElementById("checkPassword").style.color='#00CC00';
			document.getElementById("checkPassword").innerHTML='&radic;';
			$("input[type='submit']").css('opacity','1');
			$("input[type='submit']").unbind('click',prevDef);
		}
		else
		{
			document.getElementById("checkPassword").innerHTML='!';
			document.getElementById("checkPassword").style.color='#990000';
			$("input[type='submit']").css('opacity','.5');
			$("input[type='submit']").bind('click',prevDef);
		}
      }
    }
  xmlHttp.open("POST","",true);
  xmlHttp.send(null);
  }

function prevDef(event)
{
	event.preventDefault();
}