var isIE = (document.all) ? true : false;
var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
/*
*div居中，有层遮盖
*/
function layinfo(layid){
	var layObj = document.getElementById(layid);
	//创建一个overlay的层
	var overlayObj =document.createElement("div");
	overlayObj.id = "goverlay";
	overlayObj.style.position = "absolute";
	overlayObj.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px";
	overlayObj.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px";
	overlayObj.style.top = "0";
	overlayObj.style.left = "0";
	overlayObj.style.zIndex = 99;
	overlayObj.style.background = "#000";
	overlayObj.style.filter = "alpha(opacity:50)";
	overlayObj.style.opacity = "0.35";
	layObj.style.zIndex = 1000;
	overlayObj.style.zIndex  = layObj.style.zIndex  - 1;
	document.body.appendChild(overlayObj);
	overlayObj.style.display = "block";
	layObj.style.display = "block";
	//绝对定位
	/*
	if(isIE6){
		layObj.style.position = "absolute";
		layObj.style.setExpression('top',"(_=(document.body.scrollTop || document.documentElement.scrollTop+ 100)) + 'px' ");
	}else{
		layObj.style.position = "fixed";
	}
	*/

	layObj.style.position = "absolute";
	//解决IE6下不能覆盖select的问题
	if(isIE6){
		overlayObj.innerHTML = '<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);"></iframe>'
	}
	layObj.style.left = (parseInt(document.documentElement.clientWidth) - parseInt(layObj.offsetWidth)) / 2 + "px";
	layObj.style.top = (parseInt(document.documentElement.clientHeight) - parseInt(layObj.offsetHeight)) / 2 + "px";

}

/*
*div居中，无层遮盖
*/
function layinfo1(layid){
	var layObj = document.getElementById(layid);
	
	layObj.style.zIndex = 1000;
	layObj.style.display = "block";
	//绝对定位
	/*
	if(isIE6){
		layObj.style.position = "absolute";
		layObj.style.setExpression('top',"(_=(document.body.scrollTop || document.documentElement.scrollTop+ 100)) + 'px' ");
	}else{
		layObj.style.position = "fixed";
	}
	*/

	layObj.style.position = "absolute";
	layObj.style.left = (parseInt(document.documentElement.clientWidth) - parseInt(layObj.offsetWidth)) / 2 + "px";
	layObj.style.top = (parseInt(document.documentElement.clientHeight) - parseInt(layObj.offsetHeight)) / 2 + "px";

}


//关闭层的方法
function layclose(layid){
	var overlay = document.getElementById("goverlay");	
	if(overlay != null) {
		overlay.outerHTML = "";
		overlay.style.display= "none";
	}
	document.getElementById(layid).style.display= "none";
}

/*让FF支持outerHTML*/
if(window.HTMLElement) {
    HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){
        var r=this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df=r.createContextualFragment(sHTML);
        this.parentNode.replaceChild(df,this);
        return sHTML;
        });

    HTMLElement.prototype.__defineGetter__("outerHTML",function(){
     var attr;
        var attrs=this.attributes;
        var str="<"+this.tagName.toLowerCase();
        for(var i=0;i<attrs.length;i++){
            attr=attrs[i];
            if(attr.specified)
                str+=" "+attr.name+'="'+attr.value+'"';
            }
        if(!this.canHaveChildren)
            return str+">";
        return str+">"+this.innerHTML+"</"+this.tagName.toLowerCase()+">";
        });
        
 HTMLElement.prototype.__defineGetter__("canHaveChildren",function(){
  switch(this.tagName.toLowerCase()){
            case "area":
            case "base":
         	case "basefont":
            case "col":
            case "frame":
            case "hr":
            case "img":
            case "br":
            case "input":
            case "isindex":
            case "link":
            case "meta":
            case "param":
            return false;
        }
        return true;
     });
}

function laylogin(returnURL){
	var logindiv =document.createElement("div");
	logindiv.id="loginwindownew";
	var content = '';
	/**   
	content += '<form action="/login.do"  method="post" name="layloginform" onsubmit="return laylogincheck();">';
	content += '<input type="hidden" name="returnurl" value="'+returnURL+'">';
    content += '<ul>';
	content += '<li>注册邮箱 <input name="email" type="text" class="loginwindow"/></li>';
    content += '<li>登录密码 <input name="passwd" type="password" class="loginwindow"/></li>';
	content += '</ul>';
	content += '<h1><input type="image" src="http://images.juedui100.com/images/dl_tc_6.gif" border="0" /></h1>';
	content += '<h2><input name="rememberme" type="checkbox" value="1" id="rememberme" onclick="layrem();"/> <label for="rememberme">记住我</label></h2>'
	content += '<h3>如果您还不会员，请<a href="/register/register1.jsp">免费注册</a></h3>';
	content += '</form>';
	*/
	/**2009-12-16 14:48:48 phz modify*/
	content += '<div id="lg1216">';
	content += '<form action="/login.do"  method="post" name="layloginform" onsubmit="return laylogincheck();">';
	content += '<input type="hidden" name="returnurl" value="'+returnURL+'">';
	content += '<div id="lg1216_t1">注册成为绝对100会员，浏览1000万会员的交友资料</div>';
	content += '<div id="lg1216_t2">请相信，我们一定会帮您找到最适合您的TA</div>';
	content += '<a href="/register/register1.jsp"><img src="http://images.juedui100.com/images/login1216_reg.gif" alt="免费注册"></a>';
	content += '<div id="lg1216_t3">已经是会员？请登陆</div>';
	content += '<div id="lg1216_form">';
	content += '邮箱 <input type="text" id="lg1216_email" name="email"/>';
	content += '密码 <input type="password" id="lg1216_pw" name="passwd"/>';
	content += '<input type="image" id="lg1216_login" src="http://images.juedui100.com/images/login1216_log.gif"/>';
	content += '<input type="checkbox" id="rememberme" class="lg1216_reme" onclick="layrem();" value="1" name="rememberme"/>';
	content += '<label for="rememberme" style="margin:0;">记住我</label>';
	content += '</div>';
	content += '</form>';
	content += '</div>';
	logindiv.innerHTML = content;
	logindiv.style.position = "absolute";
	logindiv.style.top = "0";
	document.body.appendChild(logindiv);
	layinfo("loginwindownew");
	window.location.href="#";
}

function laylogincheck(){
  var re = /^[_a-zA-Z0-9\-\.]+@([\-_a-zA-Z0-9]+\.)+[a-zA-Z0-9]{2,3}$/;
  if(document.layloginform.email.value==""){
   	alert("登录邮箱不能为空！");
   	document.layloginform.email.select();
  	return false;
  }
  if(!document.layloginform.email.value.match(re)){
	alert("请输入合法的登录邮箱");
	document.layloginform.email.select();
  	return false;
  }
  
  if(document.layloginform.passwd.value==""){
   	alert("登录密码不能为空！");
   	document.layloginform.passwd.select();
  	 return false;
  }
	return true;
}

function layrem(){
	var thisinput = document.getElementById("rememberme");
	if(thisinput == null) return;
	if(thisinput.checked == true){
		if(!confirm('浏览器将在一年内保持您的登录状态，网吧或公共机房上网者请慎用。您能确认本次操作吗？')){
			thisinput.checked = false;
		}
	}else{
	  	thisinput.checked = false;
	}
}


