


function init() {	
	
	var objReg;
	var param;		
	
	
		 				
	if (frames && frames.main && frames.main.location.href.indexOf('quasar2/index.pl') == -1) {
	
		objReg = new RegExp();
		objReg = /(.*)\?(.*)/;	
		
		param = '';
		
		if (objReg.test(location.href) == true) {
			param = '&' + RegExp.$2;
		}
		
		frames.main.location.replace(script + param);	
		
	}
	
	
}

function init2() {	
		
	var objReg;
	var param;
	
	objReg = new RegExp();
	objReg = /(.*)\?(.*)/;	
	
	param = '';
	
	if (objReg.test(location.href) == true) {
		param = '?' + RegExp.$2;
	}

	frames.start.location.replace('index2.htm' + param);
	

}



function set_frames (aid,sid,cid,url,navi) {	
	

	if (navi == 'noframes') return true;
	

	if (0 && url.length > 0 && (top.location.href.indexOf('/html/') != -1 || top.location.href.indexOf(url) != 0 || top.location.href.indexOf('quasar2/index.pl') != -1)) {  				

	
		div = '<div class="redirect">Redirecting Page to:<br><br><a href=' + url + '>' + url + '</a></div>';		

		if (document.getElementById('content')) document.getElementById('content').innerHTML = div;
		
		objReg = new RegExp();
		objReg = /(.*)\?(.*)/;	
	
		param = '';	
		
		if (objReg.test(location.href) == true) {
			param = '/?' + RegExp.$2 + '&s=' + sid;
			url = url + param;
			
		}

		top.location.replace(url);
		return true;
	
	}		

	n = top.frames.navi;
	
	if (top.frames[0] && top.frames[0].frames.navi) {
		n = top.frames[0].frames.navi;
	}
	
	if (navi == 'no') return true;	

				
	if (n) {					
		if (navi == 'force' || ( navi == 'check' && ! String(n.location).match(/quasar2\/index.pl/gi))) {
			n.location.replace(location.pathname + "?sid=" + sid + "&c=" + cid + "&a=" + aid + "&t=1");
		}			
	}	
	
	
	nb = top.frames.navi_bottom;
	
	if (top.frames[0] && top.frames[0].frames.navi_bottom) {
		nb = top.frames[0].frames.navi_bottom;
	}
	
	
	if (navi == 'no') return true;	

				
	if (nb) {					
		if (navi == 'force' || ( navi == 'check' && ! String(nb.location).match(/quasar2\/index.pl/gi))) {
			nb.location.replace(location.pathname + "?sid=" + sid + "&c=" + cid + "&a=" + aid + "&t=3");
		}			
	}		
	
	
	b = 0;

	if (top.frames[0] && top.frames[0].frames && top.frames[0].frames.bottom) {
		b = top.frames[0].frames.bottom.bottom2;
	}
	
	
	if (b) {		
		
		if (navi == 'force' || ( navi == 'check' && ! String(b.location).match(/quasar2\/index.pl/gi))) {
			
			b.location.replace(location.pathname + "?sid=" + sid + "&c=" + cid + "&a=" + aid + "&t=2");
		}			
	}		
	
	
	return true;
			
}


