//begin
var userAgent = navigator.userAgent.toLowerCase();
var is_firefox = (userAgent.indexOf('firefox') != -1);

function $(s)
{
    return document.getElementById(s);
}

//get radio value
function $$(name)
{
	var r = "";
	
	var objs = document.getElementsByName(name);
	if(objs)
	{
		for(var i=0;i<objs.length;i++)
		{
			if(objs[i].checked)
			{
				r = objs[i].value;
				break;
			}
		}
	}
	
	return r;
}

//for firefox
if(typeof(HTMLElement)!="undefined" && !window.opera) 
{ 
    HTMLElement.prototype.__defineGetter__("outerHTML",function() 
    { 
        var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
        if(a[i].specified) 
            str+=" "+a[i].name+'="'+a[i].value+'"'; 
        if(!this.canHaveChildren) 
            return str+" />"; 
        return str+">"+this.innerHTML+"</"+this.tagName+">"; 
    }); 
    HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
    { 
        var r = this.ownerDocument.createRange(); 
        r.setStartBefore(this); 
        var df = r.createContextualFragment(s); 
        this.parentNode.replaceChild(df, this); 
        return s; 
    }); 
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
    { 
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
    }); 
}
//

function openwinp1(_url)
{
	//弹出居中窗口
	_wname = "openwin";
	window.open(_url,_wname,"scrollbars=no,width=380,height=160,left=" + ((window.screen.width - 380) / 2) + ",top=" + ((window.screen.height - 160) / 2));
}

function openwinp4(_url, _wname, _wwidth, _wheight)
{
	//弹出居中窗口
	window.open(_url,_wname,"scrollbars=no,width=" + _wwidth + ",height=" +_wheight + ",left=" + ((window.screen.width - _wwidth) / 2) + ",top=" + ((window.screen.height - _wheight) / 2));
}

function resizepic(_s,_h)
{
	var image = new Image(); 
	image.src = _s.src; 
	if(image.width>0 && image.height>0)
	{
		if(image.width>_h)
		{
			_s.width =_h;
			_s.height=(image.height*_h)/image.width; 
		}
		else
		{
			_s.width=image.width; 
			_s.height=image.height; 
		}
	}
}

function windowclose()
{
	window.openner = null;
	window.self.close();
}

function copyToClipBoard(txt)
{
	window.clipboardData.setData("Text", txt);
	alert("地址已经复制到剪贴板!\n");
}

function IsNum(str)
{
    for(i=0;i<str.length;i++)
	{
		if(str.charAt(i)>="0" && str.charAt(i)<="9")
		{
		}
		else
		{
		    return 0;
		}
	}
	return 1;
}

//执行正则表达式替换
function execRE(re, rp, content)
{
    var oReg = new RegExp(re, "ig");
	var r = content.replace(oReg, rp);
	return r;
}

function ShowChooseArea()
{
    if($("city_choose").style.display == 'none')
    {
        $("city_choose").style.display = 'block';
    }
    else
    {
        $("city_choose").style.display = 'none';
    }
}

function iClose(ctl)
{
    $(ctl).style.display = 'none';
}

function SiteTop_Login()
{
    var uv = $("top_username").value;
    var pv = $("top_password").value;
    if(uv == "")
    {
        alert('请输入用户名!');
        $("top_username").focus();
        return;
    }
    if(pv == "")
    {
        alert('请输入用户密码!');
        $("top_password").focus();
        return;
    }
        
    var uri = document.location.href;
    window.location.href = "/user/login.aspx?ref="+ escape(uri) +"&tb_LoginUser="+ escape(uv) +"&tb_LoginPass="+ escape(pv) +"&Form_Action=ifirstvisitrclove&fr=top";
}

function SelValueSet(ctl, val)
{
    if($(ctl) != null)
    {
        var obj = $(ctl);
        for(var i=0; i<obj.options.length; i++)
        {
            if(obj.options[i].value == val)
            {
                obj.options[i].selected = true;
                break;
            }
        }
    }
}

function ClearOptions(s)
{
    var _obj = $(s);
    _obj.options.length = 0;
    _obj.options[0] = new Option("-不限-","-1");
}

//auto execute
function GetPermitHref()
{
	var GBL_domain = "rclove.cn";
	var temp = document.location.href;
	var uls = temp.match(/^http:\/\/(\w+\.)?(\w+?\.\w+)/);
	if (uls && uls[2])
	{
		if(uls[2].toLowerCase() != GBL_domain)
		{
		    if(uls[2].toLowerCase() == "uy99.com")
		    {
		        temp = temp.replace("http://www.uy99.com", "http://rclove.cn");
		        top.location.href = temp;
		    }
		    else
		    {
		        top.location.href = "http://www.rclove.cn";
		    }
		}
	}
}

//GetPermitHref();
//end
