Shadowbox.loadSkin('classic', 'shadowbox/skin');
Shadowbox.loadLanguage('pt-BR', 'shadowbox/lang');
Shadowbox.loadPlayer(['html', 'img', 'swf'], 'shadowbox/player');

function flashKingKoilPreto (){
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgKingKoilPreto.jpg)";
}

function flashKingKoilVermelho (){
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgKingKoilVermelho.jpg)";
}

function flashKingKoilAzul (){
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgKingKoilAzul.jpg)";
}

function flashKingKoilAmarelo (){
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgKingKoilAmarelo.jpg)";
}

function flashKingKoil(){
	
	Shadowbox.open({
		player:		'swf',
		content:	'swf/carregaKingKoil.swf?v=3',
		width:		'800',
		height:		'600'
	});
	
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgKingKoilPreto.jpg)";
	document.getElementById('shadowbox_overlay').style.backgroundPosition = "center";
	document.getElementById('shadowbox_body').style.border = "1px solid #111";
	document.getElementById('shadowbox_body').style.backgroundColor = "#000";
	document.getElementById('shadowbox_loading').style.backgroundColor = "#000";
	document.getElementById('shadowbox_nav_close').style.backgroundImage = "url(shadowbox/skin/classic/icons/closeWhite.png)";
	document.getElementById('shadowbox_loading_indicator').style.backgroundImage = "url(shadowbox/skin/classic/loadingWhite.gif)";
	
}

function flashInducol(){
	
	Shadowbox.open({
		player:		'swf',
		content:	'swf/carregaInducol.swf',
		width:		'800',
		height:		'600'
	});
	
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgInducol.jpg)";
	document.getElementById('shadowbox_overlay').style.backgroundPosition = "center";
	document.getElementById('shadowbox_body').style.border = "1px solid #DDD";
	document.getElementById('shadowbox_body').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_loading').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_nav_close').style.backgroundImage = "url(shadowbox/skin/classic/icons/closeBlack.png)";
	document.getElementById('shadowbox_loading_indicator').style.backgroundImage = "url(shadowbox/skin/classic/loadingBlack.gif)";

}

function flashNaturalResponse(){
	
	Shadowbox.open({
		player:		'swf',
		content:	'swf/carregaNaturalResponse.swf',
		width:		'800',
		height:		'600'
	});

	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgNaturalResponse.jpg)";
	document.getElementById('shadowbox_overlay').style.backgroundPosition = "center";
	document.getElementById('shadowbox_body').style.border = "1px solid #444";
	document.getElementById('shadowbox_body').style.backgroundColor = "#222";
	document.getElementById('shadowbox_loading').style.backgroundColor = "#222";
	document.getElementById('shadowbox_nav_close').style.backgroundImage = "url(shadowbox/skin/classic/icons/closeWhite.png)";
	document.getElementById('shadowbox_loading_indicator').style.backgroundImage = "url(shadowbox/skin/classic/loadingGray.gif)";

}

function flashCeluplas(){
	
	Shadowbox.open({
		player:		'swf',
		content:	'swf/carregaCeluplas.swf',
		width:		'800',
		height:		'600'
	});
	document.getElementById('shadowbox_overlay').style.backgroundImage = "url(img/bgCeluplas.jpg)";
	document.getElementById('shadowbox_overlay').style.backgroundPosition = "center";
	document.getElementById('shadowbox_overlay').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_body').style.border = "1px solid #DDD";
	document.getElementById('shadowbox_body').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_loading').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_nav_close').style.backgroundImage = "url(shadowbox/skin/classic/icons/closeBlack.png)";
	document.getElementById('shadowbox_loading_indicator').style.backgroundImage = "url(shadowbox/skin/classic/loadingBlack.gif)";
}

function ampliaFotos(foto){
	
	Shadowbox.open({
		player:		'img',
		content:	foto,
		width:		'677',
		height:		'316'
	});
	document.getElementById('shadowbox_overlay').style.backgroundImage = "none";
	document.getElementById('shadowbox_overlay').style.backgroundPosition = "center";
	document.getElementById('shadowbox_overlay').style.backgroundColor = "#000";
	//document.getElementById('shadowbox_overlay').style.filter = "alpha(opacity = 25)";
	//document.getElementById('shadowbox_overlay').style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
   //document.getElementById('shadowbox_overlay').style.opacity="0.75";
   
	document.getElementById('shadowbox_body').style.border = "4px solid #DDD";
	document.getElementById('shadowbox_body').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_loading').style.backgroundColor = "#FFF";
	document.getElementById('shadowbox_nav_close').style.backgroundImage = "url(shadowbox/skin/classic/icons/closeWhite.png)";
	document.getElementById('shadowbox_loading_indicator').style.backgroundImage = "url(shadowbox/skin/classic/loadingBlack.gif)";
}

window.onload = function() {

	Shadowbox.init({
		skipSetup: true
	});
	
}

var current =  0;

