function hideFocusBorders() {
	var theahrefs = document.getElementsByTagName("SPAN"); 
	if(!theahrefs) { return; }
	for(var x = 0; x != theahrefs.length; x++) {
		theahrefs[x].onfocus = function stopLinkFocus() { this.hideFocus = true; };
	}
}

function changeLangFor(pValue) {
	var	loc = document.location + '';
	var patt = /\/\w{3}\//;
	var found = patt.test(loc);
	
	if(found) {
		var result = loc.replace(patt, '/' + pValue + '/');
		document.location = result;
	}
	else {
		document.location = 'http://getsubtitle.com/' + pValue + '/index.htm';
	}	

	return false;
}

function optionsClick(pValue) {
	var action = '';
	switch(parseInt(pValue)) {
		case 2: { 
			action = 'login.htm';
		}
		break;
		
		case 3: {
			action = 'register.htm';
		}
		break;
			
		case 4: {
			action = 'upload.htm';
		}
		break;
		
		case 5: {
			action = 'my_page.htm';
		}
		break;
		
		case 6: {
			action = 'query/';
		}
		break;
		
		case 10: {
			action = 'download_divx_subtitles.htm';
		}
		break;
		
		default: {
			action = 'index.htm';
		}
		break;
	}
	
	var lang = '';
	if(document.getElementById('lang')) lang = document.getElementById('lang').value;
	var server_name = '';
	if(document.getElementById('server_name')) server_name = document.getElementById('server_name').value;
	
	if(action == 'query/') {
		if(lang == '')
			document.location = 'http://' + server_name + '/' + action;
		else
			document.location = 'http://' + server_name + '/' + lang + '/' + action;
	}
	else {
		if(lang == '')
			document.location = 'http://' + server_name + '/' + action + document.getElementById('fingerprint').value;
		else 
			document.location = 'http://' + server_name + '/' + lang + '/' + action + document.getElementById('fingerprint').value;
	}
	
	return false;
}

function replaceAll(string, token, newtoken) {
	while(string.indexOf(token) != -1) {
		string = string.replace(token, newtoken);
	}
	return string;
}

function urlencode(str){var hexStr=function(dec){return'%'+(dec<16?'0':'')+dec.toString(16).toUpperCase();};var ret='',unreserved=/[\w.-]/;str=(str+'').toString();for(var i=0,dl=str.length;i<dl;i++){var ch=str.charAt(i);if(unreserved.test(ch)){ret+=ch;}
else{var code=str.charCodeAt(i);if(0xD800<=code&&code<=0xDBFF){ret+=((code-0xD800)*0x400)+(str.charCodeAt(i+1)-0xDC00)+0x10000;i++;}
else if(code===32){ret+='+';}
else if(code<128){ret+=hexStr(code);}
else if(code>=128&&code<2048){ret+=hexStr((code>>6)|0xC0);ret+=hexStr((code&0x3F)|0x80);}
else if(code>=2048){ret+=hexStr((code>>12)|0xE0);ret+=hexStr(((code>>6)&0x3F)|0x80);ret+=hexStr((code&0x3F)|0x80);}}}
return ret;}