// LOAD SCREEN ATTRIBUTES
var myWidth = 0, myHeight = 0, myScroll = 0; myScrollWidth = 0; myScrollHeight = 0;

function loadScreen() 
{
	if (document.all) {
		// IE
		myWidth  = (document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth;
		myHeight = (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		myScroll = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
	} else {
		// NON-IE
		
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	}

	if (window.innerHeight && window.scrollMaxY) { 
		// NON-IE
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		// IE
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	 } else {
		// IE MAC
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}

function getNextHighestZindex()
{
	var highestIndex = 0;
	var currentIndex = 0;
	var elArray = Array();
	elArray = document.getElementsByTagName('*');
	for(var i=0; i < elArray.length; i++){
	if (elArray[i].style){
	currentIndex = parseInt(elArray[i].style['zIndex']);
	}else if(window.getComputedStyle){
	currentIndex = parseInt(document.defaultView.getComputedStyle(elArray[i],null).getPropertyValue('z-index'));
	}
	if(!isNaN(currentIndex) && currentIndex > highestIndex){ highestIndex = currentIndex; }
	}
	return(highestIndex+1);
}

function showMembership () 
{ 
	loadScreen();
	
	var bg = document.getElementById('membership_bg');
	bg.style.left = "0px";
	bg.style.top = "0px";
	bg.style.width =  myScrollWidth+"px";
	bg.style.height = myScrollHeight+"px";
	bg.style.display = "block";	
	//bg.style.zIndex = 1001;		
	
	//document.getElementById('flash').zIndex = 0;
	
	var content = document.getElementById('membership_content');
	content.style.display = "block";

	document.getElementById('membership_iframe').style.width = 502 + "px";
	document.getElementById('membership_iframe').style.height = 575 + "px";	
	document.getElementById('membership_iframe').zIndex = 1003;
	//content.style.zIndex = 1002;
	content.style.left = ((myWidth / 2)-(content.offsetWidth / 2))+"px";
	content.style.top = ((myHeight / 2)-(content.offsetHeight / 2)+myScroll)+"px";
}



function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function init()
{
	var auth_param = gup( 'auth' );
	if(auth_param != '')
	{
		membership_iframe.location.href = 'membership_thankyou.php?auth=' + auth_param; 
		showMembership();
	}
	
	var if_param = gup( 'if' );
	if(if_param != '')
	{
		membership_iframe.location.href = if_param; 
		showMembership();
	}
}

window.onload = init; 

function showFacebook (div_id) 
{ 
	var o = document.getElementById(div_id);
	o.style.display = "block";
}

function hideFacebook (div_id) 
{ 
	var o = document.getElementById(div_id);
	o.style.display = "none";
}

function hideOverlay() 
{	
	var bg = document.getElementById('membership_bg');
	bg.style.display = "none";
	
	var content = document.getElementById('membership_content');
	content.style.display = "none";	
	
	focus();
}
