function getBrowser(){if(window.XMLHttpRequest){return "mozilla";}else if(window.ActiveXObject){return "ie";}}
function doXMLRequester(){if(getBrowser() == "ie"){return new ActiveXObject("Microsoft.XMLHTTP");}else if(getBrowser() == "mozilla"){return new XMLHttpRequest();}}

//Função Para Replace!
function replaceAll( str, from, to ) {var idx = str.indexOf( from );while ( idx > -1 ) {str = str.replace( from, to ); idx = str.indexOf( from );}return str;}

function mostraCatalogoPetit(){window.open('catalogo_petit.html','revistaPetit','scrollbars=no,fullscreen=yes');}
function mostraCatalogoCouture(){window.open('catalogo_couture.html','revistaCouture','scrollbars=no,fullscreen=yes');}

function mostraCatalogoRestrito(){window.open('catalogo.restrito.asp','restrito','scrollbars=no,fullscreen=yes');}

/*CHECAGEM DO FORMULÁRIO DE CONTATO*/
function checkContato(){
	var nome = ById('frmc_nome').value;
	var email = ById('frmc_email').value;
	var mensagem = ById('frmc_mensagem').value;
	
	if(nome == ""){	
		alert("Campo Requerido (Nome)!")
		ById('frmc_nome').focus();	
	}else if(email == ""){
		alert("Campo Requerido (E-Mail)!");
		ById('frmc_email').focus();
	}else if(!eh_email(email)){
		alert("E-mail inválido!");
		ById('frmc_email').focus();	
	}else if(mensagem == ""){
		alert("Campo Requerido (Mensagem)!");
		ById('frmc_mensagem').focus();
	}else{
		document.frmContato.submit();
	}
}
/*FIM DA CHECAGEM DO FORMULÁRIO DE CONTATO*/
function checkFranquia(){
	var nome = ById('nome_f').value;
	var email = ById('email_f').value;
	
	if(nome == ""){	
		alert("Campo Requerido (Nome)!")
		ById('nome_f').focus();	
	}else if(email == ""){
		alert("Campo Requerido (E-Mail)!");
		ById('email_f').focus();
	}else if(!eh_email(email)){
		alert("E-mail inválido!");
		ById('email_f').focus();	
	}else{
		document.frmFranquia.submit();
	}
}


/*CHECAGEM DO FORMULÁRIO DE CONTATO*/
function checkAgenda()
{
	var nome = ById('frmc_nome').value;
	var email = ById('frmc_email').value;
	var telefone = ById('frmc_telefone').value;
	
	if(nome == ""){	
		alert("Campo Requerido (Nome)!")
		ById('frmc_nome').focus();	
	}else if(email == ""){
		alert("Campo Requerido (E-Mail)!");
		ById('frmc_email').focus();
	}else if(!eh_email(email)){
		alert("E-mail inválido!");
		ById('frmc_email').focus();	
	}else if(telefone == ""){
		alert("Campo Requerido (Mensagem)!");
		ById('frmc_telefone').focus();
	}else{
		document.frmAgenda.submit();
	}
}
/*FIM DA CHECAGEM DO FORMULÁRIO DE CONTATO*/


