var w = 0;
var h = 0;
function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  w = myWidth;
  h = myHeight;
}

var cur_obj_to_update;

function overlay(status, onClickFunction){
	var overlay = document.getElementById('overlay');
	if(status == 1 || status == true){
		overlay.style.display = 'block';
	}else{
		overlay.style.display = 'none';
	}
		
	//if (BrowserDetect.browser == 'Firefox' || BrowserDetect.browser == 'Safari') {
		if (onClickFunction)
			overlay.setAttribute("onClick", onClickFunction);
		else
			overlay.setAttribute("onClick", "return false;");
	/*} else {
		if (onClickFunction) {
			overlay.onlick = "function (){" + onClickFunction + "}";
		}
		else {
			overlay.onclick = "function (){return false;}";
		}
	}*/
}

function openWheel(obj,color){
	cur_obj_to_update = obj;
	var wheel = document.getElementById('wheel');
	overlay(true);
	getWindowSize();
	
	// Image is 257 pixles wide.  Divided by two that's : 128.
	// So from midpoint of page make the y value 276 less than midpoint.
	wheel.style.left = ((w/2) - 128) + "px";
	
	// Height is 257, divided by 2 that's 128.
	wheel.style.top = ((h/2) - 128) + "px";
	
	wheel.style.visibility = 'visible';
	
	if(!color){
		color = "#FFFFFF";
	}
	loadSV();

	$S('plugin').display='block';
	$S('SVslide').top=(80/100*170-7)+'px';
	$S('plugOLD').backgroundColor = color;
	HexUpdate(color);
}

function closeWheel(closeOverlay){
	var wheel = document.getElementById('wheel');
	wheel.style.visibility = 'hidden';
	overlay(closeOverlay);
}
