function showLayer(layerName)
{
	if (document.getElementById) // Netscape 6 and IE 5+
	{
		var targetElement = document.getElementById(layerName);
		targetElement.style.display = 'block';
	}
}
function hideLayer(layerName)
{
	if (document.getElementById) 
	{
		var targetElement = document.getElementById(layerName);
		targetElement.style.display = 'none';
	}
}

function toggle_visibility(id) {
	var e = document.getElementById(id);
	
	if(e.style.display == '')
	e.style.display = 'block';
	else
	if(e.style.display == 'none')
	e.style.display = 'block';
	else
	e.style.display = 'none';
}

// This function changes the image, price and displayName for a perfil that
// has been selected in the ConfigStep1.aspx
function ChangePerfil(img_path, perfilName, newPrice, iva, sgpu, ia, perfilId, modeloId, sigou, total)
{
	var name1Label = document.getElementById(labelNameId);
	name1Label.innerHTML = perfilName;
	
	var nameLabel = document.getElementById(LblCarId);
	nameLabel.innerHTML = perfilName;
	
	var PBLabel = document.getElementById(labelPrecoBaseId);
	PBLabel.innerHTML = newPrice;
		
	var ivaLabel = document.getElementById(labelIVAId);
	ivaLabel.innerHTML = iva;
		
	var sgpuLabel = document.getElementById(labelSGPUId);
	sgpuLabel.innerHTML = sgpu;
	
	var iaLabel = document.getElementById(labelIAId);
	iaLabel.innerHTML = ia;
	
	var image = document.getElementById(ImgCarId);
	image.src = img_path;
	
	var hfPerfil = document.getElementById(hfPerfilId);
	hfPerfil.value = perfilId;
	
	var hfModelo = document.getElementById(hfModeloId);
	hfModelo.value = modeloId;
	
	var hfSigou = document.getElementById(labelSigouId);
	hfSigou.innerHTML = sigou;
	
	var PVPLabel = document.getElementById(labelPVPtotal);
	PVPLabel.innerHTML = total;
	
	var coresLabel = document.getElementById(labelPrCORESId);
	coresLabel.innerHTML = 0;
	
	var estofosLabel = document.getElementById(labelPrEstofoId);
	estofosLabel.innerHTML = 0;
	
	var equipsLabel = document.getElementById(LbPEquipsId);
	equipsLabel.innerHTML = 0;
	
	var jantesLabel = document.getElementById(LbPJantesId);
	jantesLabel.innerHTML = 0;
}

//Show Detail Box for a given Gama
function ShowDB(title, description, price, imgPath, evt)
{
	var imagePopup = document.getElementById('iPop');
	var titlePopup = document.getElementById('titPop');
	var descriptionPopup = document.getElementById('descPop');
	var pricePopup = document.getElementById('prcPop');
	var priceCar = document.getElementById('prcCar');
	
	priceCar.style.display = 'block';
	imagePopup.src = imgPath;
	titlePopup.innerHTML = title;
	descriptionPopup.innerHTML = description;
	pricePopup.innerHTML = price;
	
	if(price == '999.999.999,00')
	{
		priceCar.style.display = 'none';
	}
	
	showPopup('PopupVersao', evt);
}
 
