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_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 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_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 abrir_ventana(url){
  window.top.location.href = url 
  
}

function replaceSubstring(inputString, badString,
                          goodString, caseSensitive) {
  var fixedReplace = "";
  var UI = inputString;
  var UB = badString;
  
  if ((caseSensitive != 1) && (caseSensitive != true)) {
  UI = inputString.toUpperCase();
     UB = badString.toUpperCase();
     }
  var badEnd = -1;
  var badLoc = UI.indexOf(UB);
  if (badLoc != -1) {
     for (x=1; (badLoc != -1); x++) {
        fixedReplace = fixedReplace + 
                       inputString.substring((badEnd +
                       1), badLoc) + goodString
        badEnd = badLoc + UB.length - 1;
        badLoc = UI.indexOf(UB, (badLoc + 1)); }
     fixedReplace = fixedReplace + 
                    inputString.substring((badEnd + 1),
                    inputString.length); }
     else { fixedReplace = inputString;    }
return fixedReplace;
}

function trim(inputstringTrim) {
  fixedTrim = "";
  lastCh = " ";
  for (x = 0; x < inputstringTrim.length; x++) {
     ch = inputstringTrim.charAt(x);
     if ((ch != " ") || (lastCh != " ")) { fixedTrim +=
                                          ch; }
     lastCh = ch;
}
  if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {
     fixedTrim = fixedTrim.substring(0, fixedTrim.length -
                                     1); }
  return fixedTrim;
}

function llama_tracking(queryTracking){
  var Tracking;
  Tracking=queryTracking;
  if (Tracking == "")
	alert("Por favor ingrese un nº de Contenedor, B/L o Booking.")
  else{
      Tracking = trim(Tracking);
      url = "http://www2.csav.com/rastreo/rastreo.nsf/yourtrace?openagent&" + Tracking;                      
      abrir_ventana(url);     
  }
}

function isEmail(email){
	var regex=/^\w+(\-){0,1}\w*(\.\w+(\-){0,1}\w*){0,5}@\w+(\-){0,1}\w*(\.\w+(\-){0,1}\w*){0,5}\.(\w){2,3}$/;
	return regex.test(email);
}

