var xmlHttp;
function ajaxFunction()
{
	try{  
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}catch (e){  
		// Internet Explorer  
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
		}catch (e){    
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}catch (e){      
				alert("Your browser does not support AJAX!");      
				return false;      
			}
		}
	}
}
///////////==---------------------------------------------------------// began ajax //-----------------------------------------------==//////
//call back
function cback_puplic(text,id_div)
{
  document.getElementById(id_div).innerHTML = text;
}
// began create object
function createREQ() {
try {
     req = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(err1) {
       try {
       req = new ActiveXObject('Msxml2.XMLHTTP'); /* some versions IE */
       } catch (err2) {
         try {
         req = new ActiveXObject("Microsoft.XMLHTTP"); /* some versions IE */
         } catch (err3) {
          req = false;
         }
       }
     }
     return req;
}
// TYPE SEND GET
function requestGET(url, query, req) {
myRand=parseInt(Math.random()*99999999);
req.open("GET",url+'?'+query+'&rand='+myRand,true);
req.send(null);
}
// TYPE SEND POST
function requestPOST(url, query, req) {
req.open("POST", url,true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(query);
}
// CALL BACK FUNCTION
function doCallback(callback,item,id) {
eval(callback + '(item,id)');
}
// DO AJAX
function doAjax(url,query,callback,reqtype,getxml,id) {
// create the XMLHTTPRequest object instance
var myreq = createREQ();
myreq.onreadystatechange = function() {
var item ;
if(myreq.readyState == 4) {
   if(myreq.status == 200) {
      item = myreq.responseText;
      if(getxml==1) {
         item = myreq.responseXML;
    }
      doCallback(callback, item,id);
    }
  }
  else
    {
	  item ='<div style="margin-top:50px;"><img src="images/wait.gif" border="0" width="32" height="32">';
	  doCallback(callback, item,id);
  }/**/
}
// CHECK TYPE SEND
if(reqtype=='post') {
  requestPOST(url,query,myreq);
} else {
requestGET(url,query,myreq);
}
}
/////////////////////////////////////////// to change bgcolor /////////////////////////////
function change_bg(id,num,typ)
{
  var type_div="";
  if(typ==2) type_div="t";
  if(typ==3) type_div="th";
  if(typ==4) type_div="mb";
  for(m=1;m<=num;m++)
  {
    if(m==id){
		document.getElementById(type_div+m).style.border='#447703 1px solid';
		document.getElementById(type_div+m).style.background='#fdd807';
	}else{
		if(typ==4){
		  document.getElementById(type_div+m).style.border='#D3D3D3 1px solid';
		  document.getElementById(type_div+m).style.background='#efefef';
		}else if(typ==3){
		  document.getElementById(type_div+m).style.border='#efefef 1px solid';
		  document.getElementById(type_div+m).style.background='';
		}else{
		  document.getElementById(type_div+m).style.border='#efefef 0px solid';
		  document.getElementById(type_div+m).style.background='';
		}
	}
  }
}
//border:#FF0000 1px solid;