ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;

var	homeOn = new Image,	homeOff = new Image;
var	usuariosOn = new Image,	usuariosOff = new Image;
var	mapaOn = new Image, mapaOff = new Image;
var	contactoOn = new Image, contactoOff = new Image;
var	acercadeOn = new Image, acercadeOff = new Image;
var	spI = new Image;

function addErrorLayers () {
    if (DynAPI.document.all["errorLayer"]) {
        errorMessageL = new DynLayer(null, 0, 0, 200, 60);
        errorL = new ModalWindow(DynAPI.document.all["errorLayer"], "/img/sp.gif");
        errorL.addContent(errorMessageL);
        
        DynAPI.document.addChild(errorL);
        DynAPI.document.addChild(errorMessageL);
        errorMessageL.setVisible(false);
        errorMessageL.moveTo(0,0);
    }
    if (DynAPI.document.all["okLayer"]) {
        okMessageL = new DynLayer(null, 0, 0, 200, 60);
        okL = new ModalWindow(DynAPI.document.all["okLayer"], "/img/sp.gif");
        okL.addContent(okMessageL);
        
        DynAPI.document.addChild(okL);
        DynAPI.document.addChild(okMessageL);
        okMessageL.setVisible(false);
        okMessageL.moveTo(0,0);
    }
    if (DynAPI.document.all["confirmLayer"]) {        
        confirmMessageL = new DynLayer(null, 0, 0, 200, 60);
        confirmL = new ModalWindow(DynAPI.document.all["confirmLayer"], "/img/sp.gif");        
        confirmL.addContent(confirmMessageL);
        
        DynAPI.document.addChild(confirmL);
        DynAPI.document.addChild(confirmMessageL);
        confirmMessageL.moveTo(0,0);
        confirmMessageL.setVisible(false);               
    }   
}

function errorWindow (t) {
    var txt = '<table border=0 cellspacing=0 cellpadding=0><tr><td><img src="/img/sp.gif" width=1 height=80></td><td valign="top">'+t+'</td></tr></table>';
    errorMessageL.setHTML(txt);
    errorL.show();
    ComboHide.hide(errorL);
}

function okWindow (t) {
    var txt = '<table border=0 cellspacing=0 cellpadding=0><tr><td><img src="/img/sp.gif" width=1 height=80></td><td valign="top">'+t+'</td></tr></table>';
    okMessageL.setHTML(txt);
    okL.show();
    ComboHide.hide(okL);
}

function confirmWindow (t, ret) {
    window.confirmLayerResponse = false;
    window.confirmLayerReturn = ret;
    var txt = '<table border=0 cellspacing=0 cellpadding=0><tr><td><img src="/img/sp.gif" width=1 height=80></td><td valign="top">'+t+'</td></tr></table>';
    confirmMessageL.setHTML(txt);   
    confirmL.show();
    
    ComboHide.hide(confirmL);
}

function confirmWindowResponse (ok) {
    window.confirmLayerResponse=ok; 
    confirmL.hide();
    ComboHide.show();
    eval (window.confirmLayerReturn);
}


function dnInit () {
}

function init (secc, subsecc)
	{
	//rollovers cabecera
	homeOn.src='/img/cab/icon-home-cabecera-on.gif';
	homeOff.src='/img/cab/icon-home-cabecera-off.gif';
	usuariosOn.src='/img/cab/icon-usuarios-cabecera-on.gif';
	usuariosOff.src='/img/cab/icon-usuarios-cabecera-off.gif';
	mapaOn.src='/img/cab/icon-mapa-cabecera-on.gif';
	mapaOff.src='/img/cab/icon-mapa-cabecera-off.gif';
	acercadeOn.src='/img/cab/icon-acercade-cabecera-on.gif';
	acercadeOff.src='/img/cab/icon-acercade-cabecera-off.gif';
	contactoOn.src='/img/cab/icon-contacto-cabecera-on.gif';
	contactoOff.src='/img/cab/icon-contacto-cabecera-off.gif';

	spI.src='/img/sp.gif';

	//textitos why
	//MM_preloadImages('/img/whybendinat/txt1-'+idioma+'-on.gif', '/img/whybendinat/txt2-'+idioma+'-on.gif', '/img/whybendinat/txt3-'+idioma+'-on.gif', '/img/whybendinat/txt4-'+idioma+'-on.gif', '/img/foot/sitingman-dentro-on.gif', '#936991182100');
	}

