/*自由鸟网站系统全局函数 by fws 2011.2.27*/

/*获得参数的值*/
function getarg(name,str)
{
    var reg = new RegExp(name + '=[^&]*','gi');
    if(str == '' || str == null || str == undefined)
        str = document.location.href;
    var ret = str.match(reg);
    
    if(ret != null)
    {
        var reg1 = new RegExp(name + '=','gi');
        ret = ret[0].replace(reg1,'');
    }
    else
    {
        ret = null;
    }
    //ret = urldecode(ret);
    return ret;
}
/*修改参数*/
function modifyarg(name,value,str)
{
    var ret,tmp;
    if(str == '' || str == null || str == undefined)
        str = document.location.href;
    tmp = getarg(name,str);
    tmp = str.replace(name + '=' + tmp,name + '=' + value);
    ret = tmp.match(/\?.+/gi);
    if(ret.length>0)
        ret = ret[0];
    else
        ret = '';
    ret = ret.replace(/\?/,'&');
    return ret;
}
/*删除参数*/
function delarg(name,str)
{
    var ret,tmp;
    if(str == '' || str == null || str == undefined)
        str = document.location.href;
    tmp = getarg(name,str);
    tmp = str.replace(name + '=' + tmp,'');
    ret = tmp.match(/\?.+/gi);
    if(ret != null)
    {
        if(ret.length>0)
            ret = ret[0];
        else
            ret = '';
    }
    else
    {
        ret = '';
    }
    ret = ret.replace(/\?/gi,'&');
    ret = ret.replace(/&&/gi,'&');
    return ret;
}
/*调整图片大小*/
function imagesize(o,w,h)
{
	var w1,h1,a,b;
	//o.style.border = 'solid 1px #ccc';
	o.style.border = '0px';
	a = o.width/o.height;
	b = 0;
	w1 = o.width;
	h1 = o.height;
	//o.title = '原始大小：'+w1+'x'+h1+'\r';
	//o.title = o.title+o.src;
	if(w1>w)
	{
		w1 = w;
		h1 = w1/a;
		if(h1>h)
		{
			h1 = h;
			w1 = h1*a;
		}
		b = 1;
	}
	if(h1>h)
	{
		h1 = h;
		w1 = h1*a;
		if(w1>w)
		{
			w1 = w;
			h1 = w1/a;
		}
		b = 1;
	}
	if(b == 1)
	{
		o.style.width = w1;
		o.style.height = h1;
		a = 0;
		b = 0;
		if(w1 < w) a = (w - w1)/2;
		if(h1 < h) b = (h - h1)/2;
		o.style.padding = b + 'px ' + a + 'px'
	}
}
function setimagesize()
{
	var i,o;
	o = document.images;
	for(i=0;i<o.length;i++)
	{
		if(o[i].tag == "fixpic")
		{
			imagesize(o[i],o[i].w,o[i].h);
		}
	}
}

