﻿/*浮动在页面上方的页面*/
function ShowImg(control)
{
    $(control.id+"Img").src=control.value;
}


function selectFile(type,obj,height,width,dummypaht)
{
    var ShowObj = obj;
    if(isArray(obj) && obj.length > 1)
        ShowObj = obj[1];
    showfDiv(ShowObj,"loading...",width);
    LastSelectObj = obj;
	var  options={  
			           method:'get',  
			           parameters:"widths="+width+"&heights="+ height,  
			           onComplete:function(transport)
				        {  
					        var returnvalue=transport.responseText;
					        if (returnvalue.indexOf("??")>-1)
						        showfDiv(ShowObj,'Error',width);
					        else
						        var tempstr=returnvalue;
						        showfDiv(ShowObj,tempstr,width);
				        }  
				   }; 
	var arrtype=type.split("|")[0]
	
    switch(arrtype)
    {
        case "Productclass":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=Productclass',options);
            break;
        case "Productbrand":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=Productbrand',options);
            break;
        case "productclassone":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=productclassone',options);
            break;
        case "Area":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=Area',options);
            break;
        case "OrderCardProduct":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=OrderCardProduct',options);
            break;
        case "integratepurchasProduct":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=integratepurchasProduct',options);
            break;
        case "AuctionProduct":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=AuctionProduct',options);
            break;
       case "Memberlist":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=Memberlist',options);
            break;
       case "ShopStyle":
            new  Ajax.Request(dummypaht+'admin/include/iframe.aspx?FileType=ShopStyle',options);
            break;
    }
}
//判断是否数组
function isArray(obj)
{   
  if(obj.constructor == window.Array)   
    return true;
  else   
   return false;
}
position = function(x,y)
{
    this.x = x;
    this.y = y;
}
getPosition = function(oElement)
{
    var objParent = oElement
    var oPosition = new position(0,0);
    while (objParent.tagName != "BODY")
    {
        oPosition.x += objParent.offsetLeft;
        oPosition.y += objParent.offsetTop;
        objParent = objParent.offsetParent;
    }
    return oPosition;
} 
function showfDiv(obj,content,width)
{
    var pos = getPosition(obj);
    var objDiv = document.getElementById("s_id");
    if (objDiv==null)
    {
        objDiv = document.createElement("div");
        objDiv.id="s_id";
    }
    objDiv.className="selectStyle";
    objDiv.style.position = "absolute";
	var tempheight=pos.y;
	var tempwidth1,tempheight1;
	var windowwidth=document.body.clientWidth;
	
	var isIE5 = (navigator.appVersion.indexOf("MSIE 5")>0) || (navigator.appVersion.indexOf("MSIE")>0 && parseInt(navigator.appVersion)> 4);
	var isIE55 = (navigator.appVersion.indexOf("MSIE 5.5")>0);
	var isIE6 = (navigator.appVersion.indexOf("MSIE 6")>0);
	var isIE7 = (navigator.appVersion.indexOf("MSIE 7")>0);

	if(isIE5||isIE55||isIE6||isIE7){var tempwidth=pos.x+305;}else{var tempwidth=pos.x+312;}
	objDiv.style.width = width+"px";
    objDiv.innerHTML = content;
	if (tempwidth>windowwidth)
	{
		tempwidth1=tempwidth-windowwidth
		objDiv.style.left = (pos.x-tempwidth1) + "px";
	}
	else
	{
		if(isIE5||isIE55||isIE6||isIE7){objDiv.style.left = (pos.x) + "px";}else{objDiv.style.left = (pos.x) + "px";}
	}
	if(isIE5||isIE55||isIE6||isIE7){objDiv.style.top = (pos.y+22) + "px";}else{objDiv.style.top = (pos.y+22) + "px";}

    objDiv.style.display = "";
    document.ondblclick=function () { if(objDiv.style.display==""){objDiv.style.display="none";} }
    document.body.appendChild(objDiv);
}
/*移动*/
drag=function (a,o){
	    var d=document;if(!a)a=window.event;
		if(!a.pageX)a.pageX=a.clientX;
		if(!a.pageY)a.pageY=a.clientY;
	    var x=a.pageX,y=a.pageY;
	    if(o.setCapture)
		    o.setCapture();
	    else if(window.captureEvents)
		    window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	    var backData = {x : o.style.top, y : o.style.left};
	    d.onmousemove=function(a){
		    if(!a)a=window.event;
		    if(!a.pageX)a.pageX=a.clientX;
		    if(!a.pageY)a.pageY=a.clientY;
		    var tx=a.pageX-x+parseInt(o.style.left),ty=a.pageY-y+parseInt(o.style.top);
		    o.style.left=tx+"px";
		    o.style.top=ty+"px";
			x=a.pageX;
			y=a.pageY;
	    };

	    d.onmouseup=function(a){
		    if(!a)a=window.event;
		    if(o.releaseCapture)
			    o.releaseCapture();
		    else if(window.captureEvents)
			    window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
		    d.onmousemove=null;
		    d.onmouseup=null;
		    if(!a.pageX)a.pageX=a.clientX;
		    if(!a.pageY)a.pageY=a.clientY;
		    if(!document.body.pageWidth)document.body.pageWidth=document.body.clientWidth;
		    if(!document.body.pageHeight)document.body.pageHeight=document.body.clientHeight;
		    if(a.pageX < 1 || a.pageY < 1 || a.pageX > document.body.pageWidth || a.pageY > document.body.pageHeight){
			    o.style.left = backData.y;
			    o.style.top = backData.x;
		    }
	    };
    }
    /*确认*/
