

var long = 0;
var directorio='';
var seleccionada = 1;
var autos=new Array();

function cargar_fotos(){
	var imagenes_esc =new String('');
	var p;
	for(p=1;p<=long;p++)
	{	
		autos[p]=new Image();
		autos[p].src=( directorio + '/' + new String(p) + 'b.jpg' );
		if(p==1){
			imagenes_esc+='<div onmouseover="borde('+ p +')" onmouseout="borde_out('+ p +')" id="imagen'+ p +'" style=" padding:1px; border: 2px #000000 solid; width: 53px; height:30px; margin: 1px; float: left"><img src="'+directorio+'/'+p+'a.jpg" onclick="tomar_foto('+p+')"></div>';			
		}else{
			imagenes_esc+='<div onmouseover="borde('+ p +')" onmouseout="borde_out('+ p +')" id="imagen'+ p +'" style="cursor:pointer; border: 2px #FFFFFF solid; width: 53px; padding:1px; height:30px; margin: 1px; float: left"><img src="'+directorio+'/'+p+'a.jpg" onclick="tomar_foto('+p+')"></div>';	
		}
	}
	document.writeln(imagenes_esc);
	texto_imagen.innerText=textos[0];
}

function cargar_colores(){
	var imagenes_esc =new String('');
	var p;
	for(p=1;p<=long;p++)
	{	
		autos[p]=new Image();
		autos[p].src=( directorio + '/' + new String(p) + 'b.jpg' );
		if(p==1){
			imagenes_esc+='<span id="imagen'+ p +'" onclick="tomar_color('+p+')" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; color:#333333; background-color: #F5F5F5; cursor:pointer; border: 2px #000000 solid; width: '+col_w+'px; padding:0px; height:'+col_h+'px; margin: 3px; float:left"><img src="'+directorio+'/'+p+'a.jpg"><br>'+ textos_2[p-1] +'</span>';			
		}else{
			imagenes_esc+='<span id="imagen'+ p +'" onclick="tomar_color('+p+')" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; color:#333333; background-color: #F5F5F5; cursor:pointer; border: 2px #ffffff solid; width: '+col_w+'px; padding:0px; height:'+col_h+'px; margin: 3px; float:left"><img src="'+directorio+'/'+p+'a.jpg"><br>'+ textos_2[p-1] +'</span>';	
		}
	}
	document.writeln(imagenes_esc);
}


function borde(este){
	if(este!=seleccionada){
		document.all['imagen'+new String(este)].style.border="2px solid #CCCCCC";
	}
	//alert();
}

function borde_sel(este){
	document.all['imagen'+new String(seleccionada)].style.border="2px solid #B7B7B7";
	document.all['imagen'+new String(este)].style.border="2px solid #000000";
	seleccionada=este;
}

function borde_out(este){
	if(este!=seleccionada){
		document.all['imagen'+new String(este)].style.border="2px solid #FFFFFF";
	}
	//alert(seleccionada);
}

function adelante1(){

	if((seleccionada+1)>long){
		tomar_foto(1);
	}else{
		tomar_foto(seleccionada+1);
	}	
}

function atras1(){
	if((seleccionada-1)<=0){
		tomar_foto(long);
	}else{
		tomar_foto(seleccionada-1);
	}	
}

function mostrar_pri(){
	tomar_foto(1);	
}

function tomar_foto(f){
	document.images['centro'].src=autos[f].src;
	document.images['centro'].alt=autos[f].src;
	borde_sel(f);
	texto_imagen.innerText=textos[f-1];
}
function tomar_color(f){
	document.images['centro'].src=autos[f].src;
	document.images['centro'].alt=autos[f].src;
	borde_sel(f);
	texto_imagen.innerText=textos[f-1];
}

function tomar_foto_ampliar(f){
	document.images['centro'].src= (window.opener.directorio + '/' + new String(f) + 'c.jpg');
	//document.images['centro'].alt=window.opener.autos[f].src;
	texto_imagen.innerText=window.opener.textos[f-1];
	if((f)==window.opener.long){
		document.images['next'].src=window.opener.directorio+'/'+(1)+'a.jpg';
		document.images['ant'].src=window.opener.directorio+'/'+(f-1)+'a.jpg';	
	}else{
		if((f)==1){
			document.images['next'].src=window.opener.directorio+'/'+(f+1)+'a.jpg';
			document.images['ant'].src=window.opener.directorio+'/'+(window.opener.long)+'a.jpg';	
		}else{
			document.images['next'].src=window.opener.directorio+'/'+(f+1)+'a.jpg';
			document.images['ant'].src=window.opener.directorio+'/'+(f-1)+'a.jpg';	
		}
	}
}


function tomar_foto_back(f){

	window.opener.tomar_foto(f)
}

function ampliar(){
	var ampliar = window.open("galeria.asp?s="+seleccionada+"&d="+directorio,"1","menubars=no, resizable=no, width=1000, height=720, scrollbars=no");
}

function adelante2(){
	if((window.opener.seleccionada+1)>window.opener.long){
		tomar_foto_ampliar(1);
		tomar_foto_back(1);
	}else{
		tomar_foto_ampliar(window.opener.seleccionada+1);
		tomar_foto_back(window.opener.seleccionada+1);		
	}	
}

function atras2(){
	if((window.opener.seleccionada-1)<=0){
		tomar_foto_ampliar(window.opener.long);
		tomar_foto_back(window.opener.long);
	}else{
		tomar_foto_ampliar(window.opener.seleccionada-1);
		tomar_foto_back(window.opener.seleccionada-1);
	}	
}

