/*  

v0.1 :)

*/

	/* toggle for search form field */
	jQuery.fn.toggleVal = function(focusClass) {
		this.each(function() {
			$(this).focus(function() {
				// clear value if current value is the default
				if($(this).val() == this.defaultValue) { $(this).val(""); }
				
				// if focusClass is set, add the class
				if(focusClass) { $(this).addClass(focusClass); }
			}).blur(function() {
				// restore to the default value if current value is empty
				if($(this).val() == "") { $(this).val(this.defaultValue); }
				
				// if focusClass is set, remove class
				if(focusClass) { $(this).removeClass(focusClass); }
			});
		});
	}


$(document).ready(function() {
						   
	

		function onAfter() { 
			$('#image-comments').html("").append('<p>' + this.alt + '</p>'); 
		}							   
    	$('.slideshow').cycle({
			fx:     'fade', 
			speed:  1000,
			timeout: 5000,
			pause:  1
		});
	
		$('.rotate').cycle({
			fx:     'fade', 
			speed:  1000,
			timeout: 5000,
			pause:  1
		});
		
		$('.cycle').cycle({
			fx:     'fade', 
		    prev:   '#prev', 
		    next:   '#next',
			speed:  500,
			pause:  1,
			timeout: 0,
			after:   onAfter 
		});

		$('#featured-reports .cycle-wrapper').cycle({
			fx:     'scrollHorz', 
		    prev:   '#prev', 
		    next:   '#next',
			sync:	'true',
			speed:  1100,
			timeout: 9000,
			pause:  1
		});
			
		/* clear search form field */
		$("#q").toggleVal("active");
		
		$('div#flashMessage').append('<span> [Cerrar]</span>');
		
		$('div#flashMessage span').click(function () { 
							  $('div#flashMessage').slideToggle('slow'); 
							});
		
		
});

function bookmark(url,title){
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite(url,title);
	}else{
		window.sidebar.addPanel(title,url,"");
	} 
}

