<!--
/***********************************************************************************
以下代码主要是处理广告代理商广告统计
***********************************************************************************/
var CookieAdKey = $.cookie('ADKEY');
var CookieErrAdKey = $.cookie('ERRORADKEY');
var urlParams = getUrlParams();
var urlAdKey = urlParams['ADKEY'];

if (!MyIsEmpty(urlAdKey) && CookieAdKey!=urlAdKey && urlAdKey!=CookieErrAdKey)
{
	$.ajax({
		type : 'get',
		url : 'cpslog.php?ADKEY='+urlAdKey,
		dataType:'text',
		data:'',
		success: function(msg){}
	});
}	

var NeedApply=$.cookie('APPLYUPDATENEED');
if (NeedApply == "1")
{
	$.ajax({
		type : 'post',
		url : 'applyupdate_memtodb.php?SOURCE=1',
		dataType:'text',
		data:'',			
		success: function(msg){}
		});
}

/***********************************************************************************
以下代码主要是处理显示登录、注册、购物车、历史记录
***********************************************************************************/
$(document).ready(function()
{
	$('a').tooltip({track: true, delay: 0, showURL: false, showBody: " - ",	fade: 250});

	//购物车下拉显示
	$("#shortCartBar").click(function()
	{
		$('#cartSoonShow').load('cart_info.php');
		$("#cartSoonShow").css("display","block");
	});

	$("#shortCartBar,#cartSoonShow").mouseout(function(){$("#cartSoonShow").css("display","none");});
	$("#cartSoonShow").mouseover(function(){$("#cartSoonShow").css("display","block");});
	
	//浏览历史下拉显示
	$("#showHistory").click(function()
	{
		$("#addHisClass").addClass('active');
		$('#history_list').load('history.php?act=getHistory');
		$("#history_list").css("display","block");
	});

	$("#showHistory,#history_list").mouseout(function(){$("#history_list").css("display","none"); $("#addHisClass").removeClass('active');});
	$("#history_list").mouseover(function(){$("#history_list").css("display","block"); $("#addHisClass").addClass('active');});

	//登陆判断
	var UserID = $.cookie('UserID');
	var RealName = $.cookie('RealName');
	if (RealName == "" || RealName == null){RealName = $.cookie('NickName');}
	if (RealName == "" || RealName == null){RealName = $.cookie('UserName');}

	if (Number(UserID) > 0)
	{
		var adList = ($.cookie('CloseLimit') == 1) ? ' | <a href="adlist.php">广告列表</a>' : '';
		var LoginInfo = '<a href="user.php"><b>' + RealName + '</b></a>　[ <a href="javascript:logedUrl(\'user.shtml\')">我的账户</a> | <a href="javascript:logedUrl(\'user.php?act=myorder\')">订单管理</a>' + adList + ' | <a href="login.php?act=logout">安全退出</a> ]';
	}
	else
	{
		var LoginInfo = '[ <a href="javascript:logedUrl()">用户登录</a> | <a href="javascript:logedUrl()">免费注册</a> ]';
		if ($.cookie('cmLogin') == 'true'){$.cookie('cmLogin', null);userOp();}
	}
	$('#logininfoGroup').html(LoginInfo);
	
	var CartTotalQty = $.cookie('CartTotalQty');
	var CartTotalPay = $.cookie('CartTotalPay');
	$('#cartGoodsNum').text(CartTotalQty);
	$('#totalMoneyOfCart').val(CartTotalPay);

	//如果存在快速订购窗口（同步载入时）
    if ($('#quickOrder_Group').length)
    {
		var qsgShow = (AllowChangeQuickShipType == true) ? '' : 'none';
		$('#quick_shiptype_group').css('display', qsgShow);
	    var OrderUniKey = $.cookie('OrderUniKey');

	    if (MyIsEmpty(OrderUniKey))
	    {
			$.ajax({
				type : 'get',
				url : 'sale.php?act=getUniOrderKey',
				success: function(msg){$('#order_UniKey').val(msg);}
				});
	    }
	    else
	    {
			$('#order_UniKey').val(OrderUniKey);
	    }
	}		

	var IfAskLoaded = $.cookie('AskLoaded');
	if (IfAskLoaded == "1")
	{
		$.ajax({
			type : 'post',
			url : 'user.php',
			data : 'act=UpdateIfLoaded',
			success: function(msg){}
		});
	};

	try
	{
		//获取并显示来源标识码
		var ADID = $.cookie('ADID');
		if (ADID != null){$('.whereFrom').html(" 来源：<span style='color:red;'>" + ADID + "</span>");}
		$('#float_ad').float({position:'right',	top:0, height:20,	width:70, allowClose:false});//漂浮显示来源
		//$('#callback').float({position:'right',	top:106, height:215,width:131, allowClose:false});
	}catch(e){}

	setPngTransparent();//设置PNG透明

	//单品页左边浮动导航链接加下划线样式补丁
	$('.ljdis_nav1 span').mouseover(function(){$(this).css('border-bottom','1px solid #333')}).mouseout(function()
	{
		$(this).css('border-bottom','1px solid #FFF');
	});
});

function userOp(){Boxy.load("login.php?show=1",{title:'一起购商城用户操作',unloadOnHide:true,modal:true});}

function logedUrl(url)
{
	if (Number($.cookie('UserID')) > 0)
	{
		self.location = url;
	}
	else
	{
		url = url || self.location.href;
		$.cookie('step', url);userOp();
	}
}

//显示Tip图片
function showGiftPic(obj)
{
	$(obj).tooltip(
		{
			delay: 0, track: true, opacity: 0, showURL: false, extraClass: 'radius',
			bodyHandler: function()
			{
				var imgsrc = $(obj).attr('imgsrc');
				return $("<img/>").attr("src", imgsrc);
			}
		}
	);
}

function newsNote(id){Boxy.load("/help_id-" + id + ".shtml?type=pop",{title:'一起购商城公告',unloadOnHide:true,modal:true});}//显示系统公告

//设置PNG透明
function setPngTransparent()
{
	if (!document.all){return;}//不为IE则无需执行PNG透明处理
	try
	{
		var arVersion = navigator.appVersion.split("MSIE");
		var version = parseFloat(arVersion[1]);
		if ((version < 7) && (document.body.filters))
		{
			for (var j = 0; j < document.images.length; ++j)
			{
				var img = document.images[j];
				var imgName = img.src.toUpperCase();
				if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
				{
					var imgID = (img.id) ? "id='" + img.id + "' " : "";
					var imgClass = (img.className) ? "class='" + img.className + "' " : "";
					var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
					var imgStyle = "display:inline-block;" + img.style.cssText;
					if (img.align == "left") imgStyle = "float:left;" + imgStyle;
					if (img.align == "right") imgStyle = "float:right;" + imgStyle;
					if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
					var strNewHTML = "<span " + imgID + imgClass + imgTitle	+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" +
					imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
					img.outerHTML = strNewHTML;
					j = j-1;
				}
			}
		}
	}catch (e){}
}
//-->