function cqstr(){
var login=document.getElementById("idlogin").value; 
var pass=document.getElementById("idpass").value; 
var email=document.getElementById("idemail").value; 
var qstrd = "uname="+encodeURI(login)+"&email="+encodeURI(email);
return qstrd;
}
function cgetXmlHttpRequestObject() {
var ua = navigator.userAgent.toLowerCase();
var sr;
if (!window.ActiveXObject){
sr = new XMLHttpRequest();
}else if (ua.indexOf('msie 5') == -1){
sr = new ActiveXObject("Msxml2.XMLHTTP");
}else{
sr = new ActiveXObject("Microsoft.XMLHTTP");
}
return sr;
}
var csearchReq = cgetXmlHttpRequestObject();

function cautodisc() {
if (csearchReq.readyState == 4 || csearchReq.readyState == 0) {
var qs = qstr();
document.getElementById('userchecks').innerHTML = 'Checking User Info...';
csearchReq.open("POST", "http://www.marketingdoover.com/cusercheck.php", true);
csearchReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
csearchReq.send(qs);
csearchReq.onreadystatechange = chandledisc; 
} 
}

function chandledisc() {
if (csearchReq.readyState == 4) {
var missfield = false;

if(document.getElementById("idfname").value.length < 1 || document.getElementById("idsurname").value.length < 1 || document.getElementById("idaccttos").checked == false){
missfield = true;
}
if(document.getElementById("idret").value == 'contestant'){
if(document.getElementById("iddob").value.length < 1 || document.getElementById("idcountry").value.length < 1 || document.getElementById("idczip").value.length < 1 || document.getElementById("idaccttos").checked == false){
missfield = true;
}
}
//alert(searchReq.responseText);
//document.getElementById('affchecks').innerHTML = searchReq.responseText;
if(document.getElementById("idpass").value != document.getElementById("idpass2").value){
document.getElementById('userchecks').style.background = '#ffcfcf';
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />Your passwords do not match. Please re-enter them carefully.</p>';
}else if(document.getElementById("idpass").value.length < 4 || document.getElementById("idpass").value.length > 10){
document.getElementById('userchecks').style.background = '#ffcfcf';
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />Your password must be between 4 and 10 characters in length.</p>';
}else if(document.getElementById("idlogin").value.length < 4 || document.getElementById("idlogin").value.length > 16){
document.getElementById('userchecks').style.background = '#ffcfcf';
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />Your username must be between 4 and 16 characters in length.</p>';
}else if(missfield == true){
document.getElementById('userchecks').style.background = '#ffcfcf';
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />You still have empty fields that need to be filled out. All fields are required to properly enter you into our system.</p>';
}else if(searchReq.responseText == 'uname'){
document.getElementById('userchecks').style.background = '#ffcfcf';
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />Your desired username is already in the system. If you are upgrading your voter account to become a contestant, please use the upgrade page to become a contestant.</p>';
}else if(searchReq.responseText == 'good' || location.href == 'http://www.marketingdoover.com/voter-upgrade.php' || location.href == 'http://www.marketingdoover.com/contestant.php'){
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />Transferring you to our messaging system...<br /><br />Please stand by...</p>';
document.getElementById("idform").action ='http://www.aweber.com/scripts/addlead.pl';
document.getElementById("idform").submit();
}else{
document.getElementById('userchecks').style.background = '#ffcfcf';
document.getElementById('userchecks').innerHTML = '<p><a style="clear: both; float: right" onclick="document.getElementById(\'userchecks\').style.display = \'none\';">[Close]</a><br /><br />An Error occured while processing your info. The webmaster has been notified.</p>';
}
}
}

function cformsend(){
document.getElementById('userchecks').style.display = 'block';
document.getElementById('userchecks').style.position = 'absolute';
document.getElementById('userchecks').style.top = '300';
document.getElementById('userchecks').style.left = '300';
document.getElementById('userchecks').style.height = '200px';
document.getElementById('userchecks').style.width = '300px';
document.getElementById('userchecks').style.background = '#cfffcf';
document.getElementById('userchecks').style.color = '#000000';
document.getElementById('userchecks').style.border = '1px #ffffff solid';
document.getElementById('userchecks').style.padding = '7px 14px';


cautodisc();

return true;
}


