﻿

function aProductType(artistId, productTypeId,category) {

    PageMethods.GetProduts(artistId, productTypeId, category, OnSuccessed, OnFailed);
    highlightCategory('ar:' + artistId + 'pt:' + productTypeId + 'pc:' + category);
}

function OnSuccessed(result) {
    var theDiv = document.getElementById("artistProducts");
    theDiv.innerHTML = result;
}

function OnFailed(error) {
    var theDiv = document.getElementById("artistProducts");
    theDiv.innerHTML = error.get_message();
}

var oldId = 'nonexisting';

function highlightCategory(divId) {
    var lnk = getRealId(divId, "artacccont");
    if (lnk !== undefined) {
        lnk.className = "menuitemselected";
    }

    var oldLnk = getRealId(oldId, "artacccont");
    if (oldLnk !== undefined) {
        oldLnk.className = "menuitem";
    }
    oldId = divId;
}

function getRealId(partialid, containerID) {
    var re = new RegExp(partialid, 'g');
    var contElm = document.getElementById(containerID);
    var elems = contElm.getElementsByTagName('*'), i = 0, el;
    while (el = elems[i++]) {
        //if(el.id.match(re))
        if (el.id.endsWith(partialid)) {
            return el;
            break;
        }
    }
}


if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();