﻿var pagelink = '';
var pagehash = 0;
var inpageChildArray = new Array();
var inpageParentArray = new Array();
var inpageCount = 0;
var TrackingHash;

//redirect any request for https to http

if (window.location.href.toLowerCase().match("https")) {

    if (!(window.location.href.toLowerCase().match("checker.aspx"))) {

        var strUrl = window.location.href.toLowerCase().replace("https", "http");

        //alert(strUrl);

        window.location = strUrl;

    }

}

if ((window.location.href.toLowerCase().match("_http:")) && (window.location.href.toLowerCase().match("checker.aspx"))) {

    var strUrl1 = window.location.href.toLowerCase().replace("http", "https");

    window.location = strUrl1;

}





// Initialize.
function init_herolinks() {

    // Does element exist?
    if (!$('ul.heroLinks').length) {

        // If not, exit.
        return;
    }



    // Listen for click on tabs.
    $('div#heroContentRight ul li p a').click(function () {
        // If not current tab.
        if (!$(this).parents("li:first").hasClass('current')) {
            // Change the current tab:
            $(this).parents("li:first")
                .addClass('current')
                .siblings('li.current')
                .removeClass('current');

            // If there is a matching target container, show target container, and hide others, otherwise click event will default to browser default handling:
            pagelink = $(this).attr('href');
            linkpage = pagelink.slice(pagelink.lastIndexOf('/') + 1);
            linkpage = linkpage.substring(0, linkpage.indexOf('.'));
            if ((pagelink.indexOf('#') >= 0) && (linkpage == thispage)) {
                pagehash = pagelink.indexOf('#');
                pagelink = pagelink.slice(pagehash);
                var tempID = pagelink;
                tempID = tempID.replace('#', '');
                /*                $(pagelink).attr('id', 'temp');
                location.hash = '';
                location.hash += tempID;
                $('#temp').attr('id', tempID);
                $(pagelink)*/
                var tabTriggerId = $(this).attr('id');
                var tabContentId;
                if (tabTriggerId != '') {
                    tabContentId = tabTriggerId.substring('12');
                    // alert(tabContentId);
                }
                else {
                    tabContentId = tempID;
                }

                $('#' + tabContentId).attr('id', 'temp');
                TrackingHash = tabContentId;
                location.hash = tabContentId;
                $('#temp').attr('id', tabContentId);
                $('#' + tabContentId)
                    .show()
                    .siblings('div.tab_content')
                    .hide();
                return false;
            }
        }
    });

    /* start code to handle video filter dropdown selection */

    // set filter drop down selected to first option - 'all items'
    $(".filterselect option:eq(0)").attr("selected", "selected");

    // Listen for change on filter drop down - hide all and show selected
    $(".filterselect").change(function () {
        if ($(".filterselect option:selected").attr("value") == "all") {
            $(".filtersection").show();
        }
        else {
            $(".filtersection").hide();
            var selected = "#" + $(".filterselect option:selected").attr("value");
            $(selected).show();
        }
    });

    /* end code to handle video filter dropdown selection */
}

// set global variables to be used for deep linking
var pageloc = location.href;

// reduce string to relative path
pageloc = pageloc.replace('http://', '');
domainloc = pageloc.indexOf('/');
pageloc = pageloc.slice(domainloc);

// variables for determining inpage linking or browser navigation linking
var thispage = pageloc.slice(pageloc.lastIndexOf('/') + 1);
thispage = thispage.substring(0, thispage.indexOf('.'));
var linkpage = '';

// variable for holding anchor hrefs
var loclink = '';
var deepbool = false;

// variables for mainnav on state and string manipulation to determine subnav section item to click 
var thisSec = location.href;
var endDomain = 0;
var tailingString = 0;
var mainsec = '';
thisSec = thisSec.replace('http://', '');
endDomain = thisSec.indexOf('/');
thisSec = thisSec.slice(endDomain);

if (thisSec.indexOf('/security/') == 0) {
    thisSec = thisSec.replace('/security/', '');
}
else {
    var prefixToRemove = thisSec.indexOf('/security/') + 10;
    thisSec = thisSec.slice(prefixToRemove, thisSec.length);
}

