<!--
/*
*	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 = document.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 set_error(){
	
	
	var errordiv = findObject('errordiv');
	if (errordiv==null)return false;

	//winW /2 - errordiv.style.width / 2);
	var width = errordiv.style.width;
	width = width.substr(0,width.indexOf('px')) ;

	get_win_size();  
	errordiv.style.left=(winW /2 - parseInt(width) / 2)+'px';
	errordiv.style.visibility = 'visible';
	return true;
	

	
}

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 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;
}
