<!--
/*
*	Autor: Pablo Salaberri
*	Descripción:
*		Módulo gestor de imagenes pop dentro del navegador
*
*
*
*/
/**
 * 	Función de búsqueda de objetos
 */
var isOpera = (navigator.userAgent.indexOf('Opera') != -1);
var isIE = (!isOpera && navigator.userAgent.indexOf('MSIE') != -1);
var isNN=(navigator.appName=="Netscape")?1:0;

 
function getObject(obj){
	
	var el = isIE ? eval('document.all.'+obj) : document.getElementById(obj);
	return el;
}
function findObject(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  
  if(!(foundObj = theDoc[theObj]) && theDoc.all){ foundObj = theDoc.all[theObj];}
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = theDoc.getElementById(theObj);
  
  return foundObj;
}
//******************************* LIBRERÍA

function basename(path, suffix) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Ash Searle (http://hexmen.com/blog/)
    // +   improved by: Lincoln Ramsay
    // +   improved by: djmix
    // *     example 1: basename('/www/site/home.htm', '.htm');
    // *     returns 1: 'home'
 
    var b = path.replace(/^.*[\/\\]/g, '');
    
    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    
    return b;
}

var nmm='';
var sssnd='';
function get_ss(){
	nmm = findObj('nmm');
	sssnd = findObj('sssnd');
}
function set_ssn_action(action){
	get_ss();
	if ((nmm!=null)&&(sssnd!=null)){
		
		ssn_action = action + '&nmm='+nmm.value+'&sssnd='+sssnd.value;
	}
	else ssn_action = action;
	
	return ssn_action;
}


//Function get_window_size
var winW;
var winH;
function get_win_size(){
	if (parseInt(navigator.appVersion)>3) {

	 if (navigator.appName=="Netscape") {
		  winW = window.innerWidth;
	  	  winH = window.innerHeight;
	  	 
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  	winW = document.body.offsetWidth+16;
	  	winH = document.body.offsetHeight+16;
	 }
	}
}
function Cget_win_size(){
	if (parseInt(navigator.appVersion)>3) {

	 if (navigator.appName=="Netscape") {
		  _winW = window.innerWidth;
	  	   if(navigator.userAgent.indexOf('Safari')) _winH = window.innerHeight-50;
	  	  	else _winH = window.innerHeight;
	  	  
	  	
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	 	
	  	_winW = document.body.clientWidth-16;
	  	_winH = document.body.clientHeight-2;
	  	
	 }
	}
	
	return new Array(_winW,_winH);
}
var timeout_error;
function set_error(){
	var errordiv = findObject('errordiv');
	if (errordiv==null)return false;
	errordiv.style.visibility = 'visible';
	timeout_error = window.setTimeout(hide_error,2000);
	return true;
}
function hide_error(){
	window.clearTimeout(timeout_error);
	
	var errordiv = findObject('errordiv');
	if (errordiv==null)return false;
	errordiv.style.visibility = 'hidden';
	
}
function getFlashObj(movie){
   if (window.document[movie]) {
      return window.document[movie];
   }
   if (navigator.appName.indexOf("Microsoft Internet")==-1) {
      if (document.embeds && document.embeds[movie]) {
         return document.embeds[movie]; 
      }
   } else {
      return document.getElementById(movie);
   }
}
function getFlashDimensions(movie) {
   var movieObj = getFlashObj(movie);
   
   if (movieObj.TGetProperty("/", 8)) {
	   var width = movieObj.TGetProperty("/", 8);
	   var height= movieObj.TGetProperty("/", 9);
	   movieObj.style.width = width;
	   movieObj.style.height = height;
	
   }
}
function redim_window(){
	
	get_win_size();
	
	if (parseInt(navigator.appVersion)>3) {

	 if (navigator.appName=="Netscape") {
	  window.outerWidth= window.innerWidth;
	  window.outerHeight = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth+16;
	  winH = document.body.offsetHeight+16;
	 }
	}	
}
//******************************* LIBRERÍA

function implode(glue,array){
	var newarray = '';
	for (var i=0 ; i < (array.length-1); i++ ){
		newarray += array[i]+glue;
	}
	newarray +=array[array.length-1];
	return newarray;
}
function set_css_style(item,style){
	
	if (isIE){
		item.style.cssText = style;
		return true;
	}
	else item.setAttribute('style',style);
	return true;
} 
function setClassId(id,classn){
	var element = findObject(id);
	setClass(element,classn);
}
function setClass(item,classn){
	if (isIE){
		item.className=classn;
	}
	else{
		item.setAttribute('class',classn);
	}
}
//Get scrolling top
function get_win_top_scroll(){
	
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
	
	var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
	var dsoctop=document.all? iebody.scrollTop : pageYOffset;
	return dsoctop;
	
}

