
var DivLoading=document.createElement('div');DivLoading.setAttribute('id','loading');DivLoading.innerHTML='<img src="http://pics.miarroba.com/loading2.gif" width="32" height="32" /><br />Cargando...';var Anchors=new Array();Anchors['codigos']=true;Anchors['info']=true;Anchors['enviar']=true;Anchors['votar']=true;Anchors['abuso']=true;Anchors['subir']=true;var Partes=new Array;var Seccion=false;function AjaxXML(url,func_alt)
{var x=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();if(x)
{x.onreadystatechange=function()
{if(x.readyState==4)
{if(x.status==200)
{if(x.responseXML)
{var respuesta=x.responseXML.documentElement;var datos=false;if(datos=respuesta.getElementsByTagName('datos')[0])
{if(datos.getAttribute('funcion')!=''&&datos.getAttribute('funcion')!=null)eval(datos.getAttribute('funcion')+'(datos);');else if(func_alt)eval(func_alt+';');}
else if(func_alt)eval(func_alt+';');}
else if(func_alt)eval(func_alt+';');}
else if(func_alt)eval(func_alt+';');}}
var foo=url.split('?');x.open("POST",foo[0],true);x.setRequestHeader("Content-Type","application/x-www-form-urlencoded");x.send(((foo[1]!='')?foo[1]:null));}}
function LanzaAjax(cual)
{switch(cual)
{case'info':CambiaSeccion('info');$('muestra_urls').innerHTML='';$('muestra_urls').appendChild(DivLoading);AjaxXML("/op_ajax.php?op=info&id="+Partes[0],"MuestraError(3)");break;case'votar':var Valor=parseInt($('puntuacion').value);var votado=LeeCookie('vot['+Partes[0]+']')
if(Valor<0||Valor>10)
{alert('La puntuacion no es valida (De 0 a 10)');return;}
if(votado=="si")
{alert('Ya has puntuado anteriormente esta foto.');}
if(confirm('¿Deseas puntuar esta foto con un '+Valor+'?'))
{CreaCookie('vot['+Partes[0]+']','votando',1);$('muestra_urls').innerHTML='';$('muestra_urls').appendChild(DivLoading);AjaxXML("/op_ajax.php?op=votar&id="+Partes[0]+"&vot="+Valor,"MuestraError(4)");}
break;case'enviar':var Foo=$('email_amigo').value;$('muestra_urls').innerHTML='';$('muestra_urls').appendChild(DivLoading);AjaxXML("/op_ajax.php?op=enviar&id="+Partes[0]+"&mail="+escape(Foo),"MuestraError(6)");break;case'abuso':var Valor=$('select_abuso').value;if(Valor=='1'||Valor=='2'||Valor=='3'||Valor=='4')
{AjaxXML("/op_ajax.php?op=abuso&id="+Partes[0]+"&abs="+Valor,"alert('A ocurrido un error y no se ha podido guardar el abuso.\\nIntentelo de nuevo, gracias.')");}
break;}}
function MuestraFoto()
{if(imagen.width=="149"&&imagen.height=="149")
{MuestraError();return;}
if(Partes[0].substr(32,1)=="x")
{var Adulto=LeeCookie('adulto');if(Adulto!='si'&&Adulto!='no')
{if(confirm('Esta foto esta marcada como contenido para adultos.\n\nSi en tu pais tienes la mayoria de edad, puedes acceder a ella pulsando "Aceptar".\nSi por el contrario eres menor de edad pulsa "Cancelar"'))
{CreaCookie('adulto','si',365);Adulto='si';}
else
{CreaCookie('adulto','no',365);Adulto='no'}}
if(Adulto=='no')
{MuestraError(2);return;}}
DivTrabajo.innerHTML='';var Foo=false;var Texto=false;Foo=document.createElement('img');Foo.setAttribute('id','imagen_original');Foo.src=imagen.src;if(imagen.width>LimWidth)
{DivTrabajo.innerHTML+="La imagen est&aacute reducida para un mejor visionado. Pulse sobre ella para verla en tamaño completo<br />";Foo.setAttribute('title','Haz click para aumentar/reducir la foto');Foo.style.cursor='pointer';Foo.style.width=LimWidth+'px';Foo.style.height=parseInt(LimWidth*imagen.height/imagen.width)+'px';Foo.onclick=CambiaSize;}
DivTrabajo.appendChild(Foo);var DivCuerpo=document.createElement('div');DivCuerpo.setAttribute('id','div_cuerpo');Foo=document.createElement('div');Foo.className='t';DivCuerpo.appendChild(Foo);var dummy=Foo;Foo=document.createElement('div');Foo.className='b';dummy.appendChild(Foo);dummy=Foo;Foo=document.createElement('div');Foo.className='l';dummy.appendChild(Foo);dummy=Foo;Foo=document.createElement('div');Foo.className='r';dummy.appendChild(Foo);dummy=Foo;Foo=document.createElement('div');Foo.className='bl';dummy.appendChild(Foo);dummy=Foo;Foo=document.createElement('div');Foo.className='br';dummy.appendChild(Foo);dummy=Foo;Foo=document.createElement('div');Foo.className='tl';dummy.appendChild(Foo);dummy=Foo;Foo=document.createElement('div');Foo.className='tr';dummy.appendChild(Foo);dummy=Foo;var DivOpciones=document.createElement('div');DivOpciones.setAttribute('id','opciones_ver');Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('id','boton_subir');Foo.setAttribute('value','Subir foto');Foo.onclick=MuestraFormUp;Foo.className='menu_unselect';DivOpciones.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('id','boton_votar');Foo.setAttribute('value','Valorar foto');Foo.onclick=MuestraVotacion;Foo.className='menu_unselect';DivOpciones.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('id','boton_enviar');Foo.setAttribute('value','Enviar a un amigo');Foo.onclick=MuestraEnviarAmigo;Foo.className='menu_unselect';DivOpciones.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('id','boton_codigos');Foo.setAttribute('value','Codigos de enlace');Foo.onclick=MuestraCodigos;Foo.className='menu_unselect';DivOpciones.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('id','boton_info');Foo.setAttribute('value','Mas informacion');Foo.onclick=function(){LanzaAjax('info');}
Foo.className='menu_unselect';DivOpciones.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('id','boton_abuso');Foo.setAttribute('value','Reportar abuso');Foo.onclick=MuestraAbuso;Foo.className='menu_unselect';DivOpciones.appendChild(Foo);dummy.appendChild(DivOpciones);if(Anchors[Partes[2]]===true)
{Foo=document.createElement('a');Foo.setAttribute('name',Partes[2]);dummy.appendChild(Foo);}
Foo=document.createElement('div');Foo.setAttribute('id','muestra_urls')
dummy.appendChild(Foo);DivTrabajo.appendChild(DivCuerpo);switch(Partes[2])
{case"codigos":MuestraCodigos();scrollTo(0,5000);break;case"info":LanzaAjax('info');scrollTo(0,5000);break;case"enviar":MuestraEnviarAmigo();scrollTo(0,5000);break;case"votar":MuestraVotacion();scrollTo(0,5000);break;case"abuso":MuestraAbuso();scrollTo(0,5000);break;default:MuestraVotacion();break;}}
function MuestraPubli()
{var Foo=document.createElement('iframe');if(Partes[0].substr(-1)=="x")
{Foo.setAttribute('src','http://subefotos.com/banner.php?id=196');}
else
{Foo.setAttribute('src','http://subefotos.com/banner.php?id=187');}
Foo.setAttribute('width','728');Foo.setAttribute('height','90');Foo.setAttribute('allowtransparency','true');Foo.setAttribute('scrolling','no');Foo.frameBorder='0';Foo.marginWidth='0';Foo.marginHeight='0';Foo.style.border='0px';Foo.style.marginLeft='auto';Foo.style.marginRight='auto';Foo.style.marginBottom='10px';Foo.style.display='block';return Foo;}
function MuestraFormUp()
{CambiaSeccion('subir');var Script=document.createElement('script');Script.setAttribute('id','SfScriptUpload');Script.setAttribute('type','text/javascript');Script.setAttribute('src','http://static.subefotos.com/codsubir.js');$('muestra_urls').innerHTML='';var Table=document.createElement('table');Table.style.border='0px';Table.cellPadding='3';Table.cellSpacing='0';Table.style.marginLeft='auto';Table.style.marginRight='auto';var Tbody=document.createElement('tbody');Table.appendChild(Tbody);var Tr=document.createElement('tr');Tbody.appendChild(Tr);var Foo=document.createElement('td');Foo.style.textAlign='center';Foo.appendChild(Script);Tr.appendChild(Foo);var Tr=document.createElement('tr');Tbody.appendChild(Tr);Foo=document.createElement('td');Foo.style.textAlign='center';Foo.innerHTML="<b>¿Quieres poner este formulario en tu web?</b><br />Es facil, solo tienes que copiar el siguiente codigo en tu pagina web.<br><div class=\"codigo_ver\" style=\"padding:10px;\">&lt;script type=&quot;text/javascript&quot; src=&quot;http://static.subefotos.com/codsubir.js&quot; id=&quot;SfScriptUpload&quot; defer=&quot;true&quot;&gt;&lt;/script&gt;</div>";Tr.appendChild(Foo);$('muestra_urls').appendChild(Table);}
function CambiaSeccion(Cual)
{if(Cual!=Seccion)
{$('boton_'+Cual).className='menu_select';if(Seccion!=false)$('boton_'+Seccion).className='menu_unselect';Seccion=Cual;}}
function MuestraAbuso()
{CambiaSeccion('abuso');var Tipo=Partes[0].substr(-1);var DivAbuso=document.createElement('div')
DivAbuso.setAttribute('id','reportar_abuso');var Text=document.createTextNode('Indica el motivo del abuso:');DivAbuso.appendChild(Text);var Dummy=new Array;Dummy['1']='Foto con copyright';Dummy['2']='Foto con tematica ilegal.';if(Tipo=='o')
{Dummy['3']='Foto para adultos en zona publica';}
Dummy['4']='Otro motivo';Foo=document.createElement('select');Foo.setAttribute('id','select_abuso');var option=document.createElement('option');option.setAttribute('value','');Text=document.createTextNode('[ Selecciona motivo ]');option.appendChild(Text)
Foo.appendChild(option);for(var clave in Dummy)
{option=document.createElement('option');option.setAttribute('value',clave);Text=document.createTextNode(Dummy[clave]);option.appendChild(Text)
Foo.appendChild(option);}
DivAbuso.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('value','Enviar');Foo.className='enviar';Foo.onclick=function(){if(Dummy[$('select_abuso').value]==null)alert('Por favor, indica el motivo del abuso');else
{if(confirm('¿Deseas reportar el abuso "'+Dummy[$('select_abuso').value]+'" para esta foto?'))
{LanzaAjax("abuso");}}}
DivAbuso.appendChild(Foo);$('muestra_urls').innerHTML='';$('muestra_urls').appendChild(DivAbuso);}
function ResultadoAbuso(datos)
{alert('Gracias por reportar el abuso. En breve sera comprobado.');MuestraAbuso();}
function MuestraVotacion()
{CambiaSeccion('votar');var votado=LeeCookie('vot['+Partes[0]+']')
if(votado=='si')
{MuestraError(5);return;}
var TableVotar=document.createElement('table');TableVotar.setAttribute('id','votar_foto');TableVotar.setAttribute('title','Haz click para votar');TableVotar.cellPadding='0';TableVotar.cellSpacing='0';var Marcador=document.createElement('img');Marcador.setAttribute('id','marcador');Marcador.setAttribute('src','http://static.subefotos.com/marcador.gif');var Current=document.createElement('tbody');TableVotar.appendChild(Current);Foo=document.createElement('tr');Current.appendChild(Foo);Current=Foo;for(var x=0;x<=10;x++)
{Foo=document.createElement('td');Foo.setAttribute('rel',''+x+'');Foo.onclick=function(){LanzaAjax('votar');}
Foo.onmouseover=function(){$('puntuacion').setAttribute('value',this.getAttribute('rel'));this.appendChild(Marcador);}
Current.appendChild(Foo);if(x==0)
{Foo.appendChild(Marcador);}}
$('muestra_urls').innerHTML='<b>Puntuacion para la foto:</b>';$('muestra_urls').appendChild(TableVotar);Foo=document.createElement('input');Foo.setAttribute('id','puntuacion');Foo.setAttribute('type','text');Foo.setAttribute('value','0');Foo.setAttribute('disabled','disabled');$('muestra_urls').appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.className='votar';Foo.setAttribute('value','Votar!');Foo.onclick=function(){LanzaAjax('votar');}
$('muestra_urls').appendChild(Foo);}
function ResultadoVoto(datos)
{if(datos&&datos.getAttribute('ok')=="ok")
{CreaCookie('vot['+Partes[0]+']','si',1);LanzaAjax('info');}}
function ResultadoEnviar(datos)
{if(datos&&datos.getAttribute('ok')=="ok")
{alert('El e-mail ha sido enviado correctamente');}
else
{alert('El e-mail parece no ser correcto.');}
MuestraEnviarAmigo();}
function MuestraMasDatos(datos)
{if(Seccion=='info')
{if(datos.getAttribute('ok')=="ok")
{datos=datos.getElementsByTagName('info')[0];var Table=null;var Foo=null;var Current=null;var Tbody=null;Table=document.createElement('table');Table.setAttribute('id','tabla_info');Current=Table;Foo=document.createElement('tbody');Current.appendChild(Foo);Tbody=Foo;Foo=document.createElement('tr');Tbody.appendChild(Foo);Current=Foo;Foo=document.createElement('td');Foo.className='thumb';Foo.rowSpan='8';Foo.innerHTML='<img src="http://thumbs.subefotos.com/'+datos.getAttribute('id')+'.jpg" width="'+SacaCampo(datos,'xT')+'" height="'+SacaCampo(datos,'yT')+'" />';Current.appendChild(Foo);CreaTDinfo(Current,'Fecha:',SacaCampo(datos,'fecha'));Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Contenido:',((SacaCampo(datos,'tipo')=='xxx')?'Adultos':'Todos los publicos'));Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Tipo:','image/'+datos.getAttribute('ext'));Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Resolucion:',SacaCampo(datos,'xO')+'x'+SacaCampo(datos,'yO')+'px');Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Tamaño:',SacaCampo(datos,'sizeO'));Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Visitas:',SacaCampo(datos,'visto'));Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Puntuacion:',SacaCampo(datos,'puntuacion'));Current=document.createElement('tr');Tbody.appendChild(Current);CreaTDinfo(Current,'Votos:',SacaCampo(datos,'votos'));$('muestra_urls').innerHTML='';$('muestra_urls').appendChild(Table);}
else
{MuestraError(3);}}}
function CreaTDinfo(Obj,Eti,Valor)
{var Foo=document.createElement('td');Foo.className='eti';var Texto=document.createTextNode(Eti);Foo.appendChild(Texto);Obj.appendChild(Foo);Foo=document.createElement('td');Foo.className='valor';Texto=document.createTextNode(Valor);Foo.appendChild(Texto);Obj.appendChild(Foo);}
function SacaCampo(dato,campo)
{return dato.getElementsByTagName(campo)[0].firstChild.data;}
function MuestraCodigos()
{CambiaSeccion('codigos');var Foo=null;var Texto=null;var DivUrls=$('muestra_urls');DivUrls.innerHTML='';Foo=document.createElement('b');Texto=document.createTextNode('Enlace a esta página:');Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('div');Foo.className='codigo_ver';Texto=document.createTextNode('http://subefotos.com/ver/?'+Archivo);Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('b');Texto=document.createTextNode('Url de la thumbnail:');Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('div');Foo.className='codigo_ver';Texto=document.createTextNode('http://thumbs.subefotos.com/'+Partes[0]+'.jpg');Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('b');Texto=document.createTextNode('Codigo THUMBNAIL para foros:');Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('div');Foo.className='codigo_ver';Foo.innerHTML='[url=http://subefotos.com/ver/?'+Archivo+']\n[img]http://thumbs.subefotos.com/'+Partes[0]+'.jpg[/img][/url]';DivUrls.appendChild(Foo);Foo=document.createElement('b');Texto=document.createTextNode('Codigo THUMBNAIL HTML:');Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('div');Foo.className='codigo_ver';Foo.innerHTML='&lt;a href="http://subefotos.com/ver/?'+Archivo+'" target="_blank"&gt;\n&lt;img src="http://thumbs.subefotos.com/'+Partes[0]+'.jpg" /&gt;&lt;/a&gt;';DivUrls.appendChild(Foo);}
function MuestraEnviarAmigo()
{CambiaSeccion('enviar');var DivUrls=$('muestra_urls');DivUrls.innerHTML='';var Foo=null;var Texto=null;Foo=document.createElement('b');Texto=document.createTextNode('Email de tu amigo:');Foo.appendChild(Texto);DivUrls.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('id','email_amigo');Foo.setAttribute('type','text');DivUrls.appendChild(Foo);Foo=document.createElement('input');Foo.setAttribute('type','button');Foo.setAttribute('value','Enviar!');Foo.onclick=function(){LanzaAjax('enviar');}
DivUrls.appendChild(Foo);}
function CambiaSize()
{var ObjW=parseInt(this.style.width);var ImgW=parseInt(imagen.width);var ImgH=parseInt(imagen.height);this.style.width=((ObjW==ImgW)?LimWidth:ImgW)+"px";this.style.height=((ObjW==ImgW)?parseInt(LimWidth*ImgH/ImgW):ImgH)+"px";DivTrabajo.style.textAlign='center';}
function DameBodyWidth()
{if(document.compatMode&&document.compatMode!="BackCompat")
{return document.documentElement.clientWidth;}
else
{return document.body.clientWidth;}}
function MuestraError(error)
{if(error=='')error=1;var DivError=document.createElement('div');DivError.setAttribute('id','error_carga');switch(error)
{case 2:DivError.innerHTML='Esta foto est&aacute; marcada como contenido para adultos. Seg&uacute;n parece eres menor de edad en tu pa&iacute;s, con lo que no ser&aacute; mostrada.<br /><br />Si esta informaci&oacute;n es erronea pulsa en el siguiente enlace para poder ver la imagen.<br /><br /><a href="javascript:void();" onclick="CreaCookie(\'adulto\',\'si\',365);MuestraFoto();">Soy mayor de edad</a>';break;case 3:var DivUrls=$('muestra_urls');DivError.innerHTML='No se ha podido acceder a la informacion extendida de la foto.<br />Por favor intentelo mas tarde.';DivUrls.innerHTML='';DivUrls.appendChild(DivError);return;break;case 4:var DivUrls=$('muestra_urls');DivError.innerHTML='No se ha podido guardar tu voto.<br />Intentalo de nuevo mas tarde.';DivUrls.innerHTML='';DivUrls.appendChild(DivError);return;break;case 5:var DivUrls=$('muestra_urls');DivError.innerHTML='Ya has votado por esta foto.<br />No puedes volver a puntuarla.';DivUrls.innerHTML='';DivUrls.appendChild(DivError);return;break;case 6:var DivUrls=$('muestra_urls');DivError.innerHTML='No se ha podido enviar el e-mail.<br />Intentalo mas tarde.';DivUrls.innerHTML='';DivUrls.appendChild(DivError);return;break;default:DivError.innerHTML='Lo sentimos pero la foto a la que intentas acceder no se encuentra en nuestro servidor.<br /><br />Puede que la URL sea incorrecta o que la foto ha caducado por falta de visitas.';break;}
DivTrabajo.innerHTML='';DivTrabajo.appendChild(DivError);}
function $(cual)
{if(document.getElementById)
{return document.getElementById(cual);}
else
{return eval('document.all.'+cual);}}
function DameImagen()
{if(document.location.href.indexOf("?")>-1)
{var Archivo=document.location.href.substr(document.location.href.indexOf("?")+1).toLowerCase();if(Archivo.indexOf("#")>-1)
{var dummy=Archivo.split(/\#/);Partes=dummy[0].split(/\./);Partes[2]=dummy[1];Archivo=dummy[0];}
else
{Partes=Archivo.split(/\./);}
return Archivo;}
else
{return"";}}
function CambiaFiltro(filtro)
{if(filtro=='si')
{if(confirm('¿Eres mayor de edad y quieres ver las fotos con contenido para adultos?'))
{CreaCookie('adulto','si',365);CreaCookie('filtro','unlock',365);window.location.reload();}}
else
{CreaCookie('filtro','lock',365);window.location.reload();}}
function CreaCookie(nombre,valor,dias)
{if(dias)
{var fecha=new Date();fecha.setTime(fecha.getTime()+(dias*86400000));var expire="; expires="+fecha.toGMTString();}
else var expire="";document.cookie=nombre+"="+escape(valor)+expire+"; path=/; domain=.subefotos.com";}
function LeeCookie(nombre)
{var nomCookie=nombre+"=";var docCookie=document.cookie.split(';');for(var i=0;i<docCookie.length;i++)
{var c=docCookie[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nomCookie)==0)return unescape(c.substring(nomCookie.length,c.length));}
return false;}
function BorraCookie(nombre)
{MSN_CreaCookie(nombre,"",-1);}