if (thisSec.indexOf('/') >= 0) {
    tailingString = thisSec.indexOf('.aspx');
    thisSec = thisSec.slice(0, tailingString);
    mainsec = thisSec;
    thisSec = thisSec.replace(/\//g, '-');
    thisSec = 'sub-' + thisSec;
}
else mainsec = 'security-home';

function deepLink() {
    $('div#heroContentRight ul li p a').each(function () {
        loclink = $(this).attr('href');
        if (pageloc === loclink) {
            deepbool = true;
            $(this).click();
            this.blur();
        }
    });

    var pagelocation = location.href;
    if (deepbool == false) {
        if ($('div#heroContent')) {
            for (i = 0; i < inpageChildArray.length; i++) {
                if (pagelocation.indexOf(inpageChildArray[i]) >= 0) {
                    $(inpageParentArray[i]).addClass('current');
                    deepbool = true;
                }
            }
        }
    }

    if (deepbool == false) {
        if ($('div#heroContent')) {
            thisSec = '#' + thisSec + ' li > p > a:eq(0)';
            $(thisSec).click();
            thisSec = '';
        }

    }
}

function init_mainNav() {
    $('div#topNav ul#left li p a').each(function () {
        if ($(this).attr('href').indexOf(mainsec) >= 0) {
            $(this).addClass('on');
        }
    });

    if (mainsec == 'security-home') {
        $('div#topNav ul#left li p a:eq(0)').addClass('on');
    }
}

/* function to handle cookie retrieval */

function getCookie(name) {
    var search = name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        // if cookie exists
        if (offset != -1) {
            offset += search.length
            // set index of beginning of value
            end = document.cookie.indexOf(";", offset);
            // set index of end of cookie value
            if (end == -1) end = document.cookie.length;
            returnvalue = unescape(document.cookie.substring(offset, end))
        }
    }
    return returnvalue;
}

/* end code to handle video download dropdown language selection cookie retrieval */

/* start code to handle video download dropdown language selection onchange */

function checkCookie() {
    if (getCookie('downloadterms') != 'accepted') {
        $('#downloadterms').show();
    }
    else {
        location = document.getElementById('selectlanguage').options[document.getElementById('selectlanguage').selectedIndex].value;
        $('#downloadterms').hide();
    }
}

function setCookie() {
    if (getCookie('downloadterms') != 'accepted') {
        document.cookie = 'downloadterms=accepted';
        checkCookie();
    }
}

/* end code to handle video download dropdown language selection onchange */


// Popup Download for MSE 18th May, 2011 Start //
function HideDownload() {
    $('#LightsOutBackground').hide();
    $('#LocaleDownload').hide();
}
function showPopUpDiv() {
    $('#LightsOutBackground').show();
    $('#LocaleDownload').show();
}
//New Code for Mse download button

var download32 = '';
var download64 = '';

var msePageUrl = window.location.href;
var msePagelanguage ='';
if( msePageUrl.match(/mse.aspx/) ||msePageUrl.match(/mse-whatis.aspx/)){
if(msePageUrl.match(/http/)  )
	var msePageUrl=msePageUrl.split('/')[3];
if(!msePageUrl.match(/security/)){
msePagelanguage = msePageUrl+"/";
}
var downloadListArray = new Array();

$.ajax({
    url: "/global/"+msePagelanguage +"security/renderingassets/Mse_Download_Links.xml", 
    data: {value: 1},
    method: 'get',
    dataType:'xml', 
    error: function(data){$.get('/global/security/renderingassets/Mse_Download_Links.xml',function(xmlData){
			downloadListArray = new Array();
			download32 = $(xmlData).find('mainLink').find('x86link').text();
			download64 = $(xmlData).find('mainLink').find('x64link').text();
			$(xmlData).find('language').each(function(){
				var arrayitem86 = $(this).attr('lang')+'_86';
				var arrayitem64 = $(this).attr('lang')+'_64';
				downloadListArray["'"+arrayitem86 +"'"] = $(this).find('x86link').text();
				downloadListArray["'"+arrayitem64+"'"] = $(this).find('x64link').text();
			});
			});}
,
    success: function(xmlData){
    downloadListArray = new Array();
download32 = $(xmlData).find('mainLink').find('x86link').text();
download64 = $(xmlData).find('mainLink').find('x64link').text();

$(xmlData).find('language').each(function(){
	var arrayitem86 = $(this).attr('lang')+'_86';
	var arrayitem64 = $(this).attr('lang')+'_64';
	downloadListArray["'"+arrayitem86 +"'"] = $(this).find('x86link').text();
	downloadListArray["'"+arrayitem64+"'"] = $(this).find('x64link').text();
	//alert(	downloadListArray["'"+arrayitem64+"'"]);
});
    }
});
}
function getDownloadLinks(p_obj) {
    var seletectdLanguage = p_obj.options[p_obj.selectedIndex].value;
	var x86selectedLang = seletectdLanguage+'_86';
	var x64selectedLang = seletectdLanguage+'_64';
    switch (seletectdLanguage) {
        case 'bg-bg': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'zh-cn': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'zh-tw': download32 = downloadListArray["'"+x86selectedLang+"'"];
			download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'hr-hr': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'cs-cz': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'da-dk': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'nl-nl': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'en-us': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'et-ee': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'fi-fi': download32 = downloadListArray["'"+x86selectedLang+"'"];
			download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'fr-fr': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'de-de': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'el-gr': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'hu-hu': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'it-it': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'ja-jp': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'ko-kr': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'lv-lv': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'lt-lt': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'nb-no': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'pl-pl': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'pt-br': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'pt-pt': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'ro-ro': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'ru-ru': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'sr-latn-cs': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'sk-sk': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'es-es': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'sv-se': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'th-th': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'tr-tr': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'uk-ua': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        case 'vi-vn': download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
        default: download32 = downloadListArray["'"+x86selectedLang+"'"];
            download64 = downloadListArray["'"+x64selectedLang+"'"]; break;
    }
  
    $('#downloadWindowsXP').attr('href', download32);
    $('#downloadWindows32').attr('href', download32);
    $('#downloadWindows64').attr('href', download64);

}


