var sInfo_navegador = navigator.userAgent.toLowerCase();

var URL_IMAGE_PLUS='/foro/Themes/Dark-f/images/DVDplus.png';
var URL_IMAGE_MINUS='/foro/Themes/Dark-f/images/DVDminus.png';
/*NUEVA VERSION PAR AGREGAR DVDS*/
var CANT_DVDS_SUBIDOS=0;
function verificar_agregados(){
	ARG=verificar_agregados.arguments;
	Elementos=ARG[0]
	msg=z=m=b=zz=mm=mn=0;
	IDTDVD=new Array();
	IDTMUD=new Array();
	IDDVD=new Array();
	IDMUD=new Array();
	IDSERVER=new Array();
	IDTIMG=new Array();

	for(x=0;x<Elementos.length;x++){
		Elemento=Elementos[x];
	
		if(Elemento.getAttribute('requerido')=='si' && (Elemento.value=='' || Elemento.value==0)){
			if(Elemento.getAttribute('llave') || Elemento.getAttribute('dvd')){
				errorextra='<br/>DVDs';
			}else{
				errores=errores+'<br/>'+Elementos[x].getAttribute('texto');
					msg=1;
			}
		}
        switch (Elemento.getAttribute('llave')){
            case 'IDDVD':
               IDTDVD[z]=Elementos[x].id;
               z++;
            break;
            case 'IDMUD':
               IDTMUD[zz]=Elementos[x].id;
               zz++;
            break;
        }
        
/*INDICA LA CANTIDAD DE DVDS AGREGADOS AL POST*/
        CANT_DVDS_SUBIDOS=z;

        if(Elemento.getAttribute('dvd')){
            IDDVD[m]=Elementos[x].id;
            m++;
        }
        if(Elemento.getAttribute('mud')){
            IDMUD[mm]=Elementos[x].id;
            mm++;
        }
        if(Elemento.getAttribute('serv')){
            IDSERVER[mn]=Elementos[x].id;
            mn++;
        }


        if(Elemento.getAttribute('llave')=='IDIMG'){
            IDTIMG[b]=Elementos[x].id;
            b++;
        }
	}
	
    if(msg==1){
        document.getElementById('ERRORES').innerHTML=errores+errorextra;
        return false;
    }
	
TEXTO_DVDS='';
    for(x=0;x<IDTDVD.length;x++){
        valor=document.getElementById(IDTDVD[x]).value;
		ID=IDTDVD[x].slice(4);
		TAMANO=IDSERVER.length;
		TEXTO_DVDS+='[dvd="'+valor+'"]\n';
		for(z=0;z<TAMANO;z++){
			SERVER=IDSERVER[z].split('-');
			if(ID==SERVER[0].slice(8)){
				valor=document.getElementById(IDSERVER[z]).value;
				TEXTO_DVDS+='[server='+valor+']\n';
				TEXTO_DVDS+=document.getElementById('DV'+IDSERVER[z].slice(8)).value;
				TEXTO_DVDS+='[/server]\n';
			};
		}
		TEXTO_DVDS+='[/dvd]\n';
	}

if(IDTDVD.length==0){return true;};
	return TEXTO_DVDS;
}

var sInfo_navegador = navigator.userAgent.toLowerCase();



function imagen(){
	arg=imagen.arguments;
	
	var Img= document.createElement("img");
	Img.setAttribute("src",arg[0]);
	Img.id='IMAGEN';
	Img.align="absmiddle";
	Img.style.cursor="pointer";
	if(sInfo_navegador.indexOf('gecko') != -1){//Firefox		
		Img.setAttribute("onclick",arg[1]);
	}else if(sInfo_navegador.indexOf('msie') != -1){//Internet Explorer
		Img.onclick=new Function(arg[1]);
	}
	return Img;
}

function text(){
	arg=text.arguments;

    var CrearInput=document.getElementById(arg[0]+'[0]').cloneNode(true);
    CrearInput.setAttribute("name",arg[0]+"["+arg[1]+"]");
    CrearInput.setAttribute("type","text");
    CrearInput.setAttribute("id",arg[0]+arg[1]);
    CrearInput.setAttribute("requerido","si");
    CrearInput.setAttribute("llave",arg[2]);
    CrearInput.style.width='70%';
    CrearInput.value='Disco '+arg[1];
	return CrearInput;
}

