
/* Iguala o tamanho das colunas do layout */
ddequalcolumns.columnswatch=["conteudo", "fotos"] 


jQuery(function($){
   $("#nascimentoTitular").mask("99/99/9999");
   $(".telefone").mask("(99) 9999-9999");
});

jQuery(function($) {
	jQuery('.gallery a').lightBox({
	fixedNavigation:false,
	imageLoading: '/img/lightbox-ico-loading.gif',
	imageBtnClose: '/img/lightbox-btn-close.gif',
	imageBtnPrev: '/img/lightbox-btn-prev.gif',
	imageBtnNext: '/img/lightbox-btn-next.gif',
	imageBlank : '/img/lightbox-blank.gif'
	})
});

/* Troca de Imagens, usando as do preload */
function troca(idanterior, idmeio, idproximo, anterior, meio, proximo) {
	if (anterior != "" && idanterior != "") 
		document.getElementById(idanterior).src = images_arr[anterior].src;
	
	if (meio != "" && idmeio != "") {
		document.getElementById(idmeio).src = images_arr[meio].src;
	}
	
	if (proximo != "" && idproximo != "") {
		document.getElementById(idproximo).src = images_arr[proximo].src;
	}
}

function ImageSwap(id) {
	obj = document.getElementById(id);
	imgGrande2 = document.getElementById('imgGrande');	
	imgGrande2.src = obj.src;	
}

function Dependentes(acao) {
	obj = document.getElementById('quantidadeDependentes');
	fieldset = document.getElementById('dependentes');
	if (acao == "+") {
		if (fieldset.style.display == "none") {
			fieldset.style.display = "block";
		}
		obj.innerHTML = parseInt(obj.innerHTML) + 1;
		geraContainerDivs(obj.innerHTML);
	}
	else if (acao == "-" && obj.innerHTML > 0) {
		if (obj.innerHTML == 1){
			fieldset.style.display = "none";
		}
		obj.innerHTML = parseInt(obj.innerHTML) - 1;
		excluiContainerDiv();
	}
}

function mudaCursor(obj) {
	obj.style.cursor = "hand";
	obj.style.cursor = "pointer";
}

function geraContainerDivs(id) {
	obj = document.getElementById('dependentes');
	obj.appendChild(criaDiv("d"+id, ""));
}

function getValores() {
	obj = document.getElementById('dependentes');
	
	valores = new Array();
	valores = ["", "", "", "", "", ""];

	return valores;
}

function excluiContainerDiv() {
	numDiv = document.getElementById('quantidadeDependentes');
	Pai = document.getElementById('dependentes');
	if (Pai.lastChild == "[object Text]") {
		Pai.removeChild(Pai.lastChild);
	}
	Pai.removeChild(Pai.lastChild);
	

}

function criaDiv(id, value) {
	//cria novo label e input para anexar ao fieldset

	if (typeof value == "undefined") {
		value = "";
	}
	
	
	div = document.createElement("div");
	div.id = id;
	
	label = document.createElement('label');
	label.htmlFor = id;
	
	valor = document.createTextNode("Idade do Dependente");
	label.appendChild(valor);
	
	div.appendChild(label);
	
	input = document.createElement('input');
	input.setAttribute("id", id);
	input.setAttribute("type", "text");
	input.setAttribute("name", id);
	input.setAttribute("onKeyPress", "return checkNumero(this, event)");
	input.setAttribute("value", value);

	div.appendChild(input);
	
	obj = document.getElementById("dependentes");
	obj.appendChild(div);
	
	return div
}

function checkNumero(myfield, e, dec)
{
	erro = document.getElementById("erroNumero");
	
	var key;
	var keychar;

	if (window.event) {
	   key = window.event.keyCode;
	   }
	else if (e) {
	   key = e.which;
	   }
	else {
		erro.style.display = "none";
	   return true;
	   }
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) ) {
		erro.style.display = "none";
	   return true;
	}
	   
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1)) {
		erro.style.display = "none";
	   return true;
	   }

	// decimal point jump
	else if (dec && (keychar == "."))  {
	   myfield.form.elements[dec].focus();
	   erro.style.display = "block";
	   return false;
	   }
	else {
		erro.style.display = "block";
	   return false;
	   }
}


function insereIdPlano(id) {
	obj = document.getElementById('idplano').value = id;
}

function validaSolicitacao() {
	div_erro = document.getElementById('envia_solici');
	
	div_nome = document.getElementById('nomeTitular').value;
	div_email = document.getElementById('emailTitular').value;
	div_nascimento = document.getElementById('nascimentoTitular').value;
	div_telefone1 = document.getElementById('telefone1').value;
		
	if (div_nome != "" && div_email != "" && div_telefone1 != "" && div_nascimento != "") {
		return true;
	} else {
		div_erro.style.display = 'block';
	}
	return false;
}


function scrollss()
  {
	for (I=10000; I<=1; I=I-100)
	  {
		parent.scroll(1,I)
	  }
  }

