﻿function catClick(shortURL) {
    var fullURL = "~/App_Controls/" + shortURL + ".ascx";
    var serviceLOC = "ScriptService.asmx/GetControlHtml";
    getData(serviceLOC, fullURL);
    return false;
}
function bindEvents() {
    $('#OSTables h3').click(function() {
        $(this).next('div.catList').siblings('div.catList:visible').slideUp('normal');
        $(this).next('div.catList').slideToggle('normal');
        $(this).toggleClass('headerstd').toggleClass('headersel');
        $(this).siblings('h3').removeClass('headersel').addClass('headerstd');
        $('#closebtn').click(function() {
            $('#topWrapper').hide('fast');
        });
    });
    $('a.tipped').cluetip({ cluetipClass: 'jtip' }).append('<span class="ttip"><sup>&nbsp;(?)</sup></span>');
    $('a.tipped').click(function() {
        return false;
    });
}
function getData(serviceURL, controlLocation) {
    $('#topWrapper').hide('fast');
    $("#loader").show('fast');
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: serviceURL,
        dataType: 'json',
        data: "{'controlLocation':'" + controlLocation + "'}",
        success:
        function(msg) {
            $('#drvDetails').html("<div>" + msg.d + "</div>"); //.html(eval(msg)); //(msg.d);
            $('a.tipped', '#drvDetails').cluetip({ cluetipClass: 'jtip' }).append('<span class="ttip"><sup>&nbsp;(?)</sup></span>');
            $('#topWrapper').slideDown('fast');
            $('#drvDetails a').click(function() {
                _hbLink($(this).attr("name"));
            });
            $('#closebtn').show();
            $("#loader").hide('fast');
        }, error:
        function(XMLHttpRequest, textStatus, errorThrown) {
            $("#loader").hide('fast');
            //alert("Driver file not available");
            return true;
        }
    });
}
function contractall() {
    var inc = 0;
    while (document.getElementById("dropmsg" + inc)) {
        $('#dropmsg' + inc).hide();
        $('#dropmsga' + inc).hide();
        $('#dropmsgb' + inc).hide();
        inc++;
    }
}

function expandone(selObj, restore) {
    if (document.getElementById) {
        var selectedItem
        if (typeof (selObj.selectedIndex) == "undefined")
            selectedItem = 0;
        else
            selectedItem = selObj.selectedIndex;
        contractall();
        $('#dropmsg' + selectedItem).show();
        $('#dropmsga' + selectedItem).show();
        $('#dropmsgb' + selectedItem).show();
    }
}
function showfirst() {
    contractall();
    var firstitem = 0;
    $('#dropmsg' + firstitem).show();
    $('#dropmsga' + firstitem).show();
    $('#dropmsgb' + firstitem).show();
}
$(document).ready(function() {
    $('a.tipped').cluetip({ cluetipClass: 'jtip' }).append('<span class="ttip"><sup>&nbsp;(?)</sup></span>');
    $('a.tipped').click(function() {
        return false;
    });
});