function add_Tables(){
	arg=add_Tables.arguments;


    valor_final=parseFloat(document.getElementById('DVDS').value);
    valor_final++;

    /*DIV QUE CONTENDRÁ TODOS LOS DATOS A INSERTAR*/

	objeto=document.getElementById('TABLE'); 		//TABLA DE LOS DVDS
	
	var TBODY1= document.createElement("tbody");		//Tbody para insertar los trs
	TBODY1.setAttribute("id",'DVDs'+valor_final);	//El id que vamos a borrar
	
	var TR1= document.createElement("tr");			//El tr dentro del cual estarán los td
	
	var TD1= document.createElement("td");			//El td dentro del cual estará el + Título - y campo de texto
	TD1.setAttribute("align","center");
	TD1.setAttribute("valign","top");

	Img1=imagen(URL_IMAGE_PLUS, 'add_Tables()');
	TD1.appendChild(Img1);
	Texto1=document.createTextNode('Add/Del DVDs');
	TD1.appendChild(Texto1);
	Img2=imagen(URL_IMAGE_MINUS, 'del_DVDS('+valor_final+',"DVDs",1)');
	TD1.appendChild(Img2);
	BR1= document.createElement("br");			//El br 
	TD1.appendChild(BR1);
	Texto2=text('TDVD', valor_final, 'IDDVD');
	TD1.appendChild(Texto2);
	BR2= document.createElement("br");			//El br 
	TD1.appendChild(BR2);
	Img3=imagen(URL_IMAGE_PLUS, 'add_server('+valor_final+')');
	TD1.appendChild(Img3);
	Texto1=document.createTextNode('Add/Del Servers');
	TD1.appendChild(Texto1);
	
	/*INSERTAR ELEMENTOS EN EL PRIMER TD*/
	TR1.appendChild(TD1);
	/*FIN INSERTAR ELEMENTOS EN EL PRIMER TD*/

	var TD2= document.createElement("td");			//El td dentro del cual estará el + Tí tulo - y campo de texto
		var TABLE= document.createElement("table");			//El td dentro del cual estará  el + Título - y campo de texto
		TABLE.setAttribute("width","100%");
		TABLE.setAttribute("border","1");
		TABLE.setAttribute("cellpadding","0");
		TABLE.setAttribute("cellspacing","0");
		TABLE.setAttribute("id","TABLE"+valor_final);

		TBODY2=servidores(valor_final);
		TABLE.appendChild(TBODY2);
		
	TD2.appendChild(TABLE);


	TR1.appendChild(TD2);
	TBODY1.appendChild(TR1);
	objeto.appendChild(TBODY1);
	document.getElementById('DVDS').value=valor_final;
}

function add_server(){
	arg=add_server.arguments;
	ID=arg[0];
	objeto=document.getElementById("TABLE"+ID); 		//TABLA DE LOS DVDS
	
	TBODY2=servidores(ID);
	objeto.appendChild(TBODY2);
}


function servidores(){
	arg=servidores.arguments;
	Val_arg=arg[0];
    valor_final_server=parseFloat(document.getElementById('SERVERS').value);
    valor_final_server++;
	
		var TBODY2= document.createElement("tbody");			//El td dentro del cual estará el + Título - y campo de texto
		TBODY2.setAttribute("id",'Servers'+Val_arg+'-'+valor_final_server);	//El id que vamos a borrar
		
			var TR= document.createElement("tr");			//El tr dentro del cual estarán los td
				var TDb= document.createElement("td");			//El td dentro del cual estará el + Título - y campo de texto
					TDb.setAttribute("width","100%");

					Texto1=document.createTextNode('Add/Del Servers');
					var Crearserv=document.getElementById('servidorc').cloneNode(true);
					Crearserv.setAttribute("name","servidor["+Val_arg+"-"+valor_final_server+"]");
					Crearserv.setAttribute("id","servidor"+Val_arg+"-"+valor_final_server);
					Crearserv.setAttribute("requerido","si");
					Crearserv.setAttribute("llave",'serv');
					Crearserv.setAttribute('serv',Val_arg+"-"+valor_final_server);
		
		
					var CrearDd=document.getElementById('DVD[0]').cloneNode(true);
					CrearDd.setAttribute("name","DV["+Val_arg+"-"+valor_final_server+"]");
					CrearDd.setAttribute("id","DV"+Val_arg+"-"+valor_final_server);
					CrearDd.setAttribute("requerido","si");
					CrearDd.setAttribute("wrap","VIRTUAL");
					CrearDd.setAttribute('dvd',Val_arg+"-"+valor_final_server);
					CrearDd.style.width='95%';
					CrearDd.value='';
					CrearDd.rows='3';
	
				var TDc= document.createElement("td");			//El td dentro del cual estará el + Título - y campo de texto
					Img4=imagen(URL_IMAGE_MINUS, 'del_DVDS('+valor_final_server+',"Servers'+Val_arg+'-",1)');
				
			TDb.appendChild(Texto1);
			TDb.appendChild(Crearserv);
			TDb.appendChild(CrearDd);
			TDc.appendChild(Img4);

		TR.appendChild(TDb);
		TR.appendChild(TDc);
		TBODY2.appendChild(TR);
		document.getElementById('SERVERS').value=valor_final_server;
		return TBODY2;
}



