﻿// JScript 文件
var iframeSortList_Header;
function getSortList(obj,fieldId){
    if($('___div_SortListContainer')!=null)
    {
        $('___div_SortListContainer').style.display="";
        return;
    }
    
    var div1 = document.createElement("div");
    div1.id = "___div_SortListContainer";
    div1.innerHTML = '<iframe id="iframeSortList_Header" src="about:blank" frameBorder="0" style="width:0px; height:0px;" scrolling="no"></iframe><div id="___div_SortListContainer2" class="sortListTabCss"><div id="___div_SortListTitle"><a title="Close" href="javascript:;" onclick="this.parentNode.parentNode.parentNode.style.display='+"'none'"+';return false;" style="float:right;">×</a></div><div id="___div_SortList">Loading... </div></div>';
    div1.style.position = "absolute";
    var po = Position.cumulativeOffset(obj);
    div1.style.left =  po[0]+"px";
    div1.style.top = po[1]+Element.getHeight(obj)+"px";
    document.body.appendChild(div1);
    div1.focus();
    reqSortList(fieldId);
}
function getSortListClose(){
    $('___div_SortListContainer').style.display="none";
}
function reqSortList(fieldId){
    var divFiller = $("___div_SortList");
    var url = '/Index/ForAjax.aspx';
    var theParameters="methodName=GetCardProjectClasses";
    var myAjax = new Ajax.Request(url,{method: 'POST',parameters: theParameters,onComplete:function(req){
        var allClass = req.responseText.evalJSON();
        il=allClass[0];
        divFiller.innerHTML = '';
        il.each(function(val,index){
            var div2 = document.createElement("div");
            div2.innerHTML = '<div class="bigSort"><a href="javascript:;" onclick=\'SortListfillVal("'+val.SortId+'","'+val.SortName+'","'+val.ParentId+'"); return false;\'>'+val.SortName +'</a></div><div class="subSort">'+reqSubSortList(val.SortId,val.SortName,allClass[1][index])+'</div>';
            divFiller.appendChild(div2);
        });
        var frm1=$('iframeSortList_Header');
        frm1.style.width=divFiller.clientWidth+10+"px";
        frm1.style.height=divFiller.clientHeight+5+"px";
    }});
}
function reqSubSortList(sid,pSort,subClasses){
    var s = '';
    var il = subClasses;
    il.each(function(val,index){
        s += '<a href="javascript:;" onclick=\'SortListfillVal("'+val.SortId+'","'+val.SortName+'","'+val.ParentId+'"); return false;\'>'+val.SortName +'</a>';
    });
    return s;
}
function reqRootList(divFiller){
    var url = 'http://card.baoanren.com/req.ashx?act=ShopAjax.ShopSort_SelectRoot';
    var s = "<ul>";
    var myAjax = new Ajax.Request(url,{method: 'POST',parameters: '',onComplete:function(req){
        var il = req.responseText.evalJSON();
        il.each(function(val,index){
            alert(val.val.SortId +"|"+val.SortName +"|"+val.ParentId);
            s += '<li><a href="javascript:;" onclick=\'SortListfillVal("'+val.SortId+'","'+val.SortName+'","'+val.ParentId+'")\'>'+val.SortName +'</a></li>';
        });
        $(divFiller).innerHTML = s+"</ul>";
    }});
}

function HeaderSortListAdd(sid,s){
   $("hdHeaderSearchSid").value = sid;
   $("txtSearchClass").value = s;
}
function SortListfillVal(sid,s,ps){
    getSortListClose();
    HeaderSortListAdd(ps+"|"+sid,s)
}
function toSearch(){
        location = 'http://card.baoanren.com/Search_FH.aspx?sid='+$F("hdHeaderSearchSid")+'&cus='+ escape($F("txtSearch"));
}
var oldSelectedTabIndex = 1;
function displayTab(i){
    $("div_i"+oldSelectedTabIndex).style.display="none";
    $("a"+oldSelectedTabIndex).style.backgroundImage = "url(http://card.baoanren.com/images/shop_7.jpg)";
    
    oldSelectedTabIndex = i;
    $("a"+oldSelectedTabIndex).style.backgroundImage = "url(http://card.baoanren.com/images/shop_5.jpg)";
    $("div_i"+oldSelectedTabIndex).style.display="";
}
function toAddReadCount(id, readCount) {
    AjaxReq('ActionineAjax.UpdateReadCount','id='+enc(id)+'&readCount='+readCount,function(){
    },null);
}
function toUpdateHits(shopId) {
    AjaxReq('ShopAjax.UpdateHits','shopId='+enc(shopId),function(){
    },null);
}
