﻿var showCou;
var rolldirection;
var divSmallImgpan;
var showCoui = 0;
//小图片面板开始移动
function SmallImgRoll(direction) {
    divSmallImgpan = document.getElementById("testDiv");
    rolldirection = direction;
    if (showCou == null) {
        showCoui = 0;
        showCou = setInterval(deltamove, 1);
    }
}

//小图片面板差量移动
function deltamove() {
    showCoui++;
    if (rolldirection == "left") {
        if ((0 - divSmallImgpan.offsetLeft + 320) < divSmallImgpan.offsetWidth) {
            if (showCoui < 10 && showCoui == 1) {
                divSmallImgpan.style.left = divSmallImgpan.offsetLeft - 320;
                divSmallImgpan.style.left = divSmallImgpan.offsetLeft + (0 - divSmallImgpan.offsetLeft) % 64;
            }
            if (showCoui > 10) {

                divSmallImgpan.style.left = divSmallImgpan.offsetLeft - 8;
            }
        }
        else {
            clearInterval(showCou);
            showCou = null;
            showCoui = 0;
        }
    }
    if (rolldirection == "right") {
        if (divSmallImgpan.offsetLeft < 0) {
            if (showCoui < 10 && showCoui == 1) {
                divSmallImgpan.style.left = divSmallImgpan.offsetLeft + 320;
                divSmallImgpan.style.left = divSmallImgpan.offsetLeft + (0 - divSmallImgpan.offsetLeft) % 64;
            }
            if (showCoui > 10) {
                divSmallImgpan.style.left = divSmallImgpan.offsetLeft + 8;
            }
        }
        else {
            clearInterval(showCou);
            showCou = null;
            divSmallImgpan.style.left = 0;
            showCoui = 0;
        }
    }
}

//结束滚动
function finishedRoll() {
    clearInterval(showCou);
    showCou = null;
    showCoui = 0;
}

function Buy() {
    var strBuy;
    if (document.getElementById("ddlSize")) {
        if ($("#selectedsize").val() == "") {
            alert("请先选择尺码！");
            return;
        }
        else if ($("#txtBuyNum").val() == "" && $("#txtBuyNum").val() <= 0) {
            alert("请购买一件以上的商品!");
            return;
        }
        else
            strBuy = travelershop + "&Size=" + escape($("#selectedsize").val()) + "&Num=" + $("#txtBuyNum").val()+"&ReturnUrl="+escape(RawFullUrl);
        window.location = strBuy;
    }
    else {
        strBuy = travelershop;
        window.location = strBuy;
    }
}

function Buy2() {
    var strBuy;
    if (document.getElementById("ddlSize")) {
        if ($("#selectedsize").val() == "") {
            alert("请先选择尺码！");
            return;
        }
        else if ($("#txtBuyNum").val() == "" && $("#txtBuyNum").val() <= 0) {
            alert("请购买一件以上的商品!");
            return;
        }        
    }
    else {
        strBuy = travelershop;
        window.location = strBuy;
    }
}

function NumCheck() {
    if (Number($('#txtTotalNum').val()) < Number($('#txtBuyNum').val())) {
        alert($('#txtTotalNum').val());
        alert($('#txtBuyNum').val());
        alert("您输入的预订数量超出该商品的实际库存，请重新输入！"); return false;
    }
}
function TipsOn(id) {
    document.getElementById(id).style.display = "";
}

function TipsOut(id) {
    document.getElementById(id).style.display = "none";
}

function setSize(lid, size) {

    $('#UlSize li span').removeClass("sizenow");
	
	$('#UlSize li span').addClass("size");
	
/*	$('#'+lid+' span').addClass("sizenow");*/
/*	$('#' + lid+' span').addClass("sizenow");*/
    /*$('#' + lid.toString().replace('(', 'v1v').replace(')', 'v2v').replace('|', 'v3v').replace('.', 'v4v')+' span').toggleClass("sizenow");*/
	/*alert('lid.toString().replace('(', 'v1v').replace(')', 'v2v').replace('|', 'v3v').replace('.', 'v4v')+' span')');*/
	$('#'+lid.toString().replace('(', 'v1v').replace(')', 'v2v').replace('|', 'v3v').replace('.', 'v4v')+' span').removeClass("size");
	$('#'+lid.toString().replace('(', 'v1v').replace(')', 'v2v').replace('|', 'v3v').replace('.', 'v4v')+' span').addClass("sizenow");
	$('#'+lid.toString().replace('(', 'v1v').replace(')', 'v2v').replace('|', 'v3v').replace('.', 'v4v')+' span').blur();
    $('#selectedsize').val(lid.toString().replace('Size', ''));
    $('#txtTotalNum').text(size);
}

