/* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+  <http://cherne.net/brian/resources/jquery.hoverIntent.html>*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:3,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/* Textbox resizer(c) 2005 Nicolas Martin & Olivier Meunier and contributors */
jQuery.fn.resizehandle = function() {return this.each(function() {var me = jQuery(this);me.after(jQuery('<div class="resizehandle"></div>').bind('mousedown', function(e) {
        var h = me.height();var y = e.clientY;var moveHandler = function(e) {me.height(Math.max(20, e.clientY + h - y));};var upHandler = function(e) {jQuery('html').unbind('mousemove',moveHandler).unbind('mouseup',upHandler);};
        jQuery('html').bind('mousemove', moveHandler).bind('mouseup', upHandler);}));});}

jQuery.fn.toggleVal=function(focusClass){this.each(function(){$(this).focus(function(){if($(this).val()==this.defaultValue){$(this).val("")}if(focusClass){$(this).addClass(focusClass)}}).blur(function(){if($(this).val()==""){$(this).val(this.defaultValue)}if(focusClass){$(this).removeClass(focusClass)}})})}

$(document).ready(function(){
	$('#s').toggleVal('active');
	$('#user_login').toggleVal('active');
	$('#password').toggleVal('active');
	//For having the whole table row clickable
	$('#forumlist tr, #latest tr, #favorites tr').click( function() {
		if ($(this).attr('class') != 'headsmall' && $(this).children('.numlink')) {
		window.location=$(this).find(".numlink a").attr("href"); 	
		return false;
		};
	});
		
	$('table td.num a, table td.numdel').click(function(e) { 
		e.stopPropagation(); //Stops click event from bubbling up to the parent function
	});	
			
	//$('.hiddencontent').css('visibility','hidden');
	//$('.activeslide').css('visibility','visible');	
	
	//For searchbar
	$("#q").toggleVal("active");
	//For adding images to types of links
	$("a[@href$=pdf]").addClass("pdf");
	$("a[@href$=zip]").addClass("zip");
	$("a[@href$=doc]").addClass("doc");
	//For resizing textareas
	$("textarea").resizehandle();

	$('.sidehide a').toggle(function() {
		//setTimeout("$('#rightbar').hide(200);",400);
		$('#rightbar').hide(200);
		setTimeout("$('#main').css('width', '755px');",250);
		//$('#main').css('width', '750px'); 
		$(this).text('Show sidebar');
		return false;
	}, function() {
		$('#main').css('width', '550px');
		$('#rightbar').show(200);
		$(this).text('Hide sidebar');
		return false;		
	});

	$("#totop").hoverIntent(function(){
	$(this).animate({height: "40px", opacity: "0.8"}, 150);
	}, function() {
	$(this).animate({height: "7px", opacity: "0.3"}, 150);
	});

	$("#totop").click(function(){
	window.location=$(this).find("a").attr("href"); return false;
	});
	
}); //End doc ready
	
/*jTabber */	
	   $(function() {
			$.jtabber({
			mainLinkTag: "#navigate a", // much like a css selector, you must have a 'title' attribute that links to the div id name
			activeLinkClass: "selected", // class that is applied to the tab once it's clicked
			hiddenContentClass: "hiddencontent", // the class of the content you are hiding until the tab is clicked
			showDefaultTab: 1, // 1 will open the first tab, 2 will open the second etc.  null will open nothing by default
			showErrors: false, // true/false - if you want errors to be alerted to you
			effect: 'fade', // null, 'slide' or 'fade' - do you want your content to fade in or slide in?
			effectSpeed: '300' // 'slow', 'medium' or 'fast' - the speed of the effect
			});		
        });		

		
		
(function(jQuery){
		  
	$.extend($, {
		jtabber: function(params){				
				// parameters
				var navDiv = params.mainLinkTag;
				var selectedClass = params.activeLinkClass;
				var hiddenContentDiv = params.hiddenContentClass;
				var showDefaultTab = params.showDefaultTab;
				var showErrors = params.showErrors;
				var effect = params.effect;
				var effectSpeed = params.effectSpeed;			
				// If error checking is enabled
				if(showErrors){
					if(!$(navDiv).attr('title')){
						alert("Error: The elements in your mainLinkTag paramater need a 'title' attribute.\n ("+navDiv+")");	
						return false;
					}
					else if(!$("."+hiddenContentDiv).attr('id')){
						alert("Error: The elements in your hiddenContentClass paramater need to have an id.\n (."+hiddenContentDiv+")");	
						return false;
					}
				}					
				// If we want to show the first block of content when the page loads
				if(!isNaN(showDefaultTab)){
					showDefaultTab--;
					$("."+hiddenContentDiv+":eq("+showDefaultTab+")").css('display','block');
					$(navDiv+":eq("+showDefaultTab+")").addClass(selectedClass);	
				}				
				// each anchor
				$(navDiv).each(function(){				
				if ($(this).attr('class') != 'unselected') {			
					$(this).click(function(){
						// once clicked, remove all classes
						$(navDiv).each(function(){$(this).removeClass();})
						// hide all content
						$("."+hiddenContentDiv).css('display','none');					
						// now lets show the desired information
						$(this).addClass(selectedClass);
						var contentDivId = $(this).attr('title');					
						if(effect != null){						
							switch(effect){							
								case 'slide':
								$("#"+contentDivId).slideDown(effectSpeed,function(){$(this).fixClearType()});
								break;
								case 'fade':
								$("#"+contentDivId).fadeIn(effectSpeed,function(){$(this).fixClearType()});
								break;								
							}} else {$("#"+contentDivId).css('display','block');}
						return false;})};})}})})(jQuery);

jQuery.fn.fixClearType = function(){return this.each(function(){if(typeof this.style.filter  && this.style.removeAttribute)this.style.removeAttribute("filter");})}						