jQuery(function($) {

//logo entry
$('#logo').css({'top' : '-175px'});
$('#logo').ready(function(){
	$('#logo').delay(1000).animate({top: '0' }, 1000, 'easeInOutQuint');
});


//button effects
$('.quicklinks ul li').css({'left' : '250px'});
		
		
  $.fn.showdelay = function(){
    var delay = 0;
    return this.each(function(){
      $(this).delay(delay).animate({"left" : "-=250px" });
      delay += 1000;
    });
  };
$('.quicklinks ul li').showdelay();

$('.btn-hover').hover(function(){
		$(this).children('img').stop(true, true).animate({'opacity': 0});
	   }, function(){
		$(this).children('img').stop(true, true).animate({'opacity': 1});
});


$('.button').hover(function(){
	$(this).children('h2').stop(true, true).animate({'bottom': '60px'});
	$(this).find('img').stop(true, true).animate({'opacity': 0.6});
	
	}, function(){
		
	$(this).children('h2').stop(true, true).animate({'bottom': '3px'});
	$(this).find('img').stop(true, true).animate({'opacity': 1});
});

footerHeight();//run this function on page load
	function footerHeight() {
		var windowHeight = $(window).height();
		var containerHeight = $('#container').height();

		$('#footer-wrapper').css('height' , windowHeight - containerHeight);
	}
		$(window).resize(function() {
			footerHeight();//when you resize the window it will run the above function to resize the image container div					  
		});
		
		
//joinus form



var joinusDisplay = 0;

if ($('.joinus-form form p').children().hasClass('error') || $('.joinus-form p').hasClass('successText')){
	$('#join-us').css({'right':'0'});
	$("#join-us .tab").attr("src","images/btns/joinus-close.gif");
	joinusDisplay = 1;

} else {
$('#join-us').css({'right': '-210px'});	


}


	$('.tab').click(function () { 
		if(joinusDisplay == 1) {

			 $('#join-us').animate({right: '-210' }, 1000, 'easeOutQuad');
			 $("#join-us .tab").attr("src","images/btns/joinus.gif");
			 joinusDisplay = 0;
		} else {

			$('#join-us').animate({right: '0' }, 1000, 'easeOutQuad');
			$("#join-us .tab").attr("src","images/btns/joinus-close.gif");


			joinusDisplay = 1;
		}
	});

// for the form to show up in IE6
$('#join-us').css("position", "relative");
$('#join-us').css("position", "absolute");

//FancyBox Lightbox
		
	$("ul.gallery li a").append("<img src='images/magnify.jpg' class='magnify' />");
	$(".magnify").css({"opacity": 0});
	
	$("ul.gallery li a").hover(function(){
		$(this).children(".magnify").stop(true, true).animate({"opacity": 0.77});						
	}, function(){
		$(this).children(".magnify").stop(true, true).animate({"opacity": 0});	
	});



//Select Box Styling

//if (!$.browser.opera) {

        $('select.select').each(function(){
            var title = $(this).attr('title');
            if( $('option:selected', this).val() != ''  ) title = $('option:selected',this).text();
            $(this)
                .css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
                .after('<span class="select">' + title + '</span>')
                .change(function(){
                    val = $('option:selected',this).text();
                    $(this).next().text(val);
                    })
        });

  //  };


//Tooltip
$('.tip_trigger').each(function() {        
        var tip = $(this).find('.tip');

        $(this).hover(
            function() { tip.appendTo('body'); },
            function() { tip.appendTo(this); }
        ).mousemove(function(e) {
            var x = e.pageX + 20,
                y = e.pageY + 20,
                w = tip.width(),
                h = tip.height(),
                dx = $(window).width() - (x + w),
                dy = $(window).height() - (y + h);

            if ( dx < 20 ) x = e.pageX - w - 20;
            if ( dy < 20 ) y = e.pageY - h - 20;

            tip.css({ left: x, top: y });
        });         
    });

});//end jquery

