/*
function janelaModContatti(URL){
  window.open("http://www.eucord.com" , "eucord - modulo contatto" , "width=610,height=735,scrollbars=NO");
}
*/
//AJAX//AJAX//AJAX//AJAX//AJAX//AJAX//AJAX//AJAX
//04-11-2010 [update médico na scheda]
function submit_simulacao()
{
	var tipo = -1;
	for( i = 0; i < document.formdati.tipo_servico.length; i++ )
	{
		if( document.formdati.tipo_servico[i].checked )
			tipo = i;	
	}
	if (tipo == -1)
	{
		alert('Errore: Scegliere Servizio!');
		return(false);
	}

	document.getElementById('formdati').submit();
}

function update_dados(url)
{
	req = null;

//	document.getElementById('pagina_get').style.display = "none";

	try
	{
		// Firefox, Opera 8.0+, Safari
		req = new XMLHttpRequest();
	}
	catch (e)
	{
			// Internet Explorer
			try
			{
				req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				try
				{
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e)
				{
					alert("Seu navegador não suporta AJAX!");
					return false;
				}
			}
	}
	req.onreadystatechange = processReqChange;
	req.open("GET",url,true);
	req.send(null);
	
	
/*
	req = null;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET",url,true);
		req.send(null);
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET",url,true);
			req.send();
		}
	}
	
*/
}

function processReqChange()
{

	if (req.readyState == 4) {
		if (req.status ==200) {
			document.getElementById('pagina').innerHTML = req.responseText;
		} else {
			//alert("Houve um problema ao obter os dados:n" + req.statusText);
		}
	}
}

function actualiza_dados()
{
	var tipo = -1;
	var gemeos = -1;
	

	for( i = 0; i < document.formdati.tipo_servico.length; i++ )
	{
		if( document.formdati.tipo_servico[i].checked )
			tipo = i;	
	}

	for( i = 0; i < document.formdati.gemeos.length; i++ )
	{
		if( document.formdati.gemeos[i].checked )
			gemeos = i;	
	}

	for( i = 0; i < document.formdati.anos_servico.length; i++ )
	{
		if( document.formdati.anos_servico[i].checked )
			anos_servico = i;	
	}


	url="actualiza_dados.php?icryocod="+document.formdati.icryo_cod.value+"&anos="+anos_servico+"&tipo="+tipo+"&gemeos="+gemeos;
	update_dados(url);
}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////


function janelaModContatti(URL){
  window.open(URL , "janela1" , "width=735,height=610,scrollbars=NO");
}

function val_modulo()
{
	data=/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/;
	correio=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	//verifica campos vazios
	if ( modulo.nome.value == ''){
		alert('Errore Campo (2.) : Insere il Nome contatto.');
		return(false);
	}
	//verifica campos vazios
	if ( modulo.cognome.value == ''){
		alert('Errore campo (3.) : Insere il Cognome contatto.');
		return(false);
	}
	//E-mail
	if (!correio.test(modulo.email.value)) {
		alert('Errore campo (8.) : errore nel campo email.');
		return(false);
		}
	//CAP
	if ( modulo.cap.value == ''){
		alert('Errore campo(11.) : Insere il CAP.');
		return(false);
	}
	return confirm("Conferma?");
	modulo.submit();
}
function val_modulo_hematos()
{
	data=/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/;
	correio=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	//verifica campos vazios
	if ( document.modulo.nome.value == ''){
		alert('Errore: Insere il Nome contatto.');
		return(false);
	}
	//verifica campos vazios
	if ( document.modulo.cognome.value == ''){
		alert('Errore: Insere il Cognome contatto.');
		return(false);
	}
	//verifica campos vazios
	if ( document.modulo.citta.value == ''){
		alert('Errore: Insere Citta.');
		return(false);
	}
	//telefono
		if ( document.modulo.fax.value == ''){
		alert('Errore: Insere il Telefono.');
		return(false);
	}
	//E-mail
	if (!correio.test(document.modulo.email.value)) {
		alert('Errore: Insere il email.');
		return(false);
		}
	//struttura
	if (document.modulo.struttura.value == '') {
		alert('Errore: Ospedale dove avverra il parto.');
		return(false);
		}
	//dataparto
	if (!data.test(document.modulo.dataparto.value)) {
		alert('Errore: Data presunta del parto.');
		return(false);
		}
	return confirm("Conferma?");
	document.getElementById('modulo').submit();
}

