<!-- begin script
var peveto;
var modelov=false;
var opcionesv=false;
var promov=false;
var cargaselu=false;

if (isIMG){
i_si_on = prelee('../img/reserva/si_on.gif');
i_no_on = prelee('../img/reserva/no_on.gif');
fup = prelee('../img/reserva/fu.gif');
fdown = prelee('../img/reserva/fd.gif');
}

function versiona(imgName) {
if (isIMG) { 
imgNamedoc = imgName.substring( 0 , imgName.length - 2 )
document[imgNamedoc].src = eval ( imgName + '.src')
}
return true
}

function elmostro(texto){
if (mostro){
//deusua();
//document.identificar.submit();
domlay("deusuario","","","",texto);
}
}

function ClickCarroceria(i,enmenos){
if (colorElegido!=i) {
lCarrocerias[i-enmenos][1]=2;
colorElegido=i;
for(p=1;p<lCarrocerias.length;p++){
if (lCarrocerias[p][1]>=2) {
 if (p!=colorElegido-enmenos) {
 lCarrocerias[p][1]=0
 }
 }
}
precioColorElegido=lCarrocerias[i-enmenos][5];
texto='<span class="txt_point">Precio Pintura: <b>'+FormatearEntero(precioColorElegido)+' euros</b></span>';
domlay("preciopintura","","","",texto);
texto='<span class="txt_point"><b>Color:</b>&nbsp;'+lCarrocerias[colorElegido-enmenos][4]+'</span>';
domlay("nombrecolor","","","",texto);
DibujarPrecio();
enestepunto=i-enmenos
if (enestepunto<10) {
versiona("img0"+enestepunto);
}else{
versiona("img"+enestepunto);
}
}
return true;
}


function cargaseleccion(){
peveto=document.getElementById("mencon"+seleo);
cargaselu=true;
}

function cambiaversion(enlace){
if (colorElegido!=""){
enlace=enlace+'&col='+colorElegido
}
document.location.href=enlace;
}

function creaenlace(devolver){
devolver=devolver+"reservar.asp·sid="+lasesion+"$co="+auto+"$modelo="+autom+"$cvt="+seleo;
nopc=0;
aumentador=0;
cadena="";
for(i=0;i<nOpciones;i++) {  
if (lOpciones[i][ELEG]==2){
nopc=nopc+1
aumentador=aumentador+1;
cadena=cadena+"$opc"+aumentador+"="+lOpciones[i][0];
}
}
if (nopc!=0){
devolver=devolver+"$nopc="+nopc+cadena;
}
if (colorElegido!=""){
devolver=devolver+"$col="+colorElegido;
}
return devolver;
}

function deusua(){
enlace=creaenlace("");
document.identificar.pager.value=enlace;
}

function sal(enlaza){
enlace=creaenlace(enlaza);
document.location.href=enlace;
}

function hazreserva(){
if (colorElegido==""){
alert("Debe usted seleccionar un Color de Carrocería antes de poder efectuar su reserva.\nGracias");
}else{
enlace="reservar.asp?sid="+lasesion+"&co="+auto+"&modelo="+autom+"&col="+colorElegido;
nopc=0
aumentador=0;
cadena="";
for(i=0;i<nOpciones;i++) {  
if (lOpciones[i][ELEG]==2){
nopc=nopc+1
aumentador=aumentador+1;
cadena=cadena+"&opc"+aumentador+"="+lOpciones[i][0];
}
}
if (nopc!=0){
enlace=enlace+"&nopc="+nopc+cadena;
}
document.reservar.action=enlace;
document.reservar.hecho.value=1;
document.reservar.submit();
}
}