/*CHECAGEM DO FORMULÁRIO DE CONTATO*/
function checkCadastro()
{
	var frmc_nome 		= document.frmCadastro.frmc_nome.value;
	var frmc_sobrenome 	= document.frmCadastro.frmc_sobrenome.value;
	var frmc_email 		= document.frmCadastro.frmc_email.value;
	var frmc_telefone 	= document.frmCadastro.frmc_telefone.value;
	var frmc_rg 		= document.frmCadastro.frmc_rg.value;
	var frmc_cpf 		= document.frmCadastro.frmc_cpf.value;
	var frmc_endereco 	= document.frmCadastro.frmc_endereco.value;
	var frmc_cidade 	= document.frmCadastro.frmc_cidade.value;
	var frmc_estado 	= document.frmCadastro.frmc_estado.value;
	var frmc_pais 		= document.frmCadastro.frmc_pais.value;

	frmc_nome 		= replaceAll(frmc_nome," ","");
	frmc_sobrenome 	= replaceAll(frmc_sobrenome," ","");
	frmc_email 		= replaceAll(frmc_email," ","");
	frmc_telefone 	= replaceAll(frmc_telefone," ","");
	frmc_rg 		= replaceAll(frmc_rg," ","");
	frmc_cpf 		= replaceAll(frmc_cpf," ","");
	frmc_endereco 	= replaceAll(frmc_endereco," ","");
	frmc_cidade 	= replaceAll(frmc_cidade," ","");
	frmc_estado 	= replaceAll(frmc_estado," ","");
	frmc_pais 		= replaceAll(frmc_pais," ","");
	
	//Retorna a cor de back normal dos campos.
	/*
	document.frmCadastro.frmc_nome		.style.backgroundColor='transparent';
	document.frmCadastro.frmc_sobrenome	.style.backgroundColor='transparent';
	document.frmCadastro.frmc_email		.style.backgroundColor='transparent';
	document.frmCadastro.frmc_telefone	.style.backgroundColor='transparent';
	document.frmCadastro.frmc_rg		.style.backgroundColor='transparent';
	document.frmCadastro.frmc_cpf		.style.backgroundColor='transparent';
	document.frmCadastro.frmc_endereco	.style.backgroundColor='transparent';
	document.frmCadastro.frmc_cidade	.style.backgroundColor='transparent';
	document.frmCadastro.frmc_estado	.style.backgroundColor='transparent';
	document.frmCadastro.frmc_pais		.style.backgroundColor='transparent';
	*/
	

	var FormData = new Boolean("true");
	var ConteudoErro = "Foram detectados os seguintes erros:\n\n";

	if(frmc_nome==""){
		ConteudoErro+="- Campo requerido [NOME] .\n";
		//document.frmCadastro.frmc_nome.style.backgroundColor='#FF6600';
		FormData=false;
	}
	if(frmc_sobrenome==""){
		ConteudoErro+="- Campo requerido [SOBRENOME].\n";
		//document.frmCadastro.frmc_sobrenome.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_email==""){
		ConteudoErro+="- Campo requerido [E-MAIL].\n";
		//document.frmCadastro.frmc_email.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(!eh_email(frmc_email)){
		ConteudoErro+="- E-mail inválido [ "+frmc_email+" ].\n";
		//document.frmCadastro.frmc_email.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_telefone==""){
		ConteudoErro+="- Campo requerido [TELEFONE].\n";
		//document.frmCadastro.frmc_telefone.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_rg==""){
		ConteudoErro+="- Campo requerido [RG].\n";
		//document.frmCadastro.frmc_rg.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_cpf==""){
		ConteudoErro+="- Campo requerido [CPF].\n";
		//document.frmCadastro.frmc_cpf.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_endereco==""){
		ConteudoErro+="- Campo requerido [ENDEREÇO].\n";
		//document.frmCadastro.frmc_endereco.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_cidade==""){
		ConteudoErro+="- Campo requerido [CIDADE].\n";
		//document.frmCadastro.frmc_cidade.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_estado==""){
		ConteudoErro+="- Campo requerido [ESTADO].\n";
		//document.frmCadastro.frmc_estado.style.backgroundColor='#FFFFCC';
		FormData=false;
	}
	if(frmc_pais==""){
		ConteudoErro+="- Campo requerido [PAÍS].\n";
		//document.frmCadastro.frmc_pais.style.backgroundColor='#FFFFCC';
		FormData=false;
	}

	if(FormData)
	{
		document.frmCadastro.submit();
	}
	else
	{
		alert(ConteudoErro);	
	}
}
/*FIM DA CHECAGEM DO FORMULÁRIO DE CONTATO*/



//Checa se uma data é válida

/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2078;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}


function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(0,pos1)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("O formato da data terá de ser: dd/mm/aaaa")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Entre com um mês válido!")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Entre com um dia válido!")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Entre com um ano de quatro dígitos válido entre  "+minYear+" e "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Entre com uma data válida!");
		return false
	}
return true
}
/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/


/* MOSTRAR OU OCULTAR UMA CAMADA */
function sh_layer(camada){
	eval("var stats=document.getElementById('"+camada+"').style.display;");
	if(stats=="block"){
		eval("document.getElementById('"+camada+"').style.display='none';");
		}else{
			eval("document.getElementById('"+camada+"').style.display='block';");
			}
	
	}
/*xx MOSTRAR OU OCULTAR UMA CAMADA xx*/