function get_win_size() {
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    
    winW = window.innerWidth;
    winH = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    
    winW = document.documentElement.clientWidth;
    winH = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    
    winW = document.body.clientWidth;
    winH = document.body.clientHeight;
  }
 
}
get_win_size();
//Ficheros
function basename(path) {

	
    return path.replace( /.*\//, "" );
}
function dirname(path) {
	
    return path.match( /.*\// );
}
function set_DOM_elem_value(idelement,valueof){
	var domel = findObj(idelement);
	
	if (domel!==null){
		domel.value=valueof;
	}
	
}
function del_DOM_childs(idelement){
	
	//Buscamos en document.windows para eliminar este elemento
	while(idelement.firstChild){
		idelement.removeChild(idelement.firstChild);
	}
	
}
function del_DOM_element(idelement){
	
	//Buscamos en document.windows para eliminar este elemento
	while(idelement.firstChild){
		idelement.removeChild(idelement.firstChild);
	}
	document.body.removeChild(idelement);
	
}
//Elementos a eliminar de aqui...
function set_hiperlink(hiperlink){
 	var link = parent.document.getElementById('url');
 		link.value=hiperlink;
}
function set_imageurl(hiperlink){
 	var link = parent.document.getElementById('imageurl');
 		link.value=hiperlink;
}

//Gestión de envio de GET
var getvalue = new Array();
function set_get_value(variable,valor){
	var nueva = true;
	
	for (var i=0; i<getvalue.length;i++){
		if(getvalue[i][0]==variable){
	
			nueva = false;
			getvalue[i][1]=valor;
		}
	}
	if (nueva){
	
		getvalue[getvalue.length] =variable+'='+valor;
	}
	
	return void(0);
}

function go_get(){
	var current = window.location;
	var uri_path = current.toString();
	var path = uri_path.split("?");
	//Obtenemos el elemento _file_
	var get=implode('&',getvalue);
	var new_path=path[0]+'?'+get;
	
	window.location = new_path.toString();
	return true;
	
	
}
//Inhabilita el enter en los formularios 
function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     

     return (key != 13);
}
//Creación de un elemento de carga de archivos independiente y que se cargue solo
function create_formupload(formname,nombre){
	
	if ((eval('typeof(document.'+nombre+')')) !=='undefined'){
		if (eval('document.'+nombre+'==true')) return;
		
	}
	else eval('document.'+nombre+"=true");
	
	var div = document.createElement('div');
		div.id='uploadcontainer';
		set_css_style(div,'float:right;position:relative;z-index:10;padding:5px;background-color:#cccccc;border:1px #a3a3a3 solid;' +
				'font-family: Verdana, Arial;	font-size: 10px;	font-style:normal;');	
	var input =document.createElement('input');
		input.type='file';
		input.id = 'archivo';
		set_css_style(input,'font-family: Verdana, Arial;	font-size: 10px;	font-style:normal;');	
		div.appendChild(input);
		main = findObject(formname);
	var input2 =document.createElement('input');
		input2.type='submit';
		input2.id = 'upload';
		input2.value='ok';
		set_css_style(input2,'font-family: Verdana, Arial;	font-size: 10px;	font-style:normal;');
		div.appendChild(input2);
	var input3 =document.createElement('input');
		input3.type='button';
		input3.id = 'cancelarup';
		input3.value='cancelar';
		set_css_style(input3,'font-family: Verdana, Arial;	font-size: 10px;	font-style:normal;');
		input3.padre = div;
		input3.onclick = function(){
			
			del_DOM_element(this.padre);
		}			
		div.appendChild(input3);
		
		main = findObject(formname);
		main.appendChild(div);
}
function get_html_translation_table(table, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
    
    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }
    
    if (useQuoteStyle != 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }
 
    if (useQuoteStyle == 'ENT_QUOTES') {
        entities['39'] = '&#039;';
    }
 
    if (useTable == 'HTML_SPECIALCHARS') {
        // ascii decimals for better compatibility
        entities['38'] = '&amp;';
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
      entities['38']  = '&amp;';
      entities['60']  = '&lt;';
      entities['62']  = '&gt;';
      entities['160'] = '&nbsp;';
      entities['161'] = '&iexcl;';
      entities['162'] = '&cent;';
      entities['163'] = '&pound;';
      entities['164'] = '&curren;';
      entities['165'] = '&yen;';
      entities['166'] = '&brvbar;';
      entities['167'] = '&sect;';
      entities['168'] = '&uml;';
      entities['169'] = '&copy;';
      entities['170'] = '&ordf;';
      entities['171'] = '&laquo;';
      entities['172'] = '&not;';
      entities['173'] = '&shy;';
      entities['174'] = '&reg;';
      entities['175'] = '&macr;';
      entities['176'] = '&deg;';
      entities['177'] = '&plusmn;';
      entities['178'] = '&sup2;';
      entities['179'] = '&sup3;';
      entities['180'] = '&acute;';
      entities['181'] = '&micro;';
      entities['182'] = '&para;';
      entities['183'] = '&middot;';
      entities['184'] = '&cedil;';
      entities['185'] = '&sup1;';
      entities['186'] = '&ordm;';
      entities['187'] = '&raquo;';
      entities['188'] = '&frac14;';
      entities['189'] = '&frac12;';
      entities['190'] = '&frac34;';
      entities['191'] = '&iquest;';
      entities['192'] = '&Agrave;';
      entities['193'] = '&Aacute;';
      entities['194'] = '&Acirc;';
      entities['195'] = '&Atilde;';
      entities['196'] = '&Auml;';
      entities['197'] = '&Aring;';
      entities['198'] = '&AElig;';
      entities['199'] = '&Ccedil;';
      entities['200'] = '&Egrave;';
      entities['201'] = '&Eacute;';
      entities['202'] = '&Ecirc;';
      entities['203'] = '&Euml;';
      entities['204'] = '&Igrave;';
      entities['205'] = '&Iacute;';
      entities['206'] = '&Icirc;';
      entities['207'] = '&Iuml;';
      entities['208'] = '&ETH;';
      entities['209'] = '&Ntilde;';
      entities['210'] = '&Ograve;';
      entities['211'] = '&Oacute;';
      entities['212'] = '&Ocirc;';
      entities['213'] = '&Otilde;';
      entities['214'] = '&Ouml;';
      entities['215'] = '&times;';
      entities['216'] = '&Oslash;';
      entities['217'] = '&Ugrave;';
      entities['218'] = '&Uacute;';
      entities['219'] = '&Ucirc;';
      entities['220'] = '&Uuml;';
      entities['221'] = '&Yacute;';
      entities['222'] = '&THORN;';
      entities['223'] = '&szlig;';
      entities['224'] = '&agrave;';
      entities['225'] = '&aacute;';
      entities['226'] = '&acirc;';
      entities['227'] = '&atilde;';
      entities['228'] = '&auml;';
      entities['229'] = '&aring;';
      entities['230'] = '&aelig;';
      entities['231'] = '&ccedil;';
      entities['232'] = '&egrave;';
      entities['233'] = '&eacute;';
      entities['234'] = '&ecirc;';
      entities['235'] = '&euml;';
      entities['236'] = '&igrave;';
      entities['237'] = '&iacute;';
      entities['238'] = '&icirc;';
      entities['239'] = '&iuml;';
      entities['240'] = '&eth;';
      entities['241'] = '&ntilde;';
      entities['242'] = '&ograve;';
      entities['243'] = '&oacute;';
      entities['244'] = '&ocirc;';
      entities['245'] = '&otilde;';
      entities['246'] = '&ouml;';
      entities['247'] = '&divide;';
      entities['248'] = '&oslash;';
      entities['249'] = '&ugrave;';
      entities['250'] = '&uacute;';
      entities['251'] = '&ucirc;';
      entities['252'] = '&uuml;';
      entities['253'] = '&yacute;';
      entities['254'] = '&thorn;';
      entities['255'] = '&yuml;';
    } else {
        throw Error("Table: "+useTable+' not supported');
        return false;
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}
function htmlspecialchars_decode(string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Mateusz "loonquawl" Zalega
    // +      input by: ReverseSyntax
    // +      input by: Slawomir Kaniecki
    // +      input by: Scott Cariss
    // +      input by: Francois
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
    // *     returns 1: '<p>this -> &quot;</p>'
 
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }
 
    // &amp; must be the last character when decoding!
    delete(histogram['&']);
    histogram['&'] = '&amp;';
 
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    
    return tmp_str;
}
function htmlentities (string, quote_style) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'
    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
    // *     returns 2: 'foo&#039;bar'
 
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}
function urlencode( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Lars Fischer
    // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                             
    var histogram = {}, tmp_arr = [], unicodeStr='', hexEscStr='';
    var ret = (str+'').toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    histogram['\u00DC'] = '%DC';
    histogram['\u00FC'] = '%FC';
    histogram['\u00C4'] = '%D4';
    histogram['\u00E4'] = '%E4';
    histogram['\u00D6'] = '%D6';
    histogram['\u00F6'] = '%F6';
    histogram['\u00DF'] = '%DF';
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
 
    for (unicodeStr in histogram) {
        hexEscStr = histogram[unicodeStr];
        ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}
function openwindow(src,where){
	//src = urlencode(src);
	window.open(src,where);		
}