function GetRequest(url) 
{
	/*
	通过XMLHttp对象获取数据
	*/
	//mf
    if (window.XMLHttpRequest) {
       var xmlHttp = new XMLHttpRequest();
       xmlHttp.open("POST",url,false);
	   xmlHttp.send(url); 
    }
    //ie
    else if (window.ActiveXObject) {
       var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
       if(xmlHttp)
       {
       		xmlHttp.open("POST",url,false);
			xmlHttp.send(); 
       }
    }
	//服务器端处理返回的是经过escape编码的字符串. 
	return xmlHttp.responseText
}
function showmsg(id,msg)
{
	/*
	显示提示信息
	id:组件ID
	msg:显示内容
	*/
	document.getElementById(id).innerHTML=msg;
}
function trim(sString)
{
	/*
	去除空格
	str:字符串
	*/
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

/*
显示隐藏
*/
function SelectChange(name,id,num,nameon,classonname,classonnamess){
    for(var i=1;i<=num;i++)
	{
	  document.getElementById(name+i).style.display="none";
	  document.getElementById(nameon+i).className=classonnamess;
	}
      document.getElementById(name+id).style.display="";
	  document.getElementById(nameon+id).className=classonname;
}


//全选和取消
  function CheckAll(chkall,checkbox)
  {

     if($("#"+chkall).attr("checked") == true)
	 {    

	      $("input[@name='"+checkbox+"[]']").each(function(){
		     $(this).attr("checked","checked");
		            
		  });
	 }
	 else
	 {

	      $("input[@name='"+checkbox+"[]']").each(function(d){
		      $(this).attr("checked","");
		              
		  });
	 }

  
  }

/*
调查
name radio 的 name
id 该调查表的id
fileurl 调查文件所在的路径
*/
function diaocha(name,id,fileurl){
    var type = $('input[@name='+name+'][@checked]').val();
	//alert(wwwname);
	//return false;
	$.post(fileurl,{'action':'diaocha','type':type,'id':id},function(d){
	         if(d=="ok")
		     {
			   alert("感谢您的投票！！");
			 }
			 else
		     {
			    alert('投票失败，请查询！！');
			 }
	});


}


/*
调查
adminjob 请求的页面
action   请求的动作
id        调查ID
*/
function view_diaocha(id)
{
	window.location.href = "http://www.hzinfo.com/extensions/poll/view_poll.php?id="+id+"&action=view";
}

/**
图片宽度高度缩小函数
author：jingking
ImgD：要传送的图片参数
width：定义允许图片宽度 
height：定义允许图片高度
**/
var flag=false; 
function DrawImage(ImgD,width,height){ 
 var image=new Image(); 
 var iwidth = width; 
 var iheight = height; 
 image.src=ImgD.src; 
 if(image.width>0 && image.height>0){ 
 flag=true; 
 if(image.width/image.height>= iwidth/iheight){ 
  if(image.width>iwidth){   
  ImgD.width=iwidth; 
  ImgD.height=(image.height*iwidth)/image.width; 
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  } 
 else{ 
  if(image.height>iheight){   
  ImgD.height=iheight; 
  ImgD.width=(image.width*iheight)/image.height;   
  }else{ 
  ImgD.width=image.width;   
  ImgD.height=image.height; 
  } 
  } 
 } 
} 


/**
cookie设置，取值，删除
author：jingking
**/
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 1; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
	//var domainString = ((domain=='') ? "" : (";path="+domain))
    exp.setTime(exp.getTime() + Days*12*60*60*1000);
    value = escape(value);//加密
    //替换加密中的 + 号为%2b  方便PHP读取显示
    value = value.replace(/\+/g,"%2b");
    document.cookie = name + "="+value+ ";path=/;domain=.ejia.com ;expires=" + exp.toGMTString();
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval != null) document.cookie= name + "=null;expires="+exp.toGMTString();
}

function getCookiepc(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
     if(arr != null) return (arr[2]); return null;

}