﻿// Additional lsi.com javascript

// TakeMeTo function
// Redirects to the page specified by the passed in key
function TakeMeTo(pageid, param) 
{ 
    switch(pageid)
    {
        case 'SignIn':
        case 'ChannelSignIn':
            // the current page is the "Source" paramter on the query string
            window.location = '/_layouts/Authenticate.aspx?Source=' + escape(location.pathname);
            break;
        case 'SignInHome':
            // the home page is the "Source" paramter on the query string
            window.location = '/_layouts/Authenticate.aspx?Source=' + escape('/');
            break;
        case 'SignOut':
        case 'ChannelSignOut':
            window.location = '/_layouts/SignOut.aspx';
            break;
        case 'Register':
            window.location = '/Pages/user/register.aspx?Source=' + escape(location.pathname);
            break;
        case 'ChannelRegister':
            var g = '/channel/contact/pages/sign-up.aspx';
            if (param) {
                switch (param) {
                    case 'CN':
                        g = '/channel/china/contact/pages/sign-up.aspx';
                        break;
                    case 'JP':
                        g = '/channel/japan/contact/pages/sign-up.aspx';
                        break;
                    case 'RU':
                        g = '/channel/russia/contact/pages/sign-up.aspx';
                        break;
                    case 'DE':
                        g = '/channel/germany/contact/pages/sign-up.aspx';
                        break;
                    case 'UK':
                        g = '/channel/uk/contact/pages/sign-up.aspx';
                        break;
                    case 'FR':
                        g = '/channel/france/contact/pages/sign-up.aspx';
                        break;
                }
            }
            window.location = g;
            break;
        case 'Profile':
            window.location = '/Pages/user/profile.aspx?Source=' + escape(location.pathname);
            break;
        case 'ChannelProfile':
            window.location = '/Pages/user/profile.aspx?Source=' + escape(location.pathname);
            break;
        case 'Reset':
            window.location = '/Pages/user/reset.aspx';
            break;
        case 'Alerts':
        case 'ChannelAlerts':
            window.location = '/Pages/user/alerts.aspx?Source=' + escape(location.pathname);
            break;
        case 'Search':
            if (!param)
                window.location = '/Search/Pages/' + (location.pathname.match(/downloads.aspx/i) ? 'downloads' : 'results') + '.aspx?k=' + escape(jQuery('#searchbox').val());
            else
                window.location = '/Search/Pages/results.aspx?k=' + escape(param);
            break;
        case 'ChannelSearch':
            if (!param)
                window.location = '/Channel/Search/Pages/' + (location.pathname.match(/downloads.aspx/i) ? 'downloads' : 'results') + '.aspx?k=' + escape(jQuery('#searchbox').val());
            else
                window.location = '/Channel/Search/Pages/results.aspx?k=' + escape(param);
            break;
        case 'AssetSearch':
        case 'ChannelAssetSearch':
            if (location.pathname.match(/\/channel\//i))
                window.location = '/Channel/Search/Pages/downloads.aspx?k=' + escape(param);
            else
                window.location = '/Search/Pages/downloads.aspx?k=' + escape(param);
            break;
    }
}

function AddItemAlert(file){
    var k = jQuery.ajax({ type: 'GET', async: false, url: '/magic.axd?x=a&file=' + escape(file), dataType: 'html' }).responseText;
    if (k) alert(k); else alert('Unable to subscribe to the selected item at this time.');
}
function ScrubComment(id) {
    var k = jQuery.ajax({ type: 'GET', async: false, url: '/magic.axd?x=s&id=' + escape(id), dataType: 'html' }).responseText;
    if (k) { alert(k); window.location = window.location; } 
    else alert('Unable to remove the selected item at this time.');
}
function OpenReadme(file) {
    var k = jQuery.ajax({ type: 'GET', async: false, url: '/magic.axd?x=m&file=' + escape(file), dataType: 'html' }).responseText;
    if (k && k != "NONE") { window.location = k; return false; }
    return true;
}
function AcceptEULA(file) {
    var k = jQuery.ajax({ type: 'GET', async: false, url: '/magic.axd?x=e&file=' + escape(file), dataType: 'html' }).responseText;
    if (k && k != "NONE") { window.location = k; return false; }
    return true;
}

jQuery(document).ready(function () {
    jQuery("li.on,li.off").click(function (e) {
        var j = jQuery(this);
        var o = j.offset();
        if (e.pageX > (o.left + (j.width() - 12)) && e.pageY < (o.top + 12)) {
            j.closest('li').toggleClass('on').toggleClass('off');
            return false;
        }
        else return true;
    });
});


// BEGIN Shanthi 2011_Sept_10 Product Page Optimization JS function to work with XSLT
$(document).ready(function() {

	$('.patrigger').live('click', function() {
		ToggleProductAssets($(this).attr('spnimg'), $(this).attr('spntbl'));
	});

});

function ToggleProductAssets(imgId, tblId) {

    if ($('#' + tblId).css('display') == 'block') {
        $('#' + tblId).css('display', 'none');
        $('#' + imgId).attr('src', '/common/css/img/icon-plus.gif');
    }
    else {
        $('#' + tblId).css('display', 'block');
        $('#' + imgId).attr('src', '/common/css/img/icon-minus.gif');
    }
}

function ToggleAllProductAssets(direction)  {

	if (direction == 'expand') {
		$('.patrigger').each(function() {
			$('#' + $(this).attr('spntbl')).css('display', 'block');
			$('#' + $(this).attr('spnimg')).attr('src', '/common/css/img/icon-minus.gif');
		});
	}
	else {
		$('.patrigger').each(function() {
			$('#' + $(this).attr('spntbl')).css('display', 'none');
			$('#' + $(this).attr('spnimg')).attr('src', '/common/css/img/icon-plus.gif');
		});
	}
}

// END  Shanthi 2011_Sept_10 Product Page Optimization JS function to work with XSLT



function GetMPTabText(lang, id) {
    switch (lang) {
        case "CN":
            switch (id) {
                case 'NEWS': document.write('新闻'); break;
                case 'EVENTS': document.write('活动'); break;
                case 'INVESTORS': document.write('投资者'); break;
                case 'CAREERS': document.write('招聘'); break;
                case 'CONNECT': document.write('连接'); break;
                case 'HIGHLIGHTS': document.write('亮点'); break;
                case 'WHERE TO BUY': document.write('哪里可以买到'); break;
                case 'OVERVIEW': document.write('概述'); break;
                case 'RESOURCES': document.write('资源'); break;
                case 'RELATED PRODUCTS': document.write('相关产品'); break;
                case 'REQUIRED PRODUCTS': document.write('所需产品'); break;
                case 'FEATURES AND BENEFITS': document.write('特点和优点'); break;
                case 'SPECIFICATIONS': document.write('规格'); break;
                case 'SUPPORT AND DOWNLOADS': document.write('支持与下载'); break;
                case 'OPTIONAL PRODUCTS': document.write('可选产品'); break;
                case 'RELATED SOLUTIONS': document.write('相关解决方案'); break;
            }
            break;
        case "DE":
            switch (id) {
                case 'NEWS': document.write('Neuigkeiten'); break;
                case 'EVENTS': document.write('Veranstaltungen'); break;
                case 'INVESTORS': document.write('Investoren'); break;
                case 'CAREERS': document.write('Jobs & Karriere'); break;
                case 'CONNECT': document.write('Mit uns vernetzen'); break;
                case 'HIGHLIGHTS': document.write('Highlights'); break;
                case 'WHERE TO BUY': document.write('Business Partner Suche'); break;
                case 'OVERVIEW': document.write('Überblick'); break;
                case 'RESOURCES': document.write('Ressourcen'); break;
                case 'RELATED PRODUCTS': document.write('Verwandte Produkte'); break;
                case 'REQUIRED PRODUCTS': document.write('Erforderliche Produkte'); break;
                case 'FEATURES AND BENEFITS': document.write('Features & Benefits'); break;
                case 'SPECIFICATIONS': document.write('Technische Daten'); break;
                case 'SUPPORT AND DOWNLOADS': document.write('Support und Downloads'); break;
                case 'OPTIONAL PRODUCTS': document.write('Optionale Produkte'); break;
                case 'RELATED SOLUTIONS': document.write('Zugehörige Lösungen'); break;
            }
            break;
        case "FR":
            switch (id) {
                case 'NEWS': document.write('Nouvelles'); break;
                case 'EVENTS': document.write('Evénements'); break;
                case 'INVESTORS': document.write('Investisseurs'); break;
                case 'CAREERS': document.write('Carrières'); break;
                case 'CONNECT': document.write('Se connecter'); break;
                case 'HIGHLIGHTS': document.write('Faits saillants'); break;
                case 'WHERE TO BUY': document.write('Achats'); break;
                case 'OVERVIEW': document.write('Aperçu'); break;
                case 'RESOURCES': document.write('Ressources'); break;
                case 'RELATED PRODUCTS': document.write('Produits connexes'); break;
                case 'REQUIRED PRODUCTS': document.write('Produits incontournables'); break;
                case 'FEATURES AND BENEFITS': document.write('Caractéristiques &amp; avantages'); break;
                case 'SPECIFICATIONS': document.write('Spécifications'); break;
                case 'SUPPORT AND DOWNLOADS': document.write('Support et téléchargements'); break;
                case 'OPTIONAL PRODUCTS': document.write('Produits en option'); break;
                case 'RELATED SOLUTIONS': document.write('Solutions connexes'); break;
            }
            break;
        case "JP":
            switch (id) {
                case 'NEWS': document.write('ニュース'); break;
                case 'EVENTS': document.write('イベント'); break;
                case 'INVESTORS': document.write('投資家向け情報'); break;
                case 'CAREERS': document.write('採用情報'); break;
                case 'CONNECT': document.write('ソーシャル・メディア'); break;
                case 'HIGHLIGHTS': document.write('ハイライト'); break;
                case 'WHERE TO BUY': document.write('購入先について'); break;
                case 'OVERVIEW': document.write('概要'); break;
                case 'RESOURCES': document.write('各種資料'); break;
                case 'RELATED PRODUCTS': document.write('関連製品'); break;
                case 'REQUIRED PRODUCTS': document.write('必要な製品'); break;
                case 'FEATURES AND BENEFITS': document.write('特長／機能／メリット'); break;
                case 'SPECIFICATIONS': document.write('スペック'); break;
                case 'SUPPORT AND DOWNLOADS': document.write('サポート＆ダウンロード'); break;
                case 'OPTIONAL PRODUCTS': document.write('オプション製品'); break;
                case 'RELATED SOLUTIONS': document.write('関連ソリューション'); break;
            }
            break;
        case "RU":
            switch (id) {
                case 'NEWS': document.write('Новости'); break;
                case 'EVENTS': document.write('События'); break;
                case 'INVESTORS': document.write('Инвесторам'); break;
                case 'CAREERS': document.write('Вакансии'); break;
                case 'CONNECT': document.write('Контакты'); break;
                case 'HIGHLIGHTS': document.write('В центре внимания'); break;
                case 'WHERE TO BUY': document.write('Где купить?'); break;
                case 'OVERVIEW': document.write('Обзор'); break;
                case 'RESOURCES': document.write('Ресурсы'); break;
                case 'RELATED PRODUCTS': document.write('Сопутствующие продукты'); break;
                case 'REQUIRED PRODUCTS': document.write('Необходимые продукты'); break;
                case 'FEATURES AND BENEFITS': document.write('Характеристики и преимущества'); break;
                case 'SPECIFICATIONS': document.write('Технические характеристики'); break;
                case 'SUPPORT AND DOWNLOADS': document.write('Поддержка и материалы для  загрузки'); break;
                case 'OPTIONAL PRODUCTS': document.write('Опции'); break;
                case 'RELATED SOLUTIONS': document.write('Сопутствующие решения'); break;
            }
            break;
        default:
            switch (id) {
                case 'NEWS': document.write('News'); break;
                case 'EVENTS': document.write('Events'); break;
                case 'INVESTORS': document.write('Investors'); break;
                case 'CAREERS': document.write('Careers'); break;
                case 'CONNECT': document.write('Connect'); break;
                case 'HIGHLIGHTS': document.write('Highlights'); break;
                case 'WHERE TO BUY': document.write('Where To Buy'); break;
                case 'OVERVIEW': document.write('OVERVIEW'); break;
                case 'RESOURCES': document.write('RESOURCES'); break;
                case 'RELATED PRODUCTS': document.write('RELATED PRODUCTS'); break;
                case 'REQUIRED PRODUCTS': document.write('REQUIRED PRODUCTS'); break;
                case 'FEATURES AND BENEFITS': document.write('FEATURES &amp; BENEFITS'); break;
                case 'SPECIFICATIONS': document.write('SPECIFICATIONS'); break;
                case 'SUPPORT AND DOWNLOADS': document.write('SUPPORT &amp; DOWNLOADS'); break;
                case 'OPTIONAL PRODUCTS': document.write('OPTIONAL PRODUCTS'); break;
                case 'RELATED SOLUTIONS': document.write('RELATED SOLUTIONS'); break;
            }
            break;
    }
}
