var partesContenidoProyecto = new Array();
var css = new Array();

function changeParteContenidoProyecto(id, inactiveCSS,activeCSS){
	document.getElementById('pasos').style.display='block';
	document.getElementById('indice').style.display='none';
	document.getElementById('contenido').style.display='block';
	var n = 1;
	for (parteContenido in partesContenidoProyecto)
	{
		var j = parteContenido.substring(0,5);
		if(j=='parte'){
			if(id==parteContenido){	
				partesContenidoProyecto[parteContenido].style.display='block';
				if (document.getElementById("linkParteContenido" + n)!=null)
					document.getElementById("linkParteContenido" + n).className=activeCSS
			}
			else{
				partesContenidoProyecto[parteContenido].style.display='none';
				if (document.getElementById("linkParteContenido" + n)!=null)
					document.getElementById("linkParteContenido" + n).className=inactiveCSS
			
			}
			n = n+1;
		}
	}
}

function backIndice(){
	document.getElementById('pasos').style.display='block';
	document.getElementById('indice').style.display='block';
	document.getElementById('contenido').style.display='none';
}


function cutString (str, tam) {
	var i;
	if (str.length > tam) {
		str = str.substring(0,tam);
		i=str.length-1; 
		while ((str.charAt(i) != ' ') && (i>0) )	{
			i--;
		}
		if (i != 0 ){
			str = str.substring(0, i);	
		}
		str = str + '...';
	}
	document.write(str);
}


function balanceHeightSingle (objName1, objName2) {
	var i;
	var htmlObj_1 = window.document.getElementById(objName1);
	var htmlObj_2 = window.document.getElementById(objName2);
	
 	if (htmlObj_1 != null && htmlObj_2 != null) {
		balanceHeight = Math.max(htmlObj_1.scrollHeight, htmlObj_2.scrollHeight);
		htmlObj_1.style.height = htmlObj_2.style.height = balanceHeight + "px";
		htmlObj_1.height = balanceHeight;
		htmlObj_2.height = balanceHeight;
		//compara las alturas por si el browser agregó offset
		styleHeight = parseInt(htmlObj_1.style.height);
		scrollHeight = parseInt(htmlObj_2.scrollHeight);
	/*	
		if( styleHeight < scrollHeight ) {
			offset = scrollHeight - styleHeight;
			//htmlObj_1.style.height = htmlObj_2.style.height = styleHeight - offset;
		}
	*/
	}
		if(htmlObj_1 ==null){
			htmlObj_2.style.width=100  + "%";
			htmlObj_2.width=100;
		
		
		}
}

function balanceHeight (objName1, objName2) {
	var i, j;
	var htmlObj_1 = window.document.getElementById(objName1);
	var htmlObj_2 = window.document.getElementById(objName2);
	var padre;
	var padres = window.document.getElementsByName('parent');


 	if (htmlObj_1 != null && htmlObj_2 != null) {

	  for( j=0; j <padres.length ; j++) {
		padre = padres[j];

		for( i=0;i+1<padre.childNodes.length;i=i+2 ) {

			if( padre.childNodes[i].scrollHeight >padre.childNodes[i+1].scrollHeight){
				balanceHeight = padre.childNodes[i].scrollHeight;
				balanceHeight = balanceHeight - 36;
				padre.childNodes[i+1].style.height = balanceHeight;	
			}
			else{
				if( padre.childNodes[i].scrollHeight < padre.childNodes[i+1].scrollHeight){
					balanceHeight = padre.childNodes[i+1].scrollHeight;
					balanceHeight = balanceHeight - 36;
					padre.childNodes[i].style.height = balanceHeight;
				}	
			}
		}//for

	  }//for
	}//if
}

function balanceAllHeights (objName) {
	var i, j;
	var destacados=window.document.getElementsByName(objName);	
 	if (destacados != null) {

	var max=0;
		for( j=0;j+1<destacados.length;j=j+1 ) {
			if(max<Math.max(destacados[j].scrollHeight,destacados[j+1].scrollHeight)){
			max= Math.max(destacados[j].scrollHeight,destacados[j+1].scrollHeight);
			}
		}
	
	for( i=0;i<destacados.length;i=i+1 ) {
		destacados[i].style.height = max;
		
		}
	}//if
}

function changeBkg(id){
	var object = document.getElementById(id);
	if(object.style.backgroundColor=='#FFF')
		object.style.backgroundColor='#FFFFEC';
	else
		object.style.backgroundColor='FFF';
}


function showHide(id){
	var object = document.getElementById(id);
	if(object.style.display=='block')
		object.style.display='none';
	else
		object.style.display='block';
}

function hide(id){
	var object = document.getElementById(id);
	object.style.display='none';
}

