var browseWidth;
var browseHeight;
  
function setDimensions(){  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    browseWidth = window.innerWidth;
    browseHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    browseWidth = document.documentElement.clientWidth;
    browseHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    browseWidth = document.body.clientWidth;
    browseHeight = document.body.clientHeight;
  }
}
  
function fullScreen(){
  var origWidth=680;
  var origHeight=600;
  setDimensions();
  if (browseWidth<(screen.availWidth-30)){
		window.moveTo(0,0);
  	window.resizeTo(screen.availWidth, screen.availHeight);
  	document.getElementById("fullscreen").src="images/btn_make-small.gif";
  }else{
		window.resizeTo(origWidth+20, origHeight+55);
		window.moveTo((screen.availWidth-origWidth)/2,(screen.availHeight-origHeight)/2);
		document.getElementById("fullscreen").src="images/btn_make-big.gif";
  }
  sizeDiv();
}

function sizeDiv(){
	if (proportion){
  	setDimensions();
  	if ((document.getElementById("moreLinksArea") && !document.getElementById("color-by-numbers"))){
  		browseWidth=browseWidth-($('#moreLinksArea').width())-40;
  	}
    if (browseWidth/(browseHeight-50)>proportion){
        var gameHeight=browseHeight-50;
        var gameWidth=gameHeight*proportion;
    }else{
        var gameWidth=browseWidth;
        var gameHeight=(gameWidth/proportion);
    }
  	document.getElementById(gameDivId).style.width=gameWidth+'px';
  	document.getElementById(gameDivId).style.height=gameHeight+'px';
  	if (browseWidth){
  		document.getElementById("scroller").style.height=(gameHeight-30)+'px';
  	}
  }
}

var scores=0;
function showScores(gameId,scoresort){
	if (scores==0){
		scores=1;
		getScores(gameId,scoresort);
		new Effect.BlindDown('scores');
	}else{	
		new Effect.BlindUp('scores');
		scores=0;
	}
}

function getScores(gameId,scoresort){
	if (scores=1){
		new Ajax.Updater('scores',"/games/scores.php?gameId="+gameId+"&sort="+scoresort+"&format=2",{asynchronous:true, evalScripts:true });
		setTimeout('getScores("'+gameId+'","'+scoresort+'")', 60000);
	}
}

function getFlash(url){
  extraVarName="targetCar";
  extraVarVal=url;
	drawGame();
	if (_uacct){
		urchinTracker(url);
	}
	return false;
}