/*
Função para validação de CPF
*/
function isCPF(st) {
if (st == "")
return (false);
l = st.length;

//aleterado para se usuário não digitar os zeros na frente do CPF, completar sozinho
if ((l == 9) || (l == 8))
{
for (i = l ; i < 10; i++)
{
st = '0' + st
}
}
l = st.length;
st2 = "";
for (i = 0; i < l; i++) {
caracter = st.substring(i,i+1);
if ((caracter >= '0') && (caracter <= '9'));
st2 = st2 + caracter;
}
if ((st2.length > 11) || (st2.length < 10))
return (false);
if (st2.length==10)
st2 = '0' + st2;
digito1 = st2.substring(9,10);
digito2 = st2.substring(10,11);
digito1 = parseInt(digito1,10);
digito2 = parseInt(digito2,10);
sum = 0; mul = 10;
for (i = 0; i < 9 ; i++) {
digit = st2.substring(i,i+1);
tproduct = parseInt(digit ,10) * mul;
sum += tproduct;
mul--;
}
dig1 = ( sum % 11 );
if ( dig1==0 || dig1==1 )
dig1=0;
else
dig1 = 11 - dig1;
if (dig1!=digito1)
return (false);
sum = 0;
mul = 11;
for (i = 0; i < 10 ; i++) {
digit = st2.substring(i,i+1);
tproduct = parseInt(digit ,10)*mul;
sum += tproduct;
mul--;
}
dig2 = (sum % 11);
if ( dig2==0 || dig2==1 )
dig2=0;
else
dig2 = 11 - dig2;
if (dig2 != digito2)
return (false);
return (true);
}
/*
Fim da Função para validação do CPF
*/

/*
Função para validação de e-mail
*/
function eh_email(mail){
var ret = false;
if (typeof(mail) != "undefined"){
mail = mail.match(/(\w+)@(.+)\.(\w+)$/);
if (mail != null){
if ((mail[3].length==2) || (mail[3].length==3))
ret = true;
}
}
return ret;
}
/*
Fim da função de validação de e-mail
*/









// **************************************************
// * Calendário
// * Autor : Peter M Jordan - uranking@uranking.com *
// * página: www.uranking.com                       *
// **************************************************

// construindo o calendário
function popdate(obj,div,tam,ddd)
{
    if (ddd) 
    {
        day = ""
        mmonth = ""
        ano = ""
        c = 1
        char = ""
        for (s=0;s<parseInt(ddd.length);s++)
        {
            char = ddd.substr(s,1)
            if (char == "/") 
            {
                c++; 
                s++; 
                char = ddd.substr(s,1);
            }
            if (c==1) day    += char
            if (c==2) mmonth += char
            if (c==3) ano    += char
        }
        ddd = mmonth + "/" + day + "/" + ano
    }
  
    if(!ddd) {today = new Date()} else {today = new Date(ddd)}
    date_Form = eval (obj)
    if (date_Form.value == "") { date_Form = new Date()} else {date_Form = new Date(date_Form.value)}
  
    ano = today.getFullYear();
    mmonth = today.getMonth ();
    day = today.toString ().substr (8,2)
  
    umonth = new Array ("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro")
    days_Feb = (!(ano % 4) ? 29 : 28)
    days = new Array (31, days_Feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

    if ((mmonth < 0) || (mmonth > 11))  alert(mmonth)
    if ((mmonth - 1) == -1) {month_prior = 11; year_prior = ano - 1} else {month_prior = mmonth - 1; year_prior = ano}
    if ((mmonth + 1) == 12) {month_next  = 0;  year_next  = ano + 1} else {month_next  = mmonth + 1; year_next  = ano}
    txt  = "<table bgcolor='#eeeeee' style='border:1px solid #333333;' cellspacing='0' cellpadding='3' border='0' width='"+tam+"' height='"+tam*1.1 +"' class=fonte_padrao>"
    txt += "<tr bgcolor='#FFFFFF'><td colspan='7' align='center'><table border='0' cellpadding='0' width='100%' bgcolor='#FFFFFF'><tr>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano-1).toString())+"') class='Cabecalho_Calendario' title='Ano Anterior'><<</a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_prior+1).toString() + "/" + year_prior.toString())+"') class='Cabecalho_Calendario' title='Mês Anterior'><</a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_next+1).toString()  + "/" + year_next.toString())+"') class='Cabecalho_Calendario' title='Próximo Mês'>></a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano+1).toString())+"') class='Cabecalho_Calendario' title='Próximo Ano'>>></a></td>"
    txt += "<td width=20% align=right><a href=javascript:force_close('"+div+"') class='Cabecalho_Calendario' title='Fechar Calendário'><b>x</b></a></td></tr></table></td></tr>"
    txt += "<tr><td colspan='7' align='right' bgcolor='#eeeeee' class='mes'>" + ano.toString()
    txt += " " + umonth[mmonth] + " <div id='popd' style='position:absolute'></div></td></tr>"
    txt += "<tr bgcolor='#333333'><td width='14%' class='dia' align=center><b>Dom</b></td><td width='14%' class='dia' align=center><b>Seg</b></td><td width='14%' class='dia' align=center><b>Ter</b></td><td width='14%' class='dia' align=center><b>Qua</b></td><td width='14%' class='dia' align=center><b>Qui</b></td><td width='14%' class='dia' align=center><b>Sex<b></td><td width='14%' class='dia' align=center><b>Sab</b></td></tr>"
    today1 = new Date((mmonth+1).toString() +"/01/"+ano.toString());
    diainicio = today1.getDay () + 1;
    week = d = 1
    start = false;

    for (n=1;n<= 42;n++) 
    {
        if (week == 1)  txt += "<tr bgcolor='#eeeeee' align=left>"
        if (week==diainicio) {start = true}
        if (d > days[mmonth]) {start=false}
        if (start) 
        {
            dat = new Date((mmonth+1).toString() + "/" + d + "/" + ano.toString())
            day_dat   = dat.toString().substr(0,10)
            day_today  = date_Form.toString().substr(0,10)
            year_dat  = dat.getFullYear ()
            year_today = date_Form.getFullYear ()
            colorcell = ((day_dat == day_today) && (year_dat == year_today) ? " bgcolor='#FFCC00' " : "" )
			var mmonthNeo = mmonth+1;
			if(mmonthNeo<10){var mmonthNeo="0"+mmonthNeo;}
			var dNeo=d;
			if(dNeo<10){var dNeo="0"+dNeo;}
            txt += "<td"+colorcell+" align=left><a href=javascript:block('"+  dNeo + "/" + (mmonthNeo).toString() + "/" + ano.toString() +"','"+ obj +"','" + div +"') class='data'>"+ dNeo.toString() + "</a></td>"
            d ++ 
        } 
        else 
        { 
            txt += "<td class='data' align=left> </td>"
        }
        week ++
        if (week == 8) 
        { 
            week = 1; txt += "</tr>"} 
        }
        txt += "</table>"
        div2 = eval (div)
        div2.innerHTML = txt 
}
  
