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="/games/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="/games/images/btn_make-big.gif";
  }
  sizeDiv();
}

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

  	if (browseWidth && $('#scroller').length && !$("#color-by-numbers").length){
  		$('#scroller').height(gameHeight-30);
  	}
  }
}

var scores=0;
function showScores(gameId,scoresort){
	if (scores==0){
		scores=1;
		getScores(gameId,scoresort);
		$('#scores').show('slow');
	}else{	
		$('#scores').hide('slow');
		scores=0;
	}
}

function getScores(gameId,scoresort){
	if (scores=1){
		$('#scores').load("/games/scores.php?gameId="+gameId+"&sort="+scoresort+"&format=2");
	}
}

function getFlash(url){
  extraVarName="targetCar";
  extraVarVal=url;
	drawGame();
	if (typeof pageTracker=="object"){
		pageTracker._trackPageview(url);
	}
	return false;
}




