//检测用户登录
function LJOALoginCheck()
{
    var uname=$('siteLoginUserName').value
    var pwd=$('siteLoginPassWord').value

   
	if (uname=='')
    {
        $('siteLoginErrMsg').innerHTML='请填写完整登录信息,用户名不能为空';
        $('siteLoginUserName').focus();
        return false;
    }
    if (pwd=='')
    {
        $('siteLoginErrMsg').innerHTML='请填写完整登录信息,密码不能为空';
        $('siteLoginPassWord').focus();
        return false;
    }

    $('siteLoginErrMsg').innerHTML='正在登录,请稍候...';
    var ajaxobj=new AJAXRequest;    // 创建AJAX对象
	ajaxobj.method='GET';   // 设置请求方式为GET
	ajaxobj.url='/Lj_Common/Ajax.asp?action=login&uhidden=0&username='+escape(uname)+'&password='+pwd+'&ran='+Math.random();
	// 设置回调函数，输出响应内容
	ajaxobj.callback=function(xmlobj) {
		var response=xmlobj.responseText
		if(response.indexOf("用户名修改友情提示")>0)
		{
			show_Dialog(response,400,210)
			return false;
		}
		else if(response=='')
		{
			location.reload();
			return false;
		}
		else
		{
			response=response.replace('@@@','');
			$('siteLoginErrMsg').innerHTML=response;
			$('siteLoginPassWord').value='';
			$('siteLoginPassWord').focus();
			return false;
		}
	}
	ajaxobj.send();    // 发送请求
	return false;
}

function getUserStats()
{
	$('Main_mainwindow_title').innerHTML='<p>'+loadimg+"&nbsp;加载用户状态...</p>";
	var url="/Lj_Common/Ajax.asp?action=getUserInfo&ran="+Math.random();
	// 设置回调函数，输出响应内容
	var ajax=new AJAX_Request();    // 创建AJAX对象
	ajax.get(
			  url,
			  function(obj)
			  {
				var response=obj.responseText;
				var outresponse=response.split(",");   
				$('Main_mainwindow_title').innerHTML=outresponse[0]
				$('Main_mainwindow_my_avatar_img').src=outresponse[1]
				if (outresponse[2]==1)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state online" onclick="Showstat()"></div>';
			   }
			   if (outresponse[2]==2)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state hidden" onclick="Showstat()"></div>';
			   }
			   if (outresponse[2]==3)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state offline" onclick="Showstat()"></div>';
			   }
			   if (outresponse[2]==0)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state away" onclick="Showstat()"></div>';
			   }
			   $('Main_mainwindow_my_level_panel').innerHTML='<img src="images/'+outresponse[3]+'.gif">'
			   $('Main_mainwindow_signature').innerHTML=outresponse[4]
			  }
		)
}

function Changstat(t_stats)
{    
     var url ="Lj_Common/Ajax.asp?action=Changeonline&state="+t_stats+"&ran="+Math.random();
	 var ajax=new AJAX_Request();
	 ajax.get(
			  url,
			  function(obj)
			  { 
			   if (t_stats==1)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state online" onclick="Showstat()"></div>';
			   }
			   if (t_stats==2)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state hidden" onclick="Showstat()"></div>';
			   }
			   if (t_stats==3)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state offline" onclick="Showstat()"></div>';
			   }
			   if (t_stats==0)
               {
			   $('Showstat').innerHTML='<div id="Main_mainwindow_status_menu_button" class="my_state away" onclick="Showstat()"></div>';
			   }
			   }
		)	 
}
function Showstat()
{  
     $("Main_mainwindow_sta_mnu").style.display = "block";
     return false;

}

function getEvent() //同时兼容ie和ff的写法
{ 
if(document.all)   return window.event;    
func=getEvent.caller;        
while(func!=null){ 
var arg0=func.arguments[0];
if(arg0)
{
 if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation))
 { 
 return arg0;
 }
}
func=func.caller;
}
return null;
}

function Browser(){var ua, s, i;this.isIE = false;this.isNS = false;this.isOP = false;this.isSF = false;ua = navigator.userAgent.toLowerCase();s = "opera";if ((i = ua.indexOf(s)) >= 0){this.isOP = true;return;}s = "msie";if ((i = ua.indexOf(s)) >= 0) {this.isIE = true;return;}s = "netscape6/";if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;return;}s = "gecko";if ((i = ua.indexOf(s)) >= 0) {this.isNS = true;return;}s = "safari";if ((i = ua.indexOf(s)) >= 0) {this.isSF = true;return;}}
//用户登录弹出窗口
//判断iE
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = (userAgent.indexOf('opera') != -1);
var is_saf = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv = (userAgent.indexOf('webtv') != -1);
var is_ie = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4 = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_ie7 = ((is_ie) && (userAgent.indexOf('msie 7.') != -1));
var is_moz = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon = (userAgent.indexOf('konqueror') != -1);
var is_ns = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4 = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac = (userAgent.indexOf('mac') != -1);

