﻿function ManufacturerSelector_OnDropDownChanged(clientID, controlID)
{
    var manufacturer;
    if (clientID != null)
    {
        var dropDown = $get(controlID);
        manufacturer = dropDown.options[dropDown.selectedIndex].value;      
    }
    
    JetShop.StoreControls.Services.General.GetManufacturerInfo(manufacturer, ManufacturerSelector_OnSucceeded, ManufacturerSelector_OnFailed, clientID);    
}

// This is the event handler called after 
// the Web request returns.
function ManufacturerSelector_OnSucceeded(result, userContext, methodName) 
{        
	var cs = $get(userContext);
    ManufacturerSelector_ReloadPages(result, cs.isSingleFrameSolution);  
}

function ManufacturerSelector_OnFailed(result, userContext, methodName) 
{
}

function ManufacturerSelector_ReloadPages(result, isSingleFrameSolution)
{   
    var re = new RegExp('/[a-zA-Z]{2}[-]{1}[a-zA-Z]{2}/');
    var href;
    
    if (isSingleFrameSolution == "True")
    {   
        href = window.location.host;
        href = href.replace(re, '/');
        
        result = result.replace('~', '');
        window.location.href = result;
    }
    else
    {
        window.parent.frames.main.location.href = result;
    }
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();