<%@ page language="C#" autoeventwireup="true" inherits="member_js_ctmps_search, V5Shop.Member" enableviewstatemac="false" enableEventValidation="false" viewStateEncryptionMode="Never" %>

var bigidnow = 0;
var idnow = 0;
var brandid = 0;
var brandtype = '';

document.write("<%=bigCategoryStr %>");

var urlNow = document.URL;

GetUrlInfo(urlNow);

/*--------------------------------*/

function BindBigClass(id){
    var obj = document.getElementById("bigid");
    
    for(var i=0;i<obj.options.length;i++){
        if(obj.options[i].value == id){
           obj.options[i].selected = true; 
        }
    }
    
    ChangeBigCategory(obj);
}

function BindSmallClass(id){
    var obj = document.getElementById("id");
    
    for(var i=0;i<obj.options.length;i++){
        if(obj.options[i].value == id){
           obj.options[i].selected = true; 
        }
    }
    
    //ChangeSmallCategory(obj);
}

function BindBrand(id){
    var obj = document.getElementById("brandid");
    
    for(var i=0;i<obj.options.length;i++){
        if(obj.options[i].value == id){
           obj.options[i].selected = true; 
        }
    }
    
    ChangeBrand(obj);
}

function BindBrandType(id){
    var obj = document.getElementById("brandtype");
    
    for(var i=0;i<obj.options.length;i++){
        if(obj.options[i].value == id.replace("+"," ")){
           obj.options[i].selected = true; 
        }
    }
}
/*-------------------------------------------------*/


function selectSmallCategory(){
    if(idnow != "0"){
        BindSmallClass(idnow);
    }
}

function selectBrandCategory(){
    if(brandid != "0"){
        BindBrand(brandid);
    }
}

function selectBrandType(){
    if(brandtype != "0"){
        BindBrandType(brandtype);
    }
}


/*-------------------------------------------------*/
function GetUrlInfo(url){
    try
    {
        idnow = url.match(/&id\=[0-9]*/g)[0].replace("&id=","");
        bigidnow = url.match(/bigid\=[0-9]*/g)[0].replace("bigid=","");
        brandid = url.match(/brandid\=[0-9]*/g)[0].replace("brandid=","");
        brandtype = url.match(/brandtype\=[^&]*/g)[0].replace("brandtype=","");
    }
    catch(err) {}

    if(bigidnow != "0"){
        BindBigClass(bigidnow);
    }
    
    if(brandid != "0"){
        BindBrand(brandid);
    }
}

/*-------------------------------------------------*/

function ChangeBigCategory(obj){
    var bigId = obj.options[obj.options.selectedIndex].value;
    var url = "/member/js_ctmps_search.aspx?act=small&id=" + bigId + "&d=" + Date();
    
    if(bigId == "0"){
        $("smallarea").innerHTML = "<select id='id' name='id' style='width:120px'><option value=0>-请选择产品小类-</option></select>";
        return;
    }
    var myajax = new Ajax.Updater(    
	    {success: 'smallarea'},     
	    url,
	    { 
		    asynchronous:true,    
		    method: 'get',    
		    evalscrīpts:true,
		    onComplete : selectSmallCategory
	    }    
    );  
}

function ChangeSmallCategory(obj){
    var bigId = obj.options[obj.options.selectedIndex].value;
    var url = "/member/js_ctmps_search.aspx?act=brand&id=" + bigId + "&d=" + Date();
    
    idnow = bigId;
    
    /*var myajax = new Ajax.Updater(    
		{success: 'brandarea'},     
		url,
		{ 
			asynchronous:true,    
			method: 'get',    
			evalscrīpts:true,
			onComplete : selectBrandCategory
		}    
	);*/  
}

function ChangeBrand(obj){
    var bigId = obj.options[obj.options.selectedIndex].value;
    var url = "/member/js_ctmps_search.aspx?act=brandtype&id=" + idnow + "&brandid=" + bigId + "&d=" + Date();

    var myajax = new Ajax.Updater(    
		{success: 'brandtypearea'},     
		url,
		{ 
			asynchronous:true,    
			method: 'get',    
			evalscrīpts:true,
			onComplete : selectBrandType
		}    
	);  
}