var dialog_div_tips="<div id='DialogLoading' style='background-attachment:fixed;'><p style='color:#666666;padding-top:30px;'><img src='/images/load.gif' align='absmiddle'/> 处理数据中,请稍候…<br><br><input style='width:80px;' type='button' onclick='DialogHide()' value='取消'></div>"

var x0=0,y0=0,x1=0,y1=0;
var offx=6,offy=6;
var moveable=false;
var divWidth=769 //弹出层默认宽度
var divHeight=752 //弹出层默认高度
function Get_Request(theid,theurl,divWidth,divHeight)
{
	var ajaxobj=new AJAXRequest;
	ajaxobj.method='GET'; 
	ajaxobj.url =theurl;
	ajaxobj.callback=function(xmlobj)
	{
		var response =xmlobj.responseText;
		resize_DialogShow()
		$(theid).innerHTML = response;
	}
	ajaxobj.send();    // 发送请求
	return false;
}

function resize_DialogShow()
{
	var screenWidth,screeHeight,L,T
	screenWidth=screen.availWidth; 
	screeHeight=screen.availHeight;
	L=(screenWidth-divWidth)/2;
	T=((screeHeight-divHeight)/2)-100;
	
	var objDialog = $("DialogMove");
	objDialog.id = "DialogMove";
	var oS = objDialog.style;
	oS.top = T+document.documentElement.scrollTop + "px";
	oS.left = L + "px";
	oS.width = divWidth + "px";
	oS.height = divHeight + "px";
}


function DialogShow(showdata)
{
    //定义变量
    var screenWidth,screeHeight,L,T
	var objDialog = $("DialogMove");
	
	if(showdata==dialog_div_tips) //load
	{
		divWidth=200 //弹出层默认宽度
		divHeight=150 //弹出层默认高度
	}

	if (!objDialog) objDialog = document.createElement("div");
	screenWidth=screen.availWidth; 
    screeHeight=screen.availHeight;
	L=(screenWidth-divWidth)/2;
    T=((screeHeight-divHeight)/2)-100;
	objDialog.id = "DialogMove";
	var oS = objDialog.style;
	oS.display = "block";
	oS.top = T+document.documentElement.scrollTop + "px";
	oS.left = L + "px";
	oS.margin = "0px";
	oS.padding = "0px";
	oS.width = divWidth + "px";
	oS.height = divHeight + "px";
	oS.position = "absolute";
	oS.zIndex = "999";
	oS.background = "#FFF";
	oS.border = "solid #000 3px";
	objDialog.innerHTML = showdata;
	document.body.appendChild(objDialog);
	window.onscroll=function()
	{
		if($("DialogMove"))
		oS.top=((screeHeight-divHeight)/2)-100+document.documentElement.scrollTop + "px";
	}	
	
}

function ScreenConvert()
{
	var browser = new Browser();
	var objScreen = document.getElementById("ScreenOver");
	if(!objScreen)
	var objScreen = document.createElement("div");
	var oS = objScreen.style;
	objScreen.id = "ScreenOver";
	oS.display = "block";
	oS.top = oS.left = oS.margin = oS.padding = "0px";
	if (document.body.clientHeight)
	{
		var wh = document.body.clientHeight + "px";
	}
	else if (window.innerHeight)
	{
		var wh = window.innerHeight + "px";
	}
	else
	{
		var wh = "100%";
	}
	oS.width = "100%";
	oS.height = wh;
	oS.position = "absolute";
	oS.zIndex = "3";
	if ((!browser.isSF) && (!browser.isOP))
	{
		oS.background = "#cccccc";
	}
	else
	{
		oS.background = "#cccccc";
	}
	oS.filter = "alpha(opacity=65)";
	oS.opacity = 65/100;
	oS.MozOpacity = 65/100;
	document.body.appendChild(objScreen);
	var allselect = document.getElementsByTagName("select");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "hidden";
	var allselect = document.getElementsByTagName("embed");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "hidden";
	var allselect = document.getElementsByTagName("object");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "hidden";
	}

function ScreenClean()
{
	var objScreen = $("ScreenOver");
	if (objScreen) objScreen.style.display = "none";
	var allselect = document.getElementsByTagName("select");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";
	var allselect = document.getElementsByTagName("embed");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";
	var allselect = document.getElementsByTagName("object");
	for (var i=0; i<allselect.length; i++) allselect[i].style.visibility = "visible";
}
function DialogHide()
{
	ScreenClean();
	var objDialog = $("DialogMove");
	if (objDialog) objDialog.style.display = "none";
}

//关闭弹出层
function closeOpenDiv()
{
	divWidth=200 //弹出层默认宽度
	divHeight=150 //弹出层默认高度
    ScreenClean();
	var objDialog = $("DialogMove");
	if (objDialog) objDialog.style.display = "none";
	if($('td_play_'+music_play_id)) $('td_play_'+music_play_id).innerHTML=""; //关闭铃声
	document.body.onselectstart=function(){return true} 
}


