var year = 2012;

function mostrarMenuCabecera(lenguaje)
{
    var indice;
    var noticias, contacto, artistas, carro;
    var pagina = self.location.href.match( /\/([^/]+)$/ )[1];
   
    if (lenguaje == "es"){
    	noticias = "Noticias";
    	contacto = "Contacto";
    	artistas = "Artistas"
    	carro = "Ver carro"
    	indice ="../web/";
    }
    else{
    	noticias = "News";
    	contacto = "Contact";
    	artistas = "Artists";
    	carro = "View cart"
    	indice ="../../web/";
    }
   
    document.write('<table width=\"990\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">')
    document.write('<tr><td width=\"990\" height=\"63\" background=\"' + indice + 'imagenes/encabezado_' + estacion() + '.gif\">')
    document.write('<table width=\"990\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">')
    document.write('<tr>')
    document.write('<td width=\"20\">&nbsp;</td>')
    document.write('<td width=\"50\"><div align=\"center\"><img src=\"' + indice + 'imagenes/logo_barco.gif\" width=\"42\" height=\"41\" /></div></td>')
    document.write('<td width=\"220\"><div align=\"center\"><img src=\"' + indice + 'imagenes/logo_texto.gif\" width=\"193\" height=\"36\" /></div></td>')
    document.write('<td width=\"120\">&nbsp;</td>')
    document.write('<td>')
    document.write('<table cellspacing=\"0\" cellpadding=\"0\" id=\"DB_menu\" class=\"ddm1\">')
    document.write('<tr>')
    document.write('<td width=\"80\">')
    document.write('<a class=\"item1\" target=\"_parent\" href=\"../web\">' + noticias + '</a></td><td width=\"80\">')
    document.write('<a class=\"item1\" href=\"javascript:void(0)\">' + artistas + '</a>')
    document.write('<div class=\"section\">')
    document.write('<a class=\"item2\" target=\"_parent\" href=\"../clyde">Clyde</a>')
    document.write('<a class=\"item2\" target=\"_parent\" href=\"../8mn">Eightman</a>')
    document.write('<a class=\"item2\" target=\"_parent\" href=\"../h2v">Hacia Dos Veranos</a>')
    document.write('</div>')
    document.write('</td>')    
    document.write('<td width=\"80\"><a class=\"item1\" target=\"_parent\" href=\"../DBShop">DBShop</a></td>')
    document.write('<td width=\"80\"><a class=\"item1\" href=\"../web/DB_contacto.html\">' + contacto + '</a></td>')

		/*
    if (pagina == "DB_noticias.html" || pagina == "DB_contacto.html" ){   	
    	document.write('<td width=\"230\" bordercolor=\"0\"><div align=\"center\"><a href=\"http://www.myspace.com/discosdelabahia\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage(\'MS_DB\',\'\',\'' + indice + 'imagenes/iconos/myspace_DB_on.gif\',1)\"><img src=\"' + indice + 'imagenes/iconos/myspace_DB.gif\" alt=\"Discos de la Bahia @ MySpace\" name=\"MS_DB\" width=\"77\" height=\"19\" border=\"0\" id=\"MS_DB\" /></a></div></td>')
	  }
	  else if (pagina == "DB_shop.html" || pagina == "DB_shop_digital.html" || pagina == "DB_shop_MP.html" || pagina == "DB_shop_PP.html"){   	
    	document.write('<td width=\"230\" class=\"item1\"><form target=\"paypal\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"><div align=\"center\"><input type=\"hidden\" name=\"cmd\" value=\"_cart\"><input type=\"hidden\" name=\"business\" value=\"dbshop@discosdelabahia.com\"><input type=\"image\" src=\"' + indice + 'imagenes/iconos/shopping_cart2.gif\" border=\"0\" name=\"submit\" alt=\"' + carro + '\">&nbsp;&nbsp;' + carro + '<input type=\"hidden\" name=\"display\" value=\"1\"><input type=\"hidden\" name=\"page_style\" value=\"DB_shop\"></div></form></td>')
		}
		else{ 
		*/
    	document.write('<td width=\"182\">&nbsp;</td>')		
		// }
		
    document.write('</tr>')
    document.write('</table>')
    document.write('</td>')    
    document.write('</tr>')
    document.write('</table>')
    document.write('</td>')
    document.write('</tr>')
    document.write('</table>')    
    document.write('<script type=\"text/javascript\">var ddm1 = new DropDownMenu1(\'DB_menu\');ddm1.position.top = -1;ddm1.init();</script>')
}

