/**
 * @version			September de 2009
 * @copyright		Copyright (C) 2009 NCD Olinda. All rights reserved
 * @license			http://www.olinda.pe.gov.br
 * 
 * @author			Marcos Souza - NCD Olinda
 */
	var $j = jQuery.noConflict()
	$j(document).ready(function() {
		var loaded = 0;
		var timerId = 0;
		var current = null;

		var stop = function() {
			clearTimeout(timerId);
			timerId = 0;
		};

		var resume = function(e) {
			timerId = window.setTimeout(e, 4000);
		};

		var original = $j("#home_photo");

		original.fadeIn(1000,function() { loaded = 1; });

		$j(".banner_image").each(function(i) {
			if($j(this).attr('id') != 'banner_image') {
				var banner = $j(this);

				var e = function() {
					banner.hide();
					original.fadeIn(1000);
				};

				$j(this).mouseover(function() { stop(); });
				$j(this).mouseout(function() { resume(e); });
			}
		});

		$j("#banner_sub > a").each(function(i) {
			i++;
			var banner = $j('#banner_image'+i);
			var current = $j('#current_image');

			$j(this).mouseover(function() {
				if(!loaded)
					return;

				original.hide();
			$j("#sub_image").css("background-color","#fff")
				if(current.val() != '')
					$j('#banner_image'+current.val()).hide();

				current.val(i);
				banner.show();
				stop();
			});

			$j(this).mouseout(function() {
				if(!loaded)
					return;
                
				var e = function() {
					banner.hide();
					original.fadeIn(1000);
				$j("#sub_image").css("background-color","#ffcc00")
				};
            
				resume(e);
				
			});
		});
		$j(".sub_image1")
                       .mouseover(function(){
                               $j(this).css("background-color","#ffcc00");
                       })
                       .mouseout(function(){
                               $j(this).css("background-color","#FFF");
                       });
		$j(".sub_image2")
                       .mouseover(function(){
                               $j(this).css("background-color","#ffcc00");
							   
                       })
                       .mouseout(function(){
                               $j(this).css("background-color","#FFF");
                       });
		$j(".sub_image3")
                       .mouseover(function(){
                               $j(this).css("background-color","#ffcc00");
                       })
                       .mouseout(function(){
                               $j(this).css("background-color","#FFF");
                       });
	});
	//-->
