function upusername(){
	var username = $("#username").attr("value");
    if(username == ""){
	    $("#clew_user").html("<font color=#ff0000>用户名不能为空</font>");
	   return false;
	}else{
	  $("#clew_user").html("");
	}

}

function uppassword(){
	var password = $("#password").attr("value");
    if(password == ""){
		$("#clew_pw").html("<font color=#ff0000>密码不能为空</font>");
	    return false;
	}else{
	  $("#clew_pw").html("");
	}

}

function Logincheck(){
    var username = $("#username").attr("value");
    var password = $("#password").attr("value");
    if(username == ""){
	    $("#clew_user").html("<font color=#ff0000>用户名不能为空</font>");
	    return false;
	}else if(password == ""){
		$("#clew_pw").html("<font color=#ff0000>密码不能为空</font>");
	    return false;
	}else{
		$("#clew_user").html("");
		$("#clew_pw").html("");
		$.ajax({url:'intajax.php',
			   type: 'POST',
			   data:"username="+username+"&password="+password+"&t="+Math.random(),
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				   if(data == "1"){
					    $("#clew_user").html("<font color=#ff0000>通行证错误</font>");
						$("#password").attr("value","");
					    return false;
					}else if(data == "2"){
						$("#clew_pw").html("<font color=#ff0000>密码错误</font>");
						$("#password").attr("value","");
					    return false;
					}else{
					    $("#addADbox").html(data);
					    LoginUserName();
					}
			  }
		});
		return false;
	}
}

function LoginUserName(){
       $.ajax({url:'intajax.php?action=getcookie&t='+Math.random(),
			   type: 'GET',
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				   $("#orlogin").html(data);
			  }
		});
}

LoginUserName();

function islogin(status,uname){
	 $.ajax({url:'logging.php',
			 type: 'POST',
			 data:"status="+status+"&uname="+uname+"&t="+Math.random(),
			 dataType: 'html',
			 timeout: 1000,
			 success:function(data){

			     LoginUserName();
		  }
	});

}

function loginfasle(){
  $.ajax({url:'intajax.php?action=login&t='+Math.random(),
			   type: 'GET',
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				   $("#addADbox").html(data);
				   $("#orlogin").html("您还没有登录帐号！");
			  }
		});
}

function selectrole(){
    var re = {};
	if (document.documentElement && document.documentElement.clientHeight) {
	var doc = document.documentElement;
	re.width = (doc.clientWidth > doc.scrollWidth) ? doc.clientWidth - 1 : doc.scrollWidth;
	re.height = (doc.clientHeight > doc.scrollHeight) ? doc.clientHeight : doc.scrollHeight;
	}
	else {
	var doc = document.body;
	re.width = (window.innerWidth > doc.scrollWidth) ? window.innerWidth : doc.scrollWidth;
	re.height = (window.innerHeight > doc.scrollHeight) ? window.innerHeight : doc.scrollHeight;
	}
	  $.ajax({url:'intajax.php?action=getrole&t='+Math.random(),
			   type: 'GET',
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				   $("#roleshow").html(data);
				   document.getElementById("ly").style.display="block";
				   document.getElementById("ly").style.cssText = "position:absolute;left:0px;top:0px;width:"+re.width+"px;height:"+re.height+"px;filter:Alpha(Opacity=60);opacity:0.3;background-color:#000000;z-index:1;";
			  }
		});
}

function recdirt(){
     var roles = $('input[@name=roles][@checked]').val();

	 if(roles != ""){
	      $.ajax({url:'intajax.php?sid='+roles+'&t='+Math.random()+'',
			   type: 'GET',
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				    window.location.href='myfyb.php?sid='+roles+'';
		  	  }
		 });

	 }else{
	     window.location.href='http://www.uwan.com/';
	 }
}

function rolerecdirt(role){
	    $.ajax({url:'intajax.php?sid='+role+'&t='+Math.random()+'',
			   type: 'GET',
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				    window.location.href='myfyb.php?sid='+role+'';
		  	  }
		 });
}

function go(t,p){
	     window.location.href='search.php?username='+p+'&t='+t+'';
}
function goindex(t,p){
	     window.location.href='index.php?p='+p+'&t='+t+'';
}
function golast(t,p){
	     window.location.href='last.php?p='+p+'&t='+t+'';
}
function gopre(t,p){
	     window.location.href='pre.php?p='+p+'&t='+t+'';
}
function attention(userid,sid){
       $.ajax({url:'attention_ajax.php?t='+Math.random(),
			   type: 'POST',
			   data:"username="+userid+"&serverid="+sid+"&t="+Math.random(),
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				    alert(data);
		  	  }
		});
}

function delattention(id){
   if(confirm('是否删除该角色的关注？')) {
	   $.ajax({url:'attention_ajax.php?action=delete&t='+Math.random(),
			   type: 'POST',
			   data:"id="+id+"&t="+Math.random(),
			   dataType: 'html',
			   timeout: 1000,
			   success:function(data){
				   $('#myattention').html(data);
		  	  }
		});
   }
}
//count length
function countCharacters(str){
     var totalCount = 0;
     for (var i=0; i<str.length; i++) {
         var c = str.charCodeAt(i);
         if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
             totalCount++;
         }else {
            totalCount+=2;
        }
    }
    // alert(totalCount);
    return totalCount;
}

function searchcheck(){
    var str = $("#searchname").attr("value");

	if(str == ""){
	   alert("搜索关键字不能为空！");
	   return false;
	}else if(countCharacters(str) < 2){
	   alert("请至少输入2个字符！");
	   return false;
	}

}

function PageUp(){
	   if(document.getElementById("Content").scrollHeight>document.getElementById("Content").clientHeight && document.getElementById("Content").scrollTop>0){document.getElementById("Content").scrollTop=document.getElementById("Content").scrollTop-130;}

}


function PageDown(){
	   if(document.getElementById("Content").scrollHeight>document.getElementById("Content").clientHeight){document.getElementById("Content").scrollTop=document.getElementById("Content").scrollTop+130;}

}
function top(){document.getElementById("Content").scrollTop=0}
function Down(){document.getElementById("Content").scrollTop=document.getElementById("Content").scrollHeight}


function openhtml(id){

	  $("#kshow_"+id+"").show();
	  $("#zhan_"+id+"").html("<a href=\"javascript:hiden('"+id+"');\">-收回</a>");

}

function hiden(id){

      $("#kshow_"+id+"").hide();
	  $("#zhan_"+id+"").html("<a href=\"javascript:openhtml('"+id+"');\">+展开</a>");

}

function showtab(tid){

	if(document.getElementById("paimcon_"+tid).style.display == "none"){
	    $("#paimcon_"+tid+"").show();
		$("#img_"+tid+"").html("<a href=\"javascript:showtab('"+tid+"')\"><img src=\"images/default/images/-.jpg\" /></a>");
	}else{
	    $("#paimcon_"+tid+"").hide();
		$("#img_"+tid+"").html("<a href=\"javascript:showtab('"+tid+"')\"><img src=\"images/default/images/+.jpg\" /></a>");
    }

}