function mostrarMenuPie(lenguaje)
{
    var indice;
    var noticias, contacto, artistas;
   
    if (lenguaje == "es"){
    	noticias = "Noticias";
    	contacto = "Contacto";
    	artistas = "Artistas"
    	indice ="../web/";    	
    }
    else{
    	noticias = "News";
    	contacto = "Contact";
    	artistas = "Artists";
    	indice ="../../web/";
    }

    document.write('<table width=\"990\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">')
    document.write('<tr>')
    document.write('<td height=\"63\" valign=\"middle\" background=\"' + indice + '../web/imagenes/pie_' + estacion() + '.gif\">')
    document.write('<div align=\"center\" class=\"Estilo72\"><span class=\"Estilo22\">')
    document.write('<a class=\"item1\" href=\"../web/\">' + noticias + '</a> | ')  
    document.write('<a class=\"item1\" target=\"_parent\" href=\"../DBShop/\">DBShop</a> | ')
    document.write('<a class=\"item1\" href=\"../web/DB_contacto.html\">' + contacto + '</a>')
    document.write('<br/>Discos de la Bah&iacute;a &copy; ' + year + '<br/>')
    document.write('</span></div>')
    document.write('</td>')
    document.write('</tr>')
    document.write('</table>')    
}

function mostrarPie(lenguaje){
    document.write('<div align=\"center\" class=\"pies\">Discos de la Bah&iacute;a &copy; ' + year + '</div>')
}

function mostrarIdioma(diccionario, lenguaje){

    var destino = "";
    var encontrada = false;
    var pagina = self.location.href.match( /\/([^/]+)$/ )[1];
    var indice;
    var idioma;
    var bandera_nombre;
    var bandera_gif;
    
    var ahora = new Date();
    var dias;
    var meses;

    if (lenguaje == "es"){
        idioma="Español";
        bandera_nombre="spa_flag";
        bandera_gif="spain_flag";
        indice ="../../web/";
        dias = new Array("Sunday", "Monday", "Tuesday","Wednesday","Thursday","Friday","Saturday");
        meses = new Array("January", "February", "March", "April", "May", "June",     "July", "August", "September", "October", "November", "December");
        sep =" of "
    }
    else{
        idioma="English";
        bandera_nombre="eng_flag";
        bandera_gif="english_flag";
        indice ="../web/";        
        dias = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sabado");
        meses = new Array("enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre");
        sep = " de "
    }            

    // La buscamos en el diccionario para saber el destino que le corresponde
    var i=0;
    while (i<diccionario.length && destino ==""){ 
        if (diccionario[i][0] == pagina){
        	destino = diccionario[i][1];
        	encontrada = true;
        }
        i++;
    } 

    document.write('<table width=\"990\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">')
    document.write('<tr>')
    document.write('<td>&nbsp;</td>')
    
	// *** Mostrar icono estación ****
    document.write('<td width=\"20\" height=\"30\" valign=\"middle\">')
    document.write('<div align=\"left\">')
    document.write('<img src=\"' + indice + 'imagenes/iconos/' + estacion() + '.gif\" alt=\"' + estacion() + '\" />');
    document.write('</div>')
    document.write('</td>')
	
	// *** Mostrar fecha y hora ****
    document.write('<td width=\"870\" valign=\"middle\" class=\"Estilo114\">')
    document.write('<div align=\"left\" class=\"Estilo130\">')
    document.write(dias[ahora.getDay()]  + ', ' + ahora.getDate() + sep + meses[ahora.getMonth()] + sep + ahora.getFullYear() + ' - ' + ahora.getHours() + ':' + ahora.getMinutes() + ' h');
    document.write('</div>')
    document.write('</td>')
    document.write('<td width=\"30\" valign=\"middle\">')
    document.write('<div align=\"center\">')
	
	// *** Mostrar icono de idioma ****
	if (encontrada){
        document.write('<a href=\"' + destino +'\"')
        document.write('onmouseout=\"MM_swapImgRestore()\"')
        document.write('onmouseover=\"MM_swapImage(\'' + bandera_nombre + '\',\'\',\'' + indice + 'imagenes/' + bandera_gif + '.gif\',0)\">')
        document.write('<img src=\"' + indice + 'imagenes/' + bandera_gif + '_off.gif\" alt=\"' + idioma + '\" name=\"')
        document.write(bandera_nombre + '\" width=\"18\" height=\"12\" border=\"0\" id=\"' + bandera_nombre + '\" />')
        document.write('</a>')
	}
    
	document.write('</div>')
    document.write('</td>')
    document.write('<td width=\"50\" valign=\"middle\" class=\"Estilo114\">')
    document.write('<div align=\"left\" class=\"Estilo130\">')
	
	if (encontrada){
        document.write(idioma)
	}
    
	document.write('</div>')
    document.write('</td>')
	document.write('</tr>')
	document.write('</table>')
}