/*FIN NUEVA VERSION PAR AAGREGAR DVDS*/




function insertar(){
arg=insertar.arguments;
if(arg[1]=='DVD'){
    arg[0]='DVD'+arg[0];
    variables=new Array('DVDS','DVD','TDVD','IDDVD','dvd','Título ','DV','SERV', 'serv');
}else if(arg[1]=='IMG'){
    arg[0]='IMG'+arg[0];
    variables=new Array('IMGS','IMG','TIMG','IDIMG','imgs','Url de la Imagen ', 'serv');
}else if(arg[1]=='MUD'){
   // arg[0]='MUD'+arg[0];
  //variables=new Array('MUDS','MUD','TMUD','IDMUD','mud','Título ','MV');
    arg[0]='DVD'+arg[0];
    variables=new Array('DVDS','DVD','TDVD','IDDVD','dvd','Título ','DV','SERV', 'serv');
}


    URL_IMAGE_PLUS='http://animealacarta.com/foro/Themes/Dark-f/images/'+variables[1]+'plus.png';
    URL_IMAGE_MINUS='http://animealacarta.com/foro/Themes/Dark-f/images/'+variables[1]+'minus.png';
    valor_final=parseFloat(document.getElementById(variables[0]).value);
    valor_final++;
    /*DIV QUE CONTENDRÁ TODOS LOS DATOS A INSERTAR*/
    var Div2= document.createElement("div");
    Div2.setAttribute("id",variables[1]+valor_final+"");


    var Img= document.createElement("img");
    Img.setAttribute("src",URL_IMAGE_PLUS);
    Img.id='IMAGEN';
    Img.align="absmiddle";
    Img.style.cursor="hand";
    if(sInfo_navegador.indexOf('gecko') != -1){//Firefox		
        Img.setAttribute("onclick","insertar("+valor_final+",'"+variables[1]+"')");
    }else if(sInfo_navegador.indexOf('msie') != -1){//Internet Explorer
        Img.onclick=new Function("insertar("+valor_final+",'"+variables[1]+"')");
    }
    Div2.appendChild(Img);				//IMAGEN Dentro de DIV
    
    if(variables[0]=='DVDS' ||variables[0]=='MUDS' ){
      var CrearDvd=document.getElementById('servidor[c]').cloneNode(true);
      CrearDvd.setAttribute("name","servidor["+valor_final+"]");
      CrearDvd.setAttribute("type","text");
      CrearDvd.setAttribute("id","servidor"+valor_final);
      CrearDvd.setAttribute("requerido","si");
      CrearDvd.setAttribute("llave",variables[7]);
      CrearDvd.setAttribute(variables[8],valor_final);
      //CrearDvd.style.width='70%';
      //CrearDvd.value='';
      Div2.appendChild(CrearDvd);
    }

 
    Div2.appendChild(document.createTextNode(variables[5]));

    var CrearTDd=document.getElementById('TDVD[0]').cloneNode(true);
    CrearTDd.setAttribute("name",variables[2]+"["+valor_final+"]");
    CrearTDd.setAttribute("type","text");
    CrearTDd.setAttribute("id",variables[2]+valor_final+"");
    CrearTDd.setAttribute("requerido","si");
    CrearTDd.setAttribute("llave",variables[3]);
    CrearTDd.style.width='70%';
    CrearTDd.value='';
    
    Div2.appendChild(CrearTDd);			//INPUT TEXT Dentro de DIV

    var Img= document.createElement("img");
    Img.setAttribute("src",URL_IMAGE_MINUS);
    Img.id='IMAGEN';
    Img.align="absmiddle";
    Img.style.cursor="hand";
    if(sInfo_navegador.indexOf('gecko') != -1){//Firefox		
        Img.setAttribute("onclick","del_DVDS("+valor_final+",'"+variables[1]+"')");
    }else if(sInfo_navegador.indexOf('msie') != -1){//Internet Explorer
        Img.onclick=new Function("del_DVDS("+valor_final+",'"+variables[1]+"')");
    }
    Div2.appendChild(Img);				//IMAGEN Dentro de DIV

if(variables[0]=='DVDS' ||variables[0]=='MUDS' ){
    var CrearDd=document.getElementById('DVD[0]').cloneNode(true);
    CrearDd.setAttribute("name",variables[6]+"["+valor_final+"]");
    CrearDd.setAttribute("id",variables[6]+valor_final);
    CrearDd.setAttribute("requerido","si");
    CrearDd.setAttribute(variables[4],valor_final);
    CrearDd.style.width='90%';
    CrearDd.value='';
    CrearDd.rows='5';

    Div2.appendChild(CrearDd);			//TEXTAREA Dentro de DIV
}

referenceNode=document.getElementById(arg[0]);
document.getElementById(variables[0]).value=valor_final;
return insertAfter( referenceNode, Div2);

}
function insertAfter( referenceNode, newNode )
{
    referenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );
}
function spoiler(sObj)
{
	var sRef = sObj.parentNode.nextSibling;

	if (sRef.nodeType != 1)
		sRef = sRef.nextSibling;
		
	if (sRef.className == "hide")
	{
		sObj.innerHTML = "Esconder";
		sObj.className = "Esconder";
		sRef.className = "s_top";
	}
	else
	{
		sObj.innerHTML = "Mostrar";
		sRef.className = "hide";
		sObj.className = "sub_btn";
	}
}

