﻿	function chkAjaBrowser()
	{
		var a,ua = navigator.userAgent;
		this.bw= { 
		  safari    : ((a=ua.split('AppleWebKit/')[1])?a.split('(')[0]:0)>=124 ,
		  konqueror : ((a=ua.split('Konqueror/')[1])?a.split(';')[0]:0)>=3.3 ,
		  mozes     : ((a=ua.split('Gecko/')[1])?a.split(" ")[0]:0) >= 20011128 ,
		  opera     : (!!window.opera) && ((typeof XMLHttpRequest)=='function') ,
		  msie      : (!!window.ActiveXObject)?(!!createHttpRequest()):false 
		}
		return (this.bw.safari||this.bw.konqueror||this.bw.mozes||this.bw.opera||this.bw.msie)
	}
	
	function createHttpRequest()
	{
		if(window.ActiveXObject){
			try {
				return new ActiveXObject("Msxml2.XMLHTTP") ;
			} catch (e) {
				try {
					return new ActiveXObject("Microsoft.XMLHTTP") ;
				} catch (e2) {
					return null ;
	 			}
	 		}
		} else if(window.XMLHttpRequest){
			return new XMLHttpRequest() ;
		} else {
			return null ;
		}
	}
	
	function sendRequest(callback,data,method,url,async,sload,user,password)
	{

		var oj = createHttpRequest();
		if( oj == null ) return null;

		var sload = (!!sendRequest.arguments[5])?sload:false;
		if(sload || method.toUpperCase() == 'GET')url += "?";
		if(sload)url=url+"t="+(new Date()).getTime();
		
		var bwoj = new chkAjaBrowser();
		var opera	  = bwoj.bw.opera;
		var safari	  = bwoj.bw.safari;
		var konqueror = bwoj.bw.konqueror;
		var mozes	  = bwoj.bw.mozes ;

		if(opera || safari || mozes){
			oj.onload = function () { callback(oj); }
		} else {
		
			oj.onreadystatechange =function () 
			{
				if ( oj.readyState == 4 ){
					callback(oj);
				}
			}
		}

		data = uriEncode(data)
		if(method.toUpperCase() == 'GET') {
			url += data
		}

		oj.open(method,url,async,user,password);
		setEncHeader(oj)

		//alert("////jslb_ajaxxx.js//// \n data:"+data+" \n method:"+method+" \n url:"+url+" \n async:"+async);
		oj.send(data);
		function setEncHeader(oj){

			var contentTypeUrlenc = 'application/x-www-form-urlencoded; charset=UTF-8';

			
			if(!window.opera){
				oj.setRequestHeader('Content-Type',contentTypeUrlenc);
			} else {
				if((typeof oj.setRequestHeader) == 'function')
					oj.setRequestHeader('Content-Type',contentTypeUrlenc);
			}	
			return oj
		}

		function uriEncode(data){

			if(data!=""){
				var encdata = '';
				var datas = data.split('&');
				for(i=1;i<datas.length;i++)
				{
					var dataq = datas[i].split('=');
					encdata += '&'+encodeURIComponent(dataq[0])+'='+encodeURIComponent(dataq[1]);
				}
			} else {
				encdata = "";
			}
			return encdata;
		}


		return oj
	}

function fadeBgclGry(id){
  
  var div    = "document.getElementById('"+id+"')";
  var count  = 0;
  var tid    = 0;

  this.doBgFade   = function (f){
    count  = 0;
    clearInterval(tid);
    tid = setInterval( function(){fade(f)} ,30);
  }
   
  function fade(f){ 
    if(!f)var f = "3456789abcdef";
    if(count < f.length){ 
      var b = f.charAt(count);
      setBgcolor( '#'+b+b+b+b+b+b );
      count++;
    } else {
      clearInterval(tid);
    }
  } 
  
  function setBgcolor(color){
    if(document.getElementById) 
      eval(div).style.backgroundColor =color
  }
}


function fadeOpacity(layName,swt,stopOpacity){
  
  if(!window.fadeOpacity[layName])
    fadeOpacity[layName] =0 

  if(!arguments[1]) swt = -1
  
  if(swt==-1)        var f  = "9876543210"
  else if(swt==1)    var f  = "0123456789"
  else               var f  = "9876543210"
  
  if(!arguments[2] && swt==-1)   stopOpacity = 0
  else if(!arguments[2] && swt==1) stopOpacity = 10

  if( fadeOpacity[layName] < f.length-1 ){
  
    var opa = f.charAt(fadeOpacity[layName])/10

    if( opa == stopOpacity ){
      setOpacity(layName,stopOpacity) 
      fadeOpacity[layName] = 0  
      return
    }
    setOpacity(layName,opa)
    fadeOpacity[layName]++
    setTimeout('fadeOpacity("'+layName+'","'+swt+'","'+stopOpacity+'")',30)
  } else {
    setOpacity(layName,stopOpacity)
    fadeOpacity[layName] = 0

  }

}
function setOpacity(layName,arg) {
  if(window.opera)return
  var ua = navigator.userAgent
  if(ua.indexOf('Safari') !=-1 || ua.indexOf('KHTML') !=-1 ) { 
      document.getElementById(layName).style.opacity = arg
  } else if(document.all) {          //win-e4,win-e5,win-e6
      document.all(layName).style.filter="alpha(opacity=0)"
      document.all(layName).filters.alpha.Opacity  = (arg * 100)
  } else if(ua.indexOf('Gecko')!=-1) //n6,n7,m1
      document.getElementById(layName).style.MozOpacity = arg
}