// função para exibir a janela com os meses
function pop_month(obj, div, tam, ano)
{
  txt  = "<table bgcolor='#eeeeee' border='0' width=80 class='mes' >"
  for (n = 0; n < 12; n++) { txt += "<tr><td align=left><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+("01/" + (n+1).toString() + "/" + ano.toString())+"')>" + umonth[n] +"</a></td></tr>" }
  txt += "</table>"
  popd.innerHTML = txt
}

// função para exibir a janela com os anos
function pop_year(obj, div, tam, umonth)
{
  txt  = "<table bgcolor='#eeeeee' border='0' width=160 class='mes'>"
  l = 1
  for (n=1991; n<2012; n++)
  {  if (l == 1) txt += "<tr>"
     txt += "<td align=left><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+(umonth.toString () +"/01/" + n) +"')>" + n + "</a></td>"
     l++
     if (l == 4) 
        {txt += "</tr>"; l = 1 } 
  }
  txt += "</tr></table>"
  popd.innerHTML = txt 
}

// função para fechar o calendário
function force_close(div) 
    { div2 = eval (div); div2.innerHTML = ''}
    
// função para fechar o calendário e setar a data no campo de data associado
function block(data, obj, div)
{ 
    force_close (div)
    obj2 = eval(obj)
    obj2.value = data 
}




function getPosicaoElemento(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}


function enviarCurr(){
	var nome 		= ById('nome').value;
		nome 		= replaceAll(nome," ","");
	var email 		= ById('email').value;
		email		= replaceAll(email," ","");
	var foto 		= ById('arq_send_01').value;
		foto		= replaceAll(foto," ","");
	
	//Retorna a cor de back normal dos campos.
	//ById('nome').style.backgroundColor='#FFFFFF';
	//ById('email').style.backgroundColor='#FFFFFF';
	//ById('fotoCurr').style.backgroundColor='#FFFFFF';

	var FormData = new Boolean("true");
	var ConteudoErro = "Foram detectados os seguintes erros:\n\n";

	if(nome==""){
		ConteudoErro+="- Campo requerido [NOME] .\n";
		ById('nome').style.backgroundColor='';
		FormData=false;
	}
	if(email == "")
	{
		ConteudoErro+="- Campo requerido [E-mail] .\n";
		ById('email').style.backgroundColor='';
		FormData=false;
	}
	if(!eh_email(email))
	{
		ConteudoErro+="- E-mail inválido ["+email+"] .\n";
		ById('email').style.backgroundColor='';
		FormData=false;
	}
	if(foto==""){
		ConteudoErro+="- Campo requerido [ Enviar foto ] .\n";
		ById('arq_send_01').style.backgroundColor='';
		FormData=false;
	}
	if(FormData)
	{
		ById('frmCurriculo').submit();
	}
	else
	{
		alert(ConteudoErro);
	}
}


/* ====================================================== */
//Contador de caracteres nos campos de inserção de novo anuncio
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
cntfield.value = maxlimit - field.value.length;
}
/* ====================================================== */

