// JavaScript Document
var loadimg = new Image;
loadimg.src = "./images/BSEWait.gif";
var language = 2;

var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject() {
	var xmlHttp;
	if(window.ActiveXObject) {
		try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {
			xmlHttp = false;
		}
	} else {
		try {
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlHttp = false;
		}
	}
	if (!xmlHttp)
		alert("Error creating the XMLHttpRequest object.");
	else
		return xmlHttp;
}

function getWHeight(){
  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;
  }
  return myHeight;
}

function getWWidth(){
  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;
  }
  return myWidth;
}

function SetWaitState() {
	if(!document.getElementById("poza_wait") && loadimg != null){
		var divul = document.getElementById("poznaload");
		//200 x 30
		divul.innerHTML = "";
		divul.style.left = Math.ceil(getWWidth()/2 - 61) + "px";
		divul.style.top = Math.ceil(getWHeight()/2 - 6) +"px";
		divul.style.background = "#003366";
		divul.style.position = "absolute";
		divul.style.visibility = "visible";
		divul.style.width = "122px";
		divul.style.height = "12px";
		divul.align = "center";
		divul.style.paddingTop = "1px";
		//120 x 10
		//filter: alpha(opacity=72); -moz-opacity:0.72;
		var poza = document.createElement("img");
		poza.name = "poza_wait";
		poza.id = "poza_wait";
		poza.src = loadimg.src;
		poza.align = "absmiddle";
		divul.appendChild(poza);
	}
}

function SetIdleState() {
	if(document.getElementById("poza_wait")){
		var divul = document.getElementById("poznaload");
		divul.style.visibility = "hidden";
		var oneChild = null;
		for(var i = 0; i < divul.childNodes.length; i++) {
			oneChild = divul.childNodes[i];
			if(oneChild.name == "poza_wait") {
				divul.removeChild(oneChild);
				break;
			}
		}	
	}
}