function ReturnFun(Return_Strs)
{
    if(isArray(LastSelectObj))
    {
        for(var i=0;i<LastSelectObj.length;i++)
        {
            SetValue(LastSelectObj[i],Return_Strs[i]);
        }
    }
    else
    {
        SetValue(LastSelectObj,Return_Strs);
    }
    document.getElementById("s_id").style.display="none";
}
function SetValue(obj,val)
{
    if (obj==null || typeof(obj)=="undefined")
    {
        alert("选择失败，请重新选择。");
    }
    else
    {
        if(val == null || typeof(val)=="undefined")
            val = '';
        obj.value = val;
    }	            
}


function ShowImg(control)
{
    $(control.id+"Img").src=control.value;
    
}

function ShowDiv(tabid,num)
{
    var tab;
    for(var i=0;i<num;i++)
    {
        tab=$("tab"+i);
        if(i==tabid)
        {
            tab.style.display='block';
        }
        else
        {
            tab.style.display='none';
        }
    }
}

function ReturnLabelValueText(value)
{

    try
    {
        if(value!="")
        {
            var oEditor = FCKeditorAPI.GetInstance("ctl00_workspace_txtContent");
            if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG)
            {
               oEditor.InsertHtml(value);
            }
            else
            {
              return false;
            }
        }
    }
    catch(e)
    {
        insert(value);
    }
    finally
    {
        document.getElementById("LabelDivid").style.display="none";
        return;
    }
}

