// JavaScript Document
function checklogin(obj) {
	if (obj.username.value=="") {
		alert('请输入用户名！');
		obj.username.focus();
		return false;
	}
	if (obj.password.value=="") {
		alert('请输入密码！');
		obj.password.focus();
		return false;
	}
	if (obj.code.value=="") {
		alert('请输入验证码！');
		obj.code.focus();
		return false;
	}
	return true;
}

function checkbbsadd(obj) {
	if (obj.title) {
		if (obj.title.value.length<=8) {
			alert('帖子标题长度必须大于8！');
			obj.title.focus();
			return false;
		}
	}
	var WebEditor = document.getElementById("editor").contentWindow;
	var objcontent = WebEditor.document.body;
	var strcontent = objcontent.innerHTML;
	if (strcontent.length<20 && strcontent.replace(/<.*?>|&.*?;/g,"")=="") {
		alert('请输入帖子内容！');
		return false;
	}
	return true;
}
function reply(username, num) {
	var WebEditor = document.getElementById("editor").contentWindow;
	var objcontent = WebEditor.document.body;
	objcontent.innerHTML += "<b>回复 "+num+"楼 <i>"+username+"</i> </b><br />";
}

var answer = false;
function checkanswer(obj) {
	//var obj = obj.ans;
	if (!answer) {
		alert('请先点击寻找答案！');	
		return false;
	}
	var Num=0;
	var Total=obj.ans.length;
	if (Total==null) {
		if (obj.ans.checked==true) { Num=1;} else { Num=0;}
	} else {
	  	for (var i=0;i<Total;i++) {
			if (obj.ans[i].checked==true) { Num++;}
	  	}
	}
	if (Num==0) {
		alert('请输入正确的答案！');
		return false;
	}
	return true;
}

function goanswer(href) {
	window.open(href,'_blank');
	answer = true;
}

function InfoTip(u,x,y) {
	var userInfo = document.getElementById("userInfo");
	userInfo.style.display = "block";
	userInfo.style.left = (x+10)+"px";
	userInfo.style.top = (y+10)+"px";
	userInfo.innerHTML = "<img src=\"/images/loading.gif\" style=\"margin:28px 115px\" />";
	Request.sendGET("/ajax/user_info.php?uid="+u, callback);
	function callback(req,data)
	{
		userInfo.innerHTML = req.responseText;
	}
	setTimeout(function(){changeOpacity(userInfo, 100, 0, 30, 80);}, 1000);
}


function showInfo(u,ev){
	
}
function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return { x:ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft, y:ev.clientY + document.documentElement.scrollTop - document.body.clientTop };
}

function clickInfo(oEvent) {
    //取消冒泡
    oEvent = oEvent || window.event;
    if(document.all){
        oEvent.cancelBubble = true;
    }else{
        oEvent.stopPropagation();
    }
};

function showTips(str, mousePos, yn){
	if (document.getElementById("tips")!=null) { document.getElementById("tips").style.display = 'none'; }
	var tips = document.getElementById("tips");
	tips.style.left = (mousePos.x-100)+"px";
	tips.style.top = (mousePos.y+25)+"px";
	if (yn) {
		$("tips_cont").className = "tips_green";
		var tmp = "<img src=\"/images/tips_ok.gif\" />"
	} else {
		$("tips_cont").className = "tips_red";
		var tmp = "<img src=\"/images/tips_err.gif\" />"
	}
	$("tips_cont").innerHTML = tmp +str;
	tips.style.display = "block";
	step = 30;
	if (str=="您尚未登录，请先登录！") step = 100;
	setTimeout(function(){changeOpacity(tips, 100, 0, step, 80);}, 1000);
}
function closeTips(){
	if (document.getElementById("tips")!=null) { document.getElementById("tips").style.display = 'none'; }
}

function setOpacity(obj, value){
    if(document.all){
        if(value == 100){
            obj.style.filter = "";
        }else{
            obj.style.filter = "alpha(opacity=" + value + ")";    
        }
    }else{
        obj.style.opacity =value / 100 ;
       
    }
}
//用setTimeout循环减少透明度
function changeOpacity(obj, startValue, endValue, step, speed){
	if(startValue<=0)
    {
      obj.style.display = 'none';
	  obj.style.filter = "";
	  if (step>=100) location.href='/login.php?msg='+encodeURI('登录后，立即转回娱乐竞拍')+'&u='+encodeURI(document.location.href);
      return;
    }
    setOpacity(obj, startValue);
    setTimeout(function(){changeOpacity(obj, startValue-step, endValue, step, speed);}, speed);
}
//pai tips
document.writeln("<div id=\"tips\"><div id=\"tips_top\"><div id=\"tips_title\">温馨提示您<\/div><div id=\"tips_close\"><a href=\"javascript:;\" onclick=\"closeTips()\">X<\/a><\/div><\/div><div id=\"tips_main\"><div class=\"tips_red\" id=\"tips_cont\"><\/div><\/div><div id=\"tips_end\"><\/div><\/div>")

function copy(obj){ 
	obj.select(); 
	js=obj.createTextRange(); 
	js.execCommand("Copy") 
	alert("复制成功!"); 
}