function cambiar_titulo(){
	arg=cambiar_titulo.arguments;
	document.getElementById('TITULO_DIV').innerHTML=arg[0];
	document.getElementById('TITULO2').innerHTML=arg[0];
	document.getElementById('TITULO_ID').value=arg[0];
}

function ejecutar(){
    FINAL='';

    
    LINKEAR=document.getElementById('URLS').value;
    
    TODOS=LINKEAR.split('\n');
    h=0;
    document.getElementById('LINKS').value='';
    for(x=0;x<TODOS.length;x++){
        h++;
        v='';
        TEXTO=TODOS[x];
        if(TEXTO==''){
            alert('que hay una línea en blanco en algún lugar del código');
            return;
        }
        
        if(TEXTO.indexOf('rapidshare')<0 && TODOS.length-1!=x){
            alert('Todos los links deben ser de rapidshare. El SFV puede estar donde quieras.');
            document.getElementById('LINKS').value='';
            return;
        }else if(TEXTO.indexOf('rapidshare')<0 && TODOS.length-1==x){
            if(!document.getElementById('comprobacion').checked){
                alert('Todos los links deben ser de rapidshare. El SFV puede estar donde quieras.');
                document.getElementById('LINKS').value='';
                return;
            }
        }

        if(TODOS.length-1==x){
            if(document.getElementById('comprobacion').checked){
                FINAL=FINAL+'[url='+TODOS[x]+']Comprobación[/url] - ';
                document.getElementById('LINKS').value=FINAL;
                return;
                            
            }
        }else{
            
        }

        if(h<7){
        
        }else{
            FINAL=FINAL+'\n';
            h=1;
        }
        if(x<9){
            v='0';
        }
            FINAL=FINAL+'[url='+TODOS[x]+']Parte '+v+(x+1)+'[/url] - ';
    }
    document.getElementById('LINKS').value=FINAL;
}


function popUp(URL) {
    day = new Date();
    id = 1;//day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=583,height=310,left = 200,top = 300');");
}

