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()
{
    xajax_login();
}

function register()
{
	xajax_register();
}


function recommend()
{
	xajax_recommend();
}

function voteShop(id)
{
	xajax_voteShop(id);
}

//关闭临时登陆
function hiddenLoginDiv()
{
	var templogin_hidden_div = document.getElementById("templogin_hidden_div");
	var templogin_parent = document.getElementById("quick_parent");
	templogin_parent.style.display = "none";	
	templogin_hidden_div.style.display = "none";
}

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

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

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

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 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;  
           }  
         }  
     } 
}
