js函数

//读取cookies
function getcookies(name){
var arr,reg=new RegExp(“(^| )”+name+”=([^;]*)(;|$)”);
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}
//产生随机数
function GetNum(){
var number = Math.random();
number = number * 1000000000;
number = Math.ceil(number);
return number
}
//获得option的值
function GetOption(ID){
var _select = $(ID);
var Num = _select.options[_select.selectedIndex].value;
return Num;
}
//经常要用到的函数精简版
function $(id){
return document.getElementById(id);
}
function v$(id){
return document.getElementById(id).value;
}
function e$(id){
return encodeURIComponent(document.getElementById(id).value);
}
function i$(id,str){
document.getElementById(id).innerHTML=str;
}

//大图片自动按比例缩小函数
function ResetImgaeHeight(img,width,height){
var getruleratio=eval(width/height);
var getphotoratio=eval(img.width/img.height);
if (getphotoratio>=getruleratio && img.width>width) {
img.width=width;
}
if (getphotoratio<getruleratio && img.height>height){
img.height=height;
}
}