function imgPreloader( code ){
	var img = document.createElement("img");
	img.src = images_arr[ code ].src;
	img.alt = images_arr[ code ].alt;
	img.id = images_arr[ code ].id;
	img.onload = new function(){onLoadImg();};
	window.status = "Carregando "+ (current + 1) + " de " + images_arr.length + " imagens.";
}

function onLoadImg(){
	current++;
	if( current < images_arr.length ){
		imgPreloader( current );
	}
}
///////////////////////////
function valida_contato(){
	
	if (document.contato.nome.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu nome.");
		document.contato.nome.focus(); 
		return false;
	}
	else if (!validacpf(document.contato.cpf.value)) {
		//alert("Voc\u00EA esqueceu de fornecer seu CPF.");
		document.contato.cpf.focus(); 
		return false;
	}
	else if (document.contato.telefone.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu telefone.");
		document.contato.telefone.focus(); 
		return false;
	}
	else if (document.contato.cidade.value == "") {
		alert("Voc\u00EA esqueceu de fornecer sua cidade.");
		document.contato.cidade.focus(); 
		return false;
	}
	else if (document.contato.estado.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu estado.");
		document.contato.estado.focus(); 
		return false;
	}
	
	else if (document.contato.mensagem.value == "") {
		alert("Voc\u00EA esqueceu de fornecer sua mensagem.");
		document.contato.mensagem.focus(); 
		return false;
	}
	else if (document.contato.endereco.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu endere\u00E7o.");
		document.contato.endereco.focus(); 
		return false;
	} else
		document.contato.submit();
}

 
function validacpf(cpf){
	
	if (cpf == "") {
		alert("Voc\u00EA esqueceu de fornecer seu CPF.");
		return false;
	}
 
var i;
 
s = cpf;
 
var c = s.substr(0,9);
 
var dv = s.substr(9,2);
 
var d1 = 0;
 
for (i = 0; i < 9; i++)
 
{
 
d1 += c.charAt(i)*(10-i);
 
}
 
if (d1 == 0){
 
alert("CPF Inválido");
//document.contato.cpf.focus();
 
return false;
 
}
 
d1 = 11 - (d1 % 11);
 
if (d1 > 9) d1 = 0;
 
if (dv.charAt(0) != d1)
 
{
 
alert("CPF Inválido");
//document.contato.cpf.focus();
 
return false;
 
}
 
 
d1 *= 2;
 
for (i = 0; i < 9; i++)
 
{
 
d1 += c.charAt(i)*(11-i);
 
}
 
d1 = 11 - (d1 % 11);
 
if (d1 > 9) d1 = 0;
 
if (dv.charAt(1) != d1)
 
{
 
alert("CPF Inválido");
//document.contato.cpf.focus();
 
return false;
 
}
 
return true;
 
}
///////////////////////////
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}

function valida_contato_espumas(){
	
	if (document.contato.nome.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu nome.");
		document.contato.nome.focus(); 
		return false;
	}
	else if (document.contato.empresa.value == "") {
		alert("Voc\u00EA esqueceu de fornecer sua empresa.");
		document.contato.empresa.focus(); 
		return false;
	}
	else if (!checkMail(document.contato.email.value)) {
    	alert("Voc\u00EA esqueceu de fornecer seu e-mail.");
		document.contato.email.focus(); 
		return false;
	}
	else if (document.contato.telefone.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu telefone.");
		document.contato.telefone.focus(); 
		return false;
	}
	else if (document.contato.cidade.value == "") {
		alert("Voc\u00EA esqueceu de fornecer sua cidade.");
		document.contato.cidade.focus(); 
		return false;
	}
	else if (document.contato.estado.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu estado.");
		document.contato.estado.focus(); 
		return false;
	}
	
	else if (document.contato.mensagem.value == "") {
		alert("Voc\u00EA esqueceu de fornecer sua mensagem.");
		document.contato.mensagem.focus(); 
		return false;
	}
	else if (document.contato.endereco.value == "") {
		alert("Voc\u00EA esqueceu de fornecer seu endere\u00E7o.");
		document.contato.endereco.focus(); 
		return false;
	} else
		document.contato.submit();
}

//--------------------
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];}
}

//------------------
function MM_openBrWindow(theURL,winName,features) {
	var largura = screen.availWidth;
	var altura = screen.availHeight; //v2.0
  window.open(theURL,winName,"width="+largura+",height="+altura+",top=0,left=0,scrollbars = 1, status = 0, toolbar = 0, titlebar=0");
}

function mostraDiv(campoSelect){
	valor=document.getElementById(campoSelect).value;		
	divPessoa =document.getElementById('campoOutros');	
	divPessoa2 =document.getElementById('campoOutros2');	
	if(valor == 'Outros'){
		divPessoa.style.display='block'
		divPessoa2.style.display='block'
	} 
	if(valor == 'Cliente Industrial'){
		divPessoa.style.display='none'
		divPessoa2.style.display='none'
	}
}