function show(id){
	var object = document.getElementById(id);
	object.style.display='block';
}

					/*****  CLASS    SELECTORLINKS *****/		
					function SelectorLinks(){
						
						this.entries = new Array();
						this.addLink = addLink;
						this.peekNLinks = peekNLinks;
						this.getEntrie = getEntrie;
						this.count = function count() { return this.entries.length; }
					
						function addLink(entry){
							this.entries.push(entry);
						}
						
						function getEntrie(index) {
							return this.entries[index];
						}
	
						function peekNLinks(cant){
							
							if(this.count() < 1){
								return new Array();
							}
							//Ojo, se asume que siempre hay mas de un link publicado
							index1 = Math.floor(Math.random()*(this.count()));
							link1 = this.entries[index1];
							index2 = Math.floor(Math.random()*(this.count()));
							while (index1 == index2) {
								index2 = Math.floor(Math.random()*(this.count()));						
							}
							var result = new Array();
							result.push(this.getEntrie(index1));
							result.push(this.getEntrie(index2));
							return result;
						}
					}
	
					/*****  CLASS    ENTRIES *****/						
					function Entry(_desc,  _url){
							this.description =_desc;
							this.url = _url;
							
							this.getDescription = function()  { return this.description; }
							this.getUrl = function() { return this.url; }
					}

/* SHOW-HIDE */

globalPreviousShow = 'infoGeneral';

function showOrHideGroupFrame(divId) {
			div = document.getElementById(globalPreviousShow);
			hideDiv(div);
			showHideGroupFrame(divId);
			globalPreviousShow = divId;
}

/*
  -------------------------------------------------------------------------
	                    JavaScript Form Validator 
                                Version 2.0.2
	Copyright 2003 JavaScript-coder.com. All rights reserved.
	You use this script in your Web pages, provided these opening credit
    lines are kept intact.
	The Form validation script is distributed free from JavaScript-Coder.com

	You may please add a link to JavaScript-Coder.com, 
	making it easy for others to find this script.
	Checkout the Give a link and Get a link page:
	http://www.javascript-coder.com/links/how-to-link.php

    You may not reprint or redistribute this code without permission from 
    JavaScript-Coder.com.
	
	JavaScript Coder
	It precisely codes what you imagine!
	Grab your copy here:
		http://www.javascript-coder.com/
    -------------------------------------------------------------------------  
*/
function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
    switch(command) 
    { 
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Required Field"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : "+cmdvalue+" characters maximum "; 
               }//if 
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validateEmailv2(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Please Select one option "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}
/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
					
		

function reSizeFrame(ifrmId)
{
	try{
	var oFrame = window.document.getElementById('ifrmId');
	var oBody	=	oFrame.document.body;
	//var oFrame	=	document.all("frame");
	oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);
	oFrame.style.width = oBody.scrollWidth + (oBody.offsetWidth - oBody.clientWidth);

	}
	catch(e)
	{
	window.status =	'Error: ' + e.number + '; ' + e.description;
	}
}


//navegacion ppal

function retardarPlegar(menuId,funcion){

ismouseover=false;
setTimeout(funcion , 0000);
}


function desplegar(menuId,submenuId,menuArray,pod){

if(ismouseover) return;

var submenu = document.getElementById(submenuId);
var html ='<img src="sombra_opcion1menu.jpg" width="170" height="10">';
for (i = 0; i < menuArray.length; i++) {
		j=i+3;	
		html += 
		'<div id="' + submenuId+ i +'">' +  '<a href="'  + escape(menuArray[i][1]) + '">' + menuArray[i][0]+'</a></div><img src="sombra_opcion1menu.jpg" width="170" height="1">  ';
										} 
										

	submenu.innerHTML = html;
	if (pod>0)
	submenu.style.visibility = 'visible';
	else
	submenu.style.visibility = 'hidden';
	
}
function mouseIsOver(){
ismouseover=true;
}

/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

//Devuelve true si la fecha actual estÃ¡ entre las dos pasadas por parÃ¡metro
function compararEntreFechas(fechaDesde, fechaHasta){
	var ahora = new Date();
	if (compararFechasMenorIgual(fechaDesde,ahora)&&compararFechasMenorIgual(ahora,fechaHasta))
		return true;
	else	
		return false;
}

//Devuelve  true si la primer fecha es menor o igual que la segunda
function compararFechasMenorIgual(fechaDesde, fechaHasta){
	var res = false;
	if ( fechaDesde.getYear() <= fechaHasta.getYear()){
		if ( fechaDesde.getYear() == fechaHasta.getYear()){
			if ( fechaDesde.getMonth() <= fechaHasta.getMonth()){
				if ( fechaDesde.getMonth() == fechaHasta.getMonth()){
					if ( fechaDesde.getDate() <= fechaHasta.getDate()){
						if ( fechaDesde.getDate()  == fechaHasta.getDate()){
							if ( fechaDesde.getHours() <= fechaHasta.getHours()){
								if ( fechaDesde.getHours() == fechaHasta.getHours()){
									if ( fechaDesde.getMinutes() <= fechaHasta.getMinutes()){
										if ( fechaDesde.getMinutes() == fechaHasta.getMinutes()){
											if ( fechaDesde.getSeconds() <= fechaHasta.getSeconds()){
													res = true;
											}		
										}else res = true;								
									}			
								}else res = true;						
							}				
						}else res = true;						
					}	
				}else res = true;						
			}
		}else res = true;						
	}
	return res;
}

globalPreviousShowPreview = 'modo-detalle';

function showOrHideGroupFramePreview(divId) {
			div = document.getElementById(globalPreviousShowPreview);
			hideDiv(div);
			showHideGroupFrame(divId);
			globalPreviousShowPreview = divId;
}