function generar(){
    if(document.getElementById('num_reply').value==2){
        return true;
    }
    Elementos=document.forms.postmodify.elements;
    document.getElementById('ERRORES').innerHTML='';
    errores='Estos campos son requeridos, por favor llenar:';
    errorextra='';


	DVDS_AGREGADOS=verificar_agregados(Elementos);
	if(!DVDS_AGREGADOS){
		return false;
	}else if(DVDS_AGREGADOS==true){
		DVDS_AGREGADOS='';
	}


    var radioOrigen = document.forms.postmodify.ORIGEN;
    var radioDestino = document.forms.postmodify.DESTINO;
    TEXTO_FINAL='';
    DESTINO_FINAL=0;
    for (var i = 0; i< radioOrigen.length; i++) {
        if (radioOrigen[i].checked) {
                try {
                    document.getElementById('ORIGEN').value=radioOrigen[i].value;
                    document.getElementById('origen_juego').value=radioOrigen[i].value;
                    DESTINO_FINAL=radioOrigen[i].value;
                }catch(er){
                }
        }
        try {
                if (radioDestino[i].checked) {
                    document.getElementById('DESTINO').value=radioDestino[i].value;
                    DESTINO_FINAL=radioDestino[i].value;
                }
        }catch(er){
        }
    } 

plantilla=Array();
plantilla2=Array();

plantilla['anime']=Array('BOARD','TITULO','IMG','QUIENTITULO','SINOPSIS','OTROS','DIRECTOR','CAPITULOS','CANTIDAD','IDIOMAS','SUBTITULOS','GENEROS','ORIGEN','DESTINO','SISTEMA','RELACION','PAGINA','EDITORA','AUTORIA','UPLOADERORIGINAL','NOTA','PLANTILLA','FLASHALC');
plantilla2['anime']=Array('board','titulo','img','quientitulo','sinopsis','otros','director','capitulos','cantidad','idiomas','subtitulos','generos','origen','destino','sistema','relacion','pagina','editora','autoria','uploaderoriginal','nota','plantilla','FLASHALC');

plantilla['pelicula']=Array('BOARD','TITULO','IMG','QUIENTITULO','SINOPSIS','OTROS','DIRECTOR','PRODUCCION','REPARTO','DURACION','ANO','PAISORIGEN','IDIOMAS','SUBTITULOS','GENEROS','ORIGEN','DESTINO','SISTEMA','RELACION','PAGINA','UPLOADERORIGINAL','NOTA','PLANTILLA','FLASHALC');
plantilla2['pelicula']=Array('board','titulo','img','quientitulo','sinopsis','otros','director','produccion','reparto','duracion','ano','paisorigen','idiomas','subtitulos','generos','origen','destino','sistema','relacion','pagina','uploaderoriginal','nota','plantilla','FLASHALC');

plantilla['serie']=Array('BOARD','TITULO','IMG','QUIENTITULO','SINOPSIS','OTROS','DIRECTOR','PRODUCCION','REPARTO','ANO','PAISORIGEN','TEMPORADAS','DURACIONCAP','IDIOMAS','SUBTITULOS','GENEROS','ORIGEN','DESTINO','SISTEMA','RELACION','PAGINA','UPLOADERORIGINAL','NOTA','PLANTILLA','FLASHALC');
plantilla2['serie']=Array('board','titulo','img','quientitulo','sinopsis','otros','director','produccion','reparto','ano','paisorigen','temporadas','duracioncap','idiomas','subtitulos','generos','origen','destino','sistema','relacion','pagina','uploaderoriginal','nota','plantilla','FLASHALC');

plantilla['juego']=Array('board_juego','TITULO','img','sinopsis_juego','requisitos_juego','otros_juego','desarrollado_juego','distribuidor_juego','ano_juego','jugadores_juego','online_juego','pegi_juego','paisorigen_juego','pagina_juego','idiomas_juego','subtitulos_juego','origen_juego','sistema_juego','relacion_juego','generos_juego','PLANTILLA','FLASHALC');
plantilla2['juego']=Array('board_juego','titulo_juego','img','sinopsis_juego','requisitos_juego','otros_juego','desarrollado_juego','distribuidor_juego','ano_juego','jugadores_juego','online_juego','pegi_juego','paisorigen_juego','pagina_juego','idiomas_juego','subtitulos_juego','origen_juego','sistema_juego','relacion_juego','generos_juego','plantilla','FLASHALC');

plantilla['juegosbluray']=Array('board_juego','TITULO','img','sinopsis_juego','requisitos_juego','otros_juego','desarrollado_juego','distribuidor_juego','ano_juego','jugadores_juego','online_juego','pegi_juego','paisorigen_juego','pagina_juego','idiomas_juego','subtitulos_juego','origen_juego','sistema_juego','relacion_juego','generos_juego','PLANTILLA','FLASHALC');
plantilla2['juegosbluray']=Array('board_juego','titulo_juego','img','sinopsis_juego','requisitos_juego','otros_juego','desarrollado_juego','distribuidor_juego','ano_juego','jugadores_juego','online_juego','pegi_juego','paisorigen_juego','pagina_juego','idiomas_juego','subtitulos_juego','origen_juego','sistema_juego','relacion_juego','generos_juego','plantilla','FLASHALC');


plantilla['bluray']=Array('BOARD','TITULO','IMG','QUIENTITULO','SINOPSIS','OTROS','DIRECTOR','PRODUCCION','DURACION','ANO','PAISORIGEN','CAPITULOS','CANTIDAD','IDIOMAS','SUBTITULOS','GENEROS','ORIGEN','DESTINO','CODECS','JAVA','RESOLUCION','SISTEMA','PAGINA','EDITORA','AUTORIA','UPLOADERORIGINAL','NOTA','PLANTILLA','FLASHALC');
plantilla2['bluray']=Array('board','titulo','img','quientitulo','sinopsis','otros','director','produccion','duracion','ano','paisorigen','capitulos','cantidad','idiomas','subtitulos','generos','origen','destino','codecs','java','resolucion','sistema','pagina','editora','autoria','uploaderoriginal','nota','plantilla','FLASHALC');

tipo=document.getElementById('PLANTILLA').value;
elementos=plantilla[tipo];
elementos2=plantilla2[tipo];

    for(x=0;x<elementos.length;x++){
//    alert(elementos[x]);
    valor=document.getElementById(elementos[x]).value;
//    alert('valor='+valor);
    

    valores='';
        if(elementos[x]=='IDIOMAS' || elementos[x]=='SUBTITULOS' || elementos[x]=='GENEROS' || elementos[x]=='idiomas_juego' || elementos[x]=='subtitulos_juego' || elementos[x]=='generos_juego' ){
            mySelect=document.getElementById(elementos[x]);
            for(z=0;z<mySelect.length;z++){
                if(mySelect.options[z].selected==true){
                    valores=valores+mySelect.options[z].value+', ';
                }
            }
            valor=valores.substr(0,(valores.length-1));
        }


        valor=valor.replace(/\[/gi,'"');
        valor=valor.replace(/\]/gi,'"');
        if(elementos[x]=='IDIOMAS' || elementos[x]=='idiomas_juego'){
             IDIOMAS_FINAL=valor;
             try{
                document.getElementById('IDIOMAS_PORTADA').value=IDIOMAS_FINAL;
             }catch(er){}
        }
        if(elementos[x]=='SUBTITULOS' || elementos[x]=='subtitulos_juego'){
             SUBTITULOS_FINAL=valor;
             try{
                document.getElementById('SUBTITULOS_PORTADA').value=SUBTITULOS_FINAL;
             }catch(er){}
        }
        if(elementos[x]=='FLASHALC' && valor==''){

        }else{
		TEXTO_FINAL=TEXTO_FINAL+'['+elementos2[x]+']'+valor+'[/'+elementos2[x]+']\n';
	}
    if(elementos[x]=='pegi_juego'){
    
		  TIPOS_PEGI=Array('soez','discriminacion','drogas','miedo','sexo','violencia','juego','online');
		  TIPOS_ESRB=Array('ao','e','e10','ec','m','rp','teen');
		  ESRB='';
		  PEGI='';
		  for(m=0;m<TIPOS_PEGI.length;m++){
  			if(document.getElementById(TIPOS_PEGI[m]).checked==true){
  				PEGI=PEGI+TIPOS_PEGI[m]+',';
  			}
  		}
  		TEXTO_FINAL=TEXTO_FINAL+'[pegi]'+PEGI.substr(0,(PEGI.length-1))+'[/pegi]\n';

  		for(m=0;m<TIPOS_ESRB.length;m++){
        if(document.getElementById(TIPOS_ESRB[m]).checked==true){
  			 	ESRB=ESRB+TIPOS_ESRB[m]+',';
  			}
  		}
  		
		TEXTO_FINAL=TEXTO_FINAL+'[esrb]'+ESRB.substr(0,(ESRB.length-1))+'[/esrb]\n';
        }
    }

    TEXTO_FINAL+='[imagenes]\n';
    for(x=0;x<IDTIMG.length;x++){
        TEXTO_FINAL+='[img]'+document.getElementById(IDTIMG[x]).value;
        TEXTO_FINAL+='[/img]\n';
    }
    TEXTO_FINAL+='[/imagenes]\n';

    TEXTO_FINAL+='[dvds]\n';
	/*
    for(x=0;x<IDTDVD.length;x++){
        valor=document.getElementById(IDTDVD[x]).value;

        try {
          valor_ser=document.getElementById(IDSERVER[x+1]).value;
        }catch(er){
        }
        valor=valor.replace(/\[/gi,'"');
        valor=valor.replace(/\]/gi,'"');
        TEXTO_FINAL+='[dvd="'+valor+'@'+valor_ser+'"]\n';

        TEXTO_FINAL+=document.getElementById(IDDVD[x]).value;
        TEXTO_FINAL+='\n[/dvd]\n';
    }

    for(x=0;x<IDTMUD.length;x++){

        valor=document.getElementById(IDTMUD[x]).value;
        try {
          valor_ser=document.getElementById(IDSERVER[x]).value;
        }catch(er){
        }
        valor=valor.replace(/\[/gi,'"');
        valor=valor.replace(/\]/gi,'"');
        TEXTO_FINAL+='[dvd="'+valor+'@'+valor_ser+'"]\n';

        TEXTO_FINAL+=document.getElementById(IDMUD[x]).value;
        TEXTO_FINAL+='\n[/dvd]\n';
    }
	*/
	TEXTO_FINAL+=DVDS_AGREGADOS;
    TEXTO_FINAL+='[/dvds]\n';
	

/*BUSCAR IDIOMAS*/
    CAS=IDIOMAS_FINAL.lastIndexOf('stellano');
    LAT=IDIOMAS_FINAL.lastIndexOf('atino');
    JAP=IDIOMAS_FINAL.lastIndexOf('apon');
    ING=IDIOMAS_FINAL.lastIndexOf('ngl');
    MULTI=IDIOMAS_FINAL.lastIndexOf('ulti');
//alert(CAS+'-'+LAT+'-'+JAP+'-'+ING);

if(MULTI>0){
  TIT=IDIOMAS_FINAL;
}else{
  if(CAS>0){
    TIT='CAS';
    if(LAT>0){
    	TIT='LYC';
    }else if(JAP>0){
    	TIT='CYJ';
    }else if(ING>0){
	TIT='CYI';
    }
  }else if(LAT>0){
  	TIT='LAT';
  	if(JAP>0){
  		TIT='LYJ';
  	}else if(ING>0){
  		TIT='LYI';
  	}
  }else if(JAP>0){
  	TIT='JAP';
  	if(ING>0){
  		TIT='JYI';
  	}
  }else if(ING>0){
   TIT='ING';
  }else{
    TIT='OTR';
  }
}
if(tipo=='bluray' || tipo=='juegosbluray'){
  DES_FIN=DESTINO_FINAL.split("BD");
  TIT=TIT+'-BD'+DES_FIN[1];
}else{
  DES_FIN=DESTINO_FINAL.split("DVD");
  if(DES_FIN[0]=='Rat'){
    DES_FIN[1]='Rat';
  }
  TIT=TIT+'-'+DES_FIN[1];
}

var MUDS_TIT=DVDS_TIT='';
if(document.getElementById('PLANTILLA').value=='anime'){

DVDS_TIT=0;
   try {
      DVDS_TIT=document.getElementById('SUBIDOS').value;
   }catch(er){
      
   }

   TITULO_VAR=document.getElementById('TITULO').value+'['+TIT+']'+'['+CANT_DVDS_SUBIDOS+'/'+document.getElementById('CANTIDAD').value+']';
 
    
}else{
    TITULO_VAR=document.getElementById('TITULO').value+'['+TIT+']';
}
    document.getElementById('CODIGO').value=TEXTO_FINAL;
    document.getElementsByName('message')[0].value=TEXTO_FINAL;
    document.getElementsByName('subject')[0].value=TITULO_VAR;

    return true;
    
}

