var $j = jQuery;
jQuery(document).ready(function(){
   
	$j("input[type='text'], input[type='password']").addClass("text");
	$j("input[type='button'], input[type='submit'], input[type='checkbox'], input[type='image'], input[type='radio'], input[type='reset'], button").addClass("nontext");
	$j("input[type='button'], input[type='submit'], input[type='reset'], button").addClass("button");
	$j('hr').wrap('<div class="hr"></div>')
	
	// Suckerfish Navigation
	jQuery(document).ready(function(){ 
		jQuery('#flexipages-3 .page-item-3 ul').supersubs({ 
			minWidth:    12,                                // minimum width of sub-menus in em units 
			maxWidth:    27,                                // maximum width of sub-menus in em units 
			extraWidth:  1                                  // extra width can ensure lines don't sometimes turn over 
															// due to slight rounding differences and font-family 
		}).superfish({ 
			delay:       400,                               // delay on mouseout 
			animation:   {opacity:'show',height:'show'},    // fade-in and slide-down animation 
			speed:       'fast',                            // faster animation speed 
			autoArrows:  false,                             // disable generation of arrow mark-up 
			dropShadows: false,                            // disable drop shadows 
			pathClass:  'current'
		}); 
	});
	
	// Add Class Last to Each Last Child
	$j('li:last-child').addClass('last');
			
	// Login Panel
	$j("#login_button a").click(function(){
		$j("#login-panel").animate({height: "18em"}).animate({height: "15em"}, "fast");
		$j(".panel_button").toggle();
		return false;
	});	
	$j("div#hide_button").click(function(){
		$j("#login-panel").fadeOut();
	});
	// This is the tool tip hover
	$j('#content acronym[title], #content abbr[title]').qtip({
      content: {
         text: false // Use each elements title attribute
      },
      style: 'cream' // Give it some style
   });
	// This hightlights search terms
	if(typeof(hls_query) != 'undefined'){
      $j("#content").highlight(hls_query, 1, "hls");
    }
	// This is the pop-up window
	$j(".colorbox").colorbox();
	$j(".iframe").colorbox({width:"80%", height:"80%", iframe:true});
	
	$j('#tab-content').tabs();
		
});

jQuery.fn.extend({
    highlight: function(search, insensitive, hls_class){
      var regex = new RegExp("(<[^>]*>)|(\\b"+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +")", insensitive ? "ig" : "g");
      return this.html(this.html().replace(regex, function(a, b, c){
        return (a.charAt(0) == "<") ? a : "<strong class=\""+ hls_class +"\">" + c + "</strong>";
      }));
    }
  });