function val_modulo_hematos_index()
{
	data=/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/;
	correio=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	//verifica campos vazios
	if ( document.modulo.nome.value == ''){
		alert('Errore: Insere il Nome contatto.');
		return(false);
	}
	//verifica campos vazios
	if ( document.modulo.cognome.value == ''){
		alert('Errore: Insere il Cognome contatto.');
		return(false);
	}
	//verifica campos vazios
	if ( document.modulo.citta.value == ''){
		alert('Errore: Insere Citta.');
		return(false);
	}
	//telefono
		if ( document.modulo.fax.value == ''){
		alert('Errore: Insere il Telefono.');
		return(false);
	}
	//E-mail
	if (!correio.test(document.modulo.email.value)) {
		alert('Errore: Insere il email.');
		return(false);
		}
	//struttura
	if (document.modulo.struttura.value == '') {
		alert('Errore: Ospedale dove avverra il parto.');
		return(false);
		}
	//anno//mese//giorno
	if (document.forms[0].aaaa.selectedIndex == 0 || document.forms[0].mm.selectedIndex == 0 || document.forms[0].gg.selectedIndex == 0) {
		alert('Errore: Data presunta del parto.');
		return(false);
		}

	
	return confirm("Conferma?");
	document.getElementById('modulo').submit();
}


/////////////////////////////////////////////////////////////////
////////////////////// SCHEDA DATI //////////////////////////////

///////////icryocode
function ShowHideDIV_Icriocode(NomeDIV, Valor){

if (Valor == "1"){
	document.getElementById("btn_submit").setAttribute("class", "button blue");
	document.getElementById('CampoOculto_anos_cryo').style.display = "block";
	/*
	document.getElementById('tabela_servico').style.backgroundImage="url('images/dati/dati_01.png')";
	 document.getElementById(NomeDIV).style.display = "block";
	 document.getElementById('CampoOculto_anos_cryo').style.display = "none";
	 document.getElementById('CampoOculto_isfcode').style.display = "none";
	 document.getElementById('CampoOculto_icryocode_input').style.display = "block";

	 //document.getElementById('href_servizio').href="icryo.php";
	*/
  }
if (Valor == "2"){
	document.getElementById("btn_submit").setAttribute("class", "button orange");
	document.getElementById('CampoOculto_anos_cryo').style.display = "block";
	/*
	document.getElementById('tabela_servico').style.backgroundImage="url('images/dati/dati_02.png')";
	
	document.getElementById(NomeDIV).style.display = "none";
	document.getElementById('CampoOculto_anos_cryo').style.display = "block";
	document.getElementById('CampoOculto_isfcode').style.display = "block";
	document.getElementById('CampoOculto_icryocode_input').style.display = "block";

	//document.getElementById('href_servizio').href="eucord.php";
	*/
   }
if (Valor == "3"){
	document.getElementById("btn_submit").setAttribute("class", "button magenta");
	document.getElementById('CampoOculto_anos_cryo').style.display = "none";
	/*
	document.getElementById('tabela_servico').style.backgroundImage="url('images/dati/dati_03.png')";

	document.getElementById(NomeDIV).style.display = "none";
	document.getElementById('CampoOculto_anos_cryo').style.display = "block";
	document.getElementById('CampoOculto_isfcode').style.display = "block";
	document.getElementById('CampoOculto_icryocode_input').style.display = "block";
	
	//document.getElementById('href_servizio').href="cryo.php";
	*/
   }
   //////////////////////////
  
   actualiza_dados();

}