function ShowI(title, description, price, imgPath, evt)
{	
	if(imgPath != "")
	var imagePopup = document.getElementById('iPopI');
	var titlePopup = document.getElementById('titPopI');
	var descriptionPopup = document.getElementById('descPopI');
	var pricePopup = document.getElementById('prcPopI');
	
	if(imgPath != "")
	imagePopup.src = imgPath;
	titlePopup.innerHTML = title;
	descriptionPopup.innerHTML = description;
	pricePopup.innerHTML = price;
	
	showPopup('CarModel', evt);
} 
function SelGama(gamaId)
{	
	var hfGama = document.getElementById('HFGama');
	hfGama.value = gamaId;
	__doPostBack('LBGama','');
	return false;
}
function Passo(lbButton, perfil)
{	
	var lnk = document.getElementById('lbHidden');	
	if(perfil != "")
	{
		var goBack = "./iframe/EmProcessamento.aspx?TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
		lnk.href = goBack;
		if(lnk.click) lnk.click();
		else tb_show('',goBack,''); 
		var button = "NMenu$" + lbButton;
		__doPostBack(button,'');
	}
	else
	{
		var goFw = "./iframe/Alerta.aspx?Msg=1&TB_iframe=true&amp;height=200&amp;width=439&amp;modal=true";
		lnk.href = goFw;
		if(lnk.click) lnk.click();
	}
}
function Anterior()
{	
	var lnk = document.getElementById('lbAnterior');	
	var goBack = "./iframe/EmProcessamento.aspx?TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
	lnk.href = goBack;
	if(lnk.click) lnk.click();
	else tb_show('',goFw,'');
	__doPostBack('PNav$LBPrevious','');
}
function Seguinte(perfil)
{	
	var lnk = document.getElementById('lbSeguinte');	
	if(perfil != "")
	{
		var goFw = "./iframe/EmProcessamento.aspx?TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
		lnk.href = goFw;
		if(lnk.click) lnk.click();
		else tb_show('',goFw,'');  
		__doPostBack('PNav$LBNext','');
	}
	else
	{
		var goFw = "./iframe/Alerta.aspx?Msg=1&TB_iframe=true&amp;height=200&amp;width=439&amp;modal=true";
		lnk.href = goFw;
		if(lnk.click) lnk.click();
	}
}
function SelCorExt(corExtId)
{	
	var yScrollContainer = document.getElementById('SmartScroller1_scrollTop');
	var yScroll = 0;
	if(yScrollContainer!=null) yScroll = yScrollContainer.value;
	document.getElementById('HFYS').value = yScroll;
	
	var lnk = document.getElementById('lbAddEquip');
	var addCorEstofo = "./iframe/EmProcessamento.aspx?&amp;TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
	lnk.href = addCorEstofo;
	if(lnk.click) lnk.click();
	else tb_show('Cores',addCorEstofo,''); 
	
	var hfCorExt = document.getElementById(hfCorExtId);
	if(	corExtId != hfCorExt.value)
	{
		var hfCorInt = document.getElementById(hfCorIntId);
		hfCorInt.value = '';
		var hfEquipEstofo = document.getElementById(hfEquipEstofoId);
		hfEquipEstofo.value = '';
		var hfEquipBanco = document.getElementById(hfEquipBancoId);
		hfEquipBanco.value = '';
		
		hfCorExt.value = corExtId;
		
		__doPostBack('LBSelCorExt','');
	}
}

function SelEstofo(estofoId, corIntId, equipBancoId)
{	
	var yScrollContainer = document.getElementById('SmartScroller1_scrollTop');
	var yScroll = 0;
	if(yScrollContainer!=null) yScroll = yScrollContainer.value;
	document.getElementById('HFYS').value = yScroll;
	
	var lnk = document.getElementById('lbAddEquip');
	var addCorEstofo = "./iframe/EmProcessamento.aspx?&amp;TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
	lnk.href = addCorEstofo;
	if(lnk.click) lnk.click();
	else tb_show('Cores',addCorEstofo,'');  
	
	var hfCorInt = document.getElementById(hfCorIntId);
	hfCorInt.value = corIntId;
	var hfEquipEstofo = document.getElementById(hfEquipEstofoId);
	hfEquipEstofo.value = estofoId;
	var hfEquipBanco = document.getElementById(hfEquipBancoId);
	hfEquipBanco.value = equipBancoId;
	
	__doPostBack('LBSelEstofo','');
	
}

function SelEqOpt(checkbx, equipName, dataToPost)
{   
	var yScrollContainer = document.getElementById('SmartScroller1_scrollTop');
	var yScroll = 0;
	if(yScrollContainer!=null) yScroll = yScrollContainer.value;
	var lnk = document.getElementById('lbAddEquip');
	var addEquipUrl = '';
	
	if(checkbx.checked == true)
		addEquipUrl = "./iframe/AddEquip.aspx?" + dataToPost+ "&amp;yS="+yScroll+"&amp;TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";	
	else
		addEquipUrl = "./iframe/AddEquip.aspx?" + dataToPost+ "&amp;yS="+yScroll+"&amp;rem=1&amp;TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
	
	lnk.href = addEquipUrl;
	if(lnk.click)
		lnk.click();
	else tb_show('Equipamento',addEquipUrl,'');
}

