function exibeFlash(swf, width, height){
	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab#version=8,0,24,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"0\" />";
	monta_swf += "<param name=\"wmode\" value=\"transparent\" />";
	monta_swf += "<embed src=\""+ swf +"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer_br\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";	
	document.write(monta_swf);
}


function CallPrint(strid)
{
	var prtContent = document.getElementById(strid);
	var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
	WinPrint.document.write(prtContent.innerHTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
	prtContent.innerHTML=strOldOne;
}


function closeFloater(div){
	document.getElementById(div).style["display"]="none";
}

/* 
 * Função utilizada para carregar os dados da combobox de cidades, de acordo com o estado selecionado. 
 * Parâmetros: 
 * 	- Código que será usado para carregar a lista.
 *	- target = elemento que receberá os dados.
 */
function setCiTyCombo( urlAjax , target ) {
	
	xmlhttp = getXmlHttp();
	xmlhttp.open("GET", urlAjax, true);
	document.getElementById(target).innerHTML = '<br/>Carregando...';
	xmlhttp.onreadystatechange = function() {
		if ( xmlhttp.readyState == 4 ) {
			
			document.getElementById(target).innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

/* Conexão Ajax */
function getXmlHttp(){
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	} 
	return xmlhttp;
}

/* JQuery Functions */
$(document).ready(function() {	
	$('a[@rel*=lightbox]').lightBox();
	$("a[@rel=external]").attr('target','_blank');
	$("a[@rel=external]").addClass ("external");	
	
	$("form#inscricao fieldset select#nPessoas").change(function(){
		var rootUrl = document.location.href;
		rootUrl = rootUrl.substr(0,rootUrl.indexOf('/',8));															 
		// window.location.href = rootUrl+"/comunidade/?page=pages/inscricao.php&nPessoas="+$(this).attr('value')+"#inscricao"; // Localhost
		window.location.href = rootUrl+"/?page=pages/inscricao.php&nPessoas="+$(this).attr('value')+"#inscricao"; // Locaweb
	});
	
	// Validação do form
	$("form#inscricao").validate();
	
	//Apreentação das mensagens
	$('div#msgError1').pulse({speed: 500,opacityRange: [0.0,0.9], duration: 10000});
	$('div#msgError2').pulse({speed: 500,opacityRange: [0.0,0.9], duration: 10000});
	$('div#msgSuccess1').pulse({speed: 500,opacityRange: [0.0,0.9], duration: 10000});
	$('div#msgSuccess2').pulse({speed: 500,opacityRange: [0.0,0.9], duration: 10000});
});

// Adiciona máscara aos campos
jQuery(function($){
	unMask();
	setMask();	
});

function unMask() {
	$(".txt-date").unmask();
	$(".txt-date-my").unmask();
	$(".txt-time").unmask();
	$(".txt-phone").unmask();
	$(".txt-cnpj").unmask();
	$(".txt-cpf").unmask();
	$(".txt-cep").unmask();
}

function setMask(){
	$(".txt-date").mask("99/99/9999");
	$(".txt-date-my").mask("99/9999");
	$(".txt-time").mask("99:99");
	$(".txt-phone").mask("(99) 9999-9999");
	$(".txt-cnpj").mask("99.999.999/9999-99");
	$(".txt-cpf").mask("999.999.999-99");
	$(".txt-cep").mask("99999-999");
}
