//rollover imagens
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];}
}
//rollover imagens


//ROLL OVER CAMPOS
function limpa(valor, campo,tipo) {
          if (tipo == "a") {
              if (valor == "Nome") {
                  document.getElementById(campo).value = "";
            }
        }
        if (tipo == "b") {
            if (valor == "DDD") {
                document.getElementById(campo).value = "";
            }
        }
		 if (tipo == "c") {
            if (valor == "Telefone") {
                document.getElementById(campo).value = "";
            }
        }
		if (tipo == "d") {
            if (valor == "E-mail") {
                document.getElementById(campo).value = "";
            }
        }
		
		if (tipo == "e") {
            if (valor == "Horario") {
                document.getElementById(campo).value = "";
            }
        }
    }
	    function preenche(valor, campo, tipo) {
        if (tipo == "a") {
            if (valor == "") {
                document.getElementById(campo).value = "Nome";
            }
        }
        if (tipo == "b") {
            if (valor == "") {
                document.getElementById(campo).value = "DDD";
            }
        }
		if (tipo == "c") {
            if (valor == "") {
                document.getElementById(campo).value = "Telefone";
            }
        }
		if (tipo == "d") {
            if (valor == "") {
                document.getElementById(campo).value = "E-mail";
            }
        }
		if (tipo == "e") {
            if (valor == "") {
                document.getElementById(campo).value = "Horario";
            }
        }
    }

//ROLL OVER CAMPOS


// source de validaçõe




		function isNumeric(iCampo,iNomeCampo) {
	while(iCampo.value.indexOf('.') != -1) {iCampo.value = iCampo.value.replace('.','')}
	while(iCampo.value.indexOf(' ') != -1) {iCampo.value = iCampo.value.replace(' ','')}
	while(iCampo.value.indexOf('-') != -1) {iCampo.value = iCampo.value.replace('-','')}
	if (isNaN(iCampo.value) == true) {
		alert('Utilize apenas numeros para ' + iNomeCampo);
		/* iCampo.focus(); iCampo.select(); */ return false;
	}
}

function isNumerico(iCampo,iNomeCampo) {
	if (isNaN(iCampo.value) == true) {
		alert('Utilize apenas numeros para ' + iNomeCampo);
		/* iCampo.focus(); iCampo.select(); */ return false;
	}
}

function isEmail(iCampo,iNomeCampo) {
	var str = iCampo.value;
		//alert(str);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	if ( (!r1.test(str) && r2.test(str)) ) {
		return true;
	} else {
		/* iCampo.focus(); iCampo.select(); */
		//alert(iNomeCampo+" invalido.");
		return false;
	}
	return true;
}

function EhIgual(campo) { /* Verifica se todos os valores são iguais */
	var i = 0
	var j = 1
	var igual = true;
	/* Todos os caracteres devem ser diferentes */
	while (i < campo.length-1 && igual == true) {
		while (j < campo.length && igual == true) {
			if (campo.charAt(i) != campo.charAt(j)) {
				igual = false;
			}
			else j++;
		}
		i++;
	}
	return igual;
}

function isVazio(iCampo,iNomeCampo) {
	if (iCampo.value == false) {
		alert(iNomeCampo + ' e obrigatorio.');
		iCampo.focus();
		return false;
	}
	return true;
}

function isCPF(iCampo,iNomeCampo){
	if (isNumeric(iCampo,iNomeCampo)==false) {return false;};
	if (EhIgual(iCampo.value)==true) { 
		/* iCampo.focus(); */
		alert(iNomeCampo + ' é invalido.');
		return false; 
	}
	x=0; 
	soma=0; 
	dig1=0; 
	dig2=0; 
	texto=""; 
	iCampo1="";
	len = iCampo.value.length; 
	x = len -1;
	for (var i=0; i <= len - 3; i++) {
		y = iCampo.value.substring(i,i+1); 
		soma = soma + ( y * x);
		x = x - 1; 
		texto = texto + y;
	}
	dig1 = 11 - (soma % 11);
	if (dig1 == 10) dig1=0 ; 
	if (dig1 == 11) dig1=0 ;
	iCampo1 = iCampo.value.substring(0,len - 2) + dig1 ;
	x = 11; soma=0;
	for (var i=0; i <= len - 2; i++) {
		soma = soma + (iCampo1.substring(i,i+1) * x); 
		x = x - 1;
	}
	dig2= 11 - (soma % 11);
	if (dig2 == 10) dig2=0; 
	if (dig2 == 11) dig2=0;
	if ((dig1 + "" + dig2) == iCampo.value.substring(len,len-2)) {
		return true;
	}
	/* iCampo.focus(); */
	alert(iNomeCampo + ' e invalido.');
	return false; 
}

