﻿function RellenarRecomendados(oTitulo, oGuionistas, oDibujantes, oResumen, oPrecio, oCopy)
{
    var strTitulo = document.getElementById('Titulo');
    strTitulo.innerHTML = oTitulo;
    if ((oGuionistas != '') || (oDibujantes != ''))
    {
        var strAutores = document.getElementById('Autores');
        strAutores.innerHTML = oGuionistas + '/' + oDibujantes;
    }
    else
    {
            var strAutores = document.getElementById('Autores');
            strAutores.innerHTML = '<br>';
    }    
    var strResumen = document.getElementById('Resumen');
    strResumen.innerHTML = oResumen;
    if (oPrecio != '')
    {
        var strPrecio = document.getElementById('Precio');
        strPrecio.innerHTML = oPrecio + ' €';
    }
    else
    {
        var strPrecio = document.getElementById('Precio');
        strPrecio.innerHTML = '<br>';
    }
    if (oCopy != '')
    {
        var strCopy = document.getElementById('CopyRight');
        strCopy.innerHTML = oCopy;
    }
    else
    {
        var strCopy = document.getElementById('CopyRight');
        strCopy.innerHTML = '';
    }
}


function AplicarBotonSubmit(e, pNomBoton)
{
    if (e.type.toLowerCase()=="keydown" && !document.all) return true;
    
    var tecla = (document.all) ? e.keyCode : e.which;
    var campo = (document.all) ? document.activeElement : e.target;
    
    if(tecla==13) { 
       if (campo) {
           if ((campo.type.toLowerCase()!='textarea') && 
               (campo.type.toLowerCase()!='image') && 
               (campo.type.toLowerCase()!='reset') && 
               (campo.type.toLowerCase()!='submit') && 
               (campo.type.toLowerCase()!='button')) { 
               if (document.getElementById(pNomBoton)) {                    
                   
                   //Si no pongo esto, si el enter es desde un radinput de telerik, entonces se pierde la última letra
                   try 
                   {
                        eval(campo.id.replace('_text','') + '.UpdateHiddenValue()');                   
                   }
                   catch(err) {}

                   document.getElementById(pNomBoton).focus(); 
                   top.scrollBy(0,50);
                   document.getElementById(pNomBoton).click();                    
               }                                                        
                   e.cancelBubble=true;
                   e.returnValue=false;           
            
                   return false; 
           } 
       } 
     } 
     return true;
}

function autofitIframe(id)
{   
 if (!window.opera && !document.mimeType && document.all && document.getElementById)
 {
    if (parent.document.getElementById(id)) parent.document.getElementById(id).style.height=(this.document.body.offsetHeight+80)+"px";
 }
 else if(document.getElementById) 
 {
    if (parent.document.getElementById(id)) parent.document.getElementById(id).style.height=(this.document.body.scrollHeight+80)+"px";
 }
} 

function CancelarCambioItemCombo(item)
   {
        return false;
   }     

function CancelarTeclaCombo(combo, e)
  {
       if (!e) 
       {
            e = window.event;
        }    
                
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
        e.cancel = true;
        e.returnValue = false;
      
  }


function abreVentana (pagURL, pagTarget, w, h) 
{
    var winLeft = (screen.width-w)/2;
    var winTop = (screen.height-h)/2;
    var propiedades = 'width='+ w;
    propiedades = propiedades +',height='+ h; 
    propiedades = propiedades +',left='+ winLeft;
    propiedades = propiedades +',top='+ winTop;
    propiedades = propiedades +',fullscreen=no';
    propiedades = propiedades +',directories =no';
    propiedades = propiedades +',toolbar=no'; 
    propiedades = propiedades +',status=yes';
    propiedades = propiedades +',menubar=no';
    propiedades = propiedades +',scrollbars=yes';
    propiedades = propiedades +',resizable=yes';
    window.open (pagURL, pagTarget ,propiedades);
}

function abrePopUp (pagURL, pagTarget, w, h) 
{
    var winLeft = (screen.width-w)/2;
    var winTop = (screen.height-h)/2;
    var propiedades = 'width='+ w;
    propiedades = propiedades +',height='+ h; 
    propiedades = propiedades +',left='+ winLeft;
    propiedades = propiedades +',top='+ winTop;
    propiedades = propiedades +',fullscreen=no';
    propiedades = propiedades +',directories =no';
    propiedades = propiedades +',toolbar=no'; 
    propiedades = propiedades +',status=yes';
    propiedades = propiedades +',menubar=no';
    propiedades = propiedades +',scrollbars=no';
    propiedades = propiedades +',resizable=yes';
    window.open (pagURL, pagTarget ,propiedades);
}

function CrearXMLHTTP()
{
    var xmlHttp;
    if (window.ActiveXObject)
    {
    var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    {
    var xmlHttp = new XMLHttpRequest();
    }

    
    return xmlHttp;
}


// Para contar número de caracteres en un textbox

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,limite) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  //var length=limite - entranceObj.value.length;
  var length=entranceObj.value.length;
  
  if(length > limite) {
    //length=0;
    //text='<span class="disable"> '+text+' </span>';
    //entranceObj.value=entranceObj.value.substr(0,limite);
    text='<span style="color:Red;"> '+text+' </span>';
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}

function PonerDir(elem) {
        var c1 = "info";
        var c2 = "xpandintl.com"; 
        var c3 = "ma";
        var c4 = "ilto";

        elem.href = c3 + c4 + ':' + c1 + '@' + c2 ;
    }