function goes(esto,enlace){
if (cargaselu){
if (seleo!=esto){
if (esto==4&&colorElegido==""){
alert("Por favor, debe usted seleccionar un Color de Carrocería antes de pasar a la página\nde confirmación de su Reserva.\n\nGracias");
}else{
seleo=esto;
peveto.className=clase1;
peveto=document.getElementById("mencon"+esto);
peveto.className=clase2;
enlace=enlace+'&col='+colorElegido;
nopc=0;
aumentador=0;
cadena="";
for(i=0;i<nOpciones;i++) {  
if (lOpciones[i][ELEG]==2){
nopc=nopc+1
aumentador=aumentador+1;
cadena=cadena+"&opc"+aumentador+"="+lOpciones[i][0];
}
}
if (nopc!=0){
enlace=enlace+"&nopc="+nopc+cadena;
}
var frm=window.parent.frames;
frm['page2'].location=enlace;
}
}
}
}

function totalizaopci(){
var totali=0;
for(i=0;i<nOpciones;i++){
if (lOpciones[i][ELEG]==2){
totali=totali+lOpciones[i][1];
}
}
totali=FormatearEntero(totali);
return totali;
}

function Redibuja (){
var i;
for(i=0;i<nOpciones;i++){
versionCapas(("op_"+i),eval(imagenesCheckBox[lOpciones[i][ELEG]]));
}
return true;
}

function versionCapas(imgName,imgGif){
var frm=window.frames;
if (isIMG){
frm['page2'].document[imgName].src = imgGif.src;
}
return true;
}

function tiposiguales(estu,catu){
var ju;
for (ju=0;ju<nOpciones;ju++){
if (ju!=estu&&lOpciones[ju][CATE]==catu){
lOpciones[ju][ELEG]=0;
}
}
}

function ClickOpcion (i){
if (lOpciones[i][ELEG]>=2) {
lOpciones[i][ELEG]=0;
}else{
lOpciones[i][ELEG]=2;
}
tiposiguales(i,lOpciones[i][CATE]);
//if ((! n) && (! ie)) /*NN6*/
//{
Redibuja();
//}
//redImg=true;
DibujarPrecio();
//return true;
}

function seteaon(exw){
var locambio=false;
switch(exw){
case 1:
(modelov)?locambio=false:locambio=true;
break;
case 2:
(opcionesv)?locambio=false:locambio=true;
break;
}
if (locambio){
cambiaestado(exw);
}
}

function cambiaestado(exw){
switch(exw){
case 1:
(modelov)?modelov=false:modelov=true;
break;
case 2:
(opcionesv)?opcionesv=false:opcionesv=true;
break;
case 3:
(promov)?promov=false:promov=true;
break;
}
DibujarPrecio();
}

