//通用
function IsIE()
{
	return document.all ? true : false;
}

function byId(id){
    return document.getElementById(id);
}

function s(s){if (!byId(s)) return; byId(s).style.display = "block";}
function h(s){if (!byId(s)) return; byId(s).style.display = "none";}
function sh(s){if (!byId(s)) return; byId(s).style.display = byId(s).style.display == "none"?"block":"none";}
function hs(s){if (!byId(s)) return; byId(s).style.display = byId(s).style.display == "block"?"none":"block";}
function vv(s){if (!byId(s)) return; byId(s).style.visibility = "visible";}
function vh(s){if (!byId(s)) return; byId(s).style.visibility = "hidden";}

//导航
var flag = 0;
function hy(){
	for(var i=1;i<=4;i++){
        byId("hn"+i).className = "hn_of";
		s("hn_xx"+i);
		h("hn"+i+"_l");
		setflag("hn"+i+"_l");
	}
}
function xs(n){
	hy();
	s("hn"+n+"_l");
	byId("hn"+n+"_l").focus();
	h("hn_xx"+n);
	byId("hn"+n).className = "hn_on";
	void(0);
}
function setflag(s){
	if (!byId(s)) return;
	if (document.all ? true : false){
		byId(s).onmouseover = function () { hnmouseover(event); };
		byId(s).onmouseout = function () { hnmouseout(event); };
	}
	else{
		byId(s).addEventListener("mouseover", function (evnt) { hnmouseover(evnt); }, false);
		byId(s).addEventListener("mouseout", function (evnt) { hnmouseout(evnt); }, false);
	}
}
function hnmouseover(event){ flag = 1; }
function hnmouseout(event){ flag = 0; }
function init(){
	if (document.all ? true : false){
		document.onmousedown = function () { mousedown(event); };
	}
	else{
		document.addEventListener("mousedown", function (evnt) { mousedown(evnt); }, false);
	}
}
function mousedown(evnt){
	if(flag == 0){ hy(); }
}



function copyToClipboard(txt)
{
	if (window.clipboardData)
	{
		window.clipboardData.clearData();
		window.clipboardData.setData("Text", txt);
	}
	else if (navigator.userAgent.indexOf("Opera") != -1)
	{
		window.location = txt;
	}
	else if (window.netscape)
	{
		try
		{
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch (e)
		{
			alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试");
			return false;
		}
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip)
			return false;
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans)
			return false;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString);
		var copytext = txt;
		str.data = copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid = Components.interfaces.nsIClipboard;
		if (!clip)
			return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
	return true;
}
function checkmood_length(which) {  
   var maxChars = 80;  
   if (which.value.length > maxChars)  
    which.value = which.value.substring(0,maxChars);  
   var curr = maxChars - which.value.length;  
   document.getElementById("ch_leave").innerHTML = curr.toString();  
}

moveElement = function(elementID, final_x, final_y, interval)
{
    if (!document.getElementById) return false;
    if (!document.getElementById(elementID)) return false;
    var elem = document.getElementById(elementID);
    if (elem.movement) {
        clearTimeout(elem.movement);
    }
    if (!elem.style.left) {
        elem.style.left = "0px";
    }
    if (!elem.style.top) {
        elem.style.top = "0px";
    }
    var xpos = parseInt(elem.style.left);
    var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {
        return true;
    }
    if (xpos < final_x) {
        var dist = Math.ceil((final_x - xpos) / 5);
        xpos = xpos + dist;
    }
    if (xpos > final_x) {
        var dist = Math.ceil((xpos - final_x) / 5);
        xpos = xpos - dist;
    }
    if (ypos < final_y) {
        var dist = Math.ceil((final_y - ypos) / 5);
        ypos = ypos + dist;
    }
    if (ypos > final_y) {
        var dist = Math.ceil((ypos - final_y) / 5);
        ypos = ypos - dist;
    }
    elem.style.left = xpos + "px";
    elem.style.top = ypos + "px";
    var repeat = "moveElement('" + elementID + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
}