//New Code for Mse download button

// Popup Download for MSE 18th May, 2011 End //
// Kick things off.
$(document).ready(function () {
    init_mainNav();
    init_herolinks();
    deepLink();
    $("p.downloadbutton a").hover(
      function () {
          $(this).css('background', 'url(/global/security/PublishingImages/global/btn_dwnload_sprite.png) no-repeat 0px -126px');
          $(this).children('span').css('background', 'url(/global/security/PublishingImages/global/btn_dwnload_sprite.png) no-repeat 100% -84px');

          // Popup Download for MSE 18th May, 2011 Start //
          if (window.location.href.indexOf('mse.aspx') != -1 || window.location.href.indexOf('mse-whatis.aspx') != -1) {
              var OS = navigator.userAgent;
              strPopDiv = '<div id="LocaleDownload" class="popupWindow" style="top: 360.5px; left: 356.5px;" ><div class="close"><a href="javascript:void(0);" onclick="HideDownload()">close [X]</a></div>'
                        + '<div><h2>Download Microsoft Security Essentials</h2><div>Microsoft Security Essentials is available in many locales and languages. To download Microsoft Security Essentials, choose your preferred locale or language from the list below. Next, choose your operating system to begin the download process. If you’re unsure which operating system you have, please visit <a href="http://support.microsoft.com/kb/827218">Microsoft Support</a>.</div>'
                        + '<table class="LocaleTable" cellspacing="0" cellpadding="0" width="100%"><tr><td><h4>Locale or Language</h4><select id="LocaleDropDown" name="LocaleDropDown" onchange="getDownloadLinks(this)" ><option value="bg-bg">Bulgarian</option><option value="zh-cn">Chinese (Simplified)</option><option value="zh-tw">Chinese (Traditional)</option><option value="hr-hr">Croatian</option><option value="cs-cz">Czech</option><option value="da-dk">Danish</option><option value="nl-nl">Dutch</option><option value="en-us" selected="selected">English</option><option value="et-ee">Estonian</option><option value="fi-fi">Finnish</option><option value="fr-fr">French</option><option value="de-de">German</option><option value="el-gr">Greek</option><option value="hu-hu">Hungarian</option><option value="it-it">Italian</option><option value="ja-jp">Japanese</option><option value="ko-kr">Korean</option><option value="lv-lv">Latvian</option><option value="lt-lt">Lithuanian</option><option value="nb-no">Norwegian</option><option value="pl-pl">Polish</option><option value="pt-br">Portuguese (Brazil)</option><option value="pt-pt">Portuguese (Portugal)</option><option value="ro-ro">Romanian</option><option value="ru-ru">Russian</option><option value="sr-latn-cs">Serbian</option><option value="sk-sk">Slovakian</option><option value="es-es">Spanish</option><option value="sv-se">Swedish</option><option value="th-th">Thai</option><option value="tr-tr">Turkish</option><option value="uk-ua">Ukrainian</option><option value="vi-vn">Vietnamese</option></select></td>'
                        + '<td><div class="floatRight"><h4 style="margin-bottom:4px;">Operating System</h4><ul><li><a id="downloadWindowsXP" href="' + download32 + '">Windows XP 32-bit</a></li><li><a id="downloadWindows32" href="' + download32 + '">Windows Vista/Windows 7 32-bit</a></li><li><a id="downloadWindows64" href="' + download64 + '">Windows Vista/Windows 7 64-bit</a></li></ul></div></td></tr></table></div></div>'
                        + '<div id="LightsOutBackground" class="lightsOutBackground"></div>';
              var downloadUrl = download32;
              if ((OS.indexOf("WOW64") != -1) || (OS.indexOf("x64") != -1) || (OS.indexOf("Win64") != -1) || (OS.indexOf("IA64") != -1))
                  downloadUrl = download64;
              if (OS.indexOf("Safari") != -1 || OS.indexOf("Opera") != -1) { //OS.indexOf('Chrome') != -1  && (OS.indexOf('Firefox') != -1 ||
                  if (document.getElementById('LocaleDownload') == null) {
                      $('body').append(strPopDiv);
                      $(this).attr('href', 'javascript:void(0)');
                      $(this).click(function () {
                          showPopUpDiv();
                      });
                  }
              }

              else
                  $(this).attr('href', downloadUrl);
          }
          // Popup Download for MSE 18th May, 2011 End//
      },
      function () {
          $(this).css('background', 'url(/global/security/PublishingImages/global/btn_dwnload_sprite.png) no-repeat 0px -42px');
          $(this).children('span').css('background', 'url(/global/security/PublishingImages/global/btn_dwnload_sprite.png) no-repeat 100% 0px');
      }
    );
    // faq show/hide/expand all/collapse all
    $(".answer").hide();
    $(".question").click(function () {
        $(this).toggleClass('minus').toggleClass('plus');
        $(this).next(".answer").toggle();
        return false;
    });

    $("#showAll").click(function () {
        $(".answer").show();
        $(".question").addClass('minus').removeClass('plus');
        return false;
    });
    $("#hideAll").click(function () {
        $(".answer").hide();
        $(".question").addClass('plus').removeClass('minus');
        return false;
    });
});



