// Javascript for McGoo Software (c) 2010
var getData = Array();

function GetXmlHttpObject() {
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject) {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    alert("Browser does not support HTTP Request");
    return null;
}

function onlyAlphaNumeric(evt){
    e = evt.which ? evt : window.event;
    var bAccept = false;
    var cKey = String.fromCharCode(e.keyCode).toUpperCase().charAt(0);
    if (e.keyCode > 109 && e.keyCode != 189 && e.keyCode != 190 || e.keyCode == 106 || e.keyCode == 107) {
        cKey = " ";
    }
    var strChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + String.fromCharCode(109) + String.fromCharCode(190) + String.fromCharCode(189);
    if (strChars.indexOf(cKey) > -1)    {
        bAccept = true;
    }
    var strNumbers = "0123456789" + String.fromCharCode(190);
    if(e.shiftKey != true && strNumbers.indexOf(cKey)>-1)    {
        bAccept = true;
    }
    if (e.keyCode == 8 || e.keyCode == 9 || e.keyCode == 50 || e.keyCode == 96 || e.keyCode == 46) {
        bAccept = true;
    }
    if (e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40 || e.keyCode == 37) {
        bAccept = true;
    }
    if ((e.target == getElement('txtSchoolName') || e.srcElement == getElement('txtSchoolName')) && e.keyCode == 32) {
        bAccept = true;
    }
    return bAccept;
}


function no_whitespace(str)
{
	str=str.replace(/\s/g,'\ ');
	return str;
}

function replace_plus(str)
{
	 while(str.indexOf('+')>-1)
 	{
		var iPos = str.indexOf('+');
		str = str.substr(0, iPos) + '::' + str.substr(iPos+1);
	}
	return str;
}

function popPrint(sURL)
{
 var iLeft=window.screen.width-800;
 var iTop=window.screen.height-1024;
  PrintWindow=window.open(sURL, 'Print', 'scrollbars=1, menubar=1, resizable=1,width=800,height=1024,top='+iTop+',left='+iLeft+' ');
  PrintWindow.focus();
}


function Get_URL_Str()
{
	var aIDs = new Array();
	var sIDs = '';
	var cIDs = document.getElementsByTagName('*');
	for(i=0;i<cIDs.length;i++)
	{
		if(cIDs[i].tagName=='SELECT' || cIDs[i].tagName=='INPUT' || cIDs[i].tagName=='TEXTAREA')
		{
			aIDs.push(cIDs[i].id + '=' + cIDs[i].value);
		}
	}
	sIDs = aIDs.join('&');
	return sIDs;
}

function getElement(strElementID) {
    objElement = document.getElementById(strElementID);
    return objElement;
}

function Show(strID) {
    objID = getElement(strID);
    objID.style.display = "block";
}

function Hide(strID) {
    objID = getElement(strID);
    objID.style.display = "none";
}

function checkFields() {
    if (getElement('txtUserName').value.length < 4) {
        window.alert('Name must be at least 4 characters!');
    }
    else if (getElement('txtEmailAddress').value.length < 1
     || getElement('txtEmailAddress').value.indexOf('@') < 0
     || getElement('txtEmailAddress').value.indexOf('.') < 0) {
        window.alert('You must enter a valid email address!');
    }
    else if (getElement('txtSchoolName').value.length < 1) {
        window.alert('You must enter a School Name!');
    }
    else {
        getElement('divContinue').style.display ='none';
        getElement('divCaptcha').style.display = 'block';
    }

}
