﻿/**
* 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:300,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);






var siteId = 0;

$(document).ready(
    function(){		
        
        /* QUICK LINKS */
        $('#quicklinks .button').click(function(){
            $('.linksPanel').slideToggle(200);
        })         
        
        /* MAIN NAVIGATION START */
        var previousMenu=null;
	
	    $('.sideNavDropMenu').slipnslide({'speed':100,'autoHide':true,'memory':true});
	    $('.dropMenu').slipnslide({'speed':100,'autoHide':true,'dropDown':true});
		$('.dropDown').click(function(){
			if (previousMenu) {
				$(previousMenu).find('.dropMenu').hide(200);
				$(previousMenu).find('.dropMenu').trigger('resetMenu');
				if (previousMenu!=this){
					previousMenu=this;
					$(this).find('.dropMenu').show(200);
				}else{
					previousMenu=null;
				}
			}else{
				previousMenu=this;
				$(this).find('.dropMenu').show(200);
			}
		}); 
		
		$('.topMenu').hover(function(){
			$('.dropDown').find('.dropMenu').hide(50);
			previousMenu=null;
			$('.dropDown').find('.dropMenu').trigger('resetMenu');
		},function(){});

		$('#topBar').hover(function(){
			$('.dropDown').find('.dropMenu').hide(50);
			previousMenu=null;
			$('.dropDown').find('.dropMenu').trigger('resetMenu');
		},function(){});

	    /* MAIN NAVIGATION END */
	    
	    /* HOMEPAGE PROMO START */
	    var site = '';
	    switch(siteId)
	    {
	        case '1':
	            site = 'columbus_zoo';
				$("#shopping_cart").attr("url","Cart-CZ_Green.swf");	
	            break;
	            
	        case '2':
	            site = 'zoombezi_bay';
				$("#shopping_cart").attr("url","Cart-CZ_Blue.swf");	
	            break;
	        
	        case '3':
	            site = 'safari_golf';
	            break;
	            
	        case '6':
	            site = 'contribute';
	            break;
	                
	        default:
	            site = 'columbus_zoo';
	            break;
	    }



	    $('#promoSlider').slidepanel({ pause: 15, autosize: false, autoPlay: true, prevBtn: '.prevPromo', nextBtn: '.nextPromo', loop: true, trans: 'slide', transSpeed: 2500 });
	    $('.promoInfo').each(function(){
		    $(this).after("<img class='toggleBox' src='/assets/images/" + site + "/plus.gif' style='position:absolute; top:10px;right:10px;'/>");
	    });
	    $('.toggleBox').click(function(){
		    $(this).prev('.promoInfo').slideToggle(200);
	    });
        
	    /* HOMEPAGE PROMO END */
	    
	    /* HOMEPAGE NEWSTICKER START */
	    $('#ticker').fadeIn("slow");
	    $('#ticker').slidepanel({});
	    /* HOMEPAGE NEWSTICKER END */
	    
	    /* HOMEPAGE MAIN IMG START */
	    
	    var current=0;
		var images=$("#theimage ul:first").find('li');
		var tabsPlay=true;
		
		$('.tabs h3').click(function(){ 
			var index=($('.tabs li').index($(this).parent()));
			current=index;
			tabsPlay=false;
			$('#tabTimer').stop();
			loadSlide();
		});
		$('#mainImage').hoverIntent(function(){$('#tabMenu').animate({width:270});},function(){$('#tabMenu').animate({width:0});})
		
		function loadSlide(){
			$(images).fadeOut(1000);
			$(images[current]).stop(true);
			$(images[current]).fadeIn(1000);
			var temp=$(($('.tabs li'))[current]).find('h3');
			$("#imgContent").html("<h3>" + $(temp).html() + "</h3>" +$(temp).next().html());
			$('.tabs li').removeClass('selected');
			$(($('.tabs li'))[current]).addClass('selected');
			
			if (tabsPlay){
				$('#tabTimer').fadeTo(5000,0,function (){
					current++;
					if (current>=images.length){
						current=0;
						loadSlide(current);
					}else{
						loadSlide(current);
					}
				});
			};
		}
		
		loadSlide();
			
	    $('#tabMenu').toggle(function(){
		    $(this).animate({
			    width:0
		    });
	    },function(){
		    $(this).animate({
			    width:270
		    });
	    });
	    
	    $('.tabs li').click(function(){
		    return false;
	    });	  
	    
	    $('.tabs a').click(function(){
		    window.location = $(this).attr("href");
		    return false;
	    });  	    
	    
	    //$("#imgContent").animate({opacity:4},1000);
	    /* 
	    
	    $('.tabs h3').click(function(){	         
	        
		    $("#imgContent").html("<h3>" + $(this).html() + "</h3>" +$(this).next().html());	
		    $(".tabs li").removeClass("selected");    
		    $(this).parent().addClass("selected"); 
		    var mySource = $(this).find("span").html();
		    $("#theimage img").attr("src",mySource);
	    }); */
	    
	    /* HOMEPAGE MAIN IMG END */
	    
	     //preselect main menu icon dependent on site
	    $("#zooTab"+siteId).addClass("preselectMenuItem");
	    
	    
	    
	    
	    /* MISC */
	    $(".default-value").show();
	    
	    $('.bigHeaderImageTitle').mouseover(function(){
		    $(this).fadeOut("fast");		    
	    }); 
	    
	    $('#bigHeaderImage').mouseleave(function(){
		    $('.bigHeaderImageTitle').fadeIn("fast");		    
	    });
	    
	    $("#hotbuttons a").easyTooltip(); //{xOffset:"1",yOffset:"2"}
	    $(".tn").css("border","solid 1px #999");
	
		/* for into the wild hotlinks in bg image */
	    $("#czoo").click(function(){	        
			window.open('http://www.columbuszoo.org');
	    }); 
		$("#nationwide").click(function(){	        
			window.open('http://www.nationwide.com');
	    }); 
		
		 $(".searchBoxInput").keypress(function(event){		    
		    if (event.keyCode == '13') {
		        event.preventDefault();
		        $(".searchButton").click();                
               }		       
	    });    
		
    }		    
    
);

