var IS_LOGIN = "您还未登录，现在登陆吗？";
var IS_DEL = "是否删除？";
var IS_DEBUG = true;
var HIDDEN_ERROR = false;
IE4 = (document.all) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
ver4 = (IE4 || NS4) ? 1 : 0;
var IE = (navigator.userAgent.indexOf('MSIE ') != -1);
var IE6 = (navigator.userAgent.indexOf('MSIE 6.0') != -1);
var IE7 = (navigator.userAgent.indexOf('MSIE 7.0') != -1);
var FF = (navigator.userAgent.indexOf('Firefox/') != -1);
var FF2 = (navigator.userAgent.indexOf('Firefox/2.0') != -1);
var OPERA = (navigator.userAgent.indexOf('Opera') >= 0);

function logout()
{
	xajax_logout();
}

function keyDownSubmitLogin(event)
{
    if (eventKeyCode(event) == 13)
        login();
}

function login()
{
    document.forms['loginForm'].location_url.value=document.location.href;
    document.forms['loginForm'].submit();
        //xajax_login(xajax.getFormValues("loginForm"));
}

function checkEmail()
{
        xajax_checkEmail(document.getElementById("email").value);
}

function checkPassword()
{
        xajax_checkPassword(document.getElementById("password").value);
}

function checkQEmail()
{
        xajax_checkQEmail(document.getElementById("qemail").value);
}

function checkQPassword()
{
        xajax_checkQPassword(document.getElementById("qpassword").value);
}

function quickLogin()
{
    document.forms['quickForm'].location_url.value=document.location.href;
    document.forms['quickForm'].submit();
       // xajax_quickLogin(xajax.getFormValues("quickForm"));
}

function displayElement(divId)
{//切换标签是否显示
	
    var this_div = document.getElementById(divId);
	if ("none" == this_div.style.display)
		this_div.style.display = "block";
	else
		this_div.style.display = "none";
}

function showMe(elementTag)
{//显示标签
	elementTag.style.display = "block";
}

function hiddenMe(elementTag)
{//隐藏标签
	elementTag.style.display = "none";
}

function trimPx(px_value)
{//去掉宽和高的PX
    if (px_value == "") 
    	return 0;
    else
	    return parseFloat(px_value.substring(0, px_value.length - 2));
}

function getEventX(event)
{//当前鼠标所在位置的X值
	if (IE4)
		return window.event.clientX;
	else
		return event.clientX;
}

function getEventY(event)
{//当前鼠标所在的位置的Y值
	if (IE4)
		return window.event.clientY;
	else
		return event.clientY;
}

function getEventElementId(event)
{//当前鼠标所在的位置标签的ID
	if (IE4)
		return window.event.srcElement.id;
	else
		return event.target.id;
}
function eventKeyCode(event)
{//按键值
	return event.keyCode;
}

function closeThis(tagId)
{//不显示这个ID的东西
	var obj = document.getElementById(tagId);
	obj.style.display = "none";
}
function removeThis(tagId)
{
	var obj = document.getElementById(tagId);
	obj.parentNode.removeChild(obj);
}

function goBack()
{
	window.history.back();
}

function imgOver(tag , url)
{
	tag.src = url;
}

function changeDiv(thisButton , thisContentId)
{
    /************设置按钮***********************************/
	var brotherButton = thisButton.parentNode.getElementsByTagName("li");
	try{
		for (var i = 0; i < brotherButton.length; i++)
		{
			if (brotherButton[i].id == thisButton.id)
			{
				brotherButton[i].className = "tabtitleactive";
				brotherButton[i].onmouseover = function(){};
				brotherButton[i].onmouseout = function(){};
			}
			else
			{
				brotherButton[i].className = "tabtitlehidden";
                brotherButton[i].onmouseover = function() {this.className = 'tabtitlemover'};
                brotherButton[i].onmouseout = function() {this.className = 'tabtitlehidden'};
			}
			
		}
	}
	catch(e){}
	/***************************************内容**********************************/
	var brotherContent = document.getElementById(thisContentId).parentNode.getElementsByTagName("div");
	try{
		for(var i=0; i < brotherContent.length; i++)
		{
			if ("listactive" == brotherContent[i].className || "listhidden" == brotherContent[i].className)
			{
				if (brotherContent[i].id == thisContentId)
				{
					brotherContent[i].className = "listactive";
				}
				else
				{
					brotherContent[i].className = "listhidden";
				}
			}
		}
	}
	catch(e){}
}


function get(ID)
{
	return document.getElementById(ID);
}

//图片等比收缩
function DrawImage(ImgD,width,height)
{  
       var  image=new Image();  
       image.src=ImgD.src;  
       if(image.width>0 && image.height>0)
       {  
         if(image.width/image.height>= width/height)
         {  
           if(image.width>width)
           {      
           		ImgD.width=width;  
           		ImgD.height=(image.height*width)/image.width;  
           }
           else
           {  
           		ImgD.width=image.width;      
           		ImgD.height=image.height;  
           }  
         }  
         else
         {  
           if(image.height>height)
           {
           		ImgD.height=height;  
           		ImgD.width=(image.width*height)/image.height;            
           }
           else
           {  
           		ImgD.width=image.width;      
           		ImgD.height=image.height;  
           }  
         }  
     } 
}



/******************复制到粘贴板 start added by kevin*******************/
function copy_clip(txt)
{
    if(window.clipboardData) {
        window.clipboardData.clearData();
        window.clipboardData.setData("Text", txt);
        alert("已成功复制！您可在MSN或QQ粘贴给好友。");
    } else if(navigator.userAgent.indexOf("Opera") != -1) {
        window.location = txt;
        alert("已成功复制！您可在MSN或QQ粘贴给好友。");
    } else if (window.netscape) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
        } catch (e) {
            alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
        }
        var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
        if (!clip)
            return;
        var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);

        if (!trans)
            return;
        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);
        alert("已成功复制！您可在MSN或QQ粘贴给好友。");
    }
}
/******************复制到粘贴板 end*******************/

