/// <reference name="MicrosoftAjax.js"/>  
/// <reference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />   
/// <reference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />   
/// <reference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
/// <reference path="../Services/Support.asmx" />

$(document).ready(function() {
    $('div#nav li').hover(function() {
        $(this).addClass('hover');
    }, function() {
        $(this).removeClass('hover');
    });
    $('h2.title').wrap('<span class="title-wrap" />');
    $('span.title-wrap').wrap('<span class="title-wrap-out" />');
    $('li.widget h3 span').wrap('<span class="title-wrap" />');
    $('div#container img').wrap('<div class="img-wrap" />');
    $('div#container div.wrap').wrapAll('<div class="cont-wrap" />');
    $('div#container div.cont-wrap').wrapAll('<div class="cont-wrap-out" />');
    $('li#search input').example('Search');


    $('li#brochures a,li#onlinevideos a,li#whitepapers a,li#testimonials a,li#case-studies a').each(function() {
        //hide the original url
        this.rel = this.href;
        this.href = "javascript:void(0)";
    })
    .click(function(evt) {
        var originalUrl = this.rel;

        if (!registered) {
            evt.stopPropagation();

            var oWnd = $find(downloadAppWindow);
            oWnd.set_navigateUrl(popupUrl + "?item=" + this.innerHTML);
            oWnd.show();

            //handle the close
            oWnd.add_close(function(sender, eventArgs) {
                if (eventArgs.get_argument() != null) {
                    registered = true;
                    window.location = originalUrl;
                }
            });
        } else {
            window.location = originalUrl;
        }
    });


    //hook up the popup timer
    if (!poppedReceived) {
        window.setTimeout(function() {
            $("#scnXOW a").triggerHandler("click");
            HandsOn.Services.Support.PopUp(function(result, context) {
                poppedReceived = result;
            });
        }, 60000);        
    }
});