function add_DVDS(){

    valor_final=parseFloat(document.getElementById('DVDS').value);

    URL_IMAGE='/post/minus.png';
    if(valor_final>0){
        document.getElementById('IMG_DVD').innerHTML='';
        document.getElementById('IMG_DVD').id='IMGDVD'+valor_final;
    }

    valor_final++;
    
    Div=document.getElementById('DVDS_INSERT');

    var Div2= document.createElement("div");
    Div2.setAttribute("id","DVD"+valor_final+"");
    Div2.appendChild(document.createTextNode('Título '+valor_final));
    
    var Div3= document.createElement("div");
    Div3.setAttribute("id","IMG_DVD");
    Div3.style.display='inline';
    
    var Img= document.createElement("img");
    Img.setAttribute("src",URL_IMAGE);
    Img.id='IMAGEN';
    Img.width='22';
    Img.height='22';
    Img.align="absmiddle";
    if(sInfo_navegador.indexOf('gecko') != -1){//Firefox		
        Img.setAttribute("onclick","del_DVDS("+valor_final+")");
    }else if(sInfo_navegador.indexOf('msie') != -1){//Internet Explorer
        Img.onclick=new Function("readonly_job("+valor_final+")");
    }
    
    var CrearTDd=document.getElementById('pagina').cloneNode(true);
    CrearTDd.setAttribute("name","TDVD["+valor_final+"]");
    CrearTDd.setAttribute("id","TDVD"+valor_final+"");
    CrearTDd.setAttribute("requerido","si");
    CrearDd.setAttribute("llave","IDDVD");
    CrearTDd.value='';
    
    var CrearDd=document.getElementById('sinopsis').cloneNode(true);
    CrearDd.setAttribute("name","DVD["+valor_final+"]");
    CrearDd.setAttribute("id","DVD"+valor_final+"");
    CrearDd.setAttribute("requerido","si");
    CrearDd.setAttribute("dvd",valor_final);
    CrearDd.style.width='90%';
    CrearDd.value='';
    CrearDd.rows='5';

    Div3.appendChild(Img);				//IMAGEN Dentro de DIV
    Div2.appendChild(Div3);				//IMAGEN Dentro de DIV
    Div2.appendChild(CrearTDd);			//INPUT TEXT Dentro de DIV
    Div2.appendChild(CrearDd);			//TEXTAREA Dentro de DIV
    Div.appendChild(Div2);				//DIV Dentro de DIV PRINCIPAL
    document.getElementById('DVDS').value=valor_final;
    
}
function del_DVDS(){
arg=del_DVDS.arguments;
p=arg[0];
rehacer=0;
    try{
	rehacer=arg[3];
    }catch(er){

    }

    borrado=arg[1]+p;
    p=parseFloat(p)-1;

    if(sInfo_navegador.indexOf('gecko') != -1){//Firefox		
//        document.getElementById(borrado).removeNode(true);
		var node = document.getElementById(borrado);
		node.parentNode.removeChild(document.getElementById(borrado));
    }else if(sInfo_navegador.indexOf('msie') != -1){//Internet Explorer
        document.getElementById(borrado).removeNode(true);
    }
	
		if(rehacer==0){
			document.getElementById(arg[1]+'S').value=p;
		}
	
/*    Img=document.getElementById('IMAGEN');
    if(sInfo_navegador.indexOf('gecko') != -1){//Firefox		
        Img.setAttribute("onclick","del_DVDS("+p+")");
    }else if(sInfo_navegador.indexOf('msie') != -1){//Internet Explorer
        Img.onclick=new Function("readonly_job("+p+")");
    }
*/

}

