var tout;
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.mousemove)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
var xxx;
var yyy;
var winW;
var winH;



function getMouseXY(e) {
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.documentElement.scrollLeft;
		tempY = event.clientY + document.documentElement.scrollTop;
		winW = document.body.offsetWidth;
  		winH = document.body.offsetHeight;
	}
	else {  // grab the x-y pos.s if browser is NS
		winW = window.innerWidth;
  		winH = window.innerHeight;
		tempX = e.pageX;
		tempY = e.pageY;
	}  
	if (tempX < 0) {
		tempX = 0;
	}
	if (tempY < 0) {
		tempY = 0;
	}
	xxx = tempX;
	yyy = tempY;
	//alert(yyy);
	
	return true;
} // getMouseXY


function alertSize() {
  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;
  }
  //window.alert( 'Width = ' + myWidth );
  winH = myHeight;
  return myHeight;
}

function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}




 
function show_div_popup(nm) {
	winH = alertSize();
	scrollXY = getScrollXY();
	heightDifference = yyy-scrollXY[1];
	
	//alert('winH'+winH+' scrollXY:'+scrollXY+' yyy:'+yyy);
	
	siteYcenter = scrollXY[1] + winH/2;
	siteXcenter = winW / 2;
	
	//alert("siteYcenter:" + siteYcenter + " siteXcenter:" +siteXcenter + "var_w:"+winW +"| var_h:"+ winH +"");
	//alert("xxx:"+xxx+"| yyy:"+yyy+"var_w:"+winW +"| var_h:"+ winH +"| offsetLeft:"+ offsetLeft + " scroll:"+scrollXY+" height-diff: "+heightDifference);
	
	
	//document.getElementById('bbtest').style.left=siteXcenter;
	//document.getElementById('bbtest').style.top=siteYcenter;
	//document.getElementById('bbtest').style.display='block';
	
	//alert(heightDifference);
	
	
	
	//var offsetLeft = (winW - 800) / 2;
	//var offsetLeftInner = xxx - offsetLeft - 20;
	//if (offsetLeftInner > 600) {
	//	offsetLeftInner = offsetLeftInner - 350;
	//}
	
	//document.getElementById(nm).style.position='absolute';
	
	sXx = siteXcenter-325;
	sYy = siteYcenter-273;
	//alert(sXx+'-'+sYy);
	document.getElementById(nm).style.left=sXx;
	document.getElementById(nm).style.top=sYy;
	
	document.getElementById(nm).style.display='block';
	document.getElementById('pop_menu').className = 'popupup';
	
}

 
/* SMS up GIRL */
function upG(userId, mny, upName, upAge, upCity, upDistrict, buyWithM, iMg, serHtml, terHtml)
{
	setTimeout("show_div_popup('pop_menu')", 50);
	document.getElementById('upNameId').innerHTML = upName + '<br /><span> ' + upCity + ' - ' + upDistrict + '</span>';
	
	document.getElementById('idTer').innerHTML = terHtml;
	document.getElementById('idSer').innerHTML = serHtml;
	
	document.getElementById('upId1').innerHTML = userId;
	document.getElementById('upId1p').innerHTML = userId;
	document.getElementById('upId2').innerHTML = userId;
	document.getElementById('upId3').innerHTML = userId;
	document.getElementById('upId4').innerHTML = userId;
	document.getElementById('buyOkId').innerHTML = '';
	document.getElementById('buyOkId').className = 'buyOkNo';
	
	document.getElementById('iMgId').src = iMg;
	
	if (buyWithM=='yes'){
		document.getElementById('buyWithMoney1').style.display = 'block';
		document.getElementById('buyWithMoney1').href = 'javascript:openUrlInIfr(\'/redirect.php?action=buywithbonus&id='+userId+'&buy=1\');';
		
		document.getElementById('buyWithMoney1p').style.display = 'block';
		document.getElementById('buyWithMoney1p').href = 'javascript:openUrlInIfr(\'/redirect.php?action=buywithbonus&id='+userId+'&buy=1p\');';
		
		document.getElementById('buyWithMoney2').style.display = 'block';
		document.getElementById('buyWithMoney2').href = 'javascript:openUrlInIfr(\'/redirect.php?action=buywithbonus&id='+userId+'&buy=2\');';
		document.getElementById('buyWithMoney3').style.display = 'block';
		document.getElementById('buyWithMoney3').href = 'javascript:openUrlInIfr(\'/redirect.php?action=buywithbonus&id='+userId+'&buy=3\');';
		document.getElementById('buyWithMoney4').style.display = 'block';
		document.getElementById('buyWithMoney4').href = 'javascript:openUrlInIfr(\'/redirect.php?action=buywithbonus&id='+userId+'&buy=4\');';
		document.getElementById('buyNeeded').style.display = 'block';
		document.getElementById('bmlid').innerHTML = 'Bonus: <b>' + mny + ' LVL</b>';
	}
	//document.getElementById('pop_menu_a_3_1').href = "javascript:usr('"+userId+"');";
} // show_menu





function show_item(nm) 
{
	element_name = ((nm == null) ? 'pop_menu' : nm);
	clearTimeout(tout);
	if (document.getElementById(element_name).style.display != 'block') {
		document.getElementById(element_name).style.display='block';
		document.getElementById(element_name).className='popupup';	
	}
} // show_item

function hide_menu(nm)
{
	element_name = ((nm == null) ? 'pop_menu' : nm);
	tout = setTimeout("document.getElementById('" + element_name + "').style.display='none'", 0);
	tout = setTimeout("document.getElementById('" + element_name + "').className='popupupClose'", 0);
} // hide_menu
