<!--

function popUpWindow(url,popup_name,toolbar_,location_,directories_,status_,menubar_,scrollbars_,resizable_,width_,height_,page_name) {
	sealWin=window.open(url,popup_name,'toolbar=' + toolbar_ + ',location=' + location_ + ',directories=' + directories_ + ',status=' + status_ + ',menubar=' + menubar_ + ',scrollbars=' + scrollbars_ + ',resizable=' + resizable_ + ',width=' + width_ + ',height=' + height_ + '');
	self.name = page_name;
}

// here is the sample code to call the function:
// popUpWindow('index.php','give_your_popUp_a_name','0','0','0','0','0','0','0','359','225','give_your_page_where_you_are_putting_this_code_a_name')
// for the following: toolbar_,location_,directories_,status_,menubar_,scrollbars_,resizable_, the options are '0' or '1'

function checkVotingEducator() {
	var str1, str2, str3, str4, str5, str6, str7
	var errFlag = false;
	var errCount = 0;
	var errMsg = "";
	var errExp = new RegExp(" ", "g");
	
	str1 = document.voting.first_name.value;
	str2 = document.voting.surname.value;
	str3 = document.voting.company.value;
	str4 = document.voting.address.value;
	str5 = document.voting.city.value;
	str6 = document.voting.country.value;
	str7 = document.voting.email.value;
	
	str1 = str1.replace(errExp, "")
	str2 = str2.replace(errExp, "")
	str3 = str3.replace(errExp, "")
	str4 = str4.replace(errExp, "")
	str5 = str5.replace(errExp, "")
	str6 = str6.replace(errExp, "")
	str7 = str7.replace(errExp, "")
	
	if (str1.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- first name\n";
		document.voting.first_name.focus();
	}
	
	if (str2.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- surname\n";
		document.voting.surname.focus();
	}
	
	if (str3.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- company\n";
		document.voting.company.focus();
	}
	
	if (str4.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- address\n";
		document.voting.address.focus();
	}
	
	if (str5.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- city\n";
		document.voting.city.focus();
	}
	
	if (str6.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- country\n";
		document.voting.country.focus();
	}
	
	if (str7.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- email address\n";
		document.voting.email.focus();
	} else {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str7)){
			//do nothing
		} else {
			errFlag = true;
			errMsg += "- email address\n";
			document.voting.email.focus();
		}
	}
					
	if (errFlag == true) {
		
		if (errCount > 1) {
			errMsg = "The following fields are empty or incorrect:\n" + errMsg;
		} else {	
			errMsg = "The following field is empty or incorrect:\n" + errMsg;
		}
		alert(errMsg);
		return false
	} else {
		return true;
	}
	
}

function checkVotingAgent() {
	var str1, str2, str3, str4, str5, str6, str7
	var errFlag = false;
	var errCount = 0;
	var errMsg = "";
	var errExp = new RegExp(" ", "g");
	
	str1 = document.voting.first_name.value;
	str2 = document.voting.surname.value;
	str3 = document.voting.company.value;
	str4 = document.voting.address.value;
	str5 = document.voting.city.value;
	str6 = document.voting.country.value;
	str7 = document.voting.email.value;
	
	str1 = str1.replace(errExp, "")
	str2 = str2.replace(errExp, "")
	str3 = str3.replace(errExp, "")
	str4 = str4.replace(errExp, "")
	str5 = str5.replace(errExp, "")
	str6 = str6.replace(errExp, "")
	str7 = str7.replace(errExp, "")
	
	if (str1.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- first name\n";
		document.voting.first_name.focus();
	}
	
	if (str2.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- surname\n";
		document.voting.surname.focus();
	}
	
	if (str3.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- company\n";
		document.voting.company.focus();
	}
	
	if (str4.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- address\n";
		document.voting.address.focus();
	}
	
	if (str5.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- city\n";
		document.voting.city.focus();
	}
	
	if (str6.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- country\n";
		document.voting.country.focus();
	}
	
	if (str7.length == 0) {
		errCount += 1;
		errFlag = true;
		errMsg += "- email address\n";
		document.voting.email.focus();
	} else {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str7)){
			//do nothing
		} else {
			errFlag = true;
			errMsg += "- email address\n";
			document.voting.email.focus();
		}
	}
					
	if (errFlag == true) {
		
		if (errCount > 1) {
			errMsg = "The following fields are empty or incorrect:\n" + errMsg;
		} else {	
			errMsg = "The following field is empty or incorrect:\n" + errMsg;
		}
		alert(errMsg);
		return false
	} else {
		return true;
	}
	
}
//php port
function time() {
    // http://kevin.vanzonneveld.net
    // +   original by: GeekFG (http://geekfg.blogspot.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: metjay
    // *     example 1: timeStamp = time();
    // *     results 1: timeStamp > 1000000000 && timeStamp < 2000000000

    return Math.round(new Date().getTime()/1000);
}

// makes an ajax request
function ajax_request(url, parameters, after_success, ignore_fail)
{
	new Ajax.Request(url, {
		method: 'post',
		parameters: parameters,
		evalScripts: true,
		onSuccess: function (response)
			{
				// only if the response status is something must we do anything
				// if its 0 then no response was recieved - I hope this doesnt cause bugs!
				if (parseInt(response.status) > 0)
				{
					resp = response.responseText;
					resp_array = resp.split("|");
					resp_code = resp_array.shift();
					resp_text = implode('|',resp_array);
					if (!resp_code) { alert("ERROR: No Code in resp: "+resp); }
					if (resp_code > 0)
					{
						eval(after_success);
					} else {
						alert(resp);
					}
				}
			},
		onFailure: function()
			{
				if (isset(ignore_fail))
				{

				} else {
					alert('Ajax Request Failed.');
				}
			}
		}
	);
	return true;
}
// -->
