var soccerstand_p = parseInt(getJSvars('paid_livescore.js', 'p', '0'));
var soccerstand_s = parseInt(getJSvars('paid_livescore.js', 's', '1'));
var soccerstand_l = parseInt(getJSvars('paid_livescore.js', 'l', '3'));
var PAGE_autoresize = parseInt(getJSvars('paid_livescore.js', 'r', 0));
var soccerstand_c = getJSvars('paid_livescore.js', 'c', 'default');

var soccerstand_h = getJSvars('paid_livescore.js', 'h', 'www.soccerstand.com');
function getL(l){
	switch(parseInt(l)){
		case 1: return "dk";break;
		case 3: return "en";break;
		case 9: return "ru";break;
		case 11: return "de";break;
		case 29: return "fr";break; 
		case 31: return "tr";break;
		case 23: return "pl";break;
		case 69: return "ar";break;
		default: return 'en';break;
	}
}
function getS(s){
	switch(parseInt(s)){
		case 1:return 'soccer';break;
		case 2:return 'tennis';break;
		case 23:return 'basketball';break;
		case 5:return 'icehockey';break;
		case 24:return 'football';break;
		case 26:return 'baseball';break;
		case 20:return 'handball';break;
		default: return 'soccer';break;
	}
}
var soccerstand_src = 'http://' + soccerstand_h + '/paid_livescore/' + soccerstand_c + '/' + getS(soccerstand_s)+ '/' + getL(soccerstand_l) + '/get?p=' + soccerstand_p + '&s=' + soccerstand_s + '&l=' + soccerstand_l + '&callback=' + escape(String(window.location).split('#')[0]);

switch(window.location.hostname){
	case 'foot.fr':
	case 'www.foot.fr':
		soccerstand_src = 'http://soccerstand.com/free_livescore/get_free_livescore';
		//window.location = soccerstand_src;
		//soccerstand_src = 'http://soccerstand.com/free_livescore/get_free_livescore';
		break;
}


document.getElementById('free_livescore').src = soccerstand_src;
if(typeof(PAGE_autoresize) != 'undefined' && PAGE_autoresize){ 
	setTimeout(livescore_resize, 500);
}
function livescore_resize(){
	var locHash = location.hash.replace('#','');
	if(isInteger(locHash)){
		if(parseInt(locHash)!=parseInt(document.getElementById('free_livescore').style.height)){
			document.getElementById('free_livescore').style.height = parseInt(locHash)+200+'px';
		}
	}
	setTimeout(livescore_resize, 500);
}
function isInteger(s){return (s.toString().search(/^-?[0-9]+$/) == 0);}
function getJSvars(script_name, var_name, if_empty) {
	var script_elements = document.getElementsByTagName('script');
	if(if_empty == null) {var if_empty = '';}
	for (a = 0; a < script_elements.length; a++) {
   		var source_string = script_elements[a].src;
       	if(source_string.indexOf(script_name)>=0) {
       		var_name = var_name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
       		var regex_string = new RegExp("[\\?&]"+var_name+"=([^&#]*)");
       		var parsed_vars = regex_string.exec(source_string);
       		if(parsed_vars == null) { return if_empty; }
       	else { return parsed_vars[1]; }

		}
	}
}