function retrieveCookie( cookieName ) {
	var cookieJar = document.cookie.split( "; " );
	for( var x = 0; x < cookieJar.length; x++ ) {
		var oneCookie = cookieJar[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
	}
	return null;
}

function PintaPie(){
var WebRoot = retrieveCookie("WWW_Root");
var pie = "<table width='770' border='0' cellspacing='0' cellpadding='0'>";
  var param = screen.width + ";" + screen.height +  ";" + window.screen.availWidth + ";" + window.screen.availHeight + ";" + window.screen.colorDepth + ";" + document.referrer; 
  pie = pie + "<tr>";
  pie = pie + "    <td colspan='4' height='1'><img src='/web/oficinas1.nsf/openhandlerjs?openagent&"+param +"'width='1' height='1'></td>";
  pie = pie + "  </tr>";
  pie = pie + "  <tr>";
  pie = pie + "    <td height='1' colspan='5' bgcolor='#FFFFFF' class='piesinlink'><img src='/www/imagenes/spacer.gif' width='1' height='1'></td>";
  pie = pie + "  </tr>";
  pie = pie + "  <tr>";
  pie = pie + "    <td height='20' bgcolor='#394D8C' class='piesinlink'>&nbsp;Copyright &copy; 2007, CSAV - <a href='/pages/sp_terms_conditions' class='pielink'>T&eacute;rminos y Condiciones de uso</a></td>";
  pie = pie + "    <td height='20' align='center' bgcolor='#394D8C'><img src='/www/imagenes/home2006/separador_pie.gif' width='2' height='16'></td>";
  pie = pie + "    <td width='40' height='20' align='center' bgcolor='#394D8C' class='pielink'><a href='/index_sp.htm'><img src='/www/imagenes/casita_home.gif' width='10' height='10' border='0'></a></td>";
  pie = pie + "    <td height='20' align='center' bgcolor='#394D8C'><img src='/www/imagenes/home2006/separador_pie.gif' width='2' height='16'></td>";
  pie = pie + "    <td align='center' bgcolor='#394D8C'><a href='/pages/sp_map' class='pielink'>Mapa Sitio</a></td>";
  pie = pie + "  </tr>";
  pie = pie + "</table>";
return pie
}


function HomePintaPie(){
var pie = "<table width='770' border='0' cellspacing='0' cellpadding='0'>";
  var param = screen.width + ";" + screen.height +  ";" + window.screen.availWidth + ";" + window.screen.availHeight + ";" + window.screen.colorDepth + ";" + document.referrer; 
  pie = pie + "<tr>";
  pie = pie + "<td colspan='4' height='1'><img src='/web/oficinas1.nsf/openhandlerjs?openagent&"+param +"'width='1' height='1'></td>";
  pie = pie + "</tr>";
  pie = pie + "<tr>";
  pie = pie + "<td height='40' colspan='5' align='center' bgcolor='#394D8C' class='piesinlink'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
  pie = pie + "  <tr>";
  pie = pie + "    <td width='185'>&nbsp;</td>";
  pie = pie + "    <td width='90' align='center'><b><a href='/ir/ir-sp.htm' class='piesinlink'>Inversionistas</a></b></td>";
  pie = pie + "    <td width='90' align='center'><a href='/pages/index_noticias_sp.htm' class='piesinlink'><b>Noticias</b></a></td>";
  pie = pie + "    <td width='120' align='center'><b><a href='/pages/sp_postulante.htm' class='piesinlink'>Trabaje con Nosotros</a></b></td>";
  pie = pie + "    <td width='100' align='center'><b><a href='/web/newcsav2.nsf/contactus?Openform' class='piesinlink'>Contáctenos</a></b></td>";
  pie = pie + "    <td width='185'>&nbsp;</td>";
  pie = pie + "  </tr>";
  pie = pie + "</table></td>";
  pie = pie + "</tr>";
  pie = pie + "<tr>";
  pie = pie + "<td height='1' colspan='5' bgcolor='#FFFFFF' class='piesinlink'><img src='/www/imagenes/spacer.gif' width='1' height='1'></td>";
  pie = pie + "</tr>";
  pie = pie + "<tr>";
  pie = pie + "<td height='20' bgcolor='#394D8C' class='piesinlink'>&nbsp;Copyright &copy; 2007, CSAV - <a href='/pages/sp_terms_conditions' class='pielink'>Términos y Condiciones de uso</a></td>";
  pie = pie + "<td height='20' align='center' bgcolor='#394D8C'><img src='/www/imagenes/home2006/separador_pie.gif' width='2' height='16'></td>";
  pie = pie + "<td width='40' height='20' align='center' bgcolor='#394D8C' class='pielink'><a href='/index_sp.htm'><img src='/www/imagenes/casita_home.gif' width='10' height='10' border='0'></a></td>";
  pie = pie + "<td height='20' align='center' bgcolor='#394D8C'><img src='/www/imagenes/home2006/separador_pie.gif' width='2' height='16'></td>";
  pie = pie + "<td align='center' bgcolor='#394D8C'><a href='/pages/sp_map' class='pielink'>Mapa Sitio</a></td>";
  pie = pie + "</tr>";
  pie = pie + "</table>";
return pie
}

function doNothing(){

}


function menu_ir(ruta, pag)
{
	//alert(pag);
	var HIR="investor1";
	var BOD="investor1";
	var BL="investor1";
	var AR="investor1";
	var QR="investor1";
	var AOMS="investor1";
	var MS="investor1";
	var OSI="investor1";
	var P="investor1";
	var CTTR="investor1";
	var SMM="investor1";
	var NP="investor1";
	var F="investor1";
	var Q="investor1";
	var NA="investor1";
	var TEMP="investor1";
	
	switch (pag) 
	{ 
		case "HIR":
			//alert(pag);
		   HIR="investor2";
		   break;
		case "BOD": 
		   BOD="investor2";
		   break;
		case "BL": 
		   BL="investor2";
		   break;
		case "AR": 
		   AR="investor2";
		   break;
		case "QR": 
		   QR="investor2";
		   break;
		case "AOMS": 
		   AOMS="investor2";
		   break;
		case "MS": 
		   MS="investor2";
		   break;
		case "OSI": 
		   OSI="investor2";
		   break;
		case "P": 
		   P="investor2";
		   break;
		case "CTTR": 
		   CTTR="investor2";
		   break;
		case "SMM": 
		   SMM="investor2";
		   break;
		case "NP": 
		   NP="investor2";
		   break;
		case "F": 
		   F="investor2";
		   break;
		case "Q": 
		   Q="investor2";
		   break;
		case "NA": 
		   NA="investor2";
		   break;
		case "TEMP": 
		   TEMP="investor2";
		   break;
	} 

	
	var menu =	  "	<table width='150' border='0' cellspacing='1' cellpadding='4'>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+HIR+"'><a href='/ir/ir-sp.htm' class='"+HIR+"'><b>Inversionistas</b></a></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+BOD+"'><a href='/ir/board-directors-sp.htm' class='"+BOD+"'><b>Directorio</b></a></td>";
	menu = menu + "      </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+BL+"'><a href='/ir/by-laws-sp.htm' class='"+BL+"'><b>Estatutos Sociales</b></a></td>";
	menu = menu + "      </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+AR+"'><a href='/ir/annual-reports-sp.htm' class='"+AR+"'><b>Memorias Anuales</b></a></td>";
	menu = menu + "      </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+QR+"'><a href='/ir/quarterly-summary-sp.htm' class='"+QR+"'><b>Resultados Trimestrales</b></a></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+AOMS+"'><a href='/ir/market-situation-sp.htm' class='"+AOMS+"'><b>Análisis de la Situación de Mercado</b></a></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+MS+"'><a href='/ir/monthly-statistics-sp.htm' class='"+MS+"'><b>Estadísticas Mensuales</b></a></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+OSI+"'><a href='/ir/stock-information-sp.htm' class='"+OSI+"'><b>Información Bursátil en línea</b></a></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+P+"'><b><a href='/ir/presentations-sp.htm' class='"+P+"'>Presentaciones</a></b></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+CTTR+"'><a href='/ir/communications-sp.htm' class='"+CTTR+"'>Comunicaciones</a></td>";
	menu = menu + "      </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+SMM+"'><a href='/ir/shareholders-sp.htm' class='"+SMM+"'>Accionistas</a></td>";
	menu = menu + "      </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+NP+"'><a href='/ir/news-press-sp.htm' class='"+NP+"'><b>Noticias / Prensa</b></a></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+F+"'><b><a href='/ir/faq-sp.htm' class='"+F+"'>FAQ</a></b></td>";
	menu = menu + "        </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+Q+"'><a href='/ir/questions-sp.htm' class='"+Q+"'><b>Preguntas</b></a></td>";
	menu = menu + "      </tr>";
	menu = menu + "      <tr>";
	menu = menu + "        <td height='32' class='"+NA+"'><a href='/ir/news-alerts-sp.htm' class='"+NA+"'><b>Noticias & Alertas</b></a></td>";
	menu = menu + "      </tr>";
//	menu = menu + "      <tr>";
//	menu = menu + "        <td height='32' class='"+TEMP+"'><a href='/ir/capital-increase-sp.htm' class='"+TEMP+"'><b>Aumento de Capital</b></a></td>";
//	menu = menu + "      </tr>";
	menu = menu + "    </table>";
	return menu
}
