﻿
function CheckIndustries(senderId, hfCounter, txtIndustry, hfIndustriesSelectedValues) {

    var Total;
    Total = $get(hfCounter).value * 1;
    var Value = $get(senderId).value;
    
    if (document.getElementById(senderId).checked) 
    {
        Total = Total * 1 + 1;
        $get(hfIndustriesSelectedValues).value += Value +",";
    }
    else
    {
        Total = Total * 1 - 1;
        $get(hfIndustriesSelectedValues).value = $get(hfIndustriesSelectedValues).value.replace(","+Value+",", ",");
    }
   // alert($get(hfIndustriesSelectedValues).value);

    $get(hfCounter).value = Total;

    if (Total == 0) {
        $get(txtIndustry).innerHTML = "Select up to 20 industries";
    }
    else 
    {
        $get(txtIndustry).innerHTML = Total + " Industries selected";
    }
}

function LoadIndustries(cbListId, hfIndustriesSelectedValues) {

    var objectsId = new Object();
    objectsId.cbListId = cbListId;
    objectsId.hfIndustriesSelectedValues = hfIndustriesSelectedValues;

    
    mojoPortal.Web.Services.h4s.GetIndustries(succeededLoadIndustries, failedLoadIndustries, objectsId);
}

function succeededLoadIndustries(Data, objectsId, methodName) {
    //loadCheckBoxList is in industriesCBList.ascx
    $("#" + objectsId.cbListId).loadCheckBoxList(Data, objectsId);
}

function failedLoadIndustries(exception, userContext, methodName) {
  //  alert("failedLoadIndustries" + exception);
}

