function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(whichurl) {
    http.open('get', 'outBound.php?fromurl=' + urlencode(whichurl.href));
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function goWin(){
	window.open('http://88.80.6.241/', '_blank', 'location=0:width=800:height=600:top=0:left=0');
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();
        update = response.split('|');
        document.getElementById('returndiv').innerHTML = response;
    }
}

function urlencode(text) {

     text= text.replace(/\//g,"%2F");
    text= text.replace(/\?/g,"%3F");
   text=  text.replace(/=/g,"%3D");
  text=   text.replace(/&/g,"%26");
     return text;
}

function hover_server(what){
	if (what.className == 'chosen'){
		// do nothing
	}else{
		if(what.className){
			what.className = null;
		}else{
			what.className = 'row_over';
		}
	}
}

function choose_s(which, what){
	trArray = document.getElementById('servertable').tBodies[0].rows;
	// alert('found ' + trArray.length);
	i=0;

	while(trArray[i]){
		// alert('checking ' + trArray[i].nodeName);
		if (trArray[i].className == 'chosen'){
			trArray[i].className = null;
		}
		i++;

	}
	
	checkbox = document.getElementById("server_" + which);
	createCookie('default_server',which,180);
	// alert ('choosing ' + which);
	checkbox.checked = true;
	what.className = "chosen";
}

function goDownload(){
	var captcha = document.getElementById('captcha_guess');
	if (captcha.value == ''){
		alert ('You must enter a validation code to continue.');
		captcha.focus();
	}else{
		window.location = "/" + download_query + "-download.html";
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}