// JavaScript Document

//---cookie functions-------------------
function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
//---end cookie functions-------------------

var coloract = "#dd0404";

if(!getCookie("superbg")){
	setCookie("superbg", "ffffff", "", "/");
	colorbg = "#ffffff";
}else{
	colorbg = "#"+getCookie("superbg");
}

if(!getCookie("supercolor")){
	setCookie("supercolor", "dd0404", "", "/");
	coloract = "#dd0404";
}else{
	coloract = "#"+getCookie("supercolor");
}

if(!getCookie("mailact")){
	setCookie("mailact", "0", "", "/");
	mailact = "0";
}else{
	mailact = getCookie("mailact");
}


//----BROWSER DETECTION----
function getRef(id) {
 return document.getElementById(id);
}
var nav=navigator.appName;
//----BROWSER DETECTION----

function ShowTree(id){
	var menu = 'hide' + id;

	if(getRef(menu)){
		if(getRef(menu).style.display == 'none'){
			for(i=1;i<20;i++){
			if(getRef('hide'+i) != null){
				getRef('hide'+i).style.display = 'none';
				//getRef('mlist'+i).style.display = '';
				}
			}
			getRef(menu).style.display = '';
			//getRef(mmenu).style.display = 'none';
		}
		else{
			getRef(menu).style.display = 'none';
			//getRef(mmenu).style.display = '';
		}
	}
}

//----ACTIVATING FLASH-----
function flash(flash_content){
	document.write(flash_content);
	}

function flash2(w,h,url){
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'">'
              +'<param name="movie" value="'+url+'">'
              +'<param name=quality value=high>'
              +'<param name="wmode" value="transparent">'
              +'<embed src="'+url+'" wmode="transparent" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+w+'" height="'+h+'"></embed>'
              +'</object>'
	          );
	}
//----ACTIVATING FLASH-----


//----TOTAL SPORT OVER OUT----
function tsover (obj){
	obj.style.color = "#FF7F00";
	}
function tsout (obj){
	obj.style.color = "#333333";
	}
//----TOTAL SPORT OVER OUT----


function addfav (fav){
	window.external.addFavorite(location.href, fav);
}
function printp (){
	window.print();
}

//-------------------------------------------------------------- new design ---
//var coloract = "#dd0404";

function setcolor(){
	for(i=1;i<9;i++){
		if(rgbtohex(document.getElementById('color'+i).style.borderColor) == coloract){
			document.getElementById('color'+i).style.backgroundColor = coloract;
			//chcolor(document.getElementById('color'+i));
		}
	//document.getElementById('color'+i).style.backgroundColor = colorbg;
	}
	document.getElementById('hide1').style.borderColor = coloract;
	document.getElementById('hide2').style.borderColor = coloract;
	document.getElementById('hide3').style.borderColor = coloract;
	document.getElementById('hide4').style.borderColor = coloract;
	document.getElementById('hide5').style.borderColor = coloract;
	//document.getElementById('colorline').style.backgroundColor = coloract;
	//if(mailact == 1)
	//document.getElementById('maildiv').style.display = '';
}

function fillbg(obj){
	if(obj.style.backgroundColor == ""){
		obj.style.backgroundColor = rgbtohex(obj.style.borderColor);
	}else{
		if(rgbtohex(obj.style.borderColor) != coloract){obj.style.backgroundColor = "";}
	}
}

function chcolor(obj){

	document.getElementById('color1').style.backgroundColor = "";
	document.getElementById('color2').style.backgroundColor = "";
	document.getElementById('color3').style.backgroundColor = "";
	document.getElementById('color4').style.backgroundColor = "";
	document.getElementById('color5').style.backgroundColor = "";
	document.getElementById('color6').style.backgroundColor = "";
	document.getElementById('color7').style.backgroundColor = "";
	document.getElementById('color8').style.backgroundColor = "";

	obj.style.backgroundColor = rgbtohex(obj.style.borderColor)	;
	coloract = rgbtohex(obj.style.borderColor);
	setCookie("supercolor", coloract.slice(1), "", "/");

	document.getElementById('colorline').style.backgroundColor = coloract;

	if(colorbg=='#000000'){
		imgsrc = document.getElementById('logo').src;
		document.getElementById('logo').src = imgsrc.substr(0, imgsrc.indexOf("/img/")+1)+"img/i"+coloract.slice(1)+"_b.gif";
	}
	else{
		imgsrc = document.getElementById('logo').src;
		document.getElementById('logo').src = imgsrc.substr(0, imgsrc.indexOf("/img/")+1)+"img/i"+coloract.slice(1)+".gif";
	}

	imgsrc = document.getElementById('mailimg').src;
	document.getElementById('mailimg').src = imgsrc.substr(0, imgsrc.indexOf("/img/")+1)+"img/m"+coloract.slice(1)+".gif";

	document.getElementById('txtblock1').style.borderColor = coloract;
	document.getElementById('divblock1').style.backgroundColor = coloract;
	document.getElementById('txtblock2').style.borderColor = coloract;
	document.getElementById('divblock2').style.backgroundColor = coloract;
	document.getElementById('txtblock3').style.borderColor = coloract;
	document.getElementById('divblock3').style.backgroundColor = coloract;
	if(document.getElementById('txtblock4')){
	document.getElementById('txtblock4').style.borderColor = coloract;
	document.getElementById('divblock4').style.backgroundColor = coloract;}

	imgsrc = document.getElementById('mailimg').src;
	document.getElementById('arrow').src = imgsrc.substr(0, imgsrc.indexOf("/img/")+1)+"img/arrow_"+coloract.slice(1)+".gif";

	document.getElementById('hide1').style.borderColor = coloract;
	document.getElementById('hide2').style.borderColor = coloract;
	document.getElementById('hide3').style.borderColor = coloract;
	document.getElementById('hide4').style.borderColor = coloract;
	document.getElementById('hide5').style.borderColor = coloract;

}
//rgbtohex("rgb(23,255,130)")
function rgbtohex(col){
	if(col.substr(0, 3) == 'rgb'){
		arr = col.split(",");
		arr[0] = arr[0].substr(4, arr[0].length);
		arr[2] = arr[2].substr(0, arr[2].indexOf(")"));

		out = "#" + Color2Hex(arr[0])+Color2Hex(arr[1])+Color2Hex(arr[2]);
		return out.toLowerCase();
	}else{
		return col.toLowerCase();
	}
}

function Color2Hex(n)
{
    return ToHex(n >> 4) + ToHex(n);
}
function ToHex(n)
{
    n = n % 16;
    if (n <= 0)
        return "0";
    if (n < 10)
        return n.toString();
    if (n == 10)
        return "A";
    if (n == 11)
        return "B";
    if (n == 12)
        return "C";
    if (n == 13)
        return "D";
    if (n == 14)
        return "E";
    if (n == 15)
        return "F";
}

function showmail(num)
{
	if(num == 1){
		if(mailact == 1){
			mailact = 0;
			setCookie("mailact", mailact, "", "/");}
		else{
			mailact = 1;
			setCookie("mailact", mailact, "", "/");}
	}

	if(num != 1){
		if(mailact == 0){
			if(document.getElementById('maildiv').style.display != 'none')
				document.getElementById('maildiv').style.display = 'none';
			else
				document.getElementById('maildiv').style.display = '';
		}
	}
}