/*通用脚本 by 深蓝心语-全部通用标准-可以压缩*/
function GetObj(objName) { if (document.getElementById) { return eval('document.getElementById("' + objName + '")'); } else if (document.layers) { return eval("document.layers['" + objName + "']"); } else { return eval('document.all.' + objName); } }
var SetTimeZone;
$(function() {
    $("a[rel=external]").live("click", function() { $(this).attr("target", "_blank") })/*外部新窗口*/
	if ($.browser.msie && $.browser.version <= 6 ){/*PNG图片在IE6下的补丁*/
		$(".pngfix").each(function(){
				var pngurl=$(this).css("background-image").substr(5).substring(0,$(this).css("background-image").substr(5).indexOf('"'))
				$(this).css({"background":"none","filter":"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, src='"+pngurl+"');"})  
		})
    }
    $(".myzone").hover(function() {clearTimeout(SetTimeZone);$(this).addClass("curr").find(".TabMyZone").slideDown("slow");}, function() {SetTimeZone = setTimeout('$(".myzone").removeClass("curr").find(".TabMyZone").slideUp("slow")',500);});		
})
//时间计算
function countDown(secs) { document.getElementById("backtime").innerHTML = secs; if (secs == "stop") { return false; } else { if (--secs > 0) { setTimeout("countDown(" + secs + ")", 1000); } else { window.location.href = Url; return false; } } }
/* 城市选择 深蓝心语 读取pic/javascropt/city.js文件*/
function getcity(city, citybox, town, townbox) { var t = document.getElementById(citybox); if (t == null) return false; t.options.length = 1; for (var i = 0; i < cityarray.length; i++) { if (cityarray[i][0] == city) cityid = i; t[i + 1] = new Option(cityarray[i][0], cityarray[i][0]); } if (cityid >= 0) { t.value = city; if (town != "") gettown(city, town, townbox); } }
function gettown(city, town, townbox) { var t = document.getElementById(townbox); if (t == null) return false; t.options.length = 1; cityid = get_cityid(city); if (cityid == -1) return false; for (var i = 1; i < cityarray[cityid].length; i++) { t[i] = new Option(cityarray[cityid][i], cityarray[cityid][i]); if (cityarray[cityid][i] == town) t.value = town; } }
function get_cityid(city) { for (var i = 0; i < cityarray.length; i++) { if (cityarray[i][0] == city) return i; } return -1; }
/* 城市选择 结束*/

//全局加载
function masterseach() {
    var a = document.getElementById("keyword").value;
    var b = document.getElementById("selectCategory").value;
    if (a == '' || a == '输入商品名') {
        alert(a);
    }
    else {

        if (b == 0) {
            window.location = "/seach.html?key=" + encodeURI(a);
        }
        else {
            window.location = "/seach.html?key=" + encodeURI(a)+"&SN="+b;
        }
    }
    return false;
}
//取小数位数
Math.hold = function(x, n) {
    var N = Math.pow(10, n);
    return Math.round(x * N) / N;
}
//取购物车内商品的总数量
function getShopcarComCount() {
    $.get("/AjaxHandler/ShopcarComCount.ashx?t=" + Math.random(), function(data) { $("#ShoppingCart").html(data); })

}
/*验证码弹出过程*/
function CreateCodeImg(QYCode){
	var bimg = ".CodeImage";
	var ishover = 0;
	$(QYCode).focus(function(){
		var offSet = $(this).offset();
		if ($(bimg).get(0)==null){
			$("body").append('<div class="CodeImage"><img src="/App_Themes/Default/images/blank.gif" alt="验证码" title="点击刷新图片"></div>');
			ReadCodeImages(bimg); 
		}
		$(bimg).css({
					position:"absolute",
					top: offSet.top + $(this).outerHeight()+(-58) + "px",
					left: offSet.left+"px"
					}).show();
		$(bimg).mousemove(function() {
				ishover=1;
		});
		$(bimg).mouseout(function() {
				ishover=0;
		});	
	})
	$(bimg).live("click",function(){
		$(QYCode).focus();ReadCodeImages(bimg); 
	})
	$(QYCode).blur(function(){
		if (ishover==0){
			$(bimg).hide();	
		}
})
	$(".ReturnCode").click(function(){ /*换图*/
		$(QYCode).focus();ReadCodeImages(bimg);
	})
}
function ReadCodeImages(bimg){
    $(bimg).find("img").attr("src", "/ajaxhandler/SafeCode.ashx?temp=" + Math.random())
}
