﻿/* turn off error reporting */
window.onerror = new Function("return true;");

/* constants */
var isOpera = (window.navigator.userAgent.indexOf("Opera") > -1);
var isGecko = (navigator.product == "Gecko");
var isIe = (window.navigator.userAgent.indexOf("MSIE") > -1);

/* Pone estilos apropiados si la resolución de la pantalla es grande  */
stylewidth();

function stylewidth()
{
	var theWidth = screen.width;
	var theHeight = screen.height;
	if (theWidth > 1024 && theHeight >= 800)
	{
	var linea = "<style>";
	linea += "#Texto1 {top:670px;width:932px;}"
	linea += "#Foto {height:622px;width:932px;}"
	linea += "#Foto:not(.foto2) {height:620px;width:930px;}"
	linea += "#MenuFotos1 {height:636px;}"
	linea += "#Cabecera1 {width:1060px;}"
	linea += "#MenuPr1 {top:710px;width:932px;}"
	linea += "#Logo {left:1090px;}"
	linea += "#Flash {width:1060px;height:556px;}"
	linea += ".fotograf {height:617px;}"
	linea += ".fotograf:not(.foto2) {height:618px;}"
	linea += ".fotograf2 {width:350px;}"
	linea += "</style>"
	
	document.write(linea);
	}
};

//Hace un fade-in de las imágenes
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 
//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 101);
    object.MozOpacity = (opacity / 101);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function seccion(url) {
//	document.getElementById('Foto').innerHTML = "<iframe src='" + url + "'></iframe>";
	var responseHTML = document.createElement("body");
}

//Muestra el flash en diferentes tamaños
function showFlash()
{
	var theWidth = screen.width;
	var theHeight = screen.height;
	document.write('<object	classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ')
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ')
	if (theWidth > 1024 && theHeight >= 800) { document.write('width="1060" height="556"  ALIGN="absmiddle">') }
	else { document.write('width="795" height="417"  ALIGN="absmiddle">') }
	document.write('<param name="movie" value="flash/Anuario2011.swf"> ')
	document.write('<param name="quality" value="high"> ')
	document.write('<param name="wmode" value="transparent"> ')
	document.write('<param name="scale" value="noborder"> ')
	document.write('<embed src="flash/Anuario2011.swf" quality="high" ')
	document.write('scale="noborder" align="absmiddle" wmode="transparent" ')
	if (theWidth > 1024 && theHeight >= 800) { document.write('width="1060" height="556" ') }
	else { document.write('width="795" height="417" ') }
	document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" ')
	document.write('type="application/x-shockwave-flash"> ')
	document.write('</embed> ')
	document.write('</object> ')
}

//Muestra la foto en grande al pulsar en el menú de la izquierda
function muestraF(num){
	var fotogr = new Image();
	changeOpac(0, 'fotogr');
	document.fotogr.src = "img_big/" + fotos[num];
	document.all.Texto2.innerHTML = "<span class=pais>" + paises[num] + "</span> " + texto[num];
	var myEnl = "JavaScript:openWjs('img_big/" + fotos[num] + "')"
    if (document.getElementById) {
	  document.getElementById("enlace").href = myEnl;
	  document.getElementById("enlace").title = texto[num];
    }
    else if (document.all) {
	  document.all["enlace"].href = myEnl;
	  document.links["enlace"].title = texto[num];
    }

	opacity('fotogr', 0, 100, 2000);
	return;
}

//Pone una foto aleatoria
function fotoAleat(){
	var randNum;
	var total = fotos.length-1;
	randNum = Math.random()*total;
	randNum = Math.round(randNum);
	var linea1 = '<a title="' + texto[randNum] + '" href="' + "JavaScript:openWjs('img_big/" + fotos[randNum] + "')" + '" />'
	var linea2 = '<img class="fotograf" src="img_big/' + fotos[randNum] + '"></a>'
	document.write(linea1 + linea2);
}

