function openPopup(url, name, args) {
	if (typeof(popupWin) != "object"){
		popupWin = window.open(url,name,args);
	} else {
		if (!popupWin.closed){
			popupWin.location.href = url;
		} else {
			popupWin = window.open(url, name,args);
		}
	}
	popupWin.focus();
}

function drawCount() {
	today = new Date();
	
	BigDay = new Date("March 10, 2006")
	msPerDay = 24 * 60 * 60 * 1000 ;
	timeLeft = (BigDay.getTime() - today.getTime());
	e_daysLeft = timeLeft / msPerDay;
	daysLeft = Math.floor(e_daysLeft)+1;
	
	if(daysLeft <= 0 && daysLeft > -10){
		daysLeft *=-1;
		//daysLeft +=1;
		return document.write( "<img src='/paralympics/materials/images/layout/header/during/"+daysLeft+".gif' width=\"94\">");		
	}else{
		return false;	
	}			
}




function toggle(arg){	
	if(document.getElementById("toggle_"+arg).style.display =='block') {
		document.getElementById("toggle_"+arg).style.display='none';
		document.getElementById("bar_hide_"+arg).style.display='none';
		document.getElementById("bar_show_"+arg).style.display='block';
	}else{
		document.getElementById("toggle_"+arg).style.display='block';
		document.getElementById("bar_hide_"+arg).style.display='block';
		document.getElementById("bar_show_"+arg).style.display='none';
	}
	return false;	
}

/*nav*/
function nav(arg) {
	if (arg){		
		var item = document.getElementById(arg.split("-")[0]);		
		/*
		if(arg.split("-")[0] == "Results" || arg.split("-")[0] == "Athletes"){
			document.getElementById("Sports").className="";
		}
		*/
		
		if (item){
			item.className+=" active";
		}		
		if(arg.split("-").length > 1){	
			var item = document.getElementById(arg);			
			if (item){
				item.className+=" active";
			}			
		}		
	}
	
}


/*set Title */
function title(arg){
	document.title += " - " + arg;	
}

/*bookMark*/
function bookmarksite(title, url){
	
	if(url=="" || url=="undefinded"){
		url = document.URL;
	}
	
	if(title == "" || title=="undefinded"){
		title = document.title;
	}
	
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}


/* DropDown */	

function loadDrop(){
	if (document.all&&document.getElementById) {
		addDrop(document.getElementById("dropDown1"));
		addDrop(document.getElementById("dropDown2"));		
	}	
}
function addDrop(navRoot){

	if(navRoot != null){
		for (i=0; i<navRoot.childNodes.length; i++) {
			
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
			
		}
	}
}


/* archives */
function showDiv(id){
	navRoot = document.getElementById('archives');	
	if(navRoot != null){
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];			
			if (node.nodeName=="DIV") {
				node.style.display = "none";				
			}
		}
	}
	document.getElementById(id).style.display = "block";	
}





function myWidth() {
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth; 
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	return myWidth;
}
function checkAd() {
	loadDrop();
	if(myWidth()<955){
		document.getElementById("skyscraper").style.display = "none";

	}else{
		document.getElementById("skyscraper").style.display = "block";
	}
}



/*http://www.howtocreate.co.uk/jslibs/htmlhigh/swapstyle.html
onload="useStyleAgain('styleTestStore');" onunload="rememberStyle('styleTestStore',100);"

*/
changeStyle('small');
function getAllSheets() {
	if( !window.ScriptEngine && navigator.__ice_version ) { return document.styleSheets; }
	if( document.getElementsByTagName ) { var Lt = document.getElementsByTagName('link'), St = document.getElementsByTagName('style');
	} else if( document.styleSheets && document.all ) { var Lt = document.all.tags('LINK'), St = document.all.tags('STYLE');
	} else { return []; } for( var x = 0, os = []; Lt[x]; x++ ) {
		var rel = Lt[x].rel ? Lt[x].rel : Lt[x].getAttribute ? Lt[x].getAttribute('rel') : '';
		if( typeof( rel ) == 'string' && rel.toLowerCase().indexOf('style') + 1 ) { os[os.length] = Lt[x]; }
	} for( var x = 0; St[x]; x++ ) { os[os.length] = St[x]; } return os;
}
function changeStyle() {	
	window.userHasChosen = window.MWJss;
	for( var x = 0, ss = getAllSheets(); ss[x]; x++ ) {
		if( ss[x].title ) { 
			ss[x].disabled = true; 
		}
		for( var y = 0; y < arguments.length; y++ ) {
			if( ss[x].title == arguments[y] ) { ss[x].disabled = false; }
		}
	} 
}
