/*
 * teldon.js
 * Requires jquery 1.4.4+
 */

var teldon = {
    init: function () {
        $(document).ready(function () {
            /* Display menus' content block on hover events, with a delay of 200ms */
            $("#nav ul.menu li").hoverIntent({
                over: displayMenuBlock,
                timeout: 200,
                out: hideMenuBlock
            });

            function displayMenuBlock() {
                $(this).find("a:not(.mblock a)").addClass("hover");
                $(this).find(".mblock").slideDown(); /*.show();*/
            }

            function hideMenuBlock() {
                $(this).find("a:not(.mblock a)").removeClass("hover");
                $(this).find(".mblock").slideUp(); /*.hide();*/
            }

            $("#alive-img-right-arrow").click(function () {
                if ($aliveimgleft != -351) {
                    $aliveimgleft -= 351;
                    $("#alive-img").animate({ "left": "-=351px" }, "slow");
                }
                return false;
            });

            $("#alive-img-left-arrow").click(function () {
                if ($aliveimgleft != 0) {
                    $aliveimgleft += 351;
                    $("#alive-img").animate({ "left": "+=351px" }, "slow");
                }
                return false;
            });

            $("#thrive-img-right-arrow").click(function () {
                if ($thriveimgleft != -351) {
                    $thriveimgleft -= 351;
                    $("#thrive-img").animate({ "left": "-=351px" }, "slow");
                }
                return false;
            });

            $("#thrive-img-left-arrow").click(function () {
                if ($thriveimgleft != 0) {
                    $thriveimgleft += 351;
                    $("#thrive-img").animate({ "left": "+=351px" }, "slow");
                }
                return false;
            });

            $("#aliveaus-img-right-arrow").click(function () {
                if ($aliveausimgleft != -351) {
                    $aliveausimgleft -= 351;
                    $("#aliveaus-img").animate({ "left": "-=351px" }, "slow");
                }
                return false;
            });

            $("#aliveaus-img-left-arrow").click(function () {
                if ($aliveausimgleft != 0) {
                    $aliveausimgleft += 351;
                    $("#aliveaus-img").animate({ "left": "+=351px" }, "slow");
                }
                return false;
            });

            $("#retailer-img-right-arrow").click(function () {
                if ($retailerimgleft != -351) {
                    $retailerimgleft -= 351;
                    $("#retailer-img").animate({ "left": "-=351px" }, "slow");
                }
                return false;
            });

            $("#retailer-img-left-arrow").click(function () {
                if ($retailerimgleft != 0) {
                    $retailerimgleft += 351;
                    $("#retailer-img").animate({ "left": "+=351px" }, "slow");
                }
                return false;
            });

            $("#academy-img-right-arrow").click(function () {
                if ($academyimgleft != -351) {
                    $academyimgleft -= 351;
                    $("#academy-img").animate({ "left": "-=351px" }, "slow");
                }
                return false;
            });

            $("#academy-img-left-arrow").click(function () {
                if ($academyimgleft != 0) {
                    $academyimgleft += 351;
                    $("#academy-img").animate({ "left": "+=351px" }, "slow");
                }
                return false;
            });

        });
    },

    showPreview: function (url) {
        if (url != "") {
            window.open(unescape(url), "Preview", "width=940,height=800,scrollBars=yes,toolbar=no,resizable=yes");
        }
    },

    showBigPreview: function (url) {
        if (url != "") {
            window.open(unescape(url), "Preview", "width=1080,height=940,scrollBars=yes,toolbar=no,resizable=yes");
        }
    }

};


teldon.init();
$aliveimgleft = 0;
$thriveimgleft = 0;
$aliveausimgleft = 0;
$retailerimgleft = 0;
$academyimgleft = 0;


/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
