var timePopup=5;
var adDiv;
var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
adCount=0;
function initPopup(){
	if(!ns && !ie && !w3){
		return;
	}
	if(ie){
		adDiv=eval('document.getElementById("BuycurrencyWin").style');
	}else if(ns){
		adDiv=eval('document.layers["BuycurrencyWin"]');
	}else if(w3){
		adDiv=eval('document.getElementById("BuycurrencyWin").style');
	}
	if (ie||w3){
		adDiv.visibility="visible";
	}else{
		adDiv.visibility ="show";
	}
	showPopup();
}
function showPopup(){
		if (ie){
			documentWidth  =ietruebody().offsetWidth/2+ietruebody().scrollLeft-20;
			documentHeight =ietruebody().offsetHeight/2+ietruebody().scrollTop-20;
		} else if (ns){
			documentWidth=window.innerWidth/2+window.pageXOffset-20;
			documentHeight=window.innerHeight/2+window.pageYOffset-20;
		} else if (w3){
			documentWidth=self.innerWidth/2+window.pageXOffset-20;
			documentHeight=self.innerHeight/2+window.pageYOffset-20;
		}
		adDiv.left=documentWidth-300 + 'px';
		adDiv.top =documentHeight-300 + 'px';
		//document.getElementById("showresults").innerHTML= documentHeight-250 + 'px';
		setTimeout("showPopup()",100);
}
function closePopup(){
	if (ie||w3){
		adDiv.display="none";
	}else{
		adDiv.visibility ="hide";
	}
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
} 
//onload=initPopup;

function hideSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function showSelectBoxes(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
    screenwidth=window.screen.width-20;
    screenheight=window.screen.height;
    if(pageWidth>screenwidth){screenwidth=pageWidth;}
    if(pageHeight>screenwidth){screenheight=pageHeight;}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,screenwidth,screenheight) 
	return arrayPageSize;
}

function BuycurrencyWin(){
   hideSelectBoxes();
   var arrayPageSize = getPageSize();
   document.getElementById("overplay").style.display="block";
   document.getElementById("overplay").style.height=arrayPageSize[5]+"px";
   document.getElementById("overplay").style.width=arrayPageSize[4]+"px";
   document.getElementById("BuycurrencyWin").style.display="block";
   initPopup();
} 

function CloseBuycurrencyWin(){
   showSelectBoxes();
   document.getElementById("overplay").style.display="none";
} 