// Tracking Hash change on the page : Start - Cybage 24th May 11//

$(document).ready(function () {
  if (!(window.location.href.match("password-checker.aspx"))) {
    window.onhashchange = function () {
        $('#twitter_button').html('<iframe scrolling="no" src="http://platform0.twitter.com/widgets/tweet_button.html?_=1308041734077&count=horizontal&id=twitter_tweet_button_0&lang=en&original_referer="' + window.location.href + '"&related=MS_Security&url="' + window.location.href + '"&via=security" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"  frameborder="0"></iframe>');
        $('#faceBook_button').html('<fb:like  send="false" layout="button_count" width="130" show_faces="true" action="recommend" font="arial"></fb:like>'
        + '<div id="fb-root" style="display:none"></div><script>  window.fbAsyncInit = function() {FB.init({ appId: "230319936993886", status: true, cookie: true,xfbml: true});};');
        $.getScript("/global/security/RenderingAssets/all.js", function () { });
        var secTrack = window.location.hash.split('#')[1];
        if (secTrack != null && window.location.hash.split('#')[1] != TrackingHash) {
            window.location.href = window.location.href.replace("#", "?!");
        }
    }
    }
    else
        window.onhashchange = '';
});

// Tracking Hash change on the page : End - Cybage 24th May 11//


//function addNoFollowNoIndexMetaTag()
//{
//    try {
//        var _arrayOfURLs = new Array("pc-security/default.aspx"
//                                      ,"online-privacy/default.aspx"
//                                      );


//        var _url = window.location.href;
//        var _splitUrl = _url.toLowerCase().split('/security/')[1];
//        //alert(_splitUrl);          

