// ####################################
// ###
// ### This is for the Hyves Overlay
// ###
// ####################################

//setTimeout("doSwitchSrc();",20000);
var myWidth = 0;
var myHeight = 0;

function getSize() {
	// Ondanks alles werkt dit niet in IE
  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;
  }
  //alert('width: ' + myWidth + ' height: ' + myHeight);
 // window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
}

function getFrame() {
	var iframe = document.getElementById("iframe")
  if (typeof(iframe) == "window") {
    iframe = iframe.frameElement
  }
  return iframe
}

function doSwitchSrc() {
	//alert("FIRE!")
	getSize()
	var setWidth = myWidth/2 - 275;
	var iframe = getFrame()
	//alert(iframe.frameElement.style)
	var stijl = iframe.style;
	//alert(stijl.visibility)
	stijl.visibility = "visible"
	//alert(stijl.visibility)
	stijl.height = "500px"
	stijl.width = "550px"
	stijl.top = "75px"
	stijl.left = setWidth.toString() + "px"
	iframe.src = "/fans/hyves_authorize"
}

window.onresize = function(event) {
	getSize()
	var setWidth = myWidth/2 - 275;
	stijl = getFrame().style
	if (stijl.visibility == "visible") {
		stijl.height = "500px"
		stijl.width = "550px"
		stijl.top = "75px"
		stijl.left = setWidth.toString() + "px"
	}
}

//callback
function removeFrame() {
	var iframe = getFrame()
	//alert(iframe.frameElement.style)
	var stijl = iframe.style;
	stijl.visibility = "hidden"
	stijl.height = "0px"
	stijl.width = "0px"
	//iframe.src = "/fans/hyves_authorize"
	//var flashObj = document.getElementById("nltracks")
	//flashObj.hyvesLoginSuccesfull()
}