function set_navi () {
	
	var m,n,n0,aid,sid,nb,nb0;
	
	if (top.frames.main) m = top.frames.main;
	if (top.frames[0] && top.frames[0].frames.main) m = top.frames[0].frames.main;	
	
	if (m && m.frames.main2) m = m.frames.main2;	
	
	if (!m) return;
		
	if (top.frames.navi) n = top.frames.navi;
	if (top.frames[0] && top.frames[0].frames.navi) n = top.frames[0].frames.navi;
	
	if (top.frames.navi_bottom) nb = top.frames.navi_bottom;
	if (top.frames[0] && top.frames[0].frames.navi_bottom) nb = top.frames[0].frames.navi_bottom;
	
	if (!n) return;
	
	
	
	n0 = n;
	nb0 = nb;
	
	m = m.document.formmain;
	n = n.document.formnavi;
	nb = nb.document.formnavi;
	

	if (!n) return;
	
	if (m) {
	
		aid = (m.a ? m.a.value : 0);
		sid = (m.sid ? m.sid.value : 0);
		
			
		if (aid == 0) return;
		
		if (aid < 100) return;
		
		aid = aid - (aid % 100);
		
		n.sid.value = sid;
		n.a.value = aid;
		
		if (!nb) {
			
		}
		else {
			
			n.sid.value = sid;
			n.a.value = aid;
			if (nb0.anavi[aid]) nb0.navi_id0 = nb0.anavi[aid];
			
		}
		
		if (n0.anavi[aid]) n0.navi_id0 = n0.anavi[aid];
	
	}

	n0.do_navi(0);
	
	if (nb0) {
		
		try {		
			//alert(nb.name);
			eval(nb0.do_navi(0));	
		}
		catch(e) {
			
		}
		
		
		
	}
	
}


function set_user(user_name) {
   			
  var b;
		
	if (top.frames.bottom) b = top.frames.bottom;
	if (top.frames[0] && top.frames[0].frames.bottom) b = top.frames[0].frames.bottom;	

	if (!b) return;
	
	if (b.document.getElementById("user_name")) {	
			b.document.getElementById("user_name").innerHTML = user_name;	
	}   			
   			
} 


function do_menu (a) {

	var n, s, c, u;
	var comp_id;
	
	if (top.frames.navi) n = top.frames.navi;
	if (top.frames[0] && top.frames[0].frames.navi) n = top.frames[0].frames.navi;	

	if (!n) return;

	n = n.document.formnavi;	
	
	if (!n) return;
	
	
	s = n.sid.value;
	c = n.c.value;
	
	u = n.action + '?c=' + c + '&sid=' + s + '&a=' + a;
	
	//alert(window.location.search);
	
	frames.menu.location.replace(u);
	
	
}

function do_action (a,p,t) {

	var n, s, c, u, f;
	
	if (top.frames.navi) n = top.frames.navi;
	if (top.frames[0] && top.frames[0].frames.navi) n = top.frames[0].frames.navi;	

	if (!n) return;		
	
	if (!p) p = '';
	
	
	if (!t) {
		f = 'main';
		t = 0;
	}	
	else if (t == 4) {
		f = 'menu_left';	
	}
	else if (t == 5) {
		f = 'logo';	
	}
	else if (t == 6) {
		f = 'main.frames.main2';	
		t = 0;
	}
	
	n = n.document.formnavi;	
	
	if (n) {
	
		s = n.sid.value;
		c = n.c.value;
		
		u = n.action + '?c=' + c + '&sid=' + s + '&a=' + a + '&t=' + t + p;
		
		top.frames[0] && eval('top.frames[0].frames.' + f).location.replace(u);
		
		return true;
		
	}
	
	return false;
	
}	


function do_scroll (n,dx) {

	var item;
	var m_top;

	item = document.getElementsByName(n)[0];
	
	if (! item) {		
		item = document.getElementById(n);	
	}
	
	if (! dx) dx = 0;
	
		
	m_top = 0;
	
	while (item) {

 		m_top += item.offsetTop;
 		item = item.offsetParent;			
	
	}
	
	m_top -= 4;
	
	m_top += dx;
	
	//alert(m_top + ' dx ' + dx);
	
	if (parent.frames.main) {	
		parent.frames.main.document.body.scrollTop = m_top;	
	}
	else {
		document.body.scrollTop = m_top;	
	}

}