function lasflechas(estat,carac){
var devuel;
devuel='<td class=titu height=20 align=right><A href="#" onclick="cambiaestado('+estat+');return false;"><img border=0 src="../img/reserva/f'+carac+'.gif" style="margin-right:4px" width=5 height=7></A>&nbsp;</TD></tr>';
return devuel;
}
function DibujarPrecio(){
var texto;
var i;
var pOpciones=0;
var pCarroceria=0;
var txtCarroceria="Ningún color seleccionado";
var pPromocion=0;
var txtPromocion="";
var encontrado=false;
for(i=0;i<nOpciones;i++) {  
if (lOpciones[i][ELEG]==2){
if (npromociones>0) {
for (p=0;p<npromociones;p++) {
if (opcionNoticia[p]==lOpciones[i][CODI]) {
encontrado=true }
}
}
if (!encontrado) {
pOpciones=pOpciones+lOpciones[i][PREC];
}else{
encontrado=false}
}else{
if (npromociones>0) {
for (p=0;p<npromociones;p++) {
if (opcionNoticia[p]==lOpciones[i][CODI]) {
pPromocion=pPromocion+precioNoticia[p] }
}
}
}
}
if (npromociones>0) {
for (p=0;p<npromociones;p++) {
if (opcionNoticia[p]==0) {
pPromocion=pPromocion+precioNoticia[p];
txtPromocion=noticias[p]; }
}
}
for(i=1;i<lCarrocerias.length;i++){
if (lCarrocerias[i][CAR_ELEGIDAS]>=2) {
pCarroceria=pCarroceria+lCarrocerias[i][CAR_PRECIO];
}
}
pOpciones=pOpciones+pCarroceria;
texto='<table bgcolor="#f1f6fc" border="0" cellpadding="0" cellspacing="0" width="263"><colgroup><col width=165><col width=98></colgroup><tbody><tr>';
texto=texto+'<td class=titu height=20>Modelo y Versión</td>';
if (modelov){
texto=texto+lasflechas(1,"u");
texto=texto+'<tr><td class="spaceL12" colspan=2 height=21><img class="bu1" src="../img/pixel.gif" align="middle" border="0" height="2" width="2">';
texto=texto+'<span class="txt_byo01"><b>Modelo</b> - '+autot+'</span></td></tr>';
texto=texto+'<tr><td colspan="2" bgcolor="#d9e2ee" height="1"></td></tr><tr>';
texto=texto+'<td class="spaceL12" height=21><img class="bu1" src="../img/pixel.gif" align="middle" border="0" height="2" width="2">';
texto=texto+'<span class="txt_byo01"><b>Versión</b> - '+auton+'</span></td>';
texto=texto+'<td class="spaceR12" align="right" height=21><span class="txt_byo01">'+FormatearEntero(precioBase)+' €</span></td></tr>';
texto=texto+'<tr><td colspan="2" bgcolor="#d9e2ee" height="1"></td></tr>';
}else{
texto=texto+lasflechas(1,"d");
}
texto=texto+'<tr><td class=titupr height=21>Precio Base</TD>';
texto=texto+'<td class=titupr2 height=21><b>'+FormatearEntero(precioBase)+' €</b></TD></TR>';
texto=texto+'</tbody></table>';
domlay("divmodelov","","","",texto);
texto='<table bgcolor="#f1f6fc" border="0" cellpadding="0" cellspacing="0" width="263" style="margin-top:12px;margin-bottom:6px"><colgroup><col width=165><col width=98></colgroup><tbody><tr>';
texto=texto+'<td class=titu height=20>Opciones</td>';

if (opcionesv){
texto=texto+lasflechas(2,"u");
if (pOpciones>0){
if (pCarroceria>0){
texto=texto+'<tr><td colspan="2" bgcolor="#d9e2ee" height="1"></td></tr><tr>';
texto=texto+'<td class="spaceL12" height="21"><img class="bu1" src="../img/pixel.gif" align="middle" border="0" height="2" width="2">';
texto=texto+'<span class="txt_byo01">Pintura Metalizada</span></td>';
texto=texto+'<td class="spaceR12" align="right" height=21><span class="txt_byo01">'+FormatearEntero(pCarroceria)+' €</span></td></tr>';
}
for(i=0;i<nOpciones;i++) {  
if (lOpciones[i][ELEG]==2){
texto=texto+'<tr><td colspan="2" bgcolor="#d9e2ee" height="1"></td></tr><tr>';
texto=texto+'<td class="spaceL12" height="21"><img class="bu1" src="../img/pixel.gif" align="middle" border="0" height="2" width="2">';
texto=texto+'<span class="txt_byo01">'+lOpciones[i][4]+'</span></td>';
texto=texto+'<td class="spaceR12" align="right" height=21><span class="txt_byo01">'+FormatearEntero(lOpciones[i][PREC])+' €</span></td></tr>';
}
}
}else{
texto=texto+'<tr><td colspan="2" bgcolor="#d9e2ee" height="1"></td></tr><tr>';
texto=texto+'<td class="spaceL12" height="21"><img class="bu1" src="../img/pixel.gif" align="middle" border="0" height="2" width="2">';
texto=texto+'<span class="txt_byo01">Sin Opciones</span></td>';
texto=texto+'<td class="spaceR12" align="right" height=21><span class="txt_byo01">0 €</span></td></tr>';
}
}else{
texto=texto+lasflechas(2,"d");
}
texto=texto+'<tr><td class=titupr height=21>+ Precio Opciones</TD>';
texto=texto+'<td class=titupr2 height=21><b>'+FormatearEntero(pOpciones)+' €</b></span></td></tr>';
texto=texto+'</tbody></table>';
domlay("divopcionesv","","","",texto);
if (pPromocion>0){
texto='<table bgcolor="#f1f6fc" border="0" cellpadding="0" cellspacing="0" width="263" style="margin-top:6px;margin-bottom:6px"><colgroup><col width=165><col width=98></colgroup><tbody><tr>';
texto=texto+'<td class=titu height=20>¡Promoción!</td>';
if (promov){
texto=texto+lasflechas(3,"u");
texto=texto+'<tr><td class="promot" colspan="2" height="21">'+noticias[0]+'</td></tr>';
}else{
texto=texto+lasflechas(3,"d");
}
texto=texto+'<tr><td class=titupr height=21>- Promoción</TD>';
texto=texto+'<td class=titupr2 height=21><b>'+FormatearEntero(pPromocion)+' €</b></span></td></tr>';
texto=texto+'</tbody></table>';
document.getElementById("divpromov").style.display='block';
domlay("divpromov","","","",texto);
}else{
document.getElementById("divpromov").style.display='none';
}
texto='<table bgcolor="#f1f6fc" border="0" cellpadding="0" cellspacing="0" width="263" style="margin-top:6px;margin-bottom:6px"><colgroup><col width=165><col width=98></colgroup><tbody><tr>';
texto=texto+'<td colspan="2" class=titu height=20>TOTAL RESERVA</td></tr><tr>';
texto=texto+'<td class=titupr4 height=21>Precio Recomendado*</TD>';
texto=texto+'<td class=titupr3 height=21><b>'+FormatearEntero(precioBase+pOpciones-pPromocion)+' €</b></TD></TR>';
texto=texto+'</tbody></table>';
domlay("divtotalv","","","",texto);
}

