var timer = "";
var first = 1;

function update_onuser() {
	if (timer != "") {
		clearTimeout(timer);
	}
	if (first != 1) {
		var url = "/checkuser/index/";
		new Ajax.Request(url, {
	         method:'get',
			 onSuccess : function(transport) {
				if (200 == transport.status) {
					sData = transport.responseText;
					temp = sData.split(",");
					temp[0]=parseInt(temp[0]);
					checkMultiLogin(temp[0]);
					setTime(temp[1]);
				}
			}
		});
		
	} else {
		first = 0;
	}
	timer = setTimeout("update_onuser()", 30000);
}
var timer2 = "";
function checkMultiLogin(is_multilogin) {
	if (is_multilogin == 1) {
		var str = document.getElementById("alertMsg").value.replace("{1}", "\n");
		str = str.replace("{1}", "\n");
		alert(str);
		parent.window.location.href = "/header/logout";		
	}else if(is_multilogin == 2){
      	var str = document.getElementById("alertMsgSession").value.replace("{1}", "\n");
		str = str.replace("{1}", "\n");
		alert(str);
		parent.window.location.href = "/header/logout";		
	
	}
}
function setTime(time){
	document.getElementById("time").innerHTML = time;
}
 function checkAll(checked,chkBoxName) 
{   
	var a = true;
	if(checked == 0 )
		a = false;

	var theForm = document.f;   
	for (i=0; i<theForm.elements.length; i++)
	{ 
		if (theForm.elements[i].name==chkBoxName)    
			theForm.elements[i].checked = a;    
	}
}
 function setNewCaptcha(){
		var id = Math.random();
		document.getElementById('image_code').src = "/welcome/captcha/?id="+id;
	} 
 
 function replaceT(obj){
	 var newO=document.createElement('input');
	 newO.setAttribute('type','password');
	 newO.setAttribute('name','pwd');
	 newO.setAttribute('style',"width: 70px; height: 14px; display: inline; visibility: visible;background-color: #047c61; border: 1px solid #fff;color: #fff; font-size: 11px; font-family: verdana;");
	 obj.parentNode.replaceChild(newO,obj);
	 newO.select();
	 newO.focus();
	 }

