/**
页面常用的一些js文件
author：jingking
**/


/**
图片宽度高度缩小函数
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 = 3; //此 cookie 将被保存 30 天
    var exp  = new Date();    //new Date("December 31, 9998");
	//var domainString = ((domain=='') ? "" : (";path="+domain))
    exp.setTime(exp.getTime() + Days*24*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;

}