/* 
	Title:			JustCoding 2.0 Global JS
	Author:			Michael Mottau
	Last Updated: 	May 4, 2010
*/

$(document).ready(function(){
	$('body').addClass('hasJs');
	
	// Set tracking variable
	var toggle = 0;
	
	//Add click handler to the login link - shows and hides the login box in the header of just coding
	$('#login a').click(function(event){
		//if the login box is hidden						 
		if( toggle == 0){
			//Add active class to the box container
			$(this).parent().addClass('active');
			$('#login-form').show(); // Show the box
			$('#username').focus(); // Focus on the first input field
			toggle= 1; // Set toggle to shown
			
		// if box is being shown	
		} else {
			$('#login-form').hide(); // hide the box
			$('#login').removeClass('active'); // remove class from login container
			toggle = 0; // reset toggle
		}
		return false; // stop the default link action from going to the designated 'href'
		event.stopPropagation(); // stop click event from propogating being the login container		
	});
		
	//Adds click handler to the 'body' so when the user clicks outside the login box will be hidden
	//$('body').click(function() {
 		//$('#login-form').hide(); // hide login box
		//$('#login').removeClass('active'); // remove class form login cotnainer
		//toggle = 0; // reset toggle
		//alert('hi');		
	//});

	// 07/27/2010 my: edited script as desired click outside of 'body' was not working as designed
	$('#login-form').hover(function(){ 
		mouse_is_inside = true; }, function(){ 
        mouse_is_inside = false;
    });

    $('body').mouseup(function(){ 
        if(! mouse_is_inside){
			$('#login-form').hide();
			$('#login').removeClass('active'); // remove class form login cotnainer
			toggle = 0; // reset toggle
			}
    });	

	
	// Intializes jquery.textresizer.js plugin
/*	$( "#textsizer a" ).textresizer({
		 target: ".content",
		 type: "cssClass",
		 sizes: [
			"small-text",
			"medium-text",
			"large-text",
			"larger-text"
		 ],
		 selectedIndex: 1
	  });
*/

	
	
	
	
	

}); // End Document
