$(document).ready(function(){

if (document.all&&document.getElementById) {
	globalNavRoot = document.getElementById("globalMenuDropDowns");
	if(globalNavRoot == null)
		return;
	for (i=0; i<globalNavRoot.childNodes.length; i++) {
		node = globalNavRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className+=" over"; 
				}
			node.onmouseout=function() {
			this.className=this.className.replace(" over", "");
			}
		}
	}
}

if (document.all&&document.getElementById&&document.getElementById("animalsMenuDropDowns")!=null) {
	navRoot = document.getElementById("animalsMenuDropDowns");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className+=" over"; 
				}
			node.onmouseout=function() {
			this.className=this.className.replace(" over", "");
			}
		}
	}
}

if(document.getElementById('statusMessage') != null) {
  $('#statusMessage').slideUp();
  windowOpen = false;

   $('#statusMessage')
   .bind('click', function(){
    if(windowOpen == true) {
      $('#statusMessage').slideUp();
	windowOpen = false;
	}
    else {
      $('#statusMessage').slideDown();
      windowOpen = true;
	}
  });
}

if(document.getElementById('welcomeScreen') != null) {
	$('#welcomeScreen').hide();
	$('#welcomeScreen').slideDown();
	}

if(document.getElementById('ap') != null) {
	$('#ap').hide();
	$('#ap').fadeIn();
	}	

$('.myAnimals').hide();
$('.myAnimals').fadeIn();

if(document.getElementById('alertWindow') != null) {
$('#alertWindow')
.bind('click', function(){
	$.ajax({
		type: "GET",
		url: "/alertWindow",
		data: "alert=off",
		success: function(msg){
		alert( "Data Saved: " + msg );
		}
	});
	$('#alertWindow').slideUp();
	});
}

$('.boxgrid.slidedown').hover(function(){
	$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});},
	function() {
	$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
	});

					//Horizontal Sliding
					$('.boxgrid.slideright').hover(function(){
						$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
					}, function() {
						$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
					});
					//Diagnal Sliding
					$('.boxgrid.thecombo').hover(function(){
						$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
					}, function() {
						$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
					});
					//Partial Sliding (Only show some of background)
					$('.boxgrid.peek').hover(function(){
						$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
					}, function() {
						$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
					});
					//Full Caption Sliding (Hidden to Visible)
					$('.boxgrid.captionfull').hover(function(){
						$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
					}, function() {
						$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:160});
					});
					//Caption Sliding (Partially Hidden to Visible)
					$('.boxgrid.caption').hover(function(){
						$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
					}, function() {
						$(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});
					});

});

jQuery.extend({
    dimmerOn: function(speed, opacity, callback) {
        if(jQuery('#__dimScreen').size() > 0) return;
        
        if(typeof speed == 'function') {
            callback = speed;
            speed = null;
        }

        if(typeof opacity == 'function') {
            callback = opacity;
            opacity = null;
        }

        if(speed < 1) {
            var placeholder = opacity;
            opacity = speed;
            speed = placeholder;
        }
        
        if(opacity >= 1) {
            var placeholder = speed;
            speed = opacity;
            opacity = placeholder;
        }

        speed = (speed > 0) ? speed : 500;
        opacity = (opacity > 0) ? opacity : 0.5;
        return jQuery('<div></div>').attr({
                id: '__dimScreen'
                ,fade_opacity: opacity
                ,speed: speed
            }).css({
            background: '#000'
            ,height: '100%'
            ,left: '0px'
            ,opacity: 0
            ,position: 'absolute'
            ,top: '0px'
            ,width: '100%'
            ,zIndex: 999
        }).appendTo(document.body).fadeTo(speed, opacity, callback);
    },
    
    //stops current dimming of the screen
    dimmerOff: function(callback) {
        var x = jQuery('#__dimScreen');
        var opacity = x.attr('fade_opacity');
        var speed = x.attr('speed');
        x.fadeOut(speed, function() {
            x.remove();
            if(typeof callback == 'function') callback();
        });
    }
});