function show(type,obj,title,label_width,height)
{
    var label_temp1 = "<div onmousedown=\"drag(event,$('LabelDivid'));\" style=\"text-decoration: none;padding-left:3px;background-color:#EDEFEA;font-size: 12px;color: #4499CC;font-weight:\" class=\"titile_bg\" style=\"cursor:move;\">\
    <table style=\"width:100%;height:26px\">\
    <tr>\
    <td>\
    <font style='font-size:12px' color=\"#0099CC\">" + title + "</font></td>\
    <td style=\"width:40px\">\
    <span style='cursor:hand;font-size:12px;font-weight:bold;color:#0099CC' onclick=\"closediv($('LabelDivid'));\">关闭</span>\
    </td>\
    </tr>\
    </table>\
    </div>\
    <iframe src=";
    var label_temp2 = " frameborder=\"0\" id=\"select_main\" scrolling=\"yes\" name=\"select_main\" width=\"100%\" height=\""+height+"px\" />";
    var label_temp3 = "";
    switch(type)
    {
        case "systemlabel"://系统标签
            label_temp3 = label_temp1 + "label/selectlabel.aspx?w_d_tid=1" + label_temp2;
            break;
        case "definlabel"://用户标签
            label_temp3 = label_temp1 + "label/selectlabel.aspx?w_n_tid=1" + label_temp2;
            break;
        case "freelabel": //自由标签
            label_temp3 = label_temp1 + "label/selectfreelabel.aspx?w_d_free_labelclass=3" + label_temp2;
            break;
        case "ProductBrand":
            label_temp3 = label_temp1 + "productbrand_parameter.aspx" + label_temp2;
            break;
        case "ProductListMode":
            label_temp3 = label_temp1 + "productlistmode_parameter.aspx" + label_temp2;
            break;
        case "ProductClass":
            label_temp3 = label_temp1 + "productclass_parameter.aspx" + label_temp2;
            break;
        case "ProductList":
            label_temp3 = label_temp1 + "productlist_parameter.aspx?LabelClass=0" + label_temp2;
            break;
        case "StoreProductList":
            label_temp3 = label_temp1 + "productlist_parameter.aspx?LabelClass=1" + label_temp2;
            break;
        case "ProductContent":
            label_temp3 = label_temp1 + "productcontent_parameter.aspx" + label_temp2;
            break;
        case "TeamBuy":
            label_temp3 = label_temp1 + "Lable/TeamBuy_Parameter.aspx" + label_temp2;
            break;
        case "Friendlink":
            label_temp3=label_temp1+"friedlink_parameter.aspx"+label_temp2;
            break; 
        case "Survey":
            label_temp3=label_temp1+"Lable/Survey.aspx"+label_temp2;
            break;
        case "AdvancedSearch":
            label_temp3=label_temp1+"advancedsearch_parameter.aspx"+label_temp2;
            break;
        case "LeaveWrodInfo"://留言信息列表
            label_temp3=label_temp1+"leaveword_parameter.aspx"+label_temp2;
            break;
        case "LeaveWrodForm"://留言表单
            label_temp3=label_temp1+"leavewordform_parameter.aspx"+label_temp2;
            break;
        case "MemberRegForm"://用户注册表单
            label_temp3=label_temp1+"memberregform_parameter.aspx"+label_temp2;
            break;
        case "MemberAgree"://用户注册协议
            label_temp3=label_temp1+"memberagree_parameter.aspx"+label_temp2;
            break;
        case "shoppingcart":
            label_temp3=label_temp1+"shopintcart_parameter.aspx"+label_temp2;
            break;
        case "NewsList":
            label_temp3=label_temp1+"articlelist_parameter.aspx"+label_temp2;
            break;
        case "NewsContent":
            label_temp3=label_temp1+"refercontent_parameter.aspx"+label_temp2;
            break;
        case "ImportFile":
            label_temp3=label_temp1+"importfile.aspx"+label_temp2;
            break;
        case "websitetop":
            label_temp3=label_temp1+"label_top.aspx"+label_temp2;
            break;
        case "websitebottom":
            label_temp3=label_temp1+"label_bottom.aspx"+label_temp2;
            break;
        case "CreateURL":
            label_temp3=label_temp1+"label_createurl.aspx"+label_temp2;
            break;Advertise
        case "Advertise":
            label_temp3=label_temp1+"advertise_parameter.aspx"+label_temp2;
            break;
        case "CommentInfo":
             label_temp3=label_temp1+"commentinfo_parameter.aspx"+label_temp2;
             break;
        case "ReplyInfo":
             label_temp3=label_temp1+"replyinfo_parameter.aspx"+label_temp2;
             break;
        case "CommentForm":
             label_temp3=label_temp1+"commentform_parameter.aspx"+label_temp2;
             break;
        case "Login": //会员登陆
             label_temp3=label_temp1+"login_parameter.aspx"+label_temp2;
             break;
         case "usershopinginfo":
             label_temp3=label_temp1+"usershopinginfo_parameter.aspx"+label_temp2;
             break;
         case "ProductGroupBuyInfo"://团购商品活动信息
             label_temp3=label_temp1+"groupbuyactivityinfo_parameter.aspx"+label_temp2;
             break;
         case "scanproduct":
             label_temp3=label_temp1+"scantype_parameter.aspx"+label_temp2;
             break;
         case "History":
             label_temp3=label_temp1+"history_parameter.aspx"+label_temp2;
             break;  
         case "ProductExtract":
             label_temp3=label_temp1+"extract_parameter.aspx"+label_temp2;
             break;
         case "StoreInfo"://店铺信息
             label_temp3=label_temp1+"storeinfo_parameter.aspx"+label_temp2;
             break;
         case "StoreType"://店铺类型
             label_temp3=label_temp1+"storetype_parameter.aspx"+label_temp2;
             break;
         case "StoreSearch"://店铺搜索
             label_temp3=label_temp1+"storesearchform_parameter.aspx"+label_temp2;
             break;
        default:
          break;
   }
    showlabelDiv(obj,label_temp3,label_width);
}

function showShopCart(type,obj,title,label_width,height,productId,path)
{
    var label_temp1 = "<div onmousedown=\"drag(event,$('LabelDivid'));\" style=\"text-decoration: none;padding-left:3px;background-color:#EDEFEA;font-size: 12px;color: #4499CC;font-weight:\" class=\"titile_bg\" style=\"cursor:move;\">\
    <table style=\"width:100%;height:26px\">\
    <tr>\
    <td>\
    <font style='font-size:12px' color=\"#0099CC\">" + title + "</font></td>\
    <td style=\"width:40px\">\
    <span style='cursor:hand;font-size:12px;font-weight:bold;color:#0099CC' onclick=\"closediv($('LabelDivid'));\">关闭</span>\
    </td>\
    </tr>\
    </table>\
    </div>\
    <iframe src="+path;
    var label_temp2 = " frameborder=\"0\" scrolling=\"no\" id=\"select_main\" scrolling=\"yes\" name=\"select_main\" width=\"100%\" height=\""+height+"px\" />";
    var label_temp3 = "";
    switch(type)
    {
        case "showShopCart":
            label_temp3 = label_temp1 + "controls/floatingshopcart.aspx?productId=" + productId + label_temp2;
            break;
        default:
          break;
   }
    showlabelDiv(obj,label_temp3,label_width);
}

