var brwType = '';
if (document.getElementById) brwType = "std";
else if (document.all) brwType = "ie4";
else if (document.layers) brwType = "ns4";

var myObj = new Array();

function get_obj(objId)
{
if (typeof(myObj[objId]) == "undefined")
	{
	switch (brwType)
		{
		case "std":
		{myObj[objId] = document.getElementById(objId);}
		break;
		case "ie4":
		{myObj[objId] = document.all[objId];}
		break;
		case "ns4":
		{myObj[objId] = document.layers[objId];}
		break;
		}
	}
return myObj[objId];
}


function my_getcookie(cookieName)
{
cname = cookieName + '=';

cpos  = document.cookie.indexOf( cname );
	if ( cpos != -1 )
	{
		cstart = cpos + cname.length;
		cend   = document.cookie.indexOf(";", cstart);
		
		if (cend == -1)	cend = document.cookie.length;
		
		return unescape( document.cookie.substring(cstart, cend) );
	}
	
return null;
}

function copy_ip(address,port)
{
copy_type=my_getcookie("copyType");
content=(copy_type==2)?address+":"+port:address;
if(do_copy(content)==true) alert('"'+content+'"'+" is in your clipboard now");
else return false;
}

function copy_link_code()
{
var linkCode='<a href="http://www.proxylist.us.to" target="new"><img src="http://www.proxylist.us.to/source/img/exchange.gif" alt="Free Proxy List" /></a>';
if(do_copy(linkCode)==true) alert("Link code is in your clipboard now");
else return false;
}

function do_copy(content)
{
if (window.clipboardData) 
	{
	window.clipboardData.setData("Text", content);
	return true;
	}
else 
	{
	alert("Sorry, this function is not supported in browsers other than IE so far.");
	return false;
	}
}

function init_setting()
{
copy_type=my_getcookie("copyType");
document.write('<input name="copyType" type="radio" value="1" checked="checked" />Copy <b>proxy server</b> only<br />');
if(copy_type==2) document.write('<input type="radio" name="copyType" value="2" checked="checked" />Copy <b>proxy server</b> and <b>port</b><br />');
else document.write('<input type="radio" name="copyType" value="2" />Copy <b>proxy server</b> and <b>port</b><br />');
}

function jump_to1(pageNum,prevUrl,restUrl)
{
page=get_obj("jumpTo").value;
var patternPage=/^[1-9]+[0-9]?$/;
if (!patternPage.exec(page)) {alert("Invalid page ID"); return false;}
else if(page<=0||page>pageNum) {alert("Invalid page ID"); return false;}
else location=prevUrl+page+restUrl;
}

function jump_to2(pageNum,prevUrl,restUrl)
{
if(window.event.keyCode!==13) return;
else jump_to1(pageNum,prevUrl,restUrl)
}

function search_check()
{
portVal=get_obj("port").value;
typeVal=get_obj("type").value;
countryVal=get_obj("country").value;
if(portVal==0&&typeVal==0&&countryVal==0) return false;
else return true;
}

startList = function()
{
	if (document.all&&document.getElementById)
		{
		navRoot = document.getElementById("top2");
		for (i=0; i<navRoot.childNodes.length; i++)
			{
			node = navRoot.childNodes[ i ];
			if (node.nodeName=="LI")
				{
				node.onmouseover=function()
				{this.className+=" over";}
				node.onmouseout=function()
				{this.className=this.className.replace(" over", "");}
				}
			}
		}
}
window.onload=startList;

