//param setup
var mouX = 0;//client x
var mouY = 0;//client y
//explorer type
var explorer;
if((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){
	explorer = "ie";
}else if(navigator.userAgent.indexOf('Firefox') >= 0){
	explorer = "ff";
}else if(navigator.userAgent.indexOf('Opera') >= 0){
	explorer = "opera";
}//alert(explorer);

function getById(id){
    return document.getElementById(id);
}
//init ajax loading
function loading_init(){
	var ajax_load=document.createElement('DIV');
	ajax_load.style.cssText="position:absolute; z-index:1000; display:none; text-align:center; padding-top:25px; color:#000; font-size:9px; width:55px; height:55px; background:url(http://192.168.1.18/smg/ajax/ajax_gif_1.gif);background-repeat: no-repeat;";
	ajax_load.id = "ajax_gif";
	ajax_load.innerHTML="Loading";
	document.body.appendChild(ajax_load);
}

document.onmouseup = function(e){
	if(explorer == "ie"){
	    mouX = event.clientX + document.documentElement.scrollLeft;
        mouY = event.clientY + document.documentElement.scrollTop;
	}else{
		mouX = e.pageX;
        mouY = e.pageY;
	}
}

function ajax_loading_div(){
	if(!getById('ajax_gif')){
		loading_init();
		getById('ajax_gif').style.display = "block";
		getById('ajax_gif').style.top = parseInt(mouY-20)+"px";
		getById('ajax_gif').style.left = parseInt(mouX+20)+"px";
	}else{
		getById('ajax_gif').style.display = "block";
		getById('ajax_gif').style.top = parseInt(mouY-20)+"px";
		getById('ajax_gif').style.left = parseInt(mouX+20)+"px";
	}
}

function ajax_unloading_div(){
	if(getById('ajax_gif')){
	getById('ajax_gif').style.display = "none";
	}
}

function ajax_loading_cursor(){
    document.body.style.cursor = "url('http://192.168.1.18/smg/ajax/ajax_gif_1.ani')";
}

function ajax_unloading_cursor(){
	document.body.style.cursor = "auto";
}

function loading(){
    ajax_loading_cursor();
}

function unloading(){
   	ajax_unloading_cursor();
}

function ajax_debug(){
	var ajax_debug=document.createElement('DIV');   
	ajax_debug.style.cssText="text-align:center";
	ajax_debug.id = "ajax_debug";
	document.body.appendChild(ajax_debug);
}

function xmlhttpRequest(){
    var a=null;
	try
	{
	a=new ActiveXObjext("MSXML2.XmlHttp");
	}
	catch(e)
	{
	  try
	  {
	      a=new ActiveXObject("Microsoft.XmlHttp");
	  }
	  catch(oc)
	  {
	      if(XMLHttpRequest!="undefined")
		  {
		      a=new XMLHttpRequest();
		  }
	  }
	}
	return a;
}

function getLeft(obj){
    var left;
	left = obj.offsetLeft;
	while(obj != null && obj.offsetParent != null && obj.offsetParent.tagName != "BODY" ){
      left += obj.offsetParent.offsetLeft;
      obj = obj.offsetParent;
   }
   return left;
}

function getTop(obj){
	var top;
	top = obj.offsetTop;
	while(obj != null && obj.offsetParent != null && obj.offsetParent.tagName != "BODY" ){
	  top += obj.offsetParent.offsetTop;
	  obj = obj.offsetParent;
	}
	return top;
}

function window_info(){


	  //滚动高度

	  if (self.pageYOffset) {

			  this.yScroll = self.pageYOffset;

	  } else if (document.documentElement && document.documentElement.scrollTop){   // Explorer 6 Strict

			  this.yScroll = document.documentElement.scrollTop;

	  } else if (document.body) {// all other Explorers

			  this.yScroll = document.body.scrollTop;

	  };
	  
	  //滚动宽度

	  if (self.pageXOffset) {

			  this.xScroll = self.pageXOffset;

	  } else if (document.documentElement && document.documentElement.scrollLeft){   // Explorer 6 Strict

			  this.xScroll = document.documentElement.scrollLeft;

	  } else if (document.body) {// all other Explorers

			  this.xScroll = document.body.scrollLeft;

	  };

	  //视窗尺寸

	  if (self.innerHeight) {  // all except Explorer

			  this.winWidth = self.innerWidth;

			  this.winHeight = self.innerHeight;

	  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode

			  this.winWidth = document.documentElement.clientWidth;

			  this.winHeight = document.documentElement.clientHeight;

	  } else if (document.body) { // other Explorers

			  this.winWidth = document.body.clientWidth;

			  this.winHeight = document.body.clientHeight;

	  };
	  

};