function ToolTips_quitar(){
    
    if(document.getElementById('IDTIPDS').value==1){
        document.getElementById('IDTIPDS').value=0;
    }else{
        document.getElementById('IDTIPDS').value=1;
    }
}


/***USADAS PARA JUEGOS**/
var URL_LINK='http://animealacarta.com';
function image_link(){
	arg=image_link.arguments;
	document.getElementById('pegi_image').src=URL_LINK+'/GranDZerO/PEGI'+arg[0]+'.jpg';
	
}
function color(){
	arg=color.arguments;
	if(document.getElementById(arg[0]).checked==true){
		document.getElementById('t'+arg[0]).style.borderColor = "red";
		document.getElementById('t'+arg[0]).style.borderStyle = "solid";
		document.getElementById('t'+arg[0]).style.backgroundColor = "#ffcccc";
		
	}else{
		document.getElementById('t'+arg[0]).style.borderColor = "";
		document.getElementById('t'+arg[0]).style.borderStyle = "";
		document.getElementById('t'+arg[0]).style.backgroundColor = "";
	}
}


function pagina_sipnosis(){
	arg=pagina_sipnosis.arguments;
	buscar=document.getElementById('TITULO').value;

	if(arg[0]=='juegos'){
		window.open('http://search.ign.com/products?query='+buscar);
	}else if(arg[0]=='anime'){
		window.open('http://www.google.es/search?hl=es&q='+buscar+'+wikipedia');
	}else{
		window.open('http://www.google.es/search?hl=es&q='+buscar+'+wikipedia');
	}
}

function sortfunction(a, b){
	return (a - b) //causes an array to be sorted numerically and ascending
}


function mostrar(){
  arg=mostrar.arguments;
  objeto=arg[0];
  Objeto=objeto.nextSibling;
  if(Objeto.style.display=='none'){
    objeto.innerHTML='Ocultar';
    Objeto.style.display='block';
  }else{
    Objeto.style.display='none';
    objeto.innerHTML='Mostrar';
  }
}


/*
jQuery.noConflict();
$(document).ready(function() {
  $("#IMG").live("mouseout", function(event) {
      alert($("#IMG").val());
  });
});
*/
