// Corrige o fundo transparente para imagens PNG no IE
var strGif = "Imagens/Espaco.gif"
var strFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader"

function correctPNG() 
{
   for(var i=0; i<document.images.length; i++)
   {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	  {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         if (img.useMap)
		 {		  
	      	 strAddMap = "<img style=\"position:relative; left:-" + img.width + "px;"
	         + "height:" + img.height + "px;width:" + img.width +"\" "
			 + "src=\"" + strGif + "\" usemap=\"" + img.useMap 
			 + "\" border=\"" + img.border + "\">"
		 }		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:" + strFilter
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 if (img.useMap) strNewHTML += strAddMap
		 img.outerHTML = strNewHTML
		 i = i-1
	  }
   }
   for(i=0; i < document.forms.length; i++)
   {
      findImgInputs(document.forms(i))
   }
}

function findImgInputs(oParent)
{
	var oChildren = oParent.children
    if (oChildren)
	{	
		for (var i=0; i < oChildren.length; i++ )
		{
		   var oChild = oChildren(i)
           if ((oChild.type == 'image') && (oChild.src))
		   {
		       var origSrc = oChild.src
		       oChild.src = strGif
		       oChild.style.filter = strFilter + "(src='" + origSrc + "')"
		   }
		   findImgInputs(oChild)	
	    }
	}
}
window.attachEvent("onload", correctPNG);
//


// Funções de Carregamento de imagem do Dreamweaver
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//




// Abre Imagens (Fotos)
function Imagem(imageName,largura,altura) {

	if (altura > 600) {
			valtura = 600;
		} else {
			valtura = altura
	}

	var wevento = window.open("","newWindow","width="+(largura+18)+",height="+valtura+",left="+Math.round((screen.availWidth-largura)/2)+",top="+Math.round((screen.availHeight-valtura)/2)+",toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no'");
	wevento.document.open();

	if (!wevento) {
		alert("Por Favor, \nDesabilite o seu Bloqueador de Popup");		
	} else {
		wevento.document.write('<html><title>BRASSEC</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
		wevento.document.write('<img src=\"'+imageName+'.jpg\" width='+largura+' height='+altura+'>'); 
		wevento.document.write('</body></html>');
		wevento.document.close();
		wevento.focus();
	}
}
//

// Funciona igual ao Request.QueryString do ASP.NET
function PageQuery(q) 
{
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}

function queryString(key)
{
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}	
//


// Abre janela Popup centralizada na tela
function abre_win(nome, url, largura, altura)
{
	window.open(url, name, 'left='+Math.round((screen.availWidth-largura)/2)+',top='+Math.round((screen.availHeight-altura)/2)+',width='+largura+',height='+altura+',toolbar=no,menubar=no,status=no,scrollbars=no,resizable=no');
}
// Idem, mas com Barra de Scroll
function abre_win2(nome, url, largura, altura)
{
	window.open(url, name, 'left='+Math.round((screen.availWidth-largura)/2)+',top='+Math.round((screen.availHeight-altura)/2)+',width='+largura+',height='+altura+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no');
}
// Abre Janela em FULL-SIZE
function abre_win3(nome, url, largura, altura)
{
	window.open(url, name, 'left=0 ,top=0,width='+(screen.availWidth-8)+',height='+(screen.availHeight-140)+',toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes');
}
//Abre Janela com Codigo HTML dentro. Usado apenas para IMAGENS!
function abre_win4(nome, url, largura, altura) {
	newWindow = window.open("","newWindow","width="+(largura+19)+",height="+altura+",left="+Math.round((screen.availWidth-largura)/2)+",top="+Math.round((screen.availHeight-altura)/2)+", scrollbars=yes");
	newWindow.document.open();
	newWindow.document.write('<html><title>BRASSEC</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<div align=center><img src='+url+'><div>'); 
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}
//

function Foto(Evento,Imagem,rWidth,rHeight) {

	if (rWidth==83){
			cWidth = rWidth + 417;
		} else if(rWidth==55) {
			cWidth = rWidth + 277;	
		} else {
			cWidth = rWidth;
	}

	if (rHeight==83){
			cHeight = rHeight+417;
		} else if (rHeight==55){
			cHeight = rHeight+277;	
		} else {
			cHeight = rHeight;
	}
	
	var wfoto = window.open("","newWindow","width="+cWidth+",height="+cHeight+",left="+Math.round((screen.availWidth-cWidth)/2)+",top="+Math.round((screen.availHeight-cHeight)/2));
	wfoto.document.open();

	if (!wfoto) {
		alert("Por Favor, \nDesabilite o seu Bloqueador de Popup");
	} else {
		wfoto.document.write('<html><title>BRASSEC</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
		wfoto.document.write('<img src=\"Fotos_Eventos/'+Evento+'/'+Imagem+'.JPG\" width='+cWidth+' height='+cHeight+' onDblClick=\"self.close()\" border=\"0\">'); 
		wfoto.document.write('</body></html>');
		wfoto.document.close();
		wfoto.focus();
	}
}


// Preenche o campo Telefone, Data, CEP, CPF e CNPJ com Zeros
function Retira_Zeros_TEL(campo)
	{
	if (document.getElementById(campo).value=='(00) 0000.0000')
		{
		document.getElementById(campo).value='';
		}
	}
function Retira_Zeros_Data(campo)
	{
	if (document.getElementById(campo).value=='00/00/0000')
		{
		document.getElementById(campo).value='';
		}
	}
function Retira_Zeros_CEP(campo)
	{
	if (document.getElementById(campo).value=='00000-000')
		{
		document.getElementById(campo).value='';
		}
	}
function Retira_Zeros_CPF(campo)
	{
	if (document.getElementById(campo).value=='000.000.000-00')
		{
		document.getElementById(campo).value='';
		}
	}
function Retira_Zeros_CNPJ(campo)
    {
    if (document.getElementById(campo).value=='00.000.000/0000-00')
	    {
	    document.getElementById(campo).value='';
	    }
    }
//

// Retira os Zeros do campo Telefone, CEP, CPF e CNPJ quando o usuário clica sobre ele
function Coloca_Zeros_TEL(campo)
	{
	if (document.getElementById(campo).value=='(' | document.getElementById(campo).value=='')
		{
		document.getElementById(campo).value='(00) 0000.0000';
		}
	}	
function Coloca_Zeros_Data(campo)
	{
	if (document.getElementById(campo).value=='')
		{
		document.getElementById(campo).value='00/00/0000';
		}
	}	
function Coloca_Zeros_CEP(campo)
	{
	if (document.getElementById(campo).value=='')
		{
		document.getElementById(campo).value='00000-000';
		}
	}	
function Coloca_Zeros_CPF(campo)
	{
	if (document.getElementById(campo).value=='')
		{
		document.getElementById(campo).value='000.000.000-00';
		}
	}	
function Coloca_Zeros_CNPJ(campo)
	{
	if (document.getElementById(campo).value=='')
		{
		document.getElementById(campo).value='00.000.000/0000-00';
		}
	}	
//

