function unsetCur(mID, hID) {
		 var myImage = document.getElementById(mID);
		 myImage.setAttribute('src', '/img/n05/s.gif');
		 var myHref = document.getElementById(hID);
		 myHref.className = 'nav';
}

function setCur(mID, hID) {
		 var myImage = document.getElementById(mID);
		 myImage.setAttribute('src', '/img/n05/mm.gif');
		 var myHref = document.getElementById(hID);
		 myHref.className = 'navc';
}

function setupTableResults(crTop) {
		 var container = document.getElementById('CR');
		 if (container == null) {
			return;
		 }
		 var htmlData = '';
		 
		 for (var i=0; i<crTop.length; i++) {
         if (crTop[i] == null) { break }
			 
			 htmlData = htmlData + '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33" align="right" style="padding-right:7px" class="topl">'+
			 crTop[i][0] + '.</td><td width="1" class="topl"><nobr>' + crTop[i][1] + '</nobr></td><td class="topl" background="/img/n05/ul.gif">&nbsp;</td><td width="1" align="right" class="topl">'+
			 crTop[i][2] + '</td></tr></table>';
		 }
		 container.innerHTML = htmlData;
}

function go_logout(lang) {
    var mess;
    if (lang == 'NO') {
       mess = 'Du er i ferd med ' + unescape('%E5') + ' logge ut av F1GrandPrixManager.' + "\n" + 'Er du sikker p' + unescape('%E5') + ' at du vil det?';
    } else {
       mess = 'You are about to logout of F1GrandPrixManager.' + "\n" + 'Are you sure you want to do that?';
    }
    if ( confirm(mess) ) {
                document.cookie = 'f1-session-id=' + 'gone' + ';path=/;expires=Wed Apr 24 2002 19:20:12 GMT';
            document.location = 'http://' + document.location.hostname + (document.location.port == 80 ? '': (':' + document.location.port));
        }
}

function openWindow(link) {
         popupWin = window.open(link, 'survey', 
								'width=367,height=309,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,scrolling=no,directories=0,status=0,copyhistory=0,minimise=no,maximise=no,left=30,top=70');
		 return false;

}

function checkAnswer() {
         for (i=0; i < document.survey.survey_answer.length; i++) {
			 if (document.survey.survey_answer[i].checked) {
				document.location = '/go/survey/results.html?survey_answer='+document.survey.survey_answer[i].value;
				return;
			 }
		 }
		 alert('Please choose your answer.')
}

function checkSAnswer() {
		for (a=0; a < document.bquest.answer.length; a=a+1) {
			if (document.bquest.answer[a].checked) {
			return true;
			}
		}
		alert('Please make your choice.')
		return false;
}

function showInfo(id) {
	     var placeForContent = document.getElementById('container');
		 tabData = document.getElementById('m_' + id).cloneNode(1);
		 tabData.style.height = 350 + 'px';
			 
         placeForContent.replaceChild(
					tabData, placeForContent.firstChild);
			 
}

function showHelpDiv(parentID, divID, mode) {
		var div = document.getElementById(divID);
		var prnt = document.getElementById(parentID);	
		if (mode == 'on') {
			var ot = prnt.offsetTop;
			var ol = prnt.offsetLeft;
			while((prnt = prnt.offsetParent) != null) {
				ot += prnt.offsetTop;
				ol += prnt.offsetLeft;
			}
			div.style.left = ol + 10 + "px";
			div.style.top = ot + 10 + "px";
			div.style.visibility = 'visible';
	    } else {
			div.style.visibility = 'hidden';
		}

}

var send=0; // submit form
function check_image() {
		var i = document.getElementsByName("pv")[0];
		
		if ( !i.complete ) {
		   alert('Incorrect image!' + i.completed);
		   send=0;
			 return;
		}
		if ( send ) {
		   document.getElementsByName("frm")[0].submit();
		}
}

function preview_image() {
		var u = document.getElementsByName("image")[0].value;
		if ( !u.length ) { return; }
		
		var re = new RegExp('^file://','i');
		if ( !u.match(re) ) { 
		   u='file://'+u; 
		}
		
		var re1 = new RegExp('swf$','i');
		var html;
		if ( u.match(re1) ) {
			 html = '<OBJECT id=pv name=pv classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><PARAM NAME=movie VALUE="' + u +
					'"><PARAM NAME=menu VALUE=false><PARAM NAME=quality VALUE=high></OBJECT>';
		} else {
		   html = '<img name=pv src="' + u + '">';
		}
		
		document.getElementsByName('img_pv')[0].innerHTML = html;
	   
		setTimeout(check_image, 1000);
}

function check_form() {
        if (send == 0) {
			send = 1; 
			return true;
		}
		return false;
}

function open_w(name, link, width, height, wTitle) {
         newWindow = window.open('', name, 'resizable=yes, width='+width+', height='+height+', scrollbars=no, toolbar=no, titlebar=no, menubar=no');
         newWindow.document.write('<HTML><HEAD><TITLE>'+wTitle+'</TITLE><STYLE>  BODY {                  padding: 0px px px 0px;                 margin: 0px 0px 0px 0px;       }</STYLE></HEAD><BODY ><img SRC="'+link+'" WIDTH="'+width+'" HEIGHT="'+height+'" ALT="'+wTitle+'"></BODY></HTML>');
}