function domlay(id,trigger,lax,lay,content) {
if (lax){
if (document.layers){document.layers[''+id+''].left = lax}
else if (document.all){document.all[''+id+''].style.left=lax}
else if (document.getElementById){document.getElementById(''+id+'').style.left=lax+"px"}
}
if (lay){
if (document.layers){document.layers[''+id+''].top = lay}
else if (document.all){document.all[''+id+''].style.top=lay}
else if (document.getElementById){document.getElementById(''+id+'').style.top=lay+"px"}
}
if (content){
if (document.layers){
sprite=document.layers[''+id+''].document;
sprite.open();
sprite.write(content);
sprite.close();
}
else if (document.all) document.all[''+id+''].innerHTML = content;
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById(''+id+'');
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(content)
while(el.hasChildNodes()) el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
}
if (trigger=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else if (trigger=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}

function FormatearEntero(n){
var dev=n;
var i;
var resto;
var signo=1;
var rest = new String("");
var s = new String("");
var pest = new String("");
var pest2 = new String("");
if (!isNaN(n)){
if (n==0){
dev="0";
}else{
dev=""+dev+""
if (dev.indexOf('.')>=0) {
rest = dev.substring(dev.lastIndexOf('.')+1);
dev = dev.substring(0,dev.indexOf('.'));
while (dev.length > 3) {
s = "." + dev.substring(dev.length-3, dev.length) + s;
dev = dev.substring(0, dev.length-3);
}
s = dev + s;
if (rest.length>2) {
pest = rest.substring(2,3);
if (parseInt(pest)>=5) {
pest2 = rest.substring(1,2);
n = parseInt(pest2)+1;
if (n==10) {
pest2 = rest.substring(0,1);
n = parseInt(pest2)+1;
if (n==10) {
n=0;
}
rest = ""+n+"";
}else{
pest2 = ""+n+"";
rest = rest.substring(0,1);
rest = rest+pest2;
}
}else{
rest = rest.substring(0,2);
} 
}
if (rest.length<2) {
rest = rest+"0";
}
s = s + ',' + rest;
dev = s;
}else {
dev="";
resto=Math.abs(n);
i=0;
while (resto!=0){
if (i==3){
dev="."+dev;
i=0;
}
dev=(resto%10)+dev;
resto=(resto-(resto%10))/10;
i++;
}
if (n<0) dev="-"+dev;
}
}
}
return dev;
}
// end script -->
