function loadContent(ele, url, loading)
{  
	var xmlHttp;
  try
  {   
		xmlHttp=new XMLHttpRequest();
	}
  catch (e)
  {       
		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;        
			}      
		}    
	}

  xmlHttp.onreadystatechange=function()
  {
  	if(xmlHttp.readyState==4)
    {
		if(xmlHttp.status==200){
			document.getElementById(ele).innerHTML=xmlHttp.responseText;
		} else {
			document.getElementById(ele).innerHTML='Error'+xmlHttp.status;
		}
    } else {
		if(loading==undefined||loading==true)
			document.getElementById(ele).innerHTML='<img src="ajax-loader.gif" style="width:16px;height:16px;"/> Loading...';
	}
  }
	
	xmlHttp.open("GET",url+"&ticket="+Math.random()*10,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); 
	xmlHttp.send(null);  
}

function getRandomMag()
{  
	var xmlHttp;
  try
  {   
		xmlHttp=new XMLHttpRequest();
	}
  catch (e)
  {       
		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;        
			}      
		}    
	}

  xmlHttp.onreadystatechange=function()
  {
  	if(xmlHttp.readyState==4)
    {
		if(xmlHttp.status==200){
			getMag(xmlHttp.responseText);
		} else {
			getMag(0);
		}
    } 
  }
	
	//xmlHttp.open("GET","/life/ajax/NewestMag2.action?si=36&si=42&si=8&si=35&si=10&si=45&si=46&si=63&si=58&si=69&ticket="+Math.random()*10,true);
	xmlHttp.open("GET","/life/ajax/NewestMag2.action?si=5&si=10&si=63&si=44&si=47&si=72&ticket="+Math.random()*10,true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8'); 
	xmlHttp.send(null);  
}

function getCateList(cate,max){
	var catestr;
	if(cate=="categroup1"){
		catestr="&cate=TECHNOLOGY&cate=LIFE&cate=SOCIAL";
	} else if(cate=="categroup2"){
		catestr="&cate=SCHOOL&cate=CHILDREN";
	} else if(cate=="all"){
		catestr="&cate=TECHNOLOGY&cate=LIFE&cate=SOCIAL&cate=SCHOOL&cate=CHILDREN";
	} else {
		catestr="&cate="+cate;
	}
	if(max==undefined){
			//loadContent('magdiv','/life/ajax/MagList.action?order=2'+catestr);
			loadContent('magdiv','/life/ajax/MagList.action?order=0'+catestr);
	} else {
			//loadContent('magdiv','/life/ajax/MagList.action?order=2&max='+max+catestr);
			loadContent('magdiv','/life/ajax/MagList.action?order=0&max='+max+catestr);
	}
}

function getMag(id){
	loadContent('emag_div', '/life/ajax/GetMag.action?item_id='+id,false);
}

function get_random(max)
{
    var ranNum= Math.floor(Math.random()*max);
    return ranNum;
}

function selectedValue(selectbox){
	return selectbox.options[selectbox.selectedIndex].value;
}