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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um endereço válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' deve conter um número.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve conter um número também '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é necessário.\n'; }
  } if (errors) alert('O(s) seguinte(s) erro(s) ocorreu(eram):\n'+errors);
  document.MM_returnValue = (errors == '');
}// JavaScript Document


//MENU
function horizontal() {
 
   var navItems = document.getElementById("menu_dropdown").getElementsByTagName("li");
    
   for (var i=0; i< navItems.length; i++) {
      if(navItems[i].className == "submenu")
      {
         if(navItems[i].getElementsByTagName('ul')[0] != null)
         {
            navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "";}
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "";}
         }
      }
   }
 
}

// inicializa Limpeza de Scroll no browser
// ===================================================================================================================================
	function initScroller(){
		window.document.body.scroll = "no";}
		
// exibe e oculta DIV no parametro sem Scroll
// ===================================================================================================================================
	function showBox(id){
		var obj = getID(id);
		if(obj.className == "ajaxHide") {			 
			window.document.body.scroll = "no";
			obj.className = "ajaxShow";
			obj.scrollIntoView();
			window.document.body.style.overflow ="hidden";}
		else {
			window.document.body.scroll = "yes";
			window.document.body.style.overflow="visible";
			obj.className = "ajaxHide";}}
			
			
	function showVideo(id) {
		showBox('containerAjax');
		var retorno = getID("boxerP");
		var ajax = openAjax();
		ajax.open('GET', 'http://www.amorevida.org.br/site/bin/class.VDO.php?id='+id, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 1) {
				retorno.innerHTML = '<img src="http://www.amorevida.org.br/newsletter/loaderAjaximg.gif"/>';}
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						retorno.innerHTML = ajax.responseText;} } }
		ajax.send(null);
	}
	
	function clearVideo(){
		window.document.getElementById('boxerP').innerHTML = '';
	}
	
	function sendDepoimento() {
		var nome = getID('nome').value;
		var email = getID('email').value;
		var depoimento = getID('depoimento').value;
		var ajax = openAjax();
		ajax.open('GET', 'http://www.amorevida.org.br/site/bin/send.DEP.php?nome='+nome+'&email='+email+'&depoimento='+depoimento, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 1) {}
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						alert(ajax.responseText);} } }
		ajax.send(null);
		
		getID('nome').value = '';
		getID('email').value = '';
		getID('depoimento').value = '';
	}
	
	
function showDiv(obj){
	var total = window.document.getElementById('total').value;
	var style= window.document.getElementById('mes_'+obj).style.display;
	if(style == 'none'){
		window.document.getElementById('mes_'+obj).style.display = '';
	}else{
		window.document.getElementById('mes_'+obj).style.display = 'none';
	}
	for(var i=0; i < total; i++){
		if(i != obj){
			window.document.getElementById('mes_'+i).style.display = 'none';
		}
	}
}

function showPerguntas(id){
	for(var i=1; i<=3; i++){
		if(i != id){
			window.document.getElementById('pergunta_'+i).style.display = 'none';}
	}
	
	if(window.document.getElementById('pergunta_'+id).style.display == ''){
		window.document.getElementById('pergunta_'+id).style.display = 'none';
	}else if(window.document.getElementById('pergunta_'+id).style.display == 'none'){
		window.document.getElementById('pergunta_'+id).style.display = '';
	}
}