function mostrarCabeceraAviso(lenguaje){

    var indice;
    
    if (lenguaje == "en"){
        indice ="../../web/";
    }
    else{
        indice ="../web/";        
    }     
    
    document.write('<table width=\"990\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">')
    document.write('<tr>')
    document.write('<td width=\"990\" height=\"63\" background=\"' + indice + 'imagenes/encabezado_' + estacion() + '.gif\">')
    document.write('<table width=\"280\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">')
    document.write('<tr>')
    document.write('<td width=\"50\"><div align=\"center\"><a href=\"../\" target=\"_parent\"><img src=\"' + indice + 'imagenes/logo_barco.gif\" width=\"42\" height=\"41\" border=\"0\" /></a></div></td>')
    document.write('<td width=\"220\"><div align=\"center\"><a href=\"../\" target=\"_parent\"><img src=\"' + indice + 'imagenes/logo_texto.gif\" width=\"193\" height=\"36\" border=\"0\" /></a></div></td>')
    document.write('</tr>')
    document.write('</table>')
    document.write('</td>')
    document.write('</tr>')
    document.write('</table>')
}

function mostrarPieAviso(lenguaje){
    var indice;
    
    if (lenguaje == "en"){
        indice ="../../web/";
    }
    else{
        indice ="../web/";        
    }
    document.write('<table width=\"990\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">')
    document.write('<tr>')
    document.write('<td height=\"63\" valign=\"middle\" background=\"' + indice + '../web/imagenes/pie_' + estacion() + '.gif\"><div align=\"center\" class=\"Estilo72\"> <span class=\"Estilo22\">Discos de la Bah&iacute;a &copy; ' + year + '</span></div></td>')
    document.write('</tr>')
    document.write('</table>')
}

// ***** Obtener la estación del año *********
function enRango(dHoy, mHoy, dIni, mIni, dFin, mFin){ 
    bRes = true; 
    bRes = bRes && ((mHoy > mIni) || ((mHoy == mIni) && (dHoy >= dIni))); 
    bRes = bRes && ((mHoy < mFin) || ((mHoy == mFin) && (dHoy <= dFin))); 
    return bRes; 
} 

function estacion(){ 
   	var ahora = new Date();
   	var dia=ahora.getDate();
   	var mes=ahora.getMonth()+1;
		
	if (enRango(dia, mes, 21, 3, 20, 6)) sRes = "primavera"; else 
    if (enRango(dia, mes, 21, 6, 20, 9)) sRes = "verano";    else 
    if (enRango(dia, mes, 21, 9, 20, 12)) sRes = "otono";    else 
    sRes = "invierno"; 
    return sRes; 
}
// ***********************************************

