function banners(){
	var flashvars = {};
	var params = {
		menu: "false",
		scale: "noScale",
		allowFullscreen: "true",
		allowScriptAccess: "always",
		bgcolor: "#FFFFFF",
		wmode: "transparent"
    };
 
 	var $total_banners = $('#banner #content-banner').children().size();
	for (var i = 0; i < $total_banners ; i++) {
	    var attributes = {
	        id: "banner"+(i)
	    };
	    swfobject.embedSWF("includes/swf/banner"+(i + 1)+".swf", "banner"+(i + 1), "579", "222", "7.0.0", "expressInstall.swf", flashvars, params, attributes);
	}
}

function Ativo(){
	$('.item').removeClass('atual');
	$(this).addClass('atual');
	$('#nav li').removeClass('active');
	var banner = $('.item.atual').prevAll().size();	
	$('#' + banner + '').addClass('active');
	$('#' + banner + '').parent().parent().addClass('active');
	
	if($.browser.msie == true){
		$('.atual').html('<div id="banner'+ (banner + 1) +'"></div>')
		banners();
	}
}

function controlador(){
	banners();
	
	$('#content-banner').cycle({
		//fx:     'none', 
		//speed:  100,
		timeout: 20000,
		pager:  '#nav',
		activePagerClass:'active',
		before: Ativo,
		pagerAnchorBuilder: pagerFactory			
	});	
	function pagerFactory(idx, slide) {
		return '<li><a href="javascript:void(0);" title="' + (idx+1) + '">' + (idx+1) + '</a></li>';
	};
	
}

jQuery.accordion = function(quem, velocidade){
		jQuery(quem).children('dt').click(function(){
			if(jQuery(this).next('dd').css('display') == 'none'){
				jQuery(quem).children('dt').removeClass('active');
				jQuery(this).addClass('active');
				jQuery(quem).children('dd').slideUp(velocidade);
				jQuery(this).next('dd').stop();
				jQuery(this).next('dd').slideDown(velocidade);
			}else{
				jQuery(quem).children('dt').removeClass('active');
				jQuery(quem).children('dd').slideUp(velocidade);
			}
		});
}

function Passo( n, max )
{
	var maximo = max;
	var disp;
	var cla;
	
	for ( i=1; i<=maximo; i++ ) {
		if ( i == n ) {
			disp = '';
			cla = 'ligado';
		} else {
			disp = 'none';
			cla = 'desligado';
		}
		document.getElementById('passo'+i).style.display = disp;
		document.getElementById('passo'+i).className = cla;
		document.getElementById('tab'+i).className = 'tab_'+cla;
	}
}

function confirmacao(){
	var senha = document.getElementById("senha");
	var senhac = document.getElementById("senhac");
	
	if(senha.value != senhac.value){
		showError("Mensagem de Erro", "A senha de confirmação está incorreta!");
		senhac.value = '';
		senha.focus();
	}
}

function addCidade(){
	if(document.getElementById("cidade").value == 'o'){
		document.getElementById("ocidade").style.display = '';
	}else{
		document.getElementById("outracidade").value = '';
		document.getElementById("ocidade").style.display = "none";
	}
}

function putImage(path_origem,img_destino)
{
	obj = document.getElementById(img_destino);
	obj.src = path_origem;
	if(obj.width > 300) {
		obj.width = 300;
	}
	if(obj.height > 150) {
		obj.height = 150;
	}
}

 // Popup Imagens
function popUpImg(url) {
	var largura=550;
	var altura=450;
	var e=(screen.width - largura)/2;
	var t=(screen.height - altura)/2;
	
	pp = window.open(url,"popup","top="+t+",left="+e+",width="+largura+",height="+altura+",scrollbars=0");
	if (window.focus) {pp.focus()}
	//	return false;
}

$(function(){
	controlador();
});

