/**
 * @author Jason Adkison - Webdesigner, Towerbridge Technologies, LLC
 */
$(document).ready(function(){	
	
	// Login Panel
	$("a#toggleLogin,a#closeLogin").click(function(){
		var panelHeight = $("div#panel").css('height');
		var loginMargin = $("div#panel div#login").css('margin-top');		
		togglePanel(panelHeight,loginMargin); 
		return false;
	});
	
	// Flash messages, click to hide
    $("div.flash a.clickClose").click(function(){
        $(this).parent().animate({top:"+=10px"})
			.animate({top:"-5000px"}, 800, function(){ $(this).remove(); return false; });
			return false;
    });
	
	
    $("#go").click(function(){
      $("#block").animate({ 
        width: "70%",
        opacity: 0.4,
        marginLeft: "0.6in",
        fontSize: "3em", 
        borderWidth: "10px"
      }, 1500 );
    });
	
	
	/* Select the default form text on click */
	$("input.clickSelect").focus(function(){
		$(this).select();
	});

		
	// Panel Toggle Function
	function togglePanel(panelHeight,loginMargin){		
		if($("div#panel").hasClass('errors')){
			if(panelHeight == '0px'){
				panelHeight = '132px';
				loginMargin = '0px';				
			} else {
				panelHeight = '0px';
				loginMargin = '-80px';
			}
		} else {
			if(panelHeight == '0px'){
				panelHeight = '80px';
				loginMargin = '0px';
			} else {
				panelHeight = '0px';
				loginMargin = '-80px';
			}			
		}
		$("div#panel").animate({
			height: panelHeight
		}, { "duration": 600 });	
		$("div#panel div#login").animate({
			marginTop: loginMargin
		}, 600);					
	}	
	
	
	/* Dropdown Menus */
	function addDropdown(){
		$(this).children("div").slideDown('fast');
		$(this).addClass("hovering current");
	}

	function removeDropdown(){
		$(this).children("div").slideUp('fast');
		$(this).removeClass("hovering current");
	}		
	
	var dropDownConfig = {
		interval: 100,
		sensitivity: 1,
		over: addDropdown,
		timeout: 400,
		out: removeDropdown
	};
	
	$("li.dropDown").hoverIntent(dropDownConfig);		
	
	
	
	/*
	 * Initiate fancybox effect for thumbnails
	 */ 
	$("a.lightbox").fancybox({
		'titlePosition'	: 'inside'
	});	

}); // end ready handler