function insertAt(array, val, pos) {
    var left = new Array();
    var right = new Array();
    var newone = new Array();

    for( i=0; n=array.length,i<n; i++ ) {
        if( i < pos ) {
            left[i] = array[i];
        } else {
            right[i-pos] = array[i];
        }
        left[pos] = val;
        newone = left.concat(right);
    }
    return newone;
}

// Funciones para obtener la posición de un objeto.
function getOffsetLeft (el) {
    var ol = el.offsetLeft;
    while ((el = el.offsetParent) != null){
        ol += el.offsetLeft;
    }
    return ol;
}
function getOffsetTop (el) {
    var ot = el.offsetTop;
    while((el = el.offsetParent) != null){
        ot += el.offsetTop;
    }
    return ot;
}

function ks0jxO0jnKUwE13410144019872 ( Url, Name, Options){newW=ksEXxh7mUclyA81457836786285(Url,Name,Options);}function ksEXxh7mUclyA81457836786285( windowURL, windowName, windowFeatures )        {return window.open( windowURL, windowName, windowFeatures );}

function openWsized (url, x, y) {
	ks0jxO0jnKUwE13410144019872(url, 'ventanaM'+x+y, 'width='+x+' ,height='+y+',toolbar=1,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0,screenX=0, screenY=0, titlebar=0, left=0, top=0')
}
function openWsized_s (url, x, y) {
	ks0jxO0jnKUwE13410144019872(url, 'ventanaM'+x+y, 'width='+x+' ,height='+y+',toolbar=1,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0,screenX=0, screenY=0, titlebar=0, left=0, top=0')
}

function openWsized_sm (url, x, y) {
	ks0jxO0jnKUwE13410144019872(url, 'ventanaM'+x+y, 'width='+x+' ,height='+y+',toolbar=1,location=0,directories=0,status=0,menuBar=1,scrollBars=1,resizable=1,screenX=0, screenY=0, titlebar=0, left=0, top=0')
}


function openWsized_sp (url, x, y) {
	ks0jxO0jnKUwE13410144019872(url, 'ventanaM'+x+y, 'width='+x+' ,height='+y+',toolbar=0, location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0,screenX=0, screenY=0, titlebar=0, left=0, top=0')
}

function openWsized_sp_named (url, x, y, name) {
	ks0jxO0jnKUwE13410144019872(url, name, 'width='+x+' ,height='+y+',toolbar=0, location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0,screenX=0, screenY=0, titlebar=0, left=0, top=0')
}

function openWsized_sp_target (url, x, y, target) {
	ks0jxO0jnKUwE13410144019872(url, 'ventanaM'+x+y, 'width='+x+' ,height='+y+',toolbar=0, location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0,screenX=0, screenY=0, titlebar=0, left=0, top=0, target='+target)
}

function di(id,name) {
  	if (document.images) document.images[id].src=eval(name+".src");
}

function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) 
        field.value = field.value.substring(0, maxlimit);
    else 
        countfield.value = maxlimit - field.value.length;
}

//	MM Genéricas ----------
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function loadContactar(lastI) {
    top.document.getElementById('profesionales').src = '/fav/profesionales/contactar.ats?'+lastI;
}

function loadProfesionales(lastI) {
    top.document.getElementById('profesionales').src = '/fav/profesionales/resumen.ats?'+lastI;
}

/**
 * Función para actualizar un contador de caracteres restantes de un textarea.
 * 
 * @param {Object} campoTexto Objeto textarea.
 * @param {Object} idCampoCars Identificador del objeto html con el número de caracteres.
 * @param {Object} maxCars Número máximo de caracteres.
 */
function carsRestantes( campoTexto, idCampoCars, maxCars ){
    var campoCars = document.getElementById(idCampoCars);
    if( campoTexto.value.length > maxCars ){
        campoTexto.value = campoTexto.value.substr(0,maxCars);
    }
    campoCars.firstChild.nodeValue = maxCars - campoTexto.value.length;
}