// 包含数量 2010-4-26 
function showShopCart2(type, obj, title, label_width, height, productId, path, qty_obj) {
    var label_temp1 = "<div onmousedown=\"drag(event,$('LabelDivid'));\" style=\"text-decoration: none;padding-left:3px;background-color:#EDEFEA;font-size: 12px;color: #4499CC;font-weight:\" class=\"titile_bg\" style=\"cursor:move;\">\
    <table style=\"width:100%;height:26px\">\
    <tr>\
    <td>\
    <font style='font-size:12px' color=\"#0099CC\">" + title + "</font></td>\
    <td style=\"width:40px\">\
    <span style='cursor:hand;font-size:12px;font-weight:bold;color:#0099CC' onclick=\"closediv($('LabelDivid'));\">关闭</span>\
    </td>\
    </tr>\
    </table>\
    </div>\
    <iframe src=" + path;
    var label_temp2 = " frameborder=\"0\" scrolling=\"no\" id=\"select_main\" scrolling=\"yes\" name=\"select_main\" width=\"100%\" height=\"" + height + "px\" />";
    var label_temp3 = "";
    switch (type) {
        case "showShopCart":
            label_temp3 = label_temp1 + "controls/floatingshopcart.aspx?productId=" + productId + "&buyqty=" + document.getElementById(qty_obj).value + label_temp2;
            break;
        default:
            break;
    }
    showlabelDiv(obj, label_temp3, label_width);
}

function showlabelDiv(obj,content,width)
{
    var pos = getPosition(obj);
    var objDiv = document.getElementById("LabelDivid");
    if (objDiv==null)
    {
        objDiv = document.createElement("div");
        objDiv.id="LabelDivid";
    }
    objDiv.style.className="selectStyle";//For IE
    objDiv.style.border="1px double #B4C9C6";
    objDiv.style.backgroundColor="#F4FAFF";
    objDiv.style.color="#000000";
    objDiv.style.lineheight="18px";
    objDiv.style.padding="1px";
    objDiv.style.filter="progid:DXImageTransform.Microsoft.DropShadow(color=#C5C5C5,offX=2,offY=2,positives=true)";
    
    objDiv.style.position = "absolute";
	var tempheight=pos.y;
	var tempwidth1,tempheight1;
	var windowwidth=document.body.clientWidth;
	
	var isIE5 = (navigator.appVersion.indexOf("MSIE 5")>0) || (navigator.appVersion.indexOf("MSIE")>0 && parseInt(navigator.appVersion)> 4);
	var isIE55 = (navigator.appVersion.indexOf("MSIE 5.5")>0);
	var isIE6 = (navigator.appVersion.indexOf("MSIE 6")>0);
	var isIE7 = (navigator.appVersion.indexOf("MSIE 7")>0);

	if(isIE5||isIE55||isIE6||isIE7){var tempwidth=pos.x+305;}else{var tempwidth=pos.x+312;}
	objDiv.style.width = width+"px";
    objDiv.innerHTML = content;
	if (tempwidth>windowwidth)
	{
		tempwidth1=tempwidth-windowwidth
		objDiv.style.left = (pos.x-tempwidth1) + "px";
	}
	else
	{
		if(isIE5||isIE55||isIE6||isIE7){objDiv.style.left = (pos.x) + "px";}else{objDiv.style.left = (pos.x) + "px";}
	}
	if(isIE5||isIE55||isIE6||isIE7){objDiv.style.top = (pos.y+22) + "px";}else{objDiv.style.top = (pos.y+22) + "px";}

    objDiv.style.display = "";
    document.ondblclick=function () { if(objDiv.style.display==""){objDiv.style.display="none";} }
    document.body.appendChild(objDiv);
}
function closediv(objDiv)
{
   objDiv.parentNode.removeChild(objDiv);
}
function closedivreload()
{
   window.location.reload();
}
/*<--后台全选/取消全选，删除*/
function CheckAll(form) 
{
    for (var i=0;i<form.elements.length;i++)    
    {
        var e = form.elements[i];
        if (e.name != 'chkAll')   
        {
              e.checked = form.chkAll.checked; 
        }
    }
}
function GetAllChecked()
{
    var retstr = "";
    var tb = document.getElementById("tablist");
    
    var j = 0;
    for(var i=1;i<tb.rows.length;i++)
    {
        var objtr = tb.rows[i]; 
        if(objtr.cells.length < 4)
            continue;
        var objtd = objtr.cells[0]; 
        for(var k=0;k<objtd.childNodes.length;k++)
        {
       
            var objnd = objtd.childNodes[k];
            if(objnd.type == "checkbox")
            {
                if(objnd.checked)
                {
                    if(j>0)
                        retstr += ",";
                    retstr += objnd.value;
                    j++;
                }
                break;
            }
        }
    }
    return retstr;
}

