
$(function () {
    /*
    $('.dropdown').each(function () {
        $(this).parent().eq(0).hoverIntent({
            timeout: 100,
            over: function () {
                var current = $('.dropdown:eq(0)', this);     
                current.slideDown(100);    
            },
            out: function () {
                var current = $('.dropdown:eq(0)', this);
                current.fadeOut(200);
            }
        });
    });     
    */                                           
    $(".MegaMenuLink").megamenu(".MegaMenuContent"); 
    $('#MegaMenuContent').css("text-align", "left");
                                          
    $("h1").css("z-index", 1); 
    $(".sIFR-flash").css("z-index", 1); 
    $(".MegaMenu").css("z-index", 1000);  
    
    $(".call_link").simpletooltip();
});
    
function focusSearch(object, doc) { if($(object).val() == "Search" || (doc==1 && $(object).val() == "Search Documentation Portal")) {$(object).val('');} }   
function blurSearch(object, doc) { //if($(object).val() == "") {$(object).val(((doc==1)?"Search Documentation Portal":"Search"));} 
}
    
function focusSignup(object) { if($(object).val() == "Your Email") {$(object).val('');} }   
function blurSignup(object) { if($(object).val() == "") {$(object).val('Your Email');} }

var prev_feature = 0;
function showFeature(feature, name) {   
    $('#cur_section').text('Feature: ' + name);
    $('#product_content').hide("slow");  
    $('#product_content').html($('#feature_'+feature).html());   
    $('#product_content').show("slow");
                                                                                                                
    $('#back_option').show();           
}

function showOverview() {
    $('#cur_section').text('Overview'); 
    $('#product_content').hide("slow");  
    $('#product_content').html($('#overview').html());   
    $('#product_content').show("slow");
    
    $('#back_option').hide();        
}

    
function changeMarketSegment(object, segment, title, image, url) {
    $('#segment_img').attr('src', image);
    $('#segment_img').attr('alt', title);
    $('#segment_img').attr('title', title);
    $('#segment_links div').removeClass("selected");    
    $(object).addClass("selected");    
    
    $('#solutionType').val(url);
    $('#marketplace_span').text(segment);                            
}                                                        

function findSolution() {
    $('#solutionForm').submit();
}

function goto(url) {
    location.href = url;
}

function changeVideoChapter(chapter) {

    if(isNaN(chapter)) {
        $('#video_area').html("<p>Invalid video selection</p>");
        return ;
    }                                                           

    $('#video_area').html("<p>Loading Video...</p>" + '<p><img src="/images/ajax-loader.gif" width="16" height="11"></p>');
    $.post("/include/site_ajax.php", "ChangeChapter=true&chapter=" + chapter, 
            function(data) { 
                $("#video_area").html(data);    
                $("[id^='menu_opt']").removeClass("selected");             
                $("#menu_opt_"+chapter).addClass("selected");                           
            });

}

function changeHardware() {
    location.href = '/Products/CompatibleHardware.php?'
                        + 'category=' + $("#category").val()
                        + '&version=' + $("#version").val();
}
    

function getHardwareDetails(hwID)
{   
    var tosend = "getHardwareDetails=true&hwID=" + hwID;  
                                  
    $.post("/include/downloads_fnc.php", tosend, 
        function(data) { 
            if(data.indexOf("<!--ERROR-->") > -1) {
                $("#hardware_popup").html(''); 
                $("#hardware_popup").dialog( "close" );
            }
            else {                             
                $("#hardware_popup").html(data); 
                $("#hardware_popup").dialog( "open" );
            }
        });
}

function printHardware()
{                                                                                        
    window.open('/Products/PrintHardware.php?hwID=' + $("#currentHardware").val(),'mywindow','width=700,height=350')
}

function toggleArchive(display)
{
    if(display) {
        $("#view_old").hide();
        $("#archive").show();
    } else {  
        $("#view_old").show();
        $("#archive").hide(); 
    }
}

function doSearch(search1,search2)
{
    if(search1 == "" || search1 == undefined)
        return;
    if(search2 == "undefined" || search2 == "")
        search2 = "Title, Subject, Keyword Search";
    location.href = '/Search/?s=' + escape(search1) + '&t=' + search2;
}

function doDocSearch()
{
    var search = $('#s1').val(); //if(search == "" || search == "Search Documentation Portal" || search == undefined) return;
    if(search == "Search Documentation Portal") search = "";
    var version = $('#version').val(); var category = $('#category').val();
    var search_type = $("#search_type").val();
    var urlstring = 'search=' + escape(search) + '&v=' + version + '&c=' + category + "&t=" + search_type;
    
    location.href = '/Documentation/search.php?' + urlstring;
} 

function getTrainingDetails(request)
{   
    var tosend = "getTrainingDetails=true&request=" + request;  
                                  
    $.post("/include/site_ajax.php", tosend, 
        function(data) { 
            if(data.indexOf("<!--ERROR-->") > -1) {
                $("#training_popup").html(''); 
                $("#training_popup").dialog( "close" );
            }
            else {                             
                $("#training_popup").html(data); 
                $("#training_popup").dialog( "open" );
            }
        });
}
