/**
 * VARIABLES
 *
 */
    var debug = true;

/**
 * CUFON
 *
 * Convert fonts
 */
    
	
	
	
/**
 * ISSET
 *
 * PHP style isset() method for variables and objects.
 */
    function isset(variable)  {
    	try {
    		if(typeof(eval(variable)) != 'undefined')
    		if(eval(variable) != null) return true;
    	} catch(e) {}
    	return false;
    }


/**
 * TRACE
 *
 * Browser safe console logging method.
 */
    function trace(msg) {
        try { window.console.log(msg) } catch (err) {}
    }


/**
 * INIT
 *
 * Init objects
 */
    $(function(){
        //init_menu();
        //init_tooltips();
        init_carousel();
        init_aboutus();
        init_misc();
        setup_video();
        //init_popups();
        //init_gallery();
    

    });
    
    
/**
 * MENU
 *
 * Init menu
 */
    function init_menu() {
        $('#navigation li').hover(function() { 
            $('.dd', this).show(); $(this).addClass('hover'); },
        function() {
            $('.dd', this).hide(); $(this).removeClass('hover');
        });
    }
   
   
/**
 * INIT VIDEO
 *
 */
 
 var _ratio = 1;
 
 function setup_video() {
     if($("video").length >0) {
         init_video();
     }
     
 }
 
 function init_video() {
     
     var _v1 = new MediaElementPlayer("#videoBig video", {
         success: function(video){},
         error: function(){}
     });
     
     var _v2 = new MediaElementPlayer("#videoMed video", {
          success: function(video){},
          error: function(){}
      });
      
      var _v3 = new MediaElementPlayer("#videoSm video", {
           success: function(video){},
           error: function(){}
       });
 }
 
/**
 * ABOUT US
 *
 * Init about us popup
 */
    function init_aboutus() {
        $(".about").css({ opacity: 0 }).show();
        
        $(".about-toggle").live("click", function(){
            if($(this).hasClass("closed")) {
                $(this).html("<span>About Seneca</span>").removeClass("closed");
                $(".about").stop().css({ top:"100%", opacity: 0 });
                $("#carousel .inset").show();
            } else {
                $(this).html("Close").addClass("closed");
                $(".about").animate({ top:0, opacity: 1 }, 750, "easeOutExpo");
                $("#carousel .inset").fadeOut(500);
            }
            return false;
        });
    }
    

/**
 * MISC
 *
 * Init misc stuff
 */
    function init_misc() {
        $(".content .grid-entry a > img").hover(function(){
            $(this).css("opacity", 0.75);
        }, function(){
            $(this).css("opacity", 1);
        });
        
        $(".mobile").click(function(){
            $(this).hide();
            $(".menu").slideDown(750, "easeOutExpo");
        });
     
    }

    
/**
 * TOOLTIPS
 *
 * Init Tooltips
 */
    
    function init_tooltips() {
        $(".tooltip").hover(function() { $(this).append("<div class='tt'><u></u><b>" + $(this).attr("title") + "</b></div>"); }, function() { $(".tt").remove(); });
    }



/**
 * CAROUSEL
 *
 * Init Carousel
 */
     
    function init_carousel() {
        $('#carousel').slides({ 
            effect: "slide", slideSpeed: 500, fadeSpeed: 0, preload: true, preloadImage: 'images/loading.gif',
		    play: 8000, pause: 2500, hoverPause: true, generateNextPrev: false, generatePagination: true  
				 
		});
	 
		
	}

/**
 * POPUP
 *
 * Init popups
 */
                             
	function init_popups() {
	    $("a.popup").fancybox({ 
	        inline: true, overlayOpacity: 0.2, margin:0, padding:0, autoDimensions: false,
            width: 500, overlayColor: "#000000", transitionIn: "fade", transitionOut: "fade", titlePosition: "over" 
        });
    }
                            
                            
/**
 * GALLERY
 *
 * Init Gallery
 */    
    function init_gallery() {
        $("a.gallery").fancybox({ 
            inline: true, overlayOpacity: 0.2, cyclic: true, margin:0, padding:25, 
            overlayColor: "#000000", transitionIn: "elastic", transitionOut: "elastic", titlePosition: "over" 
        });
        $("#gallery li a img").css("opacity", 0.6).hover(function(){ $(this).css("opacity", 1); }, function(){ $(this).css("opacity", 0.6); });
    }
    
    