function obtenerFondoEncabezado(path, tipo){
	
	document.write('<td height=\"30\" background=\"' + path + 'imagenes/subencabezado' + tipo + '_' + estacion() + '.gif\">');
}

function finFondoEncabezado(){
	document.write('</td>')	
}

function mostrarConciertos(lenguaje)
{

  browser_type= browserDetection();
  
	if (browser_type != "Netscape" && browser_type != "Microsoft Internet Explorer" && browser_type != "Firefox") 	{
		mostrarConciertosOtrosNavegadores(lenguaje, browser_type);
	}
	else {
	
		var mozilla = (typeof document.implementation != 'undefined') && 
				  				(typeof document.implementation.createDocument != 'undefined');
		var ie = (typeof window.ActiveXObject != 'undefined');
    var browserName=navigator.appName; 
  	var numeroConciertos = 0;
	
  	if (lenguaje == "es"){
    	fichero_conciertos = "./anuncios/conciertos.xml";
    	sin_conciertos = "No hay conciertos por el momento...";
    }
    else{
    	fichero_conciertos = "../../web/anuncios/conciertos.xml";
    	sin_conciertos = "No venues for the moment...";
    }
    
  	if (browserName=="Netscape" || browserName=="Firefox") {
    	xmldoc = document.implementation.createDocument("", "", null)
    	xmldoc.async = false;
    	xmldoc.load(fichero_conciertos);
  	} 
  	else if (browserName=="Microsoft Internet Explorer") {
  		var xmldoc=new ActiveXObject("MSXML2.DOMDocument.3.0");
  		xmldoc.async = false;
  		xmldoc.load(fichero_conciertos);
  	} 
 	  
		var grupos = xmldoc.getElementsByTagName('grupo');
	
  	for (g=0;g<grupos.length;g++)	{
  
  		var conciertos=grupos[g].getElementsByTagName("concierto");	
		
			if (conciertos.length > 0){
				
				var listadoConciertos = "";  
		
				for (c=0;c<conciertos.length;c++)	{
    			fecha = conciertos[c].getElementsByTagName("fecha")[0].firstChild.data;
    			ciudad = conciertos[c].getElementsByTagName("ciudad")[0].firstChild.data;
    			lugar = conciertos[c].getElementsByTagName("lugar")[0].firstChild.data;
    			listadoConciertos += "<tr><td><div align=\"justify\" class=\"Estilo60\">&nbsp;&nbsp;&nbsp;" + fecha+", <b>" + ciudad + "</b> - " +  lugar + "</div></td></tr><tr>";
    			numeroConciertos+=1;
				}
			
				grupo= "<tr><td height=\"35\"><font class=\"Estilo75\">&nbsp;" 
								+ grupos[g].getAttribute("nombre") + "</font></td></tr>";
  							document.write(grupo + listadoConciertos + "</span><tr><td>&nbsp;</td></tr>");
				listadoConciertos="";
			}
  	}  
 	
 
 		if (numeroConciertos==0){
			document.write("<span class=\"Estilo4\"><font color=\"#999999\">" + sin_conciertos + "</font></span><br/>");
 		}
 	}
}

function mostrarConciertosOtrosNavegadores(lenguaje, browser_type)
{
	if (lenguaje == "es"){
  	sin_conciertos = "Anuncio de conciertos deshabilitado para " + browser_type + " ...";
  }
  else{
   	sin_conciertos = "Concerts info unavailable for " + browser_type + " ...";
  }
  
	document.write("<span class=\"Estilo4\"><font color=\"#999999\">" + sin_conciertos  + "</font></span><br/>");
	
		
}