function isCNPJ(iCampo, iNomeCampo) {
	if (EhIgual(iCampo.value)==true) { 
		iCampo.focus();
		alert(iNomeCampo + ' e invalido.');
		return false; 
	}
	dac1 = 0; 
	dac2 = 0; 
	dac = ""; 
	dact = ""; 
	sum = 0;
	iCampo1="";
	dac = iCampo.value.substring(iCampo.value.length-2, iCampo.value.length);
	iCampo1 = iCampo.value.substring(0,iCampo.value.length-2);
	for (i=iCampo1.length-1, j=2; i >= 0 ; i--, j++) {	
		j = (j == 10) ? 2 : j; 
		sum += (iCampo1.substring(i, i+1) * j); 
	}
	dac1 = ((sum * 10) % 11); 
	dac1 = (dac1 == 10) ? 0 : dac1; 
	sum = 0;
	for (i=iCampo1.length-1, j=3; i >= 0 ; i--, j++){	
		j = (j == 10) ? 2 : j; 
		sum += (iCampo1.substring(i, i+1) * j); 
	}
	sum  += (dac1 * 2); 
	dac2 = ((sum * 10) % 11); 
	dac2 = (dac2 == 10) ? 0 : dac2; 
	dact = dac1+""+dac2;
	if (dact == dac) {
		return true;
	} else {	
		iCampo.focus();
		alert(iNomeCampo + ' e invalido.');
		return false; 
	}
}

function isData(strData,dataObj,alertData) {
	var exprData = new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)[0-9]{2}", "gi");

	ret = exprData.exec(strData);

	if(strData == '' || ret == null){
		alert(alertData); /* dataObj.focus() */ ;return false;
	} else {
		arrData = strData.split('/');
		testData = new Date(arrData[2], arrData[1]-1, arrData[0], 0, 0, 0, 0);

		if((testData.getDate()==arrData[0])&&
			 ((testData.getMonth())==(arrData[1]-1))&&
				(testData.getFullYear()==arrData[2])){
		} else {
			alert(alertData); /* dataObj.focus();dataObj.select(); */ return false;
		}
	}
}
function prc_campo(campo, qtd, valor) {
    if (valor.length == qtd) {
        document.getElementById(campo).focus();
    }


}

var isNav4, isNav, isIE;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
    isNav = (navigator.appName == "Netscape") ? true : false;
    isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}
if (navigator.appName == "Netscape") {
    isNav4 = (parseInt(navigator.appVersion.charAt(0)) == 4);
}
function onlynum(e) {
    var keyNumber = (isIE) ? event.keyCode : e.which;
    if (((keyNumber < 48) || (keyNumber > 57)) && (keyNumber != 13) && (keyNumber != "0") &&

(keyNumber != 8) && (keyNumber != 44)) {
        if (isIE) event.keyCode = 0;
        return false;
    }
}
	  
	  
	// source de validaçõe
	
	
	
	
	//VALIDACOES
	
	
	function validaColDirForm()
{
    nform = document.forms['ColDirForm'];
    

    if(nform.nome.value == '' || nform.nome.value == 'Nome') {

        alert('Digite o seu Nome!');

        nform.nome.focus();

        return false;
    }

    if(nform.ddd.value == ''  || nform.ddd.value == 'DDD') {

        alert('Informe seu DDD.');

        nform.ddd.focus();

        return false;
    }

    if(nform.telefone.value == ''  || nform.telefone.value == 'Telefone') {

        alert('Informe seu Telefone.');

        nform.telefone.focus();

        return false;
    }
	
	 if(isEmail(nform.email,'E-mail')==false) {

        alert('Digite um E-mail valido.');

        nform.email.focus();

        return false;

    }
	
    if(nform.tipoCirurgia.value == '') {

        alert('Selecione um tipo de cirurgia.');

        nform.tipoCirurgia.focus();

        return false;

    }

    if(nform.preferenciaHorario.value == '') {

        alert('Informe um horario.');

        nform.preferenciaHorario.focus();

        return false;

    }


   

}
			
			
			
function validaContato()
           {
			   var nform = document.Contato;
			   
          if(nform.departamento.value ==''){
			 alert('Selecione um departamento!');
			 nform.departamento.focus();
           	 return false;
		  }
		 
			 if(nform.nome.value == '' || nform.nome.value == 'Nome') {
           alert('Digite o seu Nome!');
           nform.nome.focus();
           return false;
            }
			
			if(nform.telefone_ddd.value == ''  || nform.telefone_ddd.value == 'DDD') {
           alert('Informe seu DDD.');
           nform.telefone_ddd.focus();
           return false;
          }
		  
		  if(nform.telefone.value == ''  || nform.telefone.value == 'Telefone') {
           alert('Informe seu Telefone.');
           nform.telefone.focus();
           return false;
          }
		  
		  if(nform.celular_ddd.value == ''  || nform.celular_ddd.value == 'DDDCelular') {
           alert('Informe seu DDD do Celular.');
           nform.celular_ddd.focus();
           return false;
          }
		  
		  if(nform.celular.value == ''  || nform.celular.value == 'Celular') {
           alert('Informe seu Celular.');
           nform.celular.focus();
           return false;
          }
		  
		   if(nform.email.value == ''  || nform.email.value == 'E-mail') {
           alert('Informe seu E-mail.');
           nform.email.focus();
           return false;
          }
		  
		  if(isEmail(nform.email,'E-mail')==false) {
		   alert('Informe um e-mail valido.');
           nform.email.focus();
           return false; 
		  }
		  
		   if(nform.cAssunto.value == ''  || nform.cAssunto.value == 'Assunto') {
           alert('Informe o assunto.');
           nform.cAssunto.focus();
           return false;
          }	
		  
		   if(nform.mensagem.value == ''  || nform.mensagem.value == 'Mensagem') {
           alert('Mande sua mensagem.');
           nform.mensagem.focus();
           return false;
          }	
		   
		  
            }
			
