﻿/*!
* Heelys java library v1.0.0
*
* Use for Heelys Website custom java functions
* 
* Created By: L Ashbrook (1-26-2010)
* Last Updated: 1-26-2010
*
*/

function sitemenuMegaHoverOver() {
    
    newItemWidth = 0;
    if ($(this).data('origWidth')) {
        //Data element exist
        newItemWidth = $(this).data('origWidth') + 30;
    }
    else {
        $(this).data('origWidth', $(this).width());
        newItemWidth = $(this).width() + 30;
    }
    //$(this).find(".sitemenutopitem").stop().animate({ width: newItemWidth }, 300);
    //$(this).find(".sitemenusubitems").stop().slideDown('fast').show();
    $(this).find(".sitemenusubitems").stop().fadeTo('medium', 1).show();
    (function($) {
        //Function to calculate total width of all ul's
        jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            $(this).find("ul").each(function() { //for each ul...
                rowWidth += $(this).width(); //Add each ul's width together
            });
        };
    })(jQuery);

    if ($(this).find(".row").length > 0) { //If row exists...

        var biggestRow = 0;

        $(this).find(".row").each(function() {	//for each row...
            $(this).calcSubWidth(); //Call function to calculate width of all ul's
            //Find biggest row
            if (rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });

        $(this).find(".sitemenusubitems").css({ 'width': biggestRow }); //Set width
        $(this).find(".row:last").css({ 'margin': '0' });  //Kill last row's margin

    } else { //If row does not exist...

        $(this).calcSubWidth();  //Call function to calculate width of all ul's
        $(this).find(".sitemenusubitems").css({ 'width': rowWidth }); //Set Width

    }
}

function sitemenuMegaHoverOut() {
    //$(this).find(".sitemenusubitems").stop().slideUp('fast').show();
    //$(this).find(".sitemenusubitems").stop().fadeTo('fast', 0).show();
    $(this).find(".sitemenusubitems").stop().fadeTo('fast', 0).slideUp('fast').show();
    newItemWidth = 0;
    newItemWidth = $(this).data('origWidth');
    //$(this).find(".sitemenutopitem").stop().animate({ width: newItemWidth }, 200);
}


function FootFilterNavMegaHoverOver() {
    newItemWidth = 0;
    if ($(this).data('origWidth')) {
        //Data element exist
        newItemWidth = $(this).data('origWidth') + 30;
    }
    else {
        $(this).data('origWidth', $(this).width());
        newItemWidth = $(this).width() + 30;
    }
    //$(this).find(".sitemenutopitem").stop().animate({ width: newItemWidth }, 300);
    $(this).find(".subitems").stop().slideDown('medium').show();
    (function($) {
        //Function to calculate total width of all ul's
        jQuery.fn.calcSubWidth = function() {
            rowWidth = 0;
            //Calculate row
            $(this).find("ul").each(function() { //for each ul...
                rowWidth += $(this).width(); //Add each ul's width together
            });
        };
    })(jQuery);

    if ($(this).find(".row").length > 0) { //If row exists...

        var biggestRow = 0;

        $(this).find(".row").each(function() {	//for each row...
            $(this).calcSubWidth(); //Call function to calculate width of all ul's
            //Find biggest row
            if (rowWidth > biggestRow) {
                biggestRow = rowWidth;
            }
        });

        $(this).find(".subitems").css({ 'width': biggestRow }); //Set width
        $(this).find(".row:last").css({ 'margin': '0' });  //Kill last row's margin

    } else { //If row does not exist...

        $(this).calcSubWidth();  //Call function to calculate width of all ul's
        $(this).find(".subitems").css({ 'width': rowWidth }); //Set Width

    }
}

function FootFilterNavMegaHoverOut() {
    $(this).find(".subitems").stop().slideUp('fast').show();
    newItemWidth = 0;
    newItemWidth = $(this).data('origWidth');
    //$(this).find(".sitemenutopitem").stop().animate({ width: newItemWidth }, 200);    
}