/*选项卡切换*/
function ShowTabs(id,num)
{
    var tab;
    for(var i=0;i<num;i++)
    {
        tab=$("tab"+i);
        if(i==id)
        {
            $("TabTitle"+i).className="titlemouseover";
            tab.style.display='block';
        }
        else
        {
            $("TabTitle"+i).className="tabtitle";
            tab.style.display='none';
        }
    }
}  

function MaxLength(field,maxlimit){ 
   var j = field.value.replace(/[^\x00-\xff]/g,"**").length; 
   var tempString=field.value; 
   var tt=""; 
   if(j > maxlimit){
    for(var i=0;i<maxlimit;i++){
     if(tt.replace(/[^\x00-\xff]/g,"**").length < maxlimit)
      tt = tempString.substr(0,i+1);
     else 
      break; 
    } 
    if(tt.replace(/[^\x00-\xff]/g,"**").length > maxlimit) 
     tt=tt.substr(0,tt.length-1); 
     field.value = tt; 
   }else{ 
    ; 
   } 
} 





/* zhf 2011-12-17 首页分类隐藏*/
function Show(div,type)
{
var id =div.id.toString ().substr(23,3);
if(type=="in")
{
$("#"+div.id).addClass("Check");
}
else if (type=="out")
{
$("#"+div.id).removeClass("Check");
}
}

function addToFavorite(){
var a="http://www.neoglory.net/";
var b="新光饰品-买饰品上新光，省钱又放心";
if(document.all){
window.external.AddFavorite(a,b)
}
else if(window.sidebar){
window.sidebar.addPanel(b,a,"")
}
else{
alert("对不起，您的浏览器不支持此操作!\n请您使用菜单栏或Ctrl+D收藏本站。")
}
}

function showgaoji(aid,did){
    var obj = document.getElementById(aid);
    var divotherChannel=document.getElementById(did);
    obj.className="menu_btn hover";
    divotherChannel.style.zIndex = 1000 ;
    divotherChannel.style.display = "block";
}

function hideotherchannel(aid,did){
    var divotherChannel=document.getElementById(did);
    var mydd=document.getElementById(aid);
    if(divotherChannel.style.display!="none"){
            divotherChannel.style.display="none";
            mydd.className="menu_btn";
    }
}

function Change()
{
    var objColor=$("#ProductColor");
    var objStyle=$("#ProductStyle");
    var objPrice=$("#ProductPrice");
    var span=$("#span");
    if(objColor.hasClass("hidden"))
    {
        objColor.removeClass("hidden");
        objStyle.removeClass("hidden");
        objPrice.removeClass("hidden");
        span.removeClass("span1");
        span.addClass("span2");
    }
    else
    {
        objColor.addClass("hidden");
        objStyle.addClass("hidden");
        objPrice.addClass("hidden");
        span.removeClass("span2");
        span.addClass("span1");
    }   
}
//显示更多信息
function ShowMore(jo)
{
 var obj=$("#"+jo.id);
 var obj2=obj.prevAll("ul").eq(0);
 var ids= $(obj2).attr("id"); 
var div= document .getElementById (ids);
if(div.scrollHeight-div.offsetHeight>5)
{
obj2.removeClass("height");
obj.removeClass("span1");
obj.addClass("span2");
}
else
{
obj2.hasClass("height")
{
obj2.addClass("height");
obj.removeClass("span2");
obj.addClass("span1");
}
}
}

/*搜索模块*/
//zhf 2012-01-03
 //判断哪些显示“更多”

 
 //获取URL参数
    function GetRequest() {
       var url = location.search; //获取url中"?"符后的字串
       var theRequest = new Object();
       if (url.indexOf("?") !=-1) {
          var str =url.substr(1);
          strs =str.split("&");
          for(var i = 0; i< strs.length; i ++) {
            theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
          }
       }
       return theRequest;
    }

    //替换字符串(,无法解码)
    function ReplaceValue(value)
    {
        while (value.indexOf ("%2C")>-1)
        {
            value =value .replace("%2C",",")
        }
        return value;
    }
    
 