$(document).ready(function() {
						
<!--    $('#linkBtnBuy').attr('title', $('#linkBtnBuy').attr('title').replace('<em>', '').replace('</em>', ''));-->
			Setgotop();
			//评论开始
            $(".list_tab span:first").addClass("now"); //为第一个SPAN添加当前效果样式
         $(".tab2").hide(); 
		 $(".tab5").hide();
           /*  $(".tab3").hide(); 
	        $(".tab4").hide();
			 //隐藏其它的UL*/
			
			/*$(".msg_tab2").hide();*/
            $(".list_tab span").click(function() {
											   if($(this)[0]==$(".list_tab span:first")[0])
											   {
												  $(".list_tab span").removeClass("now"); //去掉所有SPAN的样式
														$(this).addClass("now");
														$("." + $(this).attr("id")).fadeIn('slow');
														$(".tab2").hide();
														$(".tab4").show(); 
														$(".tab6").show();
														$(".tab7").show();
														$(".display_title").show();														
												}else
												{
													    $(".list_tab span").removeClass("now"); //去掉所有SPAN的样式
														$(this).addClass("now");
														$(".tab1").hide(); 
														$(".tab2").hide(); 
														$(".tab3").hide(); 
														$(".tab4").hide(); 
														$(".tab5").hide();
														$(".tab6").hide();
														$(".tab7").hide();
														$(".display_title").hide();
														$("." + $(this).attr("id")).fadeIn('slow');
												}
               
            });//功能分类TAB
			$("#addmsg_menu span").click(function(){
				$("#addmsg_menu span").removeClass("now");
				$(this).addClass("now");
				/*$(".msg_tab1").hide(); 
				$(".msg_tab2").hide();
				$("." + $(this).attr("id")).fadeIn('slow');*/
			});//评论结束
    $('.oogoods').bind("click", function() {
        //openWindow($('.oogoods').attr('href'), "290", "200", "缺货登记！", "true");
        if (oogoods != '') {
            $('.oogoods').after(oogoods);
            oogoods = '';
        }
        $('#reg_goods :text').each(function() { this.value = ''; });
        $("#reg_page").show();
        $("#regclose").click(function() { $("#reg_page").fadeOut('fast'); });
        return false;
    }); //bind

});
function savedata() {
    if ($('#txtsize').val().length == 0
    || $('#txtname').val().length == 0
    || $('#txtphone').val().length == 0
    || $('#txtemail').val().length == 0
    ) {
        alert('请输入完整信息!');
    return false; }
    $.post($('.oogoods').attr('href'), { action: "save", size: $('#txtsize').val(), name: $('#txtname').val(), phone: $('#txtphone').val(), email: $('#txtemail').val() }, function(result) { alert(result); $("#reg_page").fadeOut('fast'); }); 
    return false; 
}

