/*
	<div id="myoverlay" onclick="hideBox()" style="display:none"></div>
	<div id="mymodal">
		<h2>Title</h2>
		asdfasdf sadfasdf sadfasdf
		<a href="javascript:history.go(-1)"><img alt="Go Back" id="mymodal_back" src="/stats/images/buttonback.png" /></a>
		<a href="/stats/upgrade"><img alt="Upgrade Account" id="mymodal_upgrade" src="/stats/images/buttonpro.png" /></a>
	</div>
	<script type="text/javascript">showmymodal(400, 170);</script>
*/

function showMyMsg(url,width,height){
	document.getElementById("flashcon").innerHTML = '<iframe id=flplayer border=0 name=flplayer src="'+url+'" frameborder="0" width="'+width+'" height="'+height+'" scrolling="no" style="overflow:hidden;"></iframe>';
	showmymodal(width,height);
}

function showmymodal(width, height){
    resizemyoverlay();
    document.getElementById('myoverlay').style.display='block';
    center('mymodal', width, height);
    return false;
}

function resizemyoverlay() {
  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;
  }
  myHeight = myHeight * 2;
  document.getElementById('myoverlay').style.width = myWidth + 'px';
  document.getElementById('myoverlay').style.height = myHeight + 'px';
}

function showCounters(){
    center('counters', 520, 300);
    return false;
}

function hidemymodal(){
	document.getElementById("flashcon").innerHTML = '';
	document.getElementById('myoverlay').style.display='none';
	document.getElementById('mymodal').style.display='none';
    return false;
}

function selectstyle(type, id, image) {
	document.getElementById('counters').style.display='none';
	document.getElementById('counterimg').src = '/stats/images/styles/' + image;
	document.forms.editwebsite.styleid.value = id;
}

function eid(ele){
	return document.getElementById(ele);
}

function findPosition( oLink ) {
	posX = oLink.offsetLeft;
	posY = oLink.offsetTop;
	return [ posX, posY ];
}
function center(element, width, height){
	var ptop = findPosition( eid("header") );
	var pbottom = findPosition( eid("footer") );
    try{
        element = eid(element);
    }catch(e){
        return;
    }
    var my_width  = 0;
    var my_height = 0;
    if ( typeof( window.innerWidth ) == 'number' ){
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    }else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    }else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ){
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }
    element.style.position = 'absolute';
    element.style.zIndex   = 999999;
    var scrollY = 0;
    if ( document.documentElement && document.documentElement.scrollTop ){
        scrollY = document.documentElement.scrollTop;
    }else if ( document.body && document.body.scrollTop ){
        scrollY = document.body.scrollTop;
    }else if ( window.pageYOffset ){
        scrollY = window.pageYOffset;
    }else if ( window.scrollY ){
        scrollY = window.scrollY;
    }    
    var setX = ( my_width  - width  ) / 2;
    var setY = ( my_height - height ) / 2 + scrollY;
    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

//	setX = "185";
//	setY = "7";
    element.style.left = setX + "px";
    element.style.top  = setY + "px";
    element.style.display  = 'block';
}