google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
  var customSearchControl = new google.search.CustomSearchControl('008052520097573842022:rvodsrczjjm');
  customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  customSearchControl.draw('cse');
}, true);



$(document).ready(function() {

    var hashnav = '#academic_programs, #about, #admissions, #support_meca, #alumni, #meca_life, #meca_connect, #news_and_events';
    var hypernav = '.academic_programs, .about, .admissions, .support_meca, .alumni, .meca_life, .meca_connect, .news_and_events';

    
    /* Take care of all window close buttons */
    $('#hyperwindow .close').click(function(){
        $(this).parent().fadeOut("slow");
        $(".navtab_content").hide(); //Hide all content
        $("ul.navtabs li").removeClass("active");
	    $("ul.navtabs li:first-child").addClass("active").show(); //Activate first navtab
	    $(".navtab_container div:first-child").show(); //Show first navtab content
    
    });


    /* Open and close hyperwindows where applicable. */
    $(hashnav).click(function() {
    
        $(".navtab_content").hide(); //Hide all content
        $("ul.navtabs li").removeClass("active");
	    $("ul.navtabs li:first-child").addClass("active").show(); //Activate first navtab
	    $(".navtab_container div:first-child").show(); //Show first navtab content
    
        var targclass = $(this).attr("id");
        targclass = '.' + targclass;
        
        
        $(hypernav).each(function() {
            
            if($(this).attr("class") != targclass) {
            
                $(this).fadeOut("fast");
            } // end if
        
        }); // end each
    
        // open hyperwindow if and only if the hyper window exists in markup
        if($(targclass).length != 0) {
            $(targclass).fadeIn("slow");
            return false;
        }
    });
    


    
    
    
    if(jQuery().cycle) {
    
        $("#slideshow").before('<div id="cycle-pager" class="cycle-pager">').cycle({
        
            speed:   800, 
            timeout: 9000, 
            pause:   0,
            pauseOnPagerHover: 0, 
            pager: '#cycle-pager' 
        
        
        });
        
    } // end if cycle
    


    $("#search, #mailing-form-button").fancybox({
        
        'autoDimensons' : true,
        'autoScale'     : true,
        'scrolling'     : 'no',
        'transitionIn'	:	'fade',
        'transitionOut'	:	'fade',
        'speedIn'		:	600, 
        'speedOut'		:	200, 
        'overlayShow'	:	true, 
        'titlePosition' :   'inside',
        'overlayOpacity':   0.7, 
        'overlayColor'  :   '#000'
                
    });


  
  
    if(jQuery().newsTicker) {
            var options = {
            newsList: "#news",
            tickerRate: 20,
            startDelay: 10,
            placeHolder1: "",
            placeHolder2: ""  }
        $().newsTicker(options);
    }



    if(jQuery().accordion) {
        $('ul#nav-list').accordion();
    }
   

}); // end ready



