﻿/* --- Foundation Page RedDot Menu --- */
function toggleFDRM(subMenu) {
    var subDivs = document.getElementById(subMenu).getElementsByTagName('div');
    var divImg = subDivs[0].getElementsByTagName('img');
                
    if (subDivs[1].style.display == "block") {
        subDivs[1].style.display = "none";
        divImg[0].src = "http://assets.techsmith.com/images/interface/widget_plus.gif";
    }
    else {
        subDivs[1].style.display = "block";
        divImg[0].src = "http://assets.techsmith.com/images/interface/widget_minus.gif";
    }
}
/* --- End --- */
jQuery(document).ready(function($) {
    
    $('.header_menu ul li.megamenu a').click(function(e){
                    e.preventDefault();
                        $('#megamenu').stop('true', 'true').slideToggle('slow'); 
                        $('.header_menu ul li.megamenu').toggleClass( 'active' );
    });
    
        //Image Banner Rotator
        //Setting up the var's
        var onscreendelay     = 5000; // How long the image stays onscreen for.
        var fadein              = 1000; // How long the image takes to fade in.
        var clicked_delay     = 10000; // How long the system waits after a dot was clicked before it startes the timmer again.
        var scroll_loop        = 10000; //How long the timmer waits before its starts the next loop
        var i                   = 1; // Var for the current count in the system.
        
        // Add the UL structor to the page
        $('.carousel-item-count .item-holder').append('<ul></ul><div class="clr"></div>');
        
        //Fill the UL with an LI for each image present 
        var countz = 0;
        $('.carousel .carousel-item').each(function () {
                                                     if(countz == 0){
                                                         $('.carousel-item-count .item-holder ul').append('<li class="active">&bull;</li>');
                                                         countz++;
                                                         }
                                                     else {
                                                           $('.carousel-item-count .item-holder ul').append('<li>&bull;</li>');
                                                     }
                               })
        
        
        //The rotating function
        function scrollimg() {
            //alert('starting');
            $('.carousel .carousel-item:visible').stop(true, true).fadeOut('slow',function(){
                        $('.carousel .carousel-item').eq(i-1).stop(true, true).fadeIn(fadein);
                        $('.carousel-item-count .item-holder ul li.active').removeClass('active');
                        $('.carousel-item-count .item-holder ul li').eq(i-1).addClass('active');
                    });            
            if (++i > $('.carousel .carousel-item').size()) i = 1;
            
        };
        
        // The DOTS click function
        $('.carousel-item-count .item-holder ul li').click(function(){
                                            
                                            //remove the active class from the li of the currently active 
                                            $('.carousel-item-count .item-holder ul li.active').removeClass('active');
                                            $('.carousel-item-count .item-holder ul li').eq($('.carousel-item-count .item-holder ul li').index(this)).addClass('active');
                                            //set the var for what num was clicked
                                            var clicked = $('.carousel-item-count .item-holder ul li').index(this);
                                            //Stop the scroller from running ny more loops
                                            clearInterval(scroll_img);
                                            
                                            //fade the current image away
                                            $('.carousel .carousel-item:visible').stop(true, true).fadeOut('fast', function(){
                                                
                                                //Set the var i to be the next image in the set
                                                i = clicked + 1;
                                                
                                                //fade in the clicked dot's corasponding image and start the timer after a set amount of time.
                                                $('.carousel .carousel-item').eq(clicked).fadeIn('slow').delay(3000,doscroll());
                                                function doscroll(){
                                                scroll_img = setInterval(scrollimg, scroll_loop)
                                                }                                                
                                                });
                                            
                                           });
        //start the rotator
        scroll_img = setInterval(scrollimg, scroll_loop);
});
 
function popupdiv(num){
    //var pageDivs = new Array('header', 'topNav', 'navHeader', 'navigation','flashArea', 'footerWrapper');
    //for (var aa = 0; aa < pageDivs.length; aa++) {
    //document.getElementById(pageDivs[aa]).style.opacity = val/100;
    //document.getElementById(pageDivs[aa]).style.filter = 'alpha(opacity='    +val+ ')';
    //document.getElementById(pageDivs[aa]).style.MozOpacity = val/100;
    //}
    
    var val = 50;
    var x,y;
    try {
    /*if (self.innerHeight) { // all except Explorer
    x = self.innerWidth;
    y = self.innerHeight;
    }
    else if (document.documentElement &&
    document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
    {
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
    x = document.body.clientWidth;
    y = document.body.clientHeight;
    }*/
    if( window.innerHeight && window.scrollMaxY ) { // Firefox
    pageWidth = window.innerWidth + window.scrollMaxX;
    pageHeight = window.innerHeight + window.scrollMaxY;
    }
    else if( document.body.scrollHeight > document.body.offsetHeight ) { //    all but Explorer Mac
    pageWidth = document.body.scrollWidth;
    pageHeight = document.body.scrollHeight;
    }
    else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
    pageWidth = document.body.offsetWidth + document.body.offsetLeft;
    pageHeight = document.body.offsetHeight + document.body.offsetTop;
    }
    //alert("Page Height: " + pageHeight + "\nOffset: " + document.body.offsetHeight);
    
    //Set the position for the hover box
    //var yy = document.body.offsetHeight;
    
    var yy = document.body.offsetWidth / 2;
    var posx = yy - 390;
    document.getElementById('overlay' + num).style.height = pageHeight+"px";
    document.getElementById('overlay-content' + num).style.height = "450px";
    document.getElementById('overlay-content' + num).style.left = posx+"px";
    document.getElementById('overlay-content' + num).style.top = "100px";
    } catch(e) {}
    //alert(document.getElementById('wrapper').style.height);
    //alert(document.body.offsetHeight);
    document.getElementById('overlay' + num).style.display = "block";
    document.getElementById('overlay' + num).style.opacity = val/100;
    document.getElementById('overlay' + num).style.filter = 'alpha(opacity=' +val+ ')';
    document.getElementById('overlay' + num).style.MozOpacity = val/100;
    document.getElementById('overlay-content' + num).style.display = "block";
}
function closeoverlay(num){
        document.getElementById('overlay-content' + num).style.display = "none";
        document.getElementById('overlay' + num).style.display = "none";
        document.getElementById('overlay-content' + num).innerHTML = "";
}
function cleartxt(element) {
    var checker = element.value;
    if(checker == "Search TechSmith.com"){
        element.value = "";
    }
}
function replacetxt(element) {
    var checker = element.value;
    if(checker == ""){
        element.value = "Search TechSmith.com";
    }
}
// For switching the site lang
function dropdownRedirect(dropdown)
{
    var myindex  = dropdown.selectedIndex
    window.location.href = dropdown.options[myindex].value;
    return true;
}
function fixOrderedListElement( elem )
{
    var tmpContent = $(elem).html();
    $(elem).empty();
    $(elem).html('&nbsp;<span>' + tmpContent + '</span>');
}
$(document).ready(function() {
        
            $('body').removeClass('no-js'); // Allows for controlled styles if JS is disabled or broken.

            $('ol.blue li').each(function() { fixOrderedListElement( this ); });
            $('ol.black li').each(function() { fixOrderedListElement( this ); });
            $('ol.blue ol li').each(function() { fixOrderedListElement( this ); });
            $('ol.black ol li').each(function() { fixOrderedListElement( this ); });
            $('ol.blue').each(function() { $(this).removeClass('blue').addClass( 'blue-bullets' ); });
            $('ol.black').each(function() { $(this).removeClass('black').addClass( 'black-bullets' ); });
            
        });