var oogoods = '<div id="reg_goods">'+
'  <div id="reg_page">'+
'    <div id="reg_top">缺货登记'+
'      <div id="regclose"></div>'+
'    </div>'+
'    <div id="reg_txt">'+
'      <div class="msg_txt">如果我们目前的库存中没有您需要的尺码,<br />'+
'      请填写以下信息,以便我们在到货后及时通知您!</div>'+
'      <table width="340" border="0" cellspacing="0" cellpadding="0">'+
'        <tr>'+
'          <td width="67" align="right">购买尺码：</td>'+
'          <td colspan="2" align="left"><input id="txtsize" type="text" class="input" />'+
'          <span class="bluel">*</span></td>'+
'        </tr>'+
'        <tr>'+
'          <td align="right">您的姓名：</td>'+
'          <td colspan="2" align="left"><input id="txtname" type="text" class="input" />'+
'          <span class="bluel">*</span></td>'+
'        </tr>'+
'        <tr>'+
'          <td align="right">联系手机：</td>'+
'          <td colspan="2" align="left"><input id="txtphone" type="text" class="input" />'+
'          <span class="bluel">*</span></td>'+
'        </tr>'+
'        <tr>'+
'          <td align="right">电子邮箱：</td>'+
'          <td colspan="2" align="left"><input id="txtemail" type="text" class="input" />'+
'            <span class="bluel">*</span></td>'+
'        </tr>'+
'        <tr>'+
'          <td height="40" align="right">&nbsp;</td>'+
'          <td width="105" align="left"><input name="imageField" type="image" src="/images/msg/reg_page_11.gif" onclick="return savedata()" /></td>'+
'          <td width="168" align="left"><a href="http://www.buy007.com/About/Help/62.html" class="bluef" target="_blank">什么是缺货登记?</a></td>' +
'        </tr>'+
'      </table>'+
'    </div>'+
'    <div id="reg_footer"><img src="/images/msg/info_msgfooter.gif" width="388" height="20" /></div>'+
'  </div>'+
'</div>'


function Setgotop() {
   $(this).scroll(function() {    // 页面发生scroll事件时触发    
            var bodyTop = 0;    
            if (typeof window.pageYOffset != 'undefined') {    
                bodyTop = window.pageYOffset;    
            } 
             else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') 
             {    
                bodyTop = document.documentElement.scrollTop;    
            }    
            else if (typeof document.body != 'undefined') {    
                bodyTop = document.body.scrollTop;    
            }    
			if(bodyTop>480){$("#qqonline").css("top", 300 + bodyTop)}   			
            });         
    }

    function AddTraveShopCar(goodsid,goodstitle) {
        try {
            var count = 0;
            var totalprice = 0;
            var selectsize = '';
            if ($("#selectedsize").val() != '')
                selectsize = '&Size=' + $("#selectedsize").val();
            jQuery.getJSON(ShopMainHostUrl+'/NewMember/ShopCarJson.aspx?action=getcar&max=40&goodsid=' + goodsid + selectsize + '&jsoncallback=?', null, function(data) {
                $(data).each(function(i) {
                    count++;
                    totalprice += (parseInt(this.Quantity) * parseFloat(this.UnitPrice));
                });
                AddShopCar(goodstitle, count, totalprice);
            });       //callback
        }
        catch (e) { }        
    }
	
	
	function CheckSelectSize(){
	
		 if (document.getElementById("ddlSize")) {
			if ($("#selectedsize").val() == "") {
				alert("请先选择尺码！");
				return false;
			}
			else if ($("#txtBuyNum").val() == "" && $("#txtBuyNum").val() <= 0) {
				alert("请购买一件以上的商品!");
				return false;
			}
			else
				strBuy = travelershop + "&Size=" + escape($("#selectedsize").val()) + "&Num=" + $("#txtBuyNum").val();
			
		}
		else {
			strBuy = travelershop;
			
		}
		return true;
	}
    
    function AddShopCar(goodstitle,totalcount,totalmoney) {
        $('#info_msgbox').remove();
			 
										$('#aBuy').after('<div id="info_msgbox"><div id="msgbox_page"><div id="msgbox_top"><strong>商品已成功添加到您的购物车！</strong>' +
													  '<div id="close"></div></div><div id="msgbox_txt">您的购物车目前共有<span class="highlight14b">' +
													  totalcount+
													  ' </span>件商品,合计:<span class="highlight14b">' +
													  parseFloat(totalmoney).toFixed(2)+
													  ' 元</span><br><a href="' + ShopMainHostUrl + '/NewMember/ShopCar.aspx?ReturnUrl='+escape(RawFullUrl)+'"><img src="/images/msg/info_msg_08.gif" width="99" height="32" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" id="aclose"><img src="/images/msg/info_msg_10.gif" width="99" height="32" border="0" /></a></div><div id="msgbox_footer"><img src="/images/msg/info_msgfooter.gif" width="388" height="20" /></div></div></div>');
								$("#msgbox_page").show();
								$("#close").click(function() { $("#info_msgbox").fadeOut('fast'); });
								$("#aclose").click(function() { $("#info_msgbox").fadeOut('fast');  });    
								jQuery.getScript("/NewMember/UserInfoScript.aspx"); 
            
    }