// JavaScript Document

(function($) {
	$.fn.fadeIn = function(speed, callback) {
		return this.animate({opacity: 'show'}, speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute("filter");
			if(jQuery.isFunction(callback))
				callback();
		});
	};
	$.fn.fadeOut = function(speed, callback) {
		return this.animate({opacity: 'hide'}, speed, function() { 
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute("filter");
			if(jQuery.isFunction(callback))
				callback();
		});
	};
	$.fn.sSlideDown = function(speed, callback) {
		return this.slideDown(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(jQuery.isFunction(callback))
				callback();
		});
	};
	$.fn.sSlideUp = function(speed, callback) {
		return this.slideUp(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(jQuery.isFunction(callback))
				callback();
		});
	};
})(jQuery);

document.writeln("<style type=\"text/css\">", "#nav1 ul li:hover ul { display: none; }", "</style>");

$(document).ready(function($){
	
	$(document).pngFix();
	
	$("a, button").click(function(){$(this).blur();});
	$("a.external, #nav1 a.featured").attr('target','_blank');
	
	// navigation
	$("div#nav1 ul li").children("ul").addClass("hide");
	$("div#nav1 ul li").hover(
		function() { $(this).children("ul").slideDown(222); },
		function() { $(this).children("ul").fadeOut(55); });
	$("#nav1 a").click(function(){this.blur();});
	
	$('div.docinfo').toggle(
		function() { $(this).children('p.synopsis').sSlideDown(222); },
		function() { $(this).children('p.synopsis').fadeOut(222); }
	);
	
	// login stuff
			// init fields
			if(jQuery('#user_login').val() !== '')
				jQuery('#userlogin_label span').hide();
				
			if(jQuery('#user_pass').val() !=  '')
				jQuery('#password_label span').hide();

			// on focus
			$('#userlogin_label span, #password_label span').focus(function() {$(this).fadeTo(100, 0.3).next('input').focus();} );
			jQuery('#userlogin_label input').focus(function() {
				jQuery('#userlogin_label span').fadeTo(100, 0.3);
				
				if(jQuery('#user_login').val() !== '')
				jQuery('#userlogin_label span').hide();
				
				if(jQuery('#user_pass').val() !=  '')
				jQuery('#password_label span').hide();
				
			});
			
			jQuery('#password_label input').focus(function() {
				jQuery('#password_label span').fadeTo(100, 0.3);
				
				if(jQuery('#user_pass').val() !==  '')
				jQuery('#password_label span').hide();
			});
			
			//on keydown
			jQuery('#userlogin_label input').keydown(function() {
    				if(jQuery('#userlogin_label span').is(':visible') )
    				jQuery('#userlogin_label span').hide();
   			});
			
			jQuery('#password_label input').keydown(function() {
				if(jQuery('#password_label span').is(':visible') )
				jQuery('#password_label span').hide();
			});
			
			//on click
			jQuery('#password_label').click(function() {
				jQuery('#user_pass').trigger('focus');
				if(jQuery('#user_pass').val() !==  '')
				jQuery('#password_label span').hide();
			});
			jQuery('#userlogin_label').click(function() {
				jQuery('#user_login').trigger('focus');
				if(jQuery('#user_login').val() !== '')
				jQuery('#userlogin_label span').hide();
			});
			
			//on blur
			jQuery('#user_login').blur(function() {
				if( jQuery('#user_login').val() ==  '') {
					jQuery('#userlogin_label span').show();
					jQuery('#userlogin_label span').fadeTo(100, 1);
				}
				if(jQuery('#user_login').val() !== '')
				jQuery('#userlogin_label span').hide();
			});
			jQuery('#user_pass').blur(function() {
				if( jQuery('#user_pass').val() ==  '') {
					jQuery('#password_label span').show();
					jQuery('#password_label span').fadeTo(100, 1);
				}
				if(jQuery('#user_pass').val() !==  '')
				jQuery('#password_label span').hide();
			});
});

function popUp(url, width, height) {
	window.open(url,'popUp','scrollbars=yes,resizable=yes,width='+width+',height='+height);
}