//	    for (var i = 0; i < _arrayOfURLs.length; i++) {
//	       // alert(_splitUrl.toLowerCase() + " " + _arrayOfURLs[i].toLowerCase());
//	        if (_splitUrl.toLowerCase().match(_arrayOfURLs[i].toLowerCase())) {
//	            //alert("match");
//	            var meta_one = document.createElement("meta");
//	            meta_one.setAttribute("NAME", "robots");
//	            meta_one.setAttribute("CONTENT", "noindex,nofollow");
//	            document.getElementsByTagName("head").item(0).appendChild(meta_one);
//	            break;
//	         }
//	    }              
//	
//    }
//    catch (Error) {
//       // alert("in catch"+ Error);
//    }
//}

//addNoFollowNoIndexMetaTag();


//Code for survey popup added on 18th May 11 : Start
/* Commented on 26th May 11
$(document).ready(function () {
$("<div id='surveyMainDiv' style='display:none;'></div>").appendTo("body");
$.post("/security/SurveyGenerator.aspx",
function (data) {
$('#surveyMainDiv').html(data);
if ($('#displaySurveyDiv').html() == "true") {
$('<link rel="stylesheet" type="text/css" href="/security/assets/styles/survey/thickbox.css">').appendTo("head");
$.getScript("/security/assets/scripts/survey/thickbox.js", function () {
$.getScript("/security/assets/scripts/survey/surveyModule.js", function () { });
});

}
}
);
});
*/
//Code for survey popup added on 18th May 11 : End


// Code for Equal Width SiteMap Columns 19th May 11 Start
$(document).ready(function () {

    $("div#siteMapContent").css({ 'width': "100%" });
    var colWrap = $("div#siteMapContent").width();

    var colNum = $("div#siteMapContent .siteMapContent_Column").length;

    var colFixed = Math.floor(colWrap / colNum);


    $("div#siteMapContent .siteMapContent_Column").css({ 'width': colFixed });



});

// Code for Equal Width SiteMap Columns 19th May 11 End


// Adding poll on the page : Start  - Cybage 31st May 11//
$(document).ready(function () {
    // alert("http://" + document.location.host);
    try {
        if (window.location.href.toLowerCase().match("/security/default.aspx")) {
            var currentLocation = window.location.href.toLowerCase();
            //currentLocation = currentLocation.substring(currentLocation.indexOf(document.location.host) + document.location.host.length, currentLocation.length);
            if (document.location.host.toLowerCase().indexOf("cspauthoring") != -1) {
                $(".featuredContentLast").show();
                return;
            }
            $.get("/security/mynews/pollConfig.xml", function (xml) {
                var pollCheck = false;
                var langCheckFlag = false;
                var enUsFlag = false;

                $(xml).find('enable').each(function () {
                    var pollCheckText = $(this).text();
                    var language = $(this).attr('locale').toLowerCase();

                    if (language == 'en-us') {
                        enUsFlag = pollCheckText.toLowerCase();
                    }
                    else if (currentLocation.match("/" + language + "/security/default.aspx")) {
                        langCheckFlag = true;
                        if (pollCheckText.toLowerCase() == "true") {
                            pollCheck = true;
                        }
                    }

                });

                if (!langCheckFlag && enUsFlag) {
                    //alert(document.location.host + "/security/default.aspx");
                    //var completeURL = window.location.href;
                    if (currentLocation.match(document.location.host + "/security/default.aspx")) {
                        pollCheck = true;
                    }
                }
                if (!langCheckFlag && enUsFlag.toLowerCase() == "false") {
                    pollCheck = false;
                }

                if (pollCheck == false) {
                    $(".featuredContentLast").show();
                }
                else if (pollCheck == true) {
                    $(".featuredContentLast").show();
                    $(".featuredContentLast").html("<h3>Live Vote</h3><p>Loading Data... Please wait</p>");
                    $(".featuredContentLast").css('margin-bottom', '0px');
                    $.getScript("/security/mynews/scripts/securityPoll.js", function () {
                        $('<link rel="stylesheet" type="text/css" href="/security/mynews/styles/securityPoll.css">').appendTo("head");
                        $.get("/security/mynews/SecurityPoll.aspx?id=1", function (data) {
                            //alert($.cookie("securityPollCookie"));
                            if ($.cookie("securityPollCookie") != null) {
                                $(".featuredContentLast").html("<h3>Live Vote</h3>" + data);
                                $(".featuredContentLast").hide();
                                $("#pollQuestionDiv").hide();
                                showPollData();
                                $(".featuredContentLast").show();
                            }
                            else {
                                $(".featuredContentLast").html("<h3>Live Vote</h3>" + data);
                            }

                        });
                    });
                }
            });
        }
        else {
            $(".featuredContentLast").show();
        }
    }
    catch (err) {
        $(".featuredContentLast").show();
    }
});
// Adding poll on the page : End - Cybage 31st May 11//

