// JavaScript Document
// -------------------------------------------------------
function StatusMsg(msgStr) 
{
  status=msgStr;
  document.MM_returnValue = true;
}
// -------------------------------------------------------
function abre_janela(arquivo, nome_janela, largura, altura, maximiza, menu, barra, status)
{
	vleft=(((screen.availWidth/2)-(largura/2))-10);
  	vtop=(((screen.availHeight/2)-(altura/2))-30);
	janela=window.open(arquivo, nome_janela, 'width='+largura+',height='+altura+',top='+vtop+', left='+vleft+', resizable='+maximiza+',menubar='+menu+',scrollbars='+barra+', status='+status+'');
	janela.focus();
}
function abre_pop(arquivo, nome_janela, largura, altura, maximiza, menu, barra, status)
{
	janela=window.open(arquivo, nome_janela, 'width='+largura+',height='+altura+',top=20, left=20, resizable='+maximiza+',menubar='+menu+',scrollbars='+barra+', status='+status+'');
	janela.focus();
}
// -------------------------------------------------------
function conf_voto()
{
	if (confirm('Confirma VOTO ?'))
		return true;
	return false;
}
// -------------------------------------------------------
function vazio(campo, mensagem)
{
	if (campo.value.length==0)
	{
		alert('O campo '+mensagem+' deve ser preenchido!');
		campo.style.background='#cccccc';
		campo.focus();
		return true;
	}
	return false;
}
// -------------------------------------------------------
function valida_email(campo)
{
	if (campo.value.length==0)
		return true;
	else
	{
	parte1 = campo.value.indexOf("@");
	parte3 = campo.value.length;
	teste1	= (parte1)
	teste3	= ((parte3-parte1)-1)
	
	if (!(teste1 >= 2 && teste3 >= 4)) 
	{
        alert ("O campo E-mail deve ser conter um endereço eletronico válido!");
 		campo.style.background='#cccccc';
		campo.focus();
        return false;
	}
	return true;
	}
}
// inicio _ Funcoes de SCROLL EM PAGINAS
// -------------------------------------------------------
function P7_JumpMenu(selObj,restore){ //v1.7 by Project Seven
var theFullString = selObj.options[selObj.selectedIndex].value;
if (restore) selObj.selectedIndex=0;
var theLength = theFullString.length;
var endPos = theFullString.lastIndexOf("~");
var theUrl, theTarget, theParent;
if (endPos > 0) 
{theUrl = theFullString.substring(0,endPos);}
else 
{theUrl = theFullString;}
endPos++
if (endPos < theLength) 
{theTarget = theFullString.substring(endPos,theLength)}
else
{theTarget = "window:Main";}
if (theTarget == "window:New") 
{window.open(theUrl);}
else if (theTarget == "window:Main") 
{eval("parent.location='"+theUrl+"'");}
else 
{eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}
function verifyCompatibleBrowser(){ 
this.ver=navigator.appVersion 
this.dom=document.getElementById?1:0 
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
this.ie4=(document.all && !this.dom)?1:0; 
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
this.ns4=(document.layers && !this.dom)?1:0; 
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
return this 
} 
bw=new verifyCompatibleBrowser() 
var speed=50 
var loop, timer 
function ConstructObject(obj,nest){ 
nest=(!nest) ? '':'document.'+nest+'.' 
this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
this.up=MoveAreaUp;this.down=MoveAreaDown; 
this.MoveArea=MoveArea; this.x; this.y; 
this.obj = obj + "Object" 
eval(this.obj + "=this") 
return this 
}
function MoveArea(x,y){
this.x=x;this.y=y 
this.css.left=this.x 
this.css.top=this.y 
}
function MoveAreaDown(move){ 
if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
this.MoveArea(0,this.y-move) 
if(loop) setTimeout(this.obj+".down("+move+")",speed) 
} 
}
function MoveAreaUp(move){ 
if(this.y<0){ 
this.MoveArea(0,this.y-move) 
if(loop) setTimeout(this.obj+".up("+move+")",speed) 
} 
} 
function PerformScroll(speed){ 
if(initialised){ 
loop=true; 
if(speed>0) objScroller.down(speed) 
else objScroller.up(speed) 
} 
} 
function CeaseScroll(){ 
loop=false 
if(timer) clearTimeout(timer) 
} 
var initialised;
function Scroll()
{ 
	objContainer=new ConstructObject('blk_mural_conteudo_movel') 
	objScroller=new ConstructObject('blk_mural_movel','blk_mural_conteudo_movel') 
	objScroller.MoveArea(0,0) 
	objContainer.css.visibility='visible' 
	initialised=true; 
}
// fim _ Funcoes de SCROLL EM PAGINAS
// -------------------------------------------------------
function mask(objForm, strField, sMask, evtKeyPress)
{
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
	
	if(document.all) // Internet Explorer
		nTecla = evtKeyPress.keyCode;
	else if(document.layers) // Nestcape
		nTecla = evtKeyPress.which;
	
	sValue = objForm[strField].value;
	
	// Limpa todos os caracteres de formatação que
	// já estiverem no campo.
	while (sValue.indexOf('-')>=0)
		sValue = sValue.toString().replace( "-", "" );
	while (sValue.indexOf(':')>=0)
		sValue = sValue.toString().replace( ":", "" );
	while (sValue.indexOf('.')>=0)
		sValue = sValue.toString().replace( ".", "" );
	while (sValue.indexOf('/')>=0)
		sValue = sValue.toString().replace( "/", "" );
	while (sValue.indexOf("(")>=0)
		sValue = sValue.toString().replace( "(", "" );
	while (sValue.indexOf(")")>=0)
		sValue = sValue.toString().replace( ")", "" );
	while (sValue.indexOf(' ')>=0)
		sValue = sValue.toString().replace( " ", "" );
	fldLen = sValue.length;
	mskLen = sMask.length;
	
	i = 0;
	nCount = 0;
	sCod = "";
	mskLen = fldLen;
	
	while (i <= mskLen)
	{
		bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".")|| (sMask.charAt(i) == ":") || (sMask.charAt(i) == "/"))
		
		bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
	
		if (bolMask)
		{
			sCod += sMask.charAt(i);
			mskLen++;
		}
		else
		{
			sCod += sValue.charAt(nCount);
			nCount++;
		}
		i++;
	}
	
	objForm[strField].value = sCod;
	
	if (nTecla != 8) // backspace
		if (sMask.charAt(i-1) == "9") // apenas números...
			return ((nTecla > 47) && (nTecla < 58));// números de 0 a 9
	return true;
}
// -------------------------------------------------------
function teste_img(campo, local, mensagem)
{
	if (campo.value.length==0) return false;

			// testa tipo imagem
				caminho = campo.value.substr(1,1)
				var tipo = campo.value.substr(((campo.value.length)-4),4);
				tipo = tipo.toLowerCase()
			
				if (caminho != ":")
				{
					alert('O campo '+mensagem+' contem um CAMINHO INVÁLIDO !');
					campo.style.background='#E5E5E5';
					campo.focus();
					return true;
				}
				if ((tipo != ".jpg") && (tipo != "jpeg"))
				{
					alert('O campo '+mensagem+' contem um arquivo INVÁLIDO \r        O formato deve ser JPG ou JPEG!');
					campo.style.background='#E5E5E5';
					campo.focus();
					return true;
				}
			// teste se tem campo localizacao
			if (local=="") return false;

			else
			{
				if (local.value.length==0)
					{
						alert('O campo de Localização - '+mensagem+' deve ser preenchido!');
						local.style.background='#E5E5E5';
						local.focus();
						return true;
					}
			}
return false;
}
// ---------------- Teste Enquete
function vazio_enquete(campo, mensagem)
{
	checado = false;
	for(i=0; i<campo.length; i++)
	{
		if (campo[i].checked)
			checado = true;
	}
	if (!checado)
	{
		alert('Você deve escolher uma opção !');
		return true;
	}
	else
		return false;
}
function fecha_div(id, metodo)
{
	obj = document.getElementById(id);
	if(metodo == 'display')
	{
		obj.style.display = 'none';
	}
	else
	{
		obj.style.visibility = 'hidden';
	}
}
function abre_foto(foto)
{
	document.getElementById('foto_principal').src = '../img/musa/'+foto;
}
// -------------------------------------------------------
function aovivo(player, arquivo)
{
//	window.open(player, 'py');
	vleft=(((screen.availWidth/2)- 171)-10);
  	vtop=(((screen.availHeight/2)- 100)-30);
	janela=window.open(arquivo, 'aovivo', 'width=342,height=200,top='+vtop+', left='+vleft+', resizable=0,menubar=0,scrollbars=0, status=0');
	janela.focus();
}