//单选OR多选
function OneOrMore(jo)
{
    var url=location.href;
    var Prevurl=url.substring(0,url.indexOf("?"));
    //是否有select参数
    if (url.indexOf("q_select") != -1) 
    {
        url=url.substring(url.indexOf("q_select"),url.length);
        var len=url.indexOf("&");
        if(len==-1)
         len=url.length;
        var paraString = url.substring(9, len);
        if(paraString =="false")
        {
            if(url.indexOf("q_proprice1")!=-1)
            {
                url=url.substring(9,url.lastIndexOf("&"));
                window .location .href=Prevurl + "?q_select=true"+url.substring(url.indexOf("&"),url.lastIndexOf("&"));
            }   
            else if(url.indexOf("q_ProductElecColor")!=-1||url.indexOf("q_ProductClass")!=-1||url.indexOf("q_ProductColor")!=-1||url.indexOf("q_ProductStyle")!=-1||url.indexOf("q_ProductSrp3")!=-1)
            {
                url=url.substring(9,url.lastIndexOf("&"));
                if(url!="false")
                    window .location .href=Prevurl + "?q_select=true"+url.substring(url.indexOf("&"),url.length);
                else
                    window .location .href=Prevurl + "?q_select=true";
            }
            else if(url.indexOf("q_proclassid")==-1)
            {
                window .location .href=Prevurl + "?q_select=true";
            }
            else
            {
                window .location .href=Prevurl + "?q_select=true"+url.substring(url.indexOf("&"),url.length);
            }
        }
        else
        {
            if( url.indexOf("q_proclassid")>-1)
            {
                url=url.substring(url.indexOf("q_proclassid"),url.length);
                if(url.length==13)
                window .location .href=Prevurl+"?q_select=false";
                else
                window .location .href=Prevurl+"?q_select=false&"+url.substring(0,url.length);
            }
            else
                window .location .href=Prevurl+"?q_select=false";
        }
    }
    else 
    {
        if( url.indexOf("q_proclassid")>-1)
        {
            url=url.substring(url.indexOf("q_proclassid"),url.length);
            if(url.indexOf("&")>-1)
                window .location .href=Prevurl+"?q_select=true&"+url.substring(0,url.indexOf("&"));
            else
                window .location .href=Prevurl+"?q_select=true&"+url.substring(0,url.length);//已测试
        }
        else
            window .location .href=Prevurl+"?q_select=true";
    }
}

function ShowShoppingCart()
{
$("#o-mycart-list").removeClass("hidden");
}
function HiddenShoppingCart()
{
$("#o-mycart-list").addClass("hidden");
}