// Removing LHS Nav, Ads and other Changes for MSEC page: Start - Cybage 21st June 11 //

$(document).ready(function () {

    var windowUrl = window.location.href;
    if (windowUrl.match('/security/msec.aspx')) {
        var oddEven = false;
        $('.column').each(function () {
            if (!oddEven) {
                $(this).css('width', '54%');
                oddEven = true;
            }
            else {
                $(this).css('width', '44%');
                oddEven = false;
            }
        });
    }
});

// Removing LHS Nav, Ads  and other Changes for MSEC page: End - Cybage 21st June 11 //

//Adding ModalVideo : Start - Cybage 21/Jul/2011 //

$(document).ready(function () {
    try {
        $('head').append("<script src='/global/security/RenderingAssets/modalvideos/jquery.colorbox-min.js' type='text/javascript'></script>"
        + " <link href='/global/security/RenderingAssets/modalvideos/colorbox.css' rel='stylesheet' />"
                + " <link href='/global/security/RenderingAssets/modalvideos/modalVideo.css' rel='stylesheet' />");

        $('#cboxClose').css("display", "none");
        var secMktLanguage = window.location.href;
        var domainName = window.location.host;
        secMktLanguage = secMktLanguage.substring(secMktLanguage.indexOf(window.location.host) + window.location.host.length + 1, secMktLanguage.length);
        secMktLanguage = secMktLanguage.substring(0, 5);
        // alert(secMktLanguage);
        addSecCookie('true');
		$(".modalVideoLink").click(function () {
			dcsMultiTrack("WT.ti", "HomePage Modal Video", "DCS.dcsuri", "/security/default.aspx", "DCS.dcssip", "www.microsoft.com", "DCS.dcsref", "http://www.microsoft.com/security/default.aspx", "WT.dl", "1");
		});
        $(".modalVideoLink").colorbox({ close: "", onClosed: function () {
            $('#cboxClose').css("display", "none");
            //            $('#cboxClose').css("visibility", "hidden");
            //            $('#cboxOverlay').remove();
            //            $('#cboxLoadedContent').html('');
        }, onLoad: function () {
		
            $('#cboxClose').css("visibility", "hidden");
        },
            onComplete: function () {

                var descriptionMaxHeight = 240 - $(".modalVideo .videoTitle").height();
                $(".modalVideo .videoDescription").truncate({ maxHeight: descriptionMaxHeight });

                $('.modalVideo .videoEmbed .codeButton').click(function () {
                    $(this).find(".getCode").toggle();
                    $(this).find(".hideCode").toggle();
                    $(this).parent().find(".code").toggle();
                });

                $('.modalVideo .videoDescription .readMore').click(function () {
                    $(this).parent().parent().find(".initial").toggle();
                });
                $('#cboxClose').css("visibility", "visible");
               // dcsMultiTrack("WT.ti", "HomePage Modal Video", "DCS.dcsuri", "/shared/templates/components/_microsoftsecurity-VideoBlock/ModalVideoPlayer.aspx", "DCS.dcssip", "www.microsoft.com", "DCS.dcsref", "http://www.microsoft.com/security/default.aspx", "WT.dl", "1");
            }
        });
    }
    catch (err)
    { rx = err; }
});
//Adding ModalVideo : End - Cybage 21/Jul/2011 //

//Adding Spacing in TopNav : Start - Cybage 05/Aug/2011 //
$(document).ready(function () {
	$('#left').find('img').each(function(){
	
		$(this).parent().attr('style','margin-left:15px !important; margin-right:-5px !important;');
	});
});
//Adding Spacing in TopNav : End - Cybage 05/Aug/2011 //


function addSecCookie(p_secMkt) {
    createCookie("secmkt", p_secMkt);
}

function createCookie(name, value, days) {
    if (window.location.href.toLowerCase().match("/security/mcsi/default.aspx")) {
        var date = new Date();
        date.setTime(date.getTime() + (5 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    }
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}