//开始移动
 function fDragging(e, limit)
 { 
        obj=document.getElementById('DialogMove');
        if(!e) e=window.event; 
        var x=parseInt(obj.style.left); 
        var y=parseInt(obj.style.top); 
       // alert(x+'dd'+y)
        var x_=e.clientX-x; 
        var y_=e.clientY-y; 
         
        if(document.addEventListener){ 
            document.addEventListener('mousemove', inFmove, true); 
            document.addEventListener('mouseup', inFup, true); 
        } else if(document.attachEvent){ 
            document.attachEvent('onmousemove', inFmove); 
            document.attachEvent('onmouseup', inFup); 
        } 
         
        inFstop(e);     
        inFabort(e) 
		
        function inFmove(e){ 
            var evt; 
            if(!e)e=window.event; 
            document.body.onselectstart=function(){return false} 
            //实现层透明
            //obj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=85,finishOpacity=100,style=0)';
            //obj.style.opacity = 0.85;
            if(is_ie && !is_mac) {
					obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=85,finishOpacity=100,style=0)";
				}
				obj.style.opacity = 0.85;
				
            if(limit){ 
                var op=obj.parentNode; 
                var opX=parseInt(op.style.left); 
                var opY=parseInt(op.style.top); 
                 
                if((e.clientX-x_)<0) return false; 
                else if((e.clientX-x_+obj.offsetWidth+opX)>(opX+op.offsetWidth)) return false; 
                 
                if(e.clientY-y_<0) return false; 
                else if((e.clientY-y_+obj.offsetHeight+opY)>(opY+op.offsetHeight)) return false; 
                //status=e.clientY-y_; 
            } 
             
            obj.style.left=e.clientX-x_+'px'; 
            obj.style.top=e.clientY-y_+'px'; 
            inFstop(e); 
        } // shawl.qiu script 
        function inFup(e){ 
            var evt; 
            if(!e)e=window.event; 
            //恢复不透明
            if(is_ie && !is_mac) {
					obj.style.filter = "";
				}
				obj.style.opacity = 100;
				
            if(document.removeEventListener){ 
                document.removeEventListener('mousemove', inFmove, true); 
                document.removeEventListener('mouseup', inFup, true); 
            } else if(document.detachEvent){ 
                document.detachEvent('onmousemove', inFmove); 
                document.detachEvent('onmouseup', inFup); 
            } 
            inFstop(e); 
			document.body.onselectstart=function(){return true} 
        } // shawl.qiu script 
  
        function inFstop(e){ 
            if(e.stopPropagation) return e.stopPropagation(); 
            else return e.cancelBubble=true;        
			
        } // shawl.qiu script 
        function inFabort(e){ 
            if(e.preventDefault) return e.preventDefault(); 
            else return e.returnValue=false; 
        } // shawl.qiu script 
    } 
//弹出窗口
function LoadDialogWindow(URL, parent, loc_x, loc_y, width, height)
{
  if(is_ie)//window.open(URL);
     window.showModalDialog(URL,parent,"edge:raised;scroll:1;status:0;help:0;resizable:1;dialogWidth:"+width+"px;dialogHeight:"+height+"px;dialogTop:"+loc_y+"px;dialogLeft:"+loc_x+"px",true);
  else
     window.open(URL,parent,"height="+height+",width="+width+",status=0,toolbar=no,menubar=no,location=no,scrollbars=yes,top="+loc_y+",left="+loc_x+",resizable=yes,modal=yes,dependent=yes,dialog=yes,minimizable=no",true);
}

//选择部门
function SelectDept(MODULE_ID,TO_ID, TO_NAME, PRIV_OP,FORM_NAME)
{
  URL="/Lj_Common/select.asp"
  loc_y=loc_x=200;
  if(is_ie)
  {
     loc_x=document.body.scrollLeft+event.clientX-100;
     loc_y=document.body.scrollTop+event.clientY+170;
  }
  LoadDialogWindow(URL,self,loc_x, loc_y, 400, 350);
}
//消息状态
function Checkstatus(username)
{    
	var url="/Lj_Common/Ajax.asp?action=jishi&ran="+Math.random();
	// 设置回调函数，输出响应内容
	var ajax=new AJAX_Request();    // 创建AJAX对象
	ajax.get(
			  url,
			  function(obj)
			  {
				var response=obj.responseText;
				var outresponse=response.split(",");   
				if (outresponse[0]==0)
               {
			   $('Showstatus').innerHTML='<span style="color:#FF6868" onclick="showCheckstatus()">你有新的短消息,来自【'+outresponse[1]+'】</span>';
			   }
			   if (outresponse[0]==1)
               {
			   $('Showstatus').innerHTML='暂无新的短消息';
			   }
			  }
		)
}

function showCheckstatus(username)
{    
	var url="/Lj_Common/Ajax.asp?action=jishi&read=1&ran="+Math.random();
	// 设置回调函数，输出响应内容
	var ajax=new AJAX_Request();    // 创建AJAX对象
	ajax.get(
			  url,
			  function(obj)
			  {
				var response=obj.responseText;
				var outresponse=response.split(",");   
				if (outresponse[0]==0)
               {
			   $('Showstatus').innerHTML=''+outresponse[2]+'';
			   }
			   if (outresponse[0]==1)
               {
			   $('Showstatus').innerHTML='暂无新的短消息';
			   }
			  }
		)
}