//产品列表搜索模块（5页面） zhf 2012-01-31
function ProductSearch()
{
    $("#allsorthover").removeClass("hidden"); //显示按钮“全部商品分类”  
    $("#advanced_search").addClass("hidden"); //隐藏按钮“高级搜索”
    var jo=$("#menu2_hot");
    if (jo.hasClass("menu2_hot"))
    {
        jo.removeClass("menu2_hot");
        jo.addClass("menu2_hot_2");
    }
    else
    {
        jo.removeClass("menu2_hot_2");
        jo.addClass("menu2_hot");
    }
    
    //zhf 2012-02-10 动态设置产品分类高度
    var height=$(".index_pro_class_new").height();
    $(".index_left_new:first").css({ "margin-top": height});
    
    //单选多选按钮文字切换
    var url=location .href;
    //是否有select参数
    if (url.indexOf("q_select") != -1) 
    {
        var len=url.indexOf("&");
        if(len==-1)
         len=url.length;
        var paraString = url.substring(url.indexOf("q_select") + 9, len);
        if(paraString =="false")
        {
            $("#OneOrMore").html("使用多选");
        }
        else
        {
            $("#OneOrMore").html("返回单选");
        }
    }
    else 
    {
        $("#OneOrMore").html("使用多选");
    }
    //初始化Input和checkbox
    var Request = new Object();
    Request = GetRequest();

    var q_ProductElecColor,q_ProductClass,q_proprice1,q_ProductColor,q_ProductStyle,q_select,q_proclassid,q_ProductSrp3;

    q_ProductElecColor = Request['q_ProductElecColor'];
    q_ProductClass = Request['q_ProductClass'];
    q_proprice1 = Request['q_proprice1'];
    q_ProductColor = Request['q_ProductColor'];
    q_ProductStyle = Request['q_ProductStyle'];
    q_select = Request['q_select'];
    $("#q_select").val(q_select);
    q_proclassid = Request['q_proclassid'];
    q_ProductSrp3=Request['q_ProductSrp3'];

    $("#q_proclassid").val(q_proclassid);
    
    //解码并替换字符  
    var value6 =ReplaceValue(decodeURI(q_ProductSrp3));
    var value5 =ReplaceValue(decodeURI(q_ProductElecColor));
    var value4 =ReplaceValue(decodeURI(q_ProductClass));
    var value1 =ReplaceValue(decodeURI(q_proprice1));
    var value3 =ReplaceValue(decodeURI(q_ProductColor));
    var value2 =ReplaceValue(decodeURI(q_ProductStyle));
    
    var q_Sort=Request['q_Sort']
    var len=url.indexOf("q_Sort");
    if (len != -1) 
    {
        switch (q_Sort)
        {
                case "Pro_ShopPrice":
                var objPrice=$("#Price");
                objPrice.addClass("curr");
                if(objPrice.hasClass("up"))
                    objPrice .removeClass("up");
                objPrice.addClass("down");
                break ;
            case "Pro_ShopPrice2":
                var objPrice=$("#Price");
                objPrice.addClass("curr");
                if(objPrice.hasClass("down"))
                    objPrice .removeClass("down");
                objPrice.addClass("up");
                break ;
            case "Pro_AutoUp":
                $("#Time").addClass("curr");
                break ;
            case "jde_crdj":
                $("#Default").addClass("curr");
                break ;  
        }
    }
    else
    {
        $("#Default").addClass("curr");
    }
    //input:text 赋值    
    $(".ur_data input:text").each(function (){
        var id=$(this).attr("id");
        var value;
        if (id=="q_proprice1"&&value1 !="undefined" )
         value=value1;
        else if (id=="q_ProductStyle"&&value2 !="undefined")
         value=value2;
        else if (id=="q_ProductColor"&&value3 !="undefined")
         value=value3;
        else if (id=="q_ProductClass"&&value4 !="undefined")
         value=value4;
        else if (id=="q_ProductElecColor"&&value5 !="undefined")
         value=value5;
        else if (id=="q_ProductSrp3"&&value5 !="undefined")
         value=value6;
        $(this).val(value);
        //input:text 有值input:checkbox处理
        if (value!=""&&value != undefined)
        {
            var ul=$(this).nextAll("ul").eq(0);
            var ul_id=$(ul).attr("id");
            $("#"+ ul_id+" input:checkbox").each(     
                function(){
                    var a=$(this).val();
                    if(value.indexOf(a)>-1)
                    {
                      this.checked="checked";
                      var li=$(this).parents("li").eq(0);
                      $(li).addClass("select");
                    }
                });
            //全选去掉打钩
            var input_All=$(this).prevAll("div").eq(0).children("div").children("input").eq(0);
            $(input_All).attr("checked",false);
         }
         else
         {
            var AllChoose=$(this).prevAll("div").eq(0).children("div").eq(0);
            $(AllChoose ).addClass("select");
         }
    });
    //“全部”引起子条件的变化
    $(".ur_data .index_price_list_th2 input:checkbox").click(
    function (){
        //不能手动取消全选
        if(this.checked=="")
        {
            this.checked="checked";
            return false;
        }
        var o_input=$("#"+this.id);
        var o_div=o_input .parent().parent();
        var o_ul=o_div .nextAll("ul").eq(0);
        var o_ul_id= $(o_ul).attr("id");
        var o_input=o_div .nextAll("input").eq(0);
        o_input.val(""); //保存全部VALUE;
        $("#"+o_ul_id+" input:checked").each(function (i){
            this.checked="";
            $($(this).parent()).removeClass("select");
        });
        $($(this).parent()).addClass("select");
    });
    //子条件引起的“全部”变动
    $(".ur_data .index_price_list_ul2 input:checkbox").click(
    function (){
      var o_input_this=$("#"+this.id);
      var o_ul=o_input_this .parent().parent();
      var o_ul_id= $(o_ul).attr("id");
      var o_div=o_ul.prevAll("div").eq(0);
      var o_div_id= $(o_div).attr("id");
      var o_input=o_ul .prevAll("input:text").eq(0);
      if($(this).attr("checked")==true)
      {
          $("#"+o_div_id +" input").attr("checked","" );
          $("#"+o_div_id +" div").removeClass("select");
          $(o_input_this .parents("li")).addClass("select");
          //保存选中value 
          if(o_input.val()=="")
          {
          o_input.val("'"+$(this).val()+"'"); 
          }
          else
          {
               o_input.val(o_input.val()+",'"+$(this).val()+"'"); 
          }
      }
      else
      {
          if(o_input .val().indexOf("'"+$(this).val()+"',")>=0)  //非最后一个
          {
            o_input .val(o_input .val().replace("'"+$(this).val()+"',",""));
          }
          else if(o_input .val().indexOf(",'"+$(this).val()+"'")>=0)  //最后一个
          {
            o_input .val(o_input .val().replace(",'"+$(this).val()+"'",""));
          }
          else                                                     //只有一个
          {
            o_input .val("");
            $(o_input.parent()).removeClass("select");
            $("#"+o_div_id +" input").attr("checked","checked" );
            $("#"+o_div_id +" div").addClass("select");
          }
          $(o_input_this .parents("li")).removeClass("select");
      }
    });
    $(".index_price_list .span1").each(function(i){
      var obj=$("#"+this.id);
      var obj2=obj.prevAll("ul").eq(0);
      var ids= $(obj2).attr("id");
      var div= document .getElementById (ids);
      if(div.scrollHeight-div.offsetHeight<5) //有1px误差需要查找原因
      {
        document .getElementById(this.id).style.height=0;
      }
    });
    //重置取消所有多选样式，添加全部样式
    $(".btn_reset").click(
    function()
    {
        $(".ur_data .index_price_list_th2 .AllChoose").each(
        function ()
        {
            $(this).addClass("select");
        });
        $(".ur_data .index_price_list_ul2 .select").each(
        function ()
        {
            $(this).removeClass("select");
        });
    });
}