function ObtenerListaDeDiscos(anuncios){
	
	// LEE DISCOS DE XML

	var mozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined');
	var ie = (typeof window.ActiveXObject != 'undefined');
  
  if (mozilla) {
    xmldoc = document.implementation.createDocument("", "", null)
    xmldoc.async = false;
    xmldoc.load("anuncios/discos.xml");
  } 
  else if (ie) {
  
  	var xmldoc=new ActiveXObject("MSXML2.DOMDocument.3.0");
  	xmldoc.async = false;
  	xmldoc.load("anuncios/discos.xml");
 	}
 	
	var discos = xmldoc.getElementsByTagName('disco');
  for (d=0;d<discos.length;d++)	{
  
 		artista=   discos[d].getAttribute("artista");
		titulo= discos[d].getAttribute("titulo");
		portada = discos[d].getElementsByTagName("portada")[0].firstChild.data;
    texto = discos[d].getElementsByTagName("texto")[0].firstChild.data;
    enlace = discos[d].getElementsByTagName("enlace")[0].firstChild.data;
		
		tabla_disco="<h3><a style=\"color:#243254;\" href=\"" + enlace + "\">" + "<i>" + artista + "</i>, " + titulo + "</a>" + "</h3>" + 
							  "<div align=\"justify\"><span class=\"Estilo4\">" + texto + 
							  "</span></div><br/><br/><div align=\"center\">" + 
								"<a href=\"" + enlace + "\"><img src=\"" + portada + "\" alt=\"" + titulo + "\" width=\"210\" height=\"225\" border=\"0\"/></a></div>"
		
		
  	anuncios[d] = tabla_disco;
  }
}

function mostrarCorreo(usuario, lenguaje){

    var dominio="discosdelabahia.com" 
    var conector="@" 
    var descripcion;
    var mensaje;
    
    if (lenguaje == "en"){
        mensaje ="contact address";
    }
    else{
        mensaje ="dirección de contacto";        
    }
    

    document.write('<a style=\"color:#000000;\" class=\"Estilo78\" href=\"mailto:' + usuario + conector + dominio + '\">');
    
    if (usuario == "contacto"){
        usuario = "General";
    }
	else if (usuario == "contratacion"){
		usuario = "Management";
	}
    
    document.write('<div align=\"center\" class=\"Estilo114\">' + usuario.toUpperCase() + ': ' + mensaje + '</div></a>');

} 

function browserDetection(){

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var fullVersion  = ''+parseFloat(navigator.appVersion); 
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;

// In Opera, the true version is after "Opera" or after "Version"
if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
 browserName = "Opera";
 fullVersion = nAgt.substring(verOffset+6);
 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
   fullVersion = nAgt.substring(verOffset+8);
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "Microsoft Internet Explorer";
 fullVersion = nAgt.substring(verOffset+5);
}
// In Chrome, the true version is after "Chrome" 
else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
 browserName = "Chrome";
 fullVersion = nAgt.substring(verOffset+7);
}
// In Safari, the true version is after "Safari" or after "Version" 
else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
 browserName = "Safari";
 fullVersion = nAgt.substring(verOffset+7);
 if ((verOffset=nAgt.indexOf("Version"))!=-1) 
   fullVersion = nAgt.substring(verOffset+8);
}
// In Firefox, the true version is after "Firefox" 
else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
 browserName = "Firefox";
 fullVersion = nAgt.substring(verOffset+8);
}
// In most other browsers, "name/version" is at the end of userAgent 
else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) 
{
 browserName = nAgt.substring(nameOffset,verOffset);
 fullVersion = nAgt.substring(verOffset+1);
 if (browserName.toLowerCase()==browserName.toUpperCase()) {
  browserName = navigator.appName;
 }
}
// trim the fullVersion string at semicolon/space if present
if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);

majorVersion = parseInt(''+fullVersion,10);
if (isNaN(majorVersion)) {
 fullVersion  = ''+parseFloat(navigator.appVersion); 
 majorVersion = parseInt(navigator.appVersion,10);
}

/*
document.write('Browser name  = '+browserName+'<br>');
document.write('Full version  = '+fullVersion+'<br>');
document.write('Major version = '+majorVersion+'<br>');
document.write('navigator.appName = '+navigator.appName+'<br>');
document.write('navigator.userAgent = '+navigator.userAgent+'<br>');
*/

return browserName;
}