function DeSelEqOpt(equipName, dataToPost)
{
	var hfEquipOpcionais = document.getElementById(hfEquipOpcionaisId);
	
	var equipSearchKey = "CODE=" + equipName + ","; 
	var equipSearchKey2 = "CODE=" + equipName; 
	hfEquipOpcionais.value = hfEquipOpcionais.value.replace(equipSearchKey,"").replace(equipSearchKey2,"");
}

function SelJante(radioBtn, img_path, janteId, precoJante, dataToPost)
{	
	var image = document.getElementById(ImgJanteId);
	image.src = img_path;
	
	var hfJante = document.getElementById(hfJanteId);
	hfJante.value = janteId;
	
	var lnk = document.getElementById('lbAddEquip');
	var addEquipUrl = "./iframe/AddEquip.aspx?" + dataToPost+ "&amp;TB_iframe=true&amp;height=300&amp;width=650&amp;modal=true";
	lnk.href = addEquipUrl;
	
	lnk.click();
}

function ShowICor(corName, description, evt)
{	
	var titlePopup = document.getElementById('titPopC');
	var descriptionPopup = document.getElementById('descPopC');
	
	titlePopup.innerHTML = corName;
	descriptionPopup.innerHTML = description;
	
	showPopup('CarCores', evt);
}

function ShowIEquip(EquipName, description, imgPath, evt)
{	
	var titlePopup = document.getElementById('titPopEq');
	var descriptionPopup = document.getElementById('descPopEq');
	var imgPopup = document.getElementById('imgPopEq');
	
	
	titlePopup.innerHTML = EquipName;
	descriptionPopup.innerHTML = description;
	imgPopup.src = imgPath;
	
	showPopup('CarSerie', evt);
}

function ShowIEquipJante(EquipName, description, evt)
{
	var titlePopup = document.getElementById('titPopEq');
	var descriptionPopup = document.getElementById('descPopEq');
	var imgPopup = document.getElementById('imgPopEq');
	
	titlePopup.innerHTML = EquipName;
	descriptionPopup.innerHTML = description;
	imgPopup.style.display = 'none';
	
	showPopup('CarSerie', evt);
}

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 SwitchOpenedClosed(mainDivId,secondDivId,currentStateTBId,currentLink)
{
	var mainDiv = document.getElementById(mainDivId);
	var secondDiv = document.getElementById(secondDivId);
	var currentStateTB = document.getElementById(currentStateTBId);

	if(currentStateTB.value == 'closed')
	{
		document.getElementById('MeuVeiculoTd').className = 'omeuveiculo_bottom_open';
		mainDiv.style.display = 'block';
		secondDiv.style.display = 'block';
		currentLink.innerText = 'fechar';
		currentStateTB.value = 'opened';
	}
	else
	{
		document.getElementById('MeuVeiculoTd').className = 'omeuveiculo_bottom';
		mainDiv.style.display = 'none';
		secondDiv.style.display = 'none';
		currentLink.innerText = 'ver mais';
		currentStateTB.value = 'closed';
	}
	return false;
}

function SwitchOpenedClosedMeuVeiculo(mainDivId,currentStateTBId,currentLink)
{
	var mainDiv = document.getElementById(mainDivId);
	var currentStateTB = document.getElementById(currentStateTBId);

	if(currentStateTB.value == 'closed')
	{
		mainDiv.style.display = 'block';
		currentLink.innerText = 'fechar';
		currentStateTB.value = 'opened';
	}
	else
	{
		mainDiv.style.display = 'none';
		currentLink.innerText = 'ver mais';
		currentStateTB.value = 'closed';
	}
	return false;
}