function get(a){
document.getElementById(a);
}
function getXMLHttp()
{
  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;
      }
    }
  }
  return xmlHttp;
}


function checkLocal(url,element)
{
  var xmlHttp = getXMLHttp();
 
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText,element);
    }
  }

  xmlHttp.open("GET", url, true);
  xmlHttp.send(null);
}

function getVal(param)
{
var strURL=param;
var req = getXMLHTTP();
req.open("GET", strURL, false);
req.send(null);
return req.responseText;
}


function getXMLHTTP() {
        var xmlHttp = false;
        if(window.ActiveXObject) {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(window.XMLHttpRequest) {
                xmlHttp = new XMLHttpRequest();
        }else{
                alert("Please upgrade your browser!");
        }
        return xmlHttp;
}

function HandleResponse(response,element)
{
  document.getElementById(element).innerHTML = response;
	checkFields();
}

function checkFields(){
	var qwe123 = 9;
	if ((document.forms["f1"].nametext.value.length==0) || (document.forms["f1"].emailtext.value.length==0) || (document.forms["f1"].celltext.value.length==0) || document.getElementById("alerttext").options[document.getElementById("alerttext").selectedIndex].index==0){
	document.getElementById("frmSub").disabled=true;	
	}
	else
	{
	qwe123 = getVal("http://www.prcboardexamresults.com/wp-sms/check.php?q=all&v="+document.getElementById("cellnumpre").options[document.getElementById("cellnumpre").selectedIndex].innerHTML+"&v2="+document.forms["f1"].emailtext.value+"&v3="+document.forms["f1"].celltext.value+"&v4="+document.getElementById("alerttext").options[document.getElementById("alerttext").selectedIndex].value);
	if (qwe123==0){
	document.getElementById("errGlobal").innerHTML="";
	document.getElementById("frmSub").disabled=false;	
	}
	else
	{
	document.getElementById("errGlobal").innerHTML="You already subscribed to our SMS update for "+qwe123;
	document.getElementById("frmSub").disabled=true;	
	}
	}
}

function checkthis(qwe)
{
	return document.getElementById(qwe).options[document.getElementById(qwe).selectedIndex].innerHTML;
}


