function echeck(str) {
    var at = "@";
    var dot = ".";
    var lat = str.indexOf(at);
    var lstr = str.length;
    var ldot = str.indexOf(dot);
    if (str.indexOf(at) == -1) {
	return false;
    }
    if ((str.indexOf(at) == -1) || (str.indexOf(at) == 0) || (str.indexOf(at) == lstr)) {
	return false;
    }
    if ((str.indexOf(dot) == -1) || (str.indexOf(dot) == 0) || (str.indexOf(dot) == lstr)) {
	return false;
    }
    if (str.indexOf(at,(lat+1)) != -1) {
	return false;
    }
    if ((str.substring(lat-1,lat) == dot) || (str.substring(lat+1,lat+2) == dot)) {
	return false;
    }
    if (str.indexOf(dot,(lat+2)) == -1) {
	return false;
    }
    if (str.indexOf(" ") != -1) {
	return false;
    }
    return true;			
}

function create_http_handle(TYPE) {
    var http_handle = false;
    if (window.XMLHttpRequest) {
	http_handle = new XMLHttpRequest();
	if (http_handle.overrideMimeType) {
	    if (TYPE == "XML") {
		http_handle.overrideMimeType('text/xml');
	    }
	    else {
		http_handle.overrideMimeType('text/html');
	    }
	}
    }
    else if (window.ActiveXObject) {
	try {
	    http_handle = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) {
	    try {
		http_handle = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    catch (e) {}
	}
    }
    if (!http_handle) {
	alert("Your browser does not support AJAX!\n\nPlease talk to Internal IT.");
	return false;
    }
    else {
	return http_handle;
    }
}

function sendHTTPrequest(URL, PARAMETERS, ONCHANGE, METHOD, TYPE) {
    if (TYPE == "") {
	TYPE = "HTML";
    }
    http = create_http_handle(TYPE);
    http.onreadystatechange = function() {
	if (http.readyState == 4 && http.status == 200) {
	    eval(ONCHANGE + '();');
	}
    }
    //Kill the Cache problem in IE.
    PARAMETERS += (PARAMETERS.indexOf("?") + 1) ? "&" : "?";
    PARAMETERS += "sid=" + Math.random();
    if (METHOD == "POST") {
	http.open('POST', URL, true);
	http.setRequestHeader("Content-type", "application/x-www-form-URLencoded");
	http.setRequestHeader("Content-length", PARAMETERS.length);
	http.setRequestHeader("Connection", "close");
	http.send(PARAMETERS);
    }
    else {
	http.open('GET', URL + PARAMETERS, true);
	http.send(null);
    }
}

function right(e) {
    if ((navigator.appName == "Netscape" && e.which == 3) || (navigator.appName=='Microsoft Internet Explorer' && event.button == 2)) {
	alert('No Copying from this Web Page.\nAll Rights Reserved\n\251 Scorpio Geek NZ Limited');
	return false;
    }
    else {
	return true;
    }
}

function rightSilent(e) {
    return false;
}

function trap() {
    if (document.images) {
	for (i = 0; i < document.images.length; i++) {
	    document.images[i].onmousedown = right;
	    document.images[i].oncontextmenu = rightSilent;
	}
    }
}

function pop_image(src,pid,w,h,ct,fsize,caption) {
    pop_photo = window.open('/resources/pop_image.php?src=' + src + '&id=' + pid + '&w=' + w + '&h=' + h + '&ct=' + ct + '&size=' + fsize + '&caption=' + caption,'pop_photo','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=' + w + ',height=' + h);
    pop_photo.focus();
}

function pop_window(a,w,h,v) {
    if (a == 1) {
	whois = window.open('/scorpiogeek/whois.php?type=employee&userid=' + v + '&w=' + w + '&h=' + h,'whois','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=' + w + ',height=' + h);
    }
    else if (a == 2) {
	whois = window.open('/scorpiogeek/whois.php?type=companies&contractno=' + v + '&w=' + w + '&h=' + h,'whois','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=' + w + ',height=' + h);
    }
    else {
	alert('There appears to be an issue with this link.');
    }
}