function fondo(){
	var ampliar = window.open("galeria-wall.asp?w=" + screen.width + "&h=" + screen.height,"1","menubars=yes, resizable=yes, width=1000, height=650, scrollbars=yes");
}

function cambiar(num){
	document.all['res1'].style.display="none";
	document.all['res2'].style.display="none";
	document.all['res3'].style.display="none";
	document.all['res4'].style.display="none";	
	document.all['res'+new String(num)].style.display="block";	
}

function poner_res(){
	document.images['resd'].src=window.opener.directorio+'/'+ window.opener.seleccionada+'d.jpg';
	document.images['rese'].src=window.opener.directorio+'/'+ window.opener.seleccionada+'e.jpg';	
	document.images['resf'].src=window.opener.directorio+'/'+ window.opener.seleccionada+'f.jpg';
	document.images['resg'].src=window.opener.directorio+'/'+ window.opener.seleccionada+'g.jpg';	
	
	switch(screen.width){
		case 800:document.all['res1'].style.display="block"; break;
		case 1024:document.all['res2'].style.display="block"; break;
		case 1280:document.all['res3'].style.display="block"; break;
		case 1600:document.all['res4'].style.display="block"; break;		
	}
}

function escribir_resolucion(){
	document.writeln(screen.width+ " x "+ screen.height);	
}

function escribir_botonera_galeria(){
	document.writeln('<table width="199" border="0" cellspacing="0" cellpadding="0">                    <tr>                      <td><table width="199" border="0" cellspacing="0" cellpadding="0">                        <tr>                          <td><img onMouseOut="MM_swapImgRestore()" onClick="atras1()" onMouseOver="MM_swapImage(\'imgstypeexterior_r5_c131\',\'\',\'images/img-s-type-exterior_r5_c13_f2.jpg\',1)" name="imgstypeexterior_r5_c131" src="images/img-s-type-exterior_r5_c13.jpg" width="97" height="42" border="0" id="imgstypeexterior_r5_c131" alt="" style="cursor:pointer"/></td>                          <td><img onMouseOut="MM_swapImgRestore()" onClick="adelante1()" onMouseOver="MM_swapImage(\'imgstypeexterior_r5_c161\',\'\',\'images/img-s-type-exterior_r5_c16_f2.jpg\',1)" name="imgstypeexterior_r5_c161" src="images/img-s-type-exterior_r5_c16.jpg" width="102" height="42" border="0" id="imgstypeexterior_r5_c161" alt="" style="cursor:pointer"/></td>                        </tr>                      </table></td>                    </tr>                    <tr>                      <td><table width="199" border="0" cellspacing="0" cellpadding="0">                        <tr>                          <td><img name="imgstypeexterior_r8_c13" src="images/img-s-type-exterior_r8_c13.jpg" width="21" height="1" border="0" id="imgstypeexterior_r8_c13" alt="" /></td>                          <td><table align="left" border="0" cellpadding="0" cellspacing="0" width="152">                              <tr>                                <td><img name="imgstypeexterior_r8_c14" src="images/img-s-type-exterior_r8_c14.jpg" width="1" height="16" border="0" id="imgstypeexterior_r8_c14" alt="" /></td>                              </tr>                              <tr>                                <td><table align="left" border="0" cellpadding="0" cellspacing="0" width="152">                                    <tr>                                      <td><img name="imgstypeexterior_r10_c14" src="images/img-s-type-exterior_r10_c14.jpg" width="1" height="1" border="0" id="imgstypeexterior_r10_c14" alt="" /></td>                                      <td><img onMouseOut="MM_swapImgRestore()" onClick="ampliar()" onMouseOver="MM_swapImage(\'imgstypeexterior_r10_c151\',\'\',\'images/img-s-type-exterior_r10_c15_f2.jpg\',1)" name="imgstypeexterior_r10_c151" src="images/img-s-type-exterior_r10_c15.jpg" width="154" height="36" border="0" id="imgstypeexterior_r10_c151" alt="" style="cursor:pointer"  /></td>                                      <td><img name="imgstypeexterior_r10_c17" src="images/img-s-type-exterior_r10_c17.jpg" width="1" height="1" border="0" id="imgstypeexterior_r10_c17" alt="" /></td>                                    </tr>                                </table></td>                              </tr>                              <tr>                                <td><img name="imgstypeexterior_r12_c14" src="images/img-s-type-exterior_r12_c14.jpg" width="1" height="27" border="0" id="imgstypeexterior_r12_c14" alt="" /></td>                              </tr>                              <!--<tr>                                <td><img onMouseOut="MM_swapImgRestore()" onClick="fondo()" onMouseOver="MM_swapImage(\'imgstypeexterior_r15_c141\',\'\',\'images/img-s-type-exterior_r15_c14_f2.jpg\',1)" name="imgstypeexterior_r15_c141" src="images/img-s-type-exterior_r15_c14.jpg" width="152" height="17" border="0" id="imgstypeexterior_r15_c141" alt="" style="cursor:pointer" /></td>                              </tr>-->                              <tr>                                <td><img name="imgstypeexterior_r17_c14" src="images/img-s-type-exterior_r17_c14.jpg" width="1" height="107" border="0" id="imgstypeexterior_r17_c14" alt="" /></td>                              </tr>                          </table></td>                          <td><img name="imgstypeexterior_r8_c18" src="images/img-s-type-exterior_r8_c18.jpg" width="26" height="1" border="0" id="imgstypeexterior_r8_c18" alt="" /></td>                        </tr>                      </table></td>                    </tr>                  </table>');
}