﻿function ToggleVisible(element) 
{
    var theElement = document.getElementById(element);
    if (theElement.style.display != 'block') theElement.style.display = 'block';
    else theElement.style.display = 'none';
}

function SetActiveTab(wrapperId,tab) 
{
    var wrapper = document.getElementById(wrapperId);
    var tabs = wrapper.getElementsByTagName('a');

    for (var i = 0; i < tabs.length; i++) {
        tabs[i].className = 'cms_tab';
    }
    tab.className = 'cms_tabActive';
    tab.blur();
}

function ToggleTabClickAndElementVisible(tab, family, count, element) {
    //hide all elements in family
    for (var i = 1; i <= count; i++) {
        document.getElementById(family + i).style.display = 'none'; //eg tab1, tab2, tab3
    }
    //then make the chosen one visible
    document.getElementById(element).style.display = 'block';

    //set tag to active
    var tabStrip = document.getElementById(family + 'Tabs');
    var tabs = tabStrip.getElementsByTagName('a');

    for (var i = 0; i < tabs.length; i++) {
        tabs[i].className = '';
    }
    tab.className = 'active';
    tab.blur();
}


function JumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function GetSilverlightVersion() {
    var version = 'No Silverlight: ' + (navigator.appVersion + ', ' + navigator.platform).substring(0, 55);
    var container = null;

    try {
        var control = null;
        var product = 'Silverlight';

        if (navigator.userAgent.indexOf("Linux") != -1) {
            product = "Silverlight (Moonlight)";
        }

        if (window.ActiveXObject) {
            control = new ActiveXObject('AgControl.AgControl');
        }
        else {
            if (navigator.plugins['Silverlight Plug-In']) {
                container = document.createElement('div');
                document.body.appendChild(container);
                container.innerHTML = '<embed type="application/x-silverlight" src="data:," />';
                control = container.childNodes[0];
            }
        }

        if (control) {
            if (control.isVersionSupported('3.0')) {
                version = product + '/3.0';
            }
            else if (control.isVersionSupported('2.0')) {
                version = product + '/2.0';
            }
            else if (control.isVersionSupported('1.0')) {
                version = product + '/1.0';
            }
        }
    }
    catch (e) { }

    if (container) {
        document.body.removeChild(container);
    }
    return version;
}

//used to toggle tab click for popups etc.
function TogglePropertyTabClick(tag, family, count, element) {
    //hide all elements in family
    for (var i = 1; i <= count; i++) {
        document.getElementById(family + i).style.display = 'none'; //eg tab1, tab2, tab3
    }
    //then make the chosen one visible
    document.getElementById(element).style.display = 'block';

    //set tag to active
    var tabStrip = document.getElementById(family + 'Tabs');
    var tabs = tabStrip.getElementsByTagName('a');

    for (var i = 0; i < tabs.length; i++) {
        tabs[i].className = '';
    }
    tag.className = 'active';
    tag.blur();
}

function BuildContentBlockEdit(name, culture, appRoot, width, height, mode, toolbar) {
    var div = document.getElementById(name);
    div.innerHTML = '<iframe width="100%" height=' + height + ' src=\"' + appRoot + '_cms/_Parts/ContentBlockEdit.aspx?n=' + name + '&c=' + culture + '&w=' + width + '&h=' + height + '&mode=' + mode + '&tb=' + toolbar + '\" frameborder=\"0\"></iframe>';
}