//zhf 2012-02-02 Tabs切换（type="one":新品上市；type="two":公告）
function SetTabs(type,num,sum)
{
    for(i=1;i<=sum;i++)
    {
       var jo=$("#"+type+i);
       if(jo.hasClass("hover"))
       {
          jo.removeClass("hover");
          $("#con_"+type+"_"+i).addClass("hidden");
       } 
    }
    $("#"+type+num).addClass("hover");
    $("#con_"+type+"_" +num).removeClass("hidden");
}

//zhf 2012-02-02 最新上市滚动效果
function nextTab()
{
    for(i=1;i<=4;i++)
    {
        if($("#one"+i).hasClass("hover"))
        {
            if(i==4)
            {
                SetTabs("one",1,4)
            }
            else
            {
                SetTabs("one",i+1,4)
            }
        }
    }
    setTimeout("nextTab()",3000); 
}

//zhf 2012-02-04  推荐位效果
function prevRecommend()
{
    var obj=$(".RecommendArea .hover");
    obj.removeClass("hover");
    obj.addClass("hidden");
    if(obj.hasClass("first"))
    {
        var objLast=$(".RecommendArea div:last");
        objLast.addClass("hover");
        objLast.removeClass("hidden");
    }
    else
    {
        obj.prev().addClass("hover");
        obj.prev().removeClass("hidden");
    }
}
function nextRecommend()
{
    var obj=$(".RecommendArea .hover");
    obj.removeClass("hover");
    obj.addClass("hidden");
    if(obj.hasClass("last"))
    {
        var objFirst=$(".RecommendArea div:first");
        objFirst.addClass("hover");
        objFirst.removeClass("hidden");
    }
    else
    {
        obj.next().addClass("hover");
        obj.next().removeClass("hidden");
    }
}
//zhf 2012-02-07 价格排序
function Price()
  {
    var url=location .href;
    if(url.indexOf("q_Sort")!=-1)
    {
        if(url.indexOf("Pro_ShopPrice2")!=-1)
        {
            window.location = url.replace("Pro_ShopPrice2","Pro_ShopPrice"); 
        }
        else if(url.indexOf("Pro_ShopPrice")!=-1)
        {
            window.location = url.replace("Pro_ShopPrice","Pro_ShopPrice2"); 
        }
        else
        {
            window.location=url.substring(0,url.indexOf("q_Sort")+7)+"Pro_ShopPrice";
        }
    }
    else
    {
        window.location=url+"?q_Sort=Pro_ShopPrice";
    }
  }
  
function ShowProductClass()
{
    $("#allsorthover").removeClass("hidden"); //显示按钮“全部商品分类”  
    $("#advanced_search").addClass("hidden"); //隐藏按钮“高级搜索”
    var jo=$("#menu2_hot");
    if (jo.hasClass("menu2_hot"))
    {
        jo.removeClass("menu2_hot");
        jo.addClass("menu2_hot_2");
    }
    else
    {
        jo.removeClass("menu2_hot_2");
        jo.addClass("menu2_hot");
    }
    
    //zhf 2012-02-10 动态设置产品分类高度
    var height=$(".index_pro_class_new").height();
    $(".index_left_new:first").css({ "margin-top": height});
}

var setAmount={
	min:1,
	max:999,
	reg:function(x){
		return new RegExp("^[1-9]\\d*$").test(x);
	},
	amount:function(obj,mode){
		var x=$(obj).val();
		if (this.reg(x)){
			if (mode){
				x++;
			}else{
				x--;
			}
		}else{
			alert("请输入正确的数量！");
			$(obj).val(1);
			$(obj).focus();
		}
		return x;						
	},
	reduce:function(){
	    var obj=".input_buy_qty";
		var x=this.amount(obj,false);
		if (x>=this.min){
			$(obj).val(x);
		}else{
			alert("商品数量最少为"+this.min);
			$(obj).val(1);
			$(obj).focus();
		}
	},
	add:function(){
	    var obj=".input_buy_qty";
		var x=this.amount(obj,true);
		if (x<=this.max){
			$(obj).val(x);
		}else{
			alert("商品数量最多为"+this.max);
			$(obj).val(999);
			$(obj).focus();
		}
	},
	modify:function(){
	    var obj=".input_buy_qty";
		var x=$(obj).val();
		if (x<this.min||x>this.max||!this.reg(x)){
			alert("请输入正确的数量！");
			$(obj).val(1);
			$(obj).focus();
		}
	}
}