function setjs() {
		 if(navigator.product == 'Gecko') {
		   document.loginform["interface"].value = 'mozilla';
		 }else if(navigator.appName == 'Microsoft Internet Explorer') {
		   document.loginform["interface"].value = 'ie';
		 }else if(window.opera) {
		   document.loginform["interface"].value = 'opera';
		 }
}
function nickvalid() {
	   setjs();
	   var nick = document.loginform.Nickname.value;
	   if(nick.match(/^[A-Za-z0-9\[\]\{\}^\\\|\_\-`]{1,32}$/))
		  return true;
	   alert('Please enter a valid nickname');
	   document.loginform.Nickname.value = nick.replace(/[^A-Za-z0-9\[\]\{\}^\\\|\_\-`]/g, '');
	   return false;
}

function get_normal_digits(tmp) {
		 tmp = tmp + '';
		 var aaa = tmp.split('.');
		 if (aaa.length == 1) {
			tmp = tmp + '.0';
		 } else {
		    //damn !!! i hate it
		    if (aaa[1].length > 4) {
			    tmp1 = aaa[1];
				if (tmp1.substr(4,1) == 9) {
					aaa[1] = aaa[1].substr(0,4)*1+1;
				} else {
					aaa[1] = aaa[1].substr(0,4)*1;
				}
				tmp = aaa[0]+'.'+aaa[1]
			}

		    if (aaa[1].length == 1) {
			   tmp = tmp + '000';
			} else if (aaa[1].length == 2) {
			   tmp = tmp + '00';
			} else if (aaa[1].length == 3) {
			   tmp = tmp + '0';
			}
		 }
		 return tmp;
}

function showtime(lang) {
		if (diff > 0) {
			diff = diff - 1;
			var CurDay = Math.floor(diff / 86400);
			var CurHour = Math.floor((diff % 86400) / 3600);
			var CurMinute = Math.floor((diff % 3600) / 60);
			var CurSecond = diff % 60; 
                                 
      if (lang == 'NO') {
         Temp3 = CurDay + 'D ' + CurHour + 'T '+CurMinute+'M '+CurSecond+'s';
      } else {
         Temp3 = CurDay + 'D ' + CurHour + 'H '+CurMinute+'M '+CurSecond+'s';
      }
		} else {
                    if (lang == 'NO') {
                        Temp3 = 'Tiden er ute';
                    } else {
			Temp3 = 'Time is up';
                    }
		}
 
		document.getElementById('time_left').replaceChild(document.createTextNode(Temp3),
				document.getElementById('time_left').firstChild);
 
		var timerID = setTimeout("showtime('"+lang+"')",1000);
}

function openGG(source, name) {
		name = escape(name)
		a = window.open(source + name,'Confirmation','resizable=no,status=no,toolbar=no,menubar=no,location=no,width=300,height=150');
}

function CheckPass() {
	if (document.getElementById('pass').value != document.getElementById('a_pass').value) {
		alert('All Password must be Equal !')
		return false;
	}
	return true;
}

function hide_div(l_type) {
		 if (l_type == 2) {
			mode = 'visible';
		 } else {
			mode = 'hidden';
		 }
		 document.getElementById('only_for_supreme').style.visibility = mode;
}

function hide_shown_div(div_id) {
		document.getElementById(div_id).style.visibility = 'hidden';
}

function show_hidden_div(div_id,parent_id) {
	var parent;
	var div = document.getElementById(div_id);
	if (parent_id instanceof String) {
		parent = document.getElementById(parent_id);
	} else {
		parent = parent_id;
	}
		
	var delta = parent.offsetHeight - 1;
		
	var ot = parent.offsetTop;
	var ol = parent.offsetLeft;
	while((parent = parent.offsetParent) != null) {
		ot += parent.offsetTop;
		ol += parent.offsetLeft;
	}
	div.style.left = ol + "px";
	div.style.top = ot + delta + "px";
	div.style.visibility = 'visible';
}

function open_image(name, link, width, height, wTitle) {
		newWindow = window.open('', name, 'resizable=no, width='+width+', height='+height+', scrollbars=no, toolbar=no, titlebar=no, menubar=no');
		newWindow.document.write('<HTML><HEAD><TITLE>'+wTitle+'</TITLE><STYLE>	BODY {			padding: 0px px px 0px;			margin:  0px 0px 0px 0px;	}</STYLE></HEAD><BODY ><img SRC="'+link+'" WIDTH="'+width+'" HEIGHT="'+height+'" ALT="'+wTitle+'"></BODY></HTML>');
}

function hide_title(obj) {
	var dObj = document.getElementById('whole_team_title');
	dObj.style.visibility = 'hidden';
}

function show_title(obj) {
	var dObj = document.getElementById('whole_team_title');
	var dtextObj = document.getElementById('whole_team_title_text');
	if (obj.firstChild.data == undefined) {
		dtextObj.innerHTML = obj.firstChild.firstChild.data;
	} else {
		dtextObj.innerHTML = obj.firstChild.data;
	}

	var parent = obj;
	var delta = parent.offsetHeight + 3;
	var ot = parent.offsetTop;
	var ol = parent.offsetLeft;
	while((parent = parent.offsetParent) != null) {
			ot += parent.offsetTop;
			ol += parent.offsetLeft;
	}

	dObj.style.left = ol + "px";
	dObj.style.top = ot + delta + "px";
	dObj.style.visibility = 'visible';
}
