/** Detect Screen Size **/
function alertSize() {
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
       //Non-IE
       myWidth = window.innerWidth;
       myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
     }
     
     var size = new Array();
     size['height'] = myHeight;
     size['width'] = myWidth;
    
     return size;
}


$(document).ready(function(){
	
	 // IE6 detect
	 var browser = navigator.appName;
	 var version = navigator.appVersion.split(';');
	 if (browser == "Microsoft Internet Explorer" && version[1] == " MSIE 6.0") { 
	   var ie6 = 1; 
	 }
	
	// This will set any input in a form to process the ajax action that is declared in "submit-action" of the form element 
	// with the enter button
	$("#header-nav").delegate("input","keypress",(function (e) {
	   
	   if (e.keyCode == 13) {
		  if(e.type == 'keypress') {
		  	e.preventDefault();
		  }
		  
		  action = $(this).parents("form").attr("submit-action");
		  eval(action);	  
	   }
 	}));
	
	
	/*** INPUT AND SELECT COLOR CHANGE ***/
	
	// Set form input background yellow on focus or mouseover
	$(".form-container").delegate("input", "mouseover", function(){
		$(this).css("background-color","#fcfdc5");
	});
	
	$(".form-container").delegate("input", "focusin", function(){
		$(this).css("background-color","#fcfdc5");
	});
		
	// Set form input background white on focusout or mouseout
	$(".form-container").delegate("input", "mouseout", function(){
		$(this).css("background-color","#FFF");
	});
	
	$(".form-container").delegate("input", "focusout", function(){
		$(this).css("background-color","#FFF");
	});
	
	
	
	
	$(".form-container").delegate("select", "focusin", function(){
		$(this).css("background-color","#fcfdc5");
	});
	
	$(".form-container").delegate("select", "focusout", function(){
		$(this).css("background-color","#FFF");
	});

	/**********************/

	// Activate Sub Menu for certain nav clicks
	$(".nav-arrow,.nav-text").live("click", function() { 
	   
	    $(this).parent().find("ul.subnav").slideDown(150).show();	 
      
        $(this).parent().hover(function(){    
    	  $(this).parent().find("ul.subnav").slideUp('slow'); 
	    });
	      
	});
	
	
	// PNG Fix
	$("img").pngfix();
	
	// Note Carousel
	$(function() {
		$(".noteContainer").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev"
		});
		
	});
	
});