function vld_news_latter(){
	if(document.getElementById("id_email_newsletter").value==""){
		alert('Informe seu E-mail.');
          document.getElementById("id_email_newsletter").focus();
           return false;
		
	}
	else if(isEmail(document.getElementById("id_email_newsletter"),'E-mail')==false) {
		   alert('Informe um e-mail valido.');
           document.getElementById("id_email_newsletter").focus();
           return false; 
		  }
	else{
		return true;	
	}
	
}



function slideShow() {

    //Set the opacity of all images to 0
    $('#gallery a').css({ opacity: 0.0 });

    //Get the first image and display it (set it to full opacity)
    $('#gallery a:first').css({ opacity: 1.0 });

    //Set the caption background to semi-transparent
    $('#gallery .caption').css({ opacity: 0.7 });

    //Resize the width of the caption according to the image width
    $('#gallery .caption').css({ width: $('#gallery a').find('img').css('width') });

    //Get the caption of the first image from REL attribute and display it
    //$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	//.animate({ opacity: 0.7 }, 400);

    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('gallery()', 6000);

}

function gallery() {

    //if no IMGs have the show class, grab the first image
    var current = ($('#gallery a.show') ? $('#gallery a.show') : $('#gallery a:first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#gallery a:first') : current.next()) : $('#gallery a:first'));

    //Get next image caption
    var caption = next.find('img').attr('rel');

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({ opacity: 0.0 })
	.addClass('show')
	.animate({ opacity: 1.0 }, 1000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000)
	.removeClass('show');

    //Set the opacity to 0 and height to 1px
    $('#gallery .caption').animate({ opacity: 0.0 }, { queue: false, duration: 0 }).animate({ height: '1px' }, { queue: true, duration: 300 });

    //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
    $('#gallery .caption').animate({ opacity: 0.7 }, 100).animate({ height: '100px' }, 500);

    //Display the content
    $('#gallery .content').html(caption);


}

/*Fim Banner Premio*/

function gallery_quem_somos() {

    //Set the opacity of all images to 0
    $('#gallery_quem_somos a').css({ opacity: 0.0 });

    //Get the first image and display it (set it to full opacity)
    $('#gallery_quem_somos a:first').css({ opacity: 1.0 });

    //Set the caption background to semi-transparent
    $('#gallery_quem_somos .caption').css({ opacity: 0.7 });

    //Resize the width of the caption according to the image width
    $('#gallery_quem_somos .caption').css({ width: $('#gallery_quem_somos a').find('img').css('width') });

    //Get the caption of the first image from REL attribute and display it
    //$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	//.animate({ opacity: 0.7 }, 400);

    //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
    setInterval('gallery_quem_somos2()', 6000);

}

function gallery_quem_somos2() {

    //if no IMGs have the show class, grab the first image
    var current = ($('#gallery_quem_somos a.show') ? $('#gallery_quem_somos a.show') : $('#gallery_quem_somos a:first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('caption')) ? $('#gallery_quem_somos a:first') : current.next()) : $('#gallery_quem_somos a:first'));

    //Get next image caption
    var caption = next.find('img').attr('rel');

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({ opacity: 0.0 })
	.addClass('show')
	.animate({ opacity: 1.0 }, 1000);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 1000)
	.removeClass('show');

    //Set the opacity to 0 and height to 1px
    $('#gallery_quem_somos .caption').animate({ opacity: 0.0 }, { queue: false, duration: 0 }).animate({ height: '1px' }, { queue: true, duration: 300 });

    //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
    $('#gallery_quem_somos .caption').animate({ opacity: 0.7 }, 100).animate({ height: '100px' }, 500);

    //Display the content
    $('#gallery_quem_somos .content').html(caption);


}


function atendimento_online() 
{
    // por Wellington, tentando arrumando problema do chat no firefox
    jchat = window.open('http://atendimento.clinicasuprema.com.br/request_email.php?l=gf&x=1','atendimento_online','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=461,height=360,top=10,left=10');
    jchat.focus();
}
function popmysql(){
	//pega a resolução do visitante
var w = screen.width;
var h = screen.height;

//divide a resolução por 2, obtendo o centro do monitor
var meio_w = w/2;
var meio_h = h/2;

//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
var altura2 = 430/2;
var largura2 = 600/2;
var meio1 = meio_h-altura2;
var meio2 = meio_w-largura2;

	
window.open('http://plasticasuprema.mysuite.com.br/clientvivo.php?param=sochat_chatdep&inf=&sl=srm&redirect=http://plasticasuprema.mysuite.com.br/empresas/srm/atendimento.php', 'minhaJanela2', 'status = 1, height = 430, width = 600, resizable = 0, scrollbars=1, top='+meio1+',left='+meio2);
}
	
