/*************************** show loading ********************/
/*
* Function when called displays a dynamically created div with loading message.
*/
var image = new Image();
image.src = '/images/loading.gif';
image.align = 'absmiddle';
image.width =  16;
image.height = 16;
var _loading = false;
var mytimeout = null;

var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempY = e.pageY
  }  
  return true
}


function getWindowWidth() {
	var winW = 1024; 
 if (IE) {
  winW = document.documentElement.clientWidth;  
 }  else {
  winW = window.innerWidth;
 }
 return winW;
}

function getBetSlipOffSet() {
	var offSet = 0;
	var winW = getWindowWidth();
  	if (winW >= 1024){
  		offSet = winW - 980 ;
  		offSet = offSet / 2 - 22;
  	}
  return offSet
}



function show_loading(offsetid){	
	//show loading message text
	if (!_loading) {
		var oDiv = document.createElement('div');
		oDiv.setAttribute('id','loading');
		oDiv.id = 'loading';
		oDiv.style.position = 'absolute';
		oDiv.style.zIndex = 50;
		//oDiv.style.top = findPosY(document.getElementById(offsetid)) - 10; // add top scroll amount	
		if (!IE) {
		oDiv.style.top = (parseInt(tempY)- parseInt(100/2))+'px';		
		oDiv.style.left = (parseInt(getWinSize() / 2)- parseInt(200/2))+'px';	
		oDiv.style.height = '50px';
		oDiv.style.width = '200px';
		oDiv.style.paddingTop = '15px';		
		oDiv.style.fontSize = '10px';		
		oDiv.style.borderWidth = '1px';			
		}else{
		oDiv.style.top = (parseInt(tempY)- parseInt(100/2));		
		oDiv.style.left = (parseInt(getWinSize() / 2)- parseInt(200/2));
		oDiv.style.height = 50;
		oDiv.style.width = 200;
		oDiv.style.paddingTop = 15;		
		oDiv.style.fontSize = 10;		
		oDiv.style.borderWidth = 1;		
		}

		oDiv.style.backgroundColor = '#FFFFFF';//'#00A8F9';
		oDiv.style.opacity = .95;
		oDiv.style.filter = 'alpha(opacity=' + 95 + ')';
		oDiv.style.textAlign = 'center';
		oDiv.style.fontFamily = 'verdana, Geneva, Helvetica';
		oDiv.style.fontWeight = 'bold';
		oDiv.style.color = '#000000';
		oDiv.style.borderStyle = 'ridge';		
		oDiv.style.borderColor = '#808080';
		oDiv.style.visibility = 'visible';
		//create image
		oDiv.appendChild(image);
		oDiv.appendChild(document.createTextNode("   正在下载...."));	
		_loading = true;
		document.body.insertBefore(oDiv, document.body.childNodes[0]);
		if (mytimeout != null)
		clearTimeout(mytimeout);
		mytimeout = setTimeout( "error_loading()", 15000 );
	}
}
	
function error_loading(){	
	var odiv = document.getElementById('loading');
	if (_loading && odiv != null ) {		
	odiv.innerHTML = "<font color='#FF0000'><b>系统繁忙!</b></font>  请重试.<br><br><a href='javascript: hide_loading();'><b><u>关闭</u></b></a>";
	}	
}
/*
*
* Function used to hide the loading message
*
*/
function hide_loading() {		
	// code to hide loading message	
	if (_loading) {	
		document.body.removeChild(document.getElementById('loading'));
		_loading = false;
	}	
}

function getWinSize() {
	var winW;
	// get window size adjusted for scrollbars
	if (window.innerWidth) {
		winW = window.innerWidth-16;
	}
	if (document.body.offsetWidth) {
		winW = document.body.offsetWidth-20;
	}
	return winW;
}

function getWinHeight() {
	var winW;
	// get window size adjusted for scrollbars
	if (window.innerHeight) {
		winW = window.innerHeight;
	}
	if (document.body.offsetHeight) {
		winW = document.body.offsetHeight;
	}
	return winW;
}

/* Find a Top position of an element in the page */
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}// JavaScript Document

/* Find a Top position of an element in the page */
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}// JavaScript Document