/////////////////////////////////////////////////////////////////

/*I****************** SHOW HIDE DIVs ***************************/

function ShowHideDIV(NomeDIV, Valor){

actualiza_dados();

if (Valor=="1"){
  document.getElementById(NomeDIV).style.display = "block";
  document.getElementById('img_tipo').src="images/car.png";
  }
  else
  {
    document.getElementById(NomeDIV).style.display = "none";
	document.getElementById('img_tipo').src="images/car_001.png";
   }
}
//////shedadati_select_mezzocontatto
function ShowHideDIV_Mezzo(NomeDIV, Valor){
if (Valor=="4"){
  document.getElementById(NomeDIV).style.display = "block";
  }
  else
  {
    document.getElementById(NomeDIV).style.display = "none";
  }
}
//////shedadati_select_Dest
function ShowHideDIV_Dest(NomeDIV, Valor){
if (Valor=="3"){
  document.getElementById(NomeDIV).style.display = "block";
  }
  else
  {
    document.getElementById(NomeDIV).style.display = "none";
  }
}
//////shedadati_select_Dest
function ShowHideDIV_Indi(NomeDIV, Valor){
if (Valor=="2"){
  document.getElementById(NomeDIV).style.display = "block";
  }
  else
  {
    document.getElementById(NomeDIV).style.display = "none";
  }
}
//////shedadati_select_Dest
function ShowHideDIV_Fatt(NomeDIV, Valor){
if (Valor=="3"){
  document.getElementById(NomeDIV).style.display = "block";
  }
  else
  {
    document.getElementById(NomeDIV).style.display = "none";
  }
}
//////shedadati_select_Organizzato
function ShowHideDIV_Org(NomeDIV, Valor){
	alert(Valor);
if (Valor=="SI"){
  document.getElementById(NomeDIV).style.display = "block";
  }
  else
  {
    document.getElementById(NomeDIV).style.display = "none";
  }
}
/******************* SHOW HIDE DIVs *************************F*/


function data_copy_papa()
{

if(document.formdati.copy[0].checked){
	document.formdati.indirizzo_papa.value = document.formdati.indirizzo_mamma.value;
	document.formdati.citta_papa.value = document.formdati.citta_mamma.value;
	document.formdati.prov_papa.selectedIndex = document.formdati.prov_mamma.selectedIndex; 
	document.formdati.cap_papa.value = document.formdati.cap_mamma.value;

	document.formdati.aux_select_prov_mamma.value = document.prov_mamma.value;
	
}else{
	document.formdati.indirizzo_papa.value = "";
	document.formdati.citta_papa.value = "";
	document.formdati.prov_papa.selectedIndex = 0;
	document.formdati.cap_papa.value = "";
}

}

function data_copy_domicilio(Valor){
if (Valor=="1"){
	document.formdati.indirizzo.value = "";
	document.formdati.citta.value = "";
	document.formdati.provincia.selectedIndex = 0;
	document.formdati.cap.value = "";
  }
if (Valor=="2"){
	document.formdati.indirizzo.value = document.formdati.indirizzo_mamma.value;
	document.formdati.citta.value = document.formdati.citta_mamma.value;
	document.formdati.provincia.selectedIndex=document.formdati.prov_mamma.selectedIndex;
	document.formdati.cap.value = document.formdati.cap_mamma.value;
  }
if (Valor=="3"){
	document.formdati.indirizzo.value = document.formdati.indirizzo_papa.value;
	document.formdati.citta.value = document.formdati.citta_papa.value;
	document.formdati.provincia.selectedIndex=document.formdati.prov_papa.selectedIndex;
	document.formdati.cap.value = document.formdati.cap_papa.value;
  
  }
}