function check_changes (aid) {

	var f;
	var e;
	var i;
	var changed;
	var n;
	var s;
	var fav_changed;
	var auto;
	

	if (! top.frames[0]) return true;
	if (! top.frames[0].frames.main) return true;
	if (! top.frames[0].frames.main.frames.main2) return true;

	
	f = top.frames[0].frames.main.frames.main2.document.formmain;
	
	
	
	if (!f) {
		return true;	
	}	
	
		
	if (f.a.value < 2100 || f.a.value > 2190 ) {
		return true;
	}
	
	
	
	if (f.saved && f.saved.value == '1') return true;
	
	auto = 0;
	if (f.tip_autosave) auto = f.tip_autosave.value;
	
	
	   		
	changed = 0;
	fav_changed = 0;	 	

	for (i = 0; i <= f.elements.length-1; i++) {

		e = f.elements[i];   	
		
		
		if (e.name.substr(0,10) == 'game_goals') {
			
			n = e.name.replace(/game_goals/gi,'');
			
			val1 = eval('f.tip' + n + '.value');		
			
			val2 = e.value;		
			
			if (val1 != val2) {

				changed = 1;
				break;
			}					
			
		}
		
		if (e.name.substr(0,10) == 'game_joker') {
			
			val1 = e.checked;
			
			n = e.value.replace(/-/gi,'_');
			
			val2 = eval('f.tipjoker_' + n + '.value');
		
			val2 = (val2 == 1 ? true : false);
			
			if (val1 != val2) {				
				changed = 1;
				break;	
			}			
			
		}
		
		
		if (e.name.substr(0,6) == 'bonus_') {
			
			n = e.name.replace(/bonus_/gi,'');
			
			val1 = eval('f.bonus2_' + n + '.value');		
			
			val2 = e.value;		
			
			if (val1 != val2) {
				changed = 1;
				break;
			}			
			
		}
		
		if (e.name.substr(0,4) == 'fav_') {
			
			n = e.name.replace(/fav_/gi,'');
			
			val1 = eval('f.fav2_' + n + '.value');		
			
			val2 = e.value;		
			
			if (val1 != val2) {
				
				changed = 1;						
				
				if (val1 == 0) {
					
					fav_changed = 1;
						
				}	
				
				if (val2 == 0) {
					return false;	
				}			
				
				break;
			}			
			
		}		
	
		
	}		
	
	if (changed == 0) {
		return true;
	}
	
	if (auto) {
		save = true;
	}
	else {
		save = confirm(eval('f.changed_question.value'));
	}
	
	
	var f1 = top.frames[0].frames.main.frames.menu.document.formmain;
	
	
	if (save == false && fav_changed == 1) {
		
		for (i = 0; i < f1.matchday.length; i++) {
		
			if (f1.matchday.options[i].value == -4) {
				f1.matchday.options[i].selected = true;
				return false;
			}
		
		}
							
		return false;	
	}
	
	
	f.saved.value = 1;
	
	
	//alert('save ' + f.name + ' aid ' + aid);

	if (save == true) {		
		
		s = top.frames[0].frames.main.frames.menu.document.formmain.matchday;
		
		if (s) {
		
		  for (i = 0; i < s.length; i++) {
		    	if (s.options[i].defaultSelected == true) {
		      		//s.options[i].selected = true;
		      }
			}		
		
		}
		
		f.tip_save.value = 1;
		
		
				
		if (aid != 2100 && aid != 2110) {
			//f.target = 'main';
			//f.a.value = aid;
		}
		
		if (aid == 2110) return true;
	
		
		f.submit();
		
		//alert('submit ' + f.tip_save.value);
		
		return false;

	}
	
	return true;   			

} 


var country = new Array();


