﻿/**
* 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';
				
				$("#twitter-link").attr("href","http://twitter.com/safari_gc");	
	            $("#twitter-link").attr("title","Safari Golf Club Twitter Feed");
	            $("#twitter-link img").attr("alt","Safari Golf Club Twitter Feed");
				
	            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");    
	    	    
	    $(".mainMenuItem").click(function(){
	        document.location = $(this).find("a").attr("href");	        
	    });
	    
	    //preloader("/assets/images/columbus_zoo/Save_Rollover.png",0);
	    $("#save_wildlife").mouseover(function(){
	        $(this).attr("src","/assets/images/columbus_zoo/Save_Rollover.png");	        
	    });
	    $("#save_wildlife").mouseleave(function(){
	        $(this).attr("src","/assets/images/columbus_zoo/Save_Normal.png");	        
	    });
	    
	    /* 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();                
               }		       
	    });  

 /* CONTEST 2010 START */
		
		voteWait();
		
	    $('.chkAgree').click(function(){
	        
	        if( $(this).attr("checked") )
	        {
	            $("#btnAgree").show();
	        }
	        else
	        {
	            $("#btnAgree").css("display","none");
	        }
	        
	    });

$(".youtubeurl").keyup(function(){
	        var lc_url = $(this).val().toLowerCase();
	        //alert($(this).val().indexOf("http://www.youtube.com/watch?v=") );
	        if( lc_url.indexOf("http://www.youtube.com/watch?v=") != 0)
	        {
	            $("#youtubeTestLink").hide();
	        }
	        else
	        {
	            $("#youtubeTestLink").show();
	            $("#youtubeTestLink").attr("href",$(this).val() );
	        }
	    });	

$(".youtubeurl").blur(function(){		

var lc_url = $(this).val().toLowerCase();
	        //alert($(this).val().indexOf("http://www.youtube.com/watch?v=") );
	        if( lc_url.indexOf("http://www.youtube.com/watch?v=") != 0)
	        {
	            $("#youtubeTestLink").hide();
	        }
	        else
	        {
	            $("#youtubeTestLink").show();
	            $("#youtubeTestLink").attr("href",$(this).val() );
	        }
			
		});
    }		    
    
);

function load(){
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

function voteWait(){
    $(".vote_item, .vote_item_alt").click(function(){        
	        $(this).html("<img src='/assets/images/shared/indicator_medium.gif' title='please wait...' style='position:absolute; left: 130px; top; 60px;' />");	       
	    });
	    $('.vote_item a, .vote_item_alt a').click(function(event){
	        event.preventDefault();
	    });
}


$.getDocHeight = function(){
    return Math.max(
        $(document).height(),
        $(window).height(),
        /* For opera: */
        document.documentElement.clientHeight
    );
};

function ContestStartup()
{   
    $('.contest_overlay').height( $.getDocHeight() );
    $('.contest_conditions').centerInClient({ container: window, forceAbsolute: true });
    $('.contest_conditions').css("top","90px");
    
    
    $(".contest_conditions").show();
        
//    var modal = "<div class='fade_message'></div><div id='fade_message' title='click to close'><img id='fade_close' src='/assets/images/admin/closebutton.png' alt='close' /><div id='fade_message_text'></div></div>";
//    var o = $.meta ? $.extend({}, opts, $(this).data()) : opts;

//    $(this).prepend(msgHtml);
}

function agree()
{
    if( $('.chkAgree').attr("checked") )
    {
        $(".contest_overlay").css("display","none");
        $(".contest_conditions").css("display","none");
        $("#ctl00_ctl00_mainContent_txtFirstName_inputTextBox").focus();
		$.scrollTo(200);
    }    
    
}

