// jQuery SWFObject v1.1.1 MIT/GPL @jon_neal ven bokka
// http://jquery.thewikies.com/swfobject
(function(f, h, i) { function k(a, c) { var b = (a[0] || 0) - (c[0] || 0); return b > 0 || !b && a.length > 0 && k(a.slice(1), c.slice(1)) } function l(a) { if (typeof a != g) return a; var c = [], b = ""; for (var d in a) { b = typeof a[d] == g ? l(a[d]) : [d, m ? encodeURI(a[d]) : a[d]].join("="); c.push(b) } return c.join("&") } function n(a) { var c = []; for (var b in a) a[b] && c.push([b, '="', a[b], '"'].join("")); return c.join(" ") } function o(a) { var c = []; for (var b in a) c.push(['<param name="', b, '" value="', l(a[b]), '" />'].join("")); return c.join("") } var g = "object", m = true; try { var j = i.description || function() { return (new i("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version") } () } catch (p) { j = "Unavailable" } var e = j.match(/\d+/g) || [0]; f[h] = { available: e[0] > 0, activeX: i && !i.name, version: { original: j, array: e, string: e.join("."), major: parseInt(e[0], 10) || 0, minor: parseInt(e[1], 10) || 0, release: parseInt(e[2], 10) || 0 }, hasVersion: function(a) { a = /string|number/.test(typeof a) ? a.toString().split(".") : /object/.test(typeof a) ? [a.major, a.minor] : a || [0, 0]; return k(e, a) }, encodeParams: true, expressInstall: "expressInstall.swf", expressInstallIsActive: false, create: function(a) { if (!a.swf || this.expressInstallIsActive || !this.available && !a.hasVersionFail) return false; if (!this.hasVersion(a.hasVersion || 1)) { this.expressInstallIsActive = true; if (typeof a.hasVersionFail == "function") if (!a.hasVersionFail.apply(a)) return false; a = { swf: a.expressInstall || this.expressInstall, height: 137, width: 214, flashvars: { MMredirectURL: location.href, MMplayerType: this.activeX ? "ActiveX" : "PlugIn", MMdoctitle: document.title.slice(0, 47) + " - Flash Player Installation"}} } attrs = { data: a.swf, type: "application/x-shockwave-flash", id: a.id || "flash_" + Math.floor(Math.random() * 999999999), width: a.width || 320, height: a.height || 180, style: a.style || "" }; m = typeof a.useEncode !== "undefined" ? a.useEncode : this.encodeParams; a.movie = a.swf; a.wmode = a.wmode || "opaque"; delete a.fallback; delete a.hasVersion; delete a.hasVersionFail; delete a.height; delete a.id; delete a.swf; delete a.useEncode; delete a.width; var c = document.createElement("div"); c.innerHTML = ["<object ", n(attrs), ">", o(a), "</object>"].join(""); return c.firstChild } }; f.fn[h] = function(a) { var c = this.find(g).andSelf().filter(g); /string|object/.test(typeof a) && this.each(function() { var b = f(this), d; a = typeof a == g ? a : { swf: a }; a.fallback = this; if (d = f[h].create(a)) { b.children().remove(); b.html(d) } }); typeof a == "function" && c.each(function() { var b = this; b.jsInteractionTimeoutMs = b.jsInteractionTimeoutMs || 0; if (b.jsInteractionTimeoutMs < 660) b.clientWidth || b.clientHeight ? a.call(b) : setTimeout(function() { f(b)[h](a) }, b.jsInteractionTimeoutMs + 66) }); return c } })(jQuery, "flash", navigator.plugins["Shockwave Flash"] || window.ActiveXObject);

$(function () {
    browser();
    var timeToOpen = 400; // 1500 = 1.5 seconds this is the time that a user needs to sit on the nav link before drop down menus open.
    var timeToClose = 125; // 750= 0.75 seconds this is the time after a user rolls off a menu before it closes.
    var hoverTimer = {};
    var fadeTimer = {};
    var $nav = $('ul.nav'); //WARNING: This modification is needed and must not be removed when merging (Needed to work when having 2 top menues)
    var $nav1 = $('.nav1'); //WARNING: This modification is needed and must not be removed when merging (Needed to work when having 2 top menues)
    $nav.children('li').hover(function () {
        MainMenu.ShowSubmenu(this, hoverTimer, fadeTimer);
    }, function () {
        MainMenu.HideSubmenu(hoverTimer, fadeTimer);
    });
    $(window).unload(function (hoverTimer, fadeTimer) {
        $('li.hoverIt', $nav).children('ul').css('display', 'none');
        $nav.children('li').removeClass('hoverIt').removeClass('closeIt')
        $.clearTimer(fadeTimer);
        $.clearTimer(hoverTimer);
    });

    /* Contact Support Dropdown */
    $("#contactSupport").hover(function () {
        $("div.slidePanel").animate({ opacity: "show" }, "fast");
        $('h3').addClass("active");
    }, function () {
        $("div.slidePanel").animate({ opacity: "hide" }, "fast");
        $('h3').removeClass("active");
    });

    /* community Home */
    showObjects = $('.showObjects');

    if (showObjects.length) {
        var objects = $('div.objects');
        var addStuff = $('div.addStuff');
        var objectsUl = showObjects.children('ul');

        $('a', addStuff).click(function () {
            addStuff.css('display', 'none');
            objects.css('display', 'block');
        });

        $('a.close', objects).click(function () {
            objects.css('display', 'none');
            addStuff.css('display', 'block');
        });

        lis = objectsUl.children('li');
        liWidth = parseInt(lis.css('width'));
        liMarginRight = parseInt(lis.css('margin-right'));
        ulWidth = lis.length * (liWidth + liMarginRight);
        objectsUl.width(ulWidth);
        $('a.leftArrow', objects).click(function () {
            clickArrow('previous');
            return false;
        });

        $('a.rightArrow', objects).click(function () {
            clickArrow('next');
            return false;
        });
        var showObjectsWidth = parseInt(showObjects.css('width'));
        var position = objectsUl.position();
        var totalLiWidth = liWidth + liMarginRight;
        var move = showObjectsWidth / totalLiWidth;
        var ulLength = ulWidth;
        var maxMove = ((ulLength - showObjectsWidth) * (-1)) + totalLiWidth;
        var moveToX = 0;
        var currentML;
        function clickArrow(direction) {
            currentML = parseInt(objectsUl.css('margin-left'));
            x = 1;
            var cml = currentML;

            while (x < (move + 1)) {
                if (direction == 'previous') {
                    if (moveToX < 0) {
                        moveToX = (cml += totalLiWidth);
                    }
                } else if (direction == 'next') {
                    if (moveToX > maxMove) {
                        moveToX = (cml -= totalLiWidth);
                    }
                }
                x += 1;
            }
            objectsUl.animate({ marginLeft: moveToX }, 500
							, function () {
							    currentML = parseInt(objectsUl.css('margin-left'));
							});
            return false;
        }
    }

    /* end Community Home */

    /* portlet code */
    removeButton = $('a.remove');
    removeButton.each(function () {
        $(this).after('<div class="delete">Delete widget</div>');
    });
    removeButton.hover(function () {
        $(this).next().css('visibility', 'visible');
    }, function () {
        $(this).next().css('visibility', 'hidden');
    });

    if ($('body').hasClass('msie6PC')) {
        // code for IE6 in ie6.js
    } else {
        $('a.closeCollapsable').toggle(function () {
            $(this).closest('div.portlet').addClass('closing');
            $(this).addClass('openCollapsable').removeClass('closeCollapsable').parent().parent().parent().children('div.collapsableOpen').slideUp('normal', function () { $('div.closing').addClass('closed').removeClass('closing') }).addClass('collapsableClosed').removeClass('collapsableOpen');
            return false;
        }, function () {
            $(this).addClass('closeCollapsable').removeClass('openCollapsable').parent().parent().parent().children('div.collapsableClosed').slideDown().addClass('collapsableOpen').removeClass('collapsableClosed');
            $(this).closest('div.portlet').removeClass('closed');
            return false;
        });

        $('a.openCollapsable').toggle(function () {
            $(this).addClass('closeCollapsable').removeClass('openCollapsable').parent().parent().parent().children('div.collapsableClosed').slideDown().addClass('collapsableOpen').removeClass('collapsableClosed');
            $(this).closest('div.portlet').removeClass('closed');
            return false;
        }, function () {
            $(this).addClass('openCollapsable').removeClass('closeCollapsable').parent().parent().parent().children('div.collapsableOpen').slideUp().addClass('collapsableClosed').removeClass('collapsableOpen');
            $(this).closest('div.portlet').addClass('closed');
            return false;
        });

        /*********************************************/
        /* Added as didn't work after AJAX poastback */
        /*********************************************/
        $('a.closeCollapsable').live('click', function () {
            $(this).toggle(function () {
                $(this).closest('div.portlet').addClass('closing');
                $(this).addClass('openCollapsable').removeClass('closeCollapsable').parent().parent().parent().children('div.collapsableOpen').slideUp('normal', function () { $('div.closing').addClass('closed').removeClass('closing') }).addClass('collapsableClosed').removeClass('collapsableOpen');
                return false;
            }, function () {
                $(this).addClass('closeCollapsable').removeClass('openCollapsable').parent().parent().parent().children('div.collapsableClosed').slideDown().addClass('collapsableOpen').removeClass('collapsableClosed');
                $(this).closest('div.portlet').removeClass('closed');
                return false;
            });
        });

        $('a.openCollapsable').live('click', function () {
            $(this).toggle(function () {
                $(this).addClass('closeCollapsable').removeClass('openCollapsable').parent().parent().parent().children('div.collapsableClosed').slideDown().addClass('collapsableOpen').removeClass('collapsableClosed');
                $(this).closest('div.portlet').removeClass('closed');
                return false;
            }, function () {
                $(this).addClass('openCollapsable').removeClass('closeCollapsable').parent().parent().parent().children('div.collapsableOpen').slideUp().addClass('collapsableClosed').removeClass('collapsableOpen');
                $(this).closest('div.portlet').addClass('closed');
                return false;
            });
        });
        /*********************************************/

    }
    /* end portletCode */

    imgHint = $('img.hint');
    if (imgHint.length) {
        imgHint.each(function () {
            var text = $(this).attr('alt');
            $(this).after('<div class="hinttop"><div class="hintbottom">' + text + '</div></div>');
        });

        imgHint.hover(function () {
            $(this).next().css('visibility', 'visible');
            var getHeight = parseInt($(this).next().height()) * (-1) + 20;
            $(this).next().css('top', getHeight);
        }, function () {
            $(this).next().css('visibility', 'hidden');
        });
    }


    $('a.register').click(function () {
        $('#register').modal({ containerCss: { width: '500px', height: '370px'} });
        return false;
    });

    if ($('html').hasClass('msie7') == false) {
        $('a.inviteMember').click(function () {
            modalHeight = $(window).height() - 30;
            $('#inviteMember').modal({ containerCss: { width: '655px', height: '600px'} });
            return false;
        });
    }

    swapValues = [];
    $(".swap").each(function (i) {
        swapValues[i] = $(this).val();
        $(this).focus(function () {
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function () {
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });

    $('#sub-nav > ul > li > a > span').each(function () {
        var lines = $(this).height();
        if (lines < 16) {
            $(this).parent().addClass('lines1');
        } else if (lines < 29) {
            $(this).parent().addClass('lines2');
        } else if (lines < 42) {
            $(this).parent().addClass('lines3');
        } else if (lines < 56) {
            $(this).parent().addClass('lines4');
        }

    });

    $('#country > a').click(function () {
        if ($(this).siblings('div').hasClass('closed')) {
            $(this).siblings('div').css('display', 'block').removeClass('closed');
        } else {
            $(this).siblings('div').css('display', 'none').addClass('closed');
        }
        return false;
    });

    $('#countrySelect > a').click(function () {
        var cc = $(this).attr('title');
        $('#currentCountry').text(cc);
        $(this).parent().slideUp().addClass('closed');
    });

    var $accordion = $('#accordion');
    if ($accordion.length) {
        $('h3 a span', $accordion).each(function () {
            if ($(this).height() > 18) {
                $(this).closest('h3').addClass('double');
            }
        });

        $('h3 a', $accordion).click(function () {
            $accordion.accordion({ autoHeight: false });
            $accordion.children('h3').children('a').removeClass('open');
            $(this).addClass('open');
            //// TODO: Revisit this: Sai
            ////            var currentheader = $(this).parent('h3');
            ////            var currentcontentdiv = null;
            ////            if (currentheader != undefined && currentheader != null) {
            ////                currentheader.children('span').remove();
            ////                currentcontentdiv = currentheader.next('div');
            ////                currentheader.removeAttr('class');
            ////                currentheader.removeAttr('style');
            ////                if (currentcontentdiv != undefined && currentcontentdiv != null) {
            ////                    currentcontentdiv.removeAttr('class').attr('class', 'open');
            ////                    currentcontentdiv.removeAttr('style');
            ////                }
            ////            }
            ////
        });
    }

    var $accordion1 = $('.accordion');
    if ($accordion1.length) {
        $('h3 a span', $accordion1).each(function () {
            if ($(this).height() > 18) {
                $(this).closest('h3').addClass('double');
            }
        });

        $('h3 a', $accordion1).click(function () {

            //WARNING: Do not change this when merging a new batchs, it's needed for the pages which have more than one accordion
            var $acc = $ektron(this).parents('.accordion');
            $acc.accordion({ autoHeight: false });
            $acc.children('h3').children('a').removeClass('open');
            $(this).addClass('open');
        });

    }

    var $tabs = $('div.tabs');
    if ($tabs.length) {
        $tabs.tabs();
    }

    var author = $('div.author a.author');
    if (author.length) {
        author.toggle(function () {
            $(this).closest('div.author').addClass('showAuthor');
            return false;
        }, function () {
            $(this).closest('div.author').removeClass('showAuthor');
            return false;
        });


    }

    ///----------------------------------------------------
    /// Necessary to have tabs working on AJAX postback
    ///----------------------------------------------------
    try {
        var rqstManager = Sys.WebForms.PageRequestManager.getInstance();
        if (rqstManager != undefined) {
            rqstManager.add_endRequest(function () {
                var $tabs = $('div.tabs');
                if ($tabs.length) {
                    $tabs.tabs();
                }

            });
        }
    }
    catch (err) { };
    ///----------------------------------------------------

    var $secondaryNav = $('#secondary-nav');
    if ($secondaryNav.length) {
        $('li a span', $secondaryNav).each(function () {
            var lines = $(this).height();
            if (lines < 16) {
                $(this).parent().addClass('lines1');
            } else if (lines < 29) {
                $(this).parent().addClass('lines2');
            } else if (lines < 42) {
                $(this).parent().addClass('lines3');
            }
        });
    }

    /*This is for the tabbedwidget*/
    var $tabMenu = $('.tab-menu');
    if ($tabMenu.length) {
        $('li a span', $tabMenu).each(function () {
            var lines = $(this).height();
            if (lines < 16) {
                $(this).parent().addClass('lines1');
            } else if (lines < 29) {
                $(this).parent().addClass('lines2');
            } else if (lines < 42) {
                $(this).parent().addClass('lines3');
            }
        });
    }

    var $solution = $('#solution');
    if ($solution.length) {
        $('img.background', $solution).reflect({ height: 0.2 });
        $('img.flip', $solution).reflect({ height: 0.2 });

        $('ul.solutionNav').children('li').hover(function () {
            $(this).addClass('hover');
        }, function () {
            $(this).removeClass('hover');
        });

        //        $('ul.solutionNav').find('a.item').click(function() {
        //            $('#solution .solutionItem').hide();
        //            var $item = $(this);
        //            var id = $item.attr('value');
        //            $('#solution .solutionItem[value="' + id + '"]').show();

        //            /// Method defined on sifr.js
        //            initialize_sIFR();
        //        });

        $('ul.solutionNav').find('a.item').hover(function () {
            $('#solution .solutionItem').hide();
            var $item = $(this);
            var id = $item.attr('data-ektron-value');
            $('#solution .solutionItem[data-ektron-value="' + id + '"]').show();
            $("#solution .solutionItem").css({ visibility: "visible" });

            /// Method defined on sifr.js
            initialize_sIFR();
        });

        $('ul.solutionNav li div').mouseout(function () {
            ShowFirstSolution();
        });

        $('ul.solutionNav li a').mouseout(function () {
            ShowFirstSolution();
        });

        //    032811 Change - DanO
        //        $('ul.solutionNav').find('a.item').click(function() {
        //            $('#solution .solutionItem').hide();
        //            var $item = $(this);
        //            var id = $item.attr('value');
        //            $('#solution .solutionItem[value="' + id + '"]').show();

        //            /// Method defined on sifr.js
        //            initialize_sIFR();
        //        });



        ShowFirstSolution();
    }

    function ShowFirstSolution() {
        $('#solution .solutionItem').hide();
        $('#solution .solutionItem:first').show();
        $('#solution .solutionItem').addClass('showMe');
    }

    var $mpStars = $('span.rating');
    if ($mpStars.length) {
        $mpStars.each(function () {
            $ar = $(this).children('span');
            var arWidth = 95 * (parseFloat($ar.attr('class')) / 5);
            $ar.css('width', arWidth);
        });
    }

    var $starRating = $('#starRating');
    if ($starRating.length) {

        $ar = $starRating.children('p').children('a').children('span');
        var arWidth = 94 * (parseFloat($ar.attr('class')) / 5);
        $ar.css('width', arWidth);
        $('a.rating').click(function () {
            $('#ratingBox').modal();
            return false;
        });
    }

    var $ratingStars = $('#ratingStars');
    if ($ratingStars.length) {
        $('input.star', $ratingStars).hover(function () {
            $(this).addClass('starhover');
            $(this).prevAll().addClass('starhover');
        }, function () {
            $(this).removeClass('starhover');
            $(this).prevAll().removeClass('starhover');
        });
    }
    var $rtNumbers = $('#rtNumbers');
    if ($rtNumbers.length) {
        $rotatorMove = $('#rotatorMove');
        theWidth = $rotatorMove.parent().width();
        theLength = $rotatorMove.children('div').length;
        $rotatorMove.width(theWidth * theLength);
        $('img.background', $rotatorMove).reflect({ height: 0.3 });
        var timeToShift = 8000; // 750= 0.75 seconds this is the time after a user rolls off a menu before it closes.
        var shiftTimer = {};
        function timedShift() {
            shiftTimer = $.timer(timeToShift, function () {
                which = $('li.active', $rtNumbers).prevAll().length;
                whichOne = which + 1
                $rtNumbers.children('li').removeClass('active');

                if (whichOne == theLength) {
                    $rotatorMove.animate({ marginLeft: 0 }, 250, 'easeOutSine');
                    $rtNumbers.children('li:eq(0)').addClass('active');
                } else {

                    $rtNumbers.children('li:eq(' + whichOne + ')').addClass('active');
                    $rotatorMove.animate({ marginLeft: (theWidth * whichOne) * (-1) }, 250, 'easeOutSine');
                }
                $.clearTimer(shiftTimer);
                timedShift();
            });
        }
        timedShift();

        $('li a', $rtNumbers).hover(function () {
            $(this).parent().addClass('hover');
        }, function () {
            $(this).parent().removeClass('hover');
        });

        $('li a', $rtNumbers).click(function () {
            $.clearTimer(shiftTimer);
            which = $(this).parent().prevAll().length;
            $rtNumbers.children('li').removeClass('active');
            $(this).parent('li').addClass('active');
            $rotatorMove.animate({
                marginLeft: (theWidth * which) * (-1)
            }, 250
				, 'easeOutSine'
				);
            return false;
        });


    }
    $sftl = $('#showftLeft');
    if ($sftl.length) {
        var ftb = $sftl.children('div.ftBackground').length;
        var ftbWidth = parseInt($sftl.children('div.ftBackground').css('width'));
        var ftr = $('#ftRight');
        var totalFt = ftr.children('ul').children('li').length;
        newWidth = parseInt(ftb * ftbWidth);
        $sftl.width(newWidth);


        var timeToSwitch = 4000;
        var switchTimer = {};

        function ftTimer() {
            switchTimer = $.timer(timeToSwitch, function () {
                whichOneActive = $sftl.children('div.active').prevAll().length + 1;
                if (whichOneActive == totalFt) {
                    nextButton();
                } else {
                    nextButton();
                    ftTimer();
                }

            });

        }
        ftTimer();

        function nextButton() {
            whichOneActive = $sftl.children('div.active').prevAll().length + 1;
            showing = 'div.ft' + whichOneActive;
            if (whichOneActive == totalFt) {
                toBeShown = 'div.ft1';
                moveFt(showing, toBeShown, 'next');
            } else {
                toBeShown = 'div.ft' + (whichOneActive + 1);
                moveFt(showing, toBeShown, 'next');
            }
        }

        function moveFt(showing, toBeShown, direction) {
            $showing = $(showing, $sftl);
            $toBeShown = $(toBeShown, $sftl);
            if (direction == 'next') {
                $showing.animate({
                    left: '+=' + (ftbWidth * (-1))
                }, 200);

                $toBeShown.css('left', ftbWidth).animate({
                    left: 0
                }, 200,
				function () {
				    $showing.removeClass('active');
				    $toBeShown.addClass('active');
				});
            } else {
                $showing.animate({
                    left: '-=' + (ftbWidth * (-1))
                }, 200);

                moveItToIt = ftbWidth * (-1);
                $toBeShown.css('left', moveItToIt).animate({
                    left: 0
                }, 200,
				function () {
				    $showing.removeClass('active');
				    $toBeShown.addClass('active');
				});
            }
            whichLi = toBeShown.split('div.ft');
            $('ul li.active', ftr).removeClass('active')
            $('ul li', ftr).eq(parseInt(whichLi[1]) - 1).addClass('active');

        }

        $('#ftArrowRight').click(function () {
            $.clearTimer(switchTimer);
            nextButton();
            return false;
        });

        $('#ftArrowLeft').click(function () {
            $.clearTimer(switchTimer);
            whichOneActive = $sftl.children('div.active').prevAll().length + 1;
            showing = 'div.ft' + whichOneActive;
            if (whichOneActive == 1) {
                toBeShown = 'div.ft' + totalFt;
                moveFt(showing, toBeShown, 'prev');
            } else {
                toBeShown = 'div.ft' + (whichOneActive - 1);
                moveFt(showing, toBeShown, 'prev');
            }
            return false;
        });


        $('a', ftr).click(function () {
            $.clearTimer(switchTimer);
            whichClicked = $(this).parent().prevAll().length + 1;
            whichOneActive = $sftl.children('div.active').prevAll().length + 1;
            showing = 'div.ft' + whichOneActive;
            toBeShown = 'div.ft' + whichClicked;
            if (whichOneActive == whichClicked) {

            } else {
                if (whichOneActive > whichClicked) {
                    direction = 'previous';
                } else {
                    direction = 'next';
                }
                moveFt(showing, toBeShown, direction);
            }

            return false;
        });


        $('img.flip').reflect({ height: 0.3 });
        $('div.flip').css('opacity', 0.6);
        $('#pftLinks div').hover(function () {
            $(this).addClass('hover').children('p').css({ 'opacity': 0, 'margin-left': '-20px', 'display': 'block' }).animate({
                marginLeft: '10px',
                opacity: 1
            }, 500);
            $(this).children('div.flip').css('opacity', 1);

        }, function () {
            $(this).removeClass('hover').children('p').css('display', 'none');
            $('div.flip').css('opacity', 0.6);
        });
    }

    var snc = $('#sub-nav.calendar');
    if (snc.length) {
        var expand = $('a.expand');

        /* Used live function instead of the click as didn't work after AJAX postback */
        expand.live("click", function () {
            $(this).toggleClass('contract').parent().siblings('ul').slideToggle();
            return false;
        });

        $('ul.form > li input:checkbox[aux!=clickoverwritten]').live('click', function () {
            if ($(this).is(':checked')) {
                $(this).parent().find('input:checkbox').attr('checked', 'checked');
            } else {
                $(this).parent().find('input:checkbox').attr('checked', '');
            }
            return true;
        });
        $('ul.form > li > ul > li input:checkbox[aux!=clickoverwritten]').live('click', function () {
            if ($(this).is(':checked')) {
                $(this).closest('li').find('input:checkbox').attr('checked', 'checked');
            } else {
                $(this).closest('li').find('input:checkbox').attr('checked', '');
            }
            return true;
        });
    }

});  


/*functions below add the ability to know what browser and os is being used*/
(function($) { $.browserTest = function(a, z) { var u = 'unknown', x = 'X', m = function(r, h) { for (var i = 0; i < h.length; i = i + 1) { r = r.replace(h[i][0], h[i][1]); } return r; }, c = function(i, a, b, c) { var r = { name: m((a.exec(i) || [u, u])[1], b) }; r[r.name] = true; r.version = (c.exec(i) || [x, x, x, x])[3]; if (r.name.match(/safari/) && r.version > 400) { r.version = '2.0'; } if (r.name === 'presto') { r.version = ($.browser.version > 9.27) ? 'futhark' : 'linear_b'; } r.versionNumber = parseFloat(r.version, 10) || 0; r.versionX = (r.version !== x) ? (r.version + '').substr(0, 1) : x; r.className = r.name + r.versionX; return r; }; a = (a.match(/Opera|Navigator|Minefield|KHTML|Chrome/) ? m(a, [[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/, ''], ['Chrome Safari', 'Chrome'], ['KHTML', 'Konqueror'], ['Minefield', 'Firefox'], ['Navigator', 'Netscape']]) : a).toLowerCase(); $.browser = $.extend((!z) ? $.browser : {}, c(a, /(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/, [], /(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/)); $.layout = c(a, /(gecko|konqueror|msie|opera|webkit)/, [['konqueror', 'khtml'], ['msie', 'trident'], ['opera', 'presto']], /(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/); $.os = { name: (/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase()) || [u])[0].replace('sunos', 'solaris') }; if (!z) { $('html').addClass([$.os.name, $.browser.name, $.browser.className, $.layout.name, $.layout.className].join(' ')); } }; $.browserTest(navigator.userAgent); })(jQuery);
browser = function() {
    var OSName = "Unknown OS";
    var browser = "";
    if (navigator.appVersion.indexOf("Mac") != -1) OSName = "Mac";
    if (navigator.appVersion.indexOf("Win") != -1) OSName = "PC";
    bodyClass = $.browser.className + OSName
    $("body").addClass(bodyClass);

}

jQuery.timer = $ektron.timer = function(time, func, callback) {
    var a = { timer: setTimeout(func, time), callback: null }
    if (typeof (callback) == 'function') { a.callback = callback; }
    return a;
};

jQuery.clearTimer = $ektron.clearTimer = function(a) {
    clearTimeout(a.timer);
    if (typeof (a.callback) == 'function') { a.callback(); };
    return this;
};

var MainMenu = {
    timeToOpen: 400,
    timeToClose: 125,

    ShowSubmenu: function(menuItem, hoverTimer, fadeTimer) {
        $(menuItem).addClass('hoverIt');
        if ($(menuItem).hasClass('closeIt') == true) {
            $(menuItem).removeClass('closeIt');
            $.clearTimer(fadeTimer);
        };
        hoverTimer = $.timer(MainMenu.timeToOpen, function() {
            if ($('.nav1').hasClass('hoverIt')) {
                $('li.hoverIt', $('ul.nav')).children('div').slideDown();
            } else {
                $('li.hoverIt', $('ul.nav')).children('ul').slideDown();
            }
        });
    },
    HideSubmenu: function(hoverTimer, fadeTimer) {
        $.clearTimer(hoverTimer);
        $('li.hoverIt', $('ul.nav')).addClass('closeIt');
        fadeTimer = $.timer(MainMenu.timeToClose, function() {
            if ($('.nav1').hasClass('closeIt')) {
                $('li.closeIt', $('ul.nav')).removeClass('hoverIt').removeClass('closeIt').children('div').slideUp('fast');
            } else {
                $('li.closeIt', $('ul.nav')).removeClass('hoverIt').removeClass('closeIt').children('ul').slideUp('fast');
            }
        });
    }
};

(function (a) { a.fn.extend({ reflect: function (b) { b = a.extend({ height: 0.33, opacity: 0.5 }, b); return this.unreflect().each(function () { var c = this; if (/^img$/i.test(c.tagName)) { function d() { var g = c.width, f = c.height, l, i, m, h, k; i = Math.floor((b.height > 1) ? Math.min(f, b.height) : f * b.height); if (a.browser.msie) { l = a("<img />").attr("src", c.src).css({ width: g, height: f, marginBottom: i - f, filter: "flipv progid:DXImageTransform.Microsoft.Alpha(opacity=" + (b.opacity * 100) + ", style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(i/f*100)+')" })[0] } else { l = a("<canvas />")[0]; if (!l.getContext) { return } h = l.getContext("2d"); try { a(l).attr({ width: g, height: i }); h.save(); h.translate(0, f - 1); h.scale(1, -1); h.drawImage(c, 0, 0, g, f); h.restore(); h.globalCompositeOperation = "destination-out"; k = h.createLinearGradient(0, 0, 0, i); k.addColorStop(0, "rgba(255, 255, 255, " + (1 - b.opacity) + ")"); k.addColorStop(1, "rgba(255, 255, 255, 1.0)"); h.fillStyle = k; h.rect(0, 0, g, i); h.fill() } catch (j) { return } } a(l).css({ display: "block", border: 0 }); m = a(/^a$/i.test(c.parentNode.tagName) ? "<span />" : "<div />").insertAfter(c).append([c, l])[0]; m.className = c.className; a.data(c, "reflected", m.style.cssText = c.style.cssText); a(m).css({ width: g, height: f + i, overflow: "hidden" }); c.style.cssText = "display: block; "; c.className = "reflected" } if (c.complete) { d() } else { a(c).load(d) } } }) }, unreflect: function () { return this.unbind("load").each(function () { var c = this, b = a.data(this, "reflected"), d; if (b !== undefined) { d = c.parentNode; c.className = d.className; c.style.cssText = b; a.removeData(c, "reflected"); d.parentNode.replaceChild(c, d) } }) } }) })(jQuery);