function country_show (id1,name1,name2,show,dx,dy) {

	var m_left;
	var m_top;
	var e;
	var i;
	var item;
	var image;
	var t;
	
	if (show == 0) {
		return;
	}		
	
	if (name2.length == 0) {
		return;	
	}
	
	name1 = name1.replace('[','%5B');
	name1 = name1.replace(']','%5D');
	
	for (i = 0; i < country.length; i++) {
		
		t = t + "\n" + i + ' ' + country[i].src + ' ' + name1
		
		if (country[i].src.toLowerCase() == name1.toLowerCase()) {
			image = country[i];
			break;	
		}
		
	}
	
	if (! image) {
		image = new Image();
		image.src = name1;	
		country[country.length] = image;
	}	
	
	
	item = document.getElementById(id1);
	e = document.getElementById('country');
	n = document.getElementById('cname');
	i = document.getElementById('cimage_0');
	
	i.style.display = 'none';
	n.innerHTML = name2;
	i.src = image.src;
	i.style.display = 'inline';
	
	m_left = 0;
	m_top = 0;				
	
	while (item) {
	
 		m_left += item.offsetLeft;
 		m_top += item.offsetTop;

 		item = item.offsetParent;			
	
	}
	
	e.style.left = m_left - 2 + dx;
	e.style.top = m_top + 24 + dy;			
	e.style.visibility = 'visible';		
		

}

function country_hide (id) {

	var e;
	var e2;

	e = document.getElementById('country');
	e2 = document.getElementById(id);
	
	e.style.visibility = 'hidden';				
	


}


function show_team (team_id,team_mode,comp_id,branch_id) {
	
	var a;
	var p;
	
	if (! team_mode) team_mode = 0;
	if (! comp_id) comp_id = 0;
	if (! branch_id) branch_id = 0;
	
	a = 1200;	
	p = '&a2=2&team_id=' + team_id + '&team_tmp=1&team_mode=' + team_mode + '&comp_id0=' + comp_id + '&branch_id0=' + branch_id;
	
	do_action(a,p);
	
	if (comp_id) {
		do_action(a,p,4);
		do_action(a,p,5);	
	}
	return;
	
}

function show_game (comp_id, branch_id,day_id, user_id,month_id) {
	
	var p;
	var a;
	
	if (! month_id) month_id = 0;
	
	
	a = 1200;
	p = '&a2=1&comp_id0=' + comp_id + '&branch_id0=' + branch_id + '&day_tmp=' + day_id + '&month_id=' + month_id;
	
	
	
	do_action(a,p);
	do_action(a,p,4);
	do_action(a,p,5);
	return;

		
}

	function show_table (mode,info) {
		
		var h1, h2, w;
		var e1, e2,e3;
		var item;
		var m_top, m_left;		
		
		e1 = document.getElementById('shadow');
		e2 = document.getElementById('table_info');	
		
		if (mode == 0) {
			e1.style.display = 'none';
			e2.style.display = 'none';
			return;
		}		

		
		h1 = document.getElementById('idbottom').offsetTop;			

		h2 = 0;
		
		h2 = (window.pageYOffset ? window.pageYOffset : document.body.scrollTop);
		
		h2 += 100;
		
		e1.style.height = h1;

		e2.style.top = h2;	
		
		
		e1.style.display = 'inline';		
		e2.style.display = 'inline';

		
		
	}	


		
function show_player (player_class,player_id,player_mode,comp_id) {

	var a;
	var p;
	
	if (! player_mode) player_mode = 0;


	if (comp_id && comp_id == '$COMP_ID') {
		comp_id = 0;	
	}


	if (! comp_id) {		
		comp_id = document.formmain.comp_id0.value;		
	}	

	
	a = 6100;	
	p = '&a2=10&player_mode=' + player_mode + '&player_class=' + player_class + '&player_id=' + player_id + '&comp_id0=' + comp_id;

	

	
	
	do_action(a,p);
	
	
	a = 1200;
	
	do_action(a,p,4);
	
	
	return;
		
}
		
function get_doc_height() {
	
    var d = document;
    return Math.max(
        Math.max(d.body.scrollHeight, d.documentElement.scrollHeight),
        Math.max(d.body.offsetHeight, d.documentElement.offsetHeight),
        Math.max(d.body.clientHeight, d.documentElement.clientHeight)
    );
}	
			
