// JavaScript Document


/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

// Cantidad de Menus
var numeroMenus=3

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["contenidoIF"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers


function handleError(errorMessage, url, line) {
    //alert("JavaScript Error\n"+errorMessage+"\n"+url+"\n"+line);
	return true;
}

window.onerror = handleError;

function resizeCaller() 
{
	var dyniframe=new Array();
	for (i=0; i<iframeids.length; i++)
	{
		if (document.getElementById)
		{
				resizeIframe(iframeids[i]);
		}
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no")
		{
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
		}
	}
}

function resizeIframe(frameid)
{
	var currentfr=document.getElementById(frameid)
	//alert("DEBUG: currentfr="+currentfr.name);
		if (currentfr && !window.opera)
		{
			currentfr.style.display="block"
			if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
				currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
			else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
				currentfr.height = currentfr.Document.body.scrollHeight;
			if (currentfr.addEventListener)
				currentfr.addEventListener("load", readjustIframe, false)
			else if (currentfr.attachEvent)
			{
				currentfr.detachEvent("onload", readjustIframe) // Bug fix line
				currentfr.attachEvent("onload", readjustIframe)
			}
		}
}

function readjustIframe(loadevt) 
{
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
	if (iframeroot){
		//alert("DEBUG: iframeroot.id="+iframeroot.id);
		resizeIframe(iframeroot.id);
		}
}

function loadintoIframe(iframeid, url)
{
	try
	{
		if (document.getElementById)
		document.getElementById(iframeid).src=url
	}
	catch (e)
	{
		alert(e);
	}
}

try{
	if (window.addEventListener)
	{
		window.addEventListener("load", resizeCaller, false)
		
	}
	else if (window.attachEvent)
	{	
		window.attachEvent("onload", resizeCaller)
	}
	else
	{	
		window.onload=resizeCaller
	}
}
catch (e)
	{alert(e);}


/* Funciones para cambira los menus laterales */
/* En el innerHTML hay que cambiar las comillas por escapes*/
function cambiarMenu(menu){
	if (menu=="1"){
		document.getElementById("menuLateral").innerHTML="<ul><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/NEWS/indexNova.htm');\">Magazine</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF', 'http://www.vincon.com/web/es/html/NEWS/suscripcion.htm');\">Suscripci&oacute;n</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/NEWS/agendabarcelona.htm');\">Agenda Barcelona</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/NEWS/agendamadrid.htm');\">Agenda Madrid</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/la_sala_vincon.htm');cambiarMenu(11);\">Agenda La Sala</a></li></ul>";
		//En este ultimo se vuelve a cambiar el menu.
		//Lo he llamado 11 por ser hijo del menu 1
	}
	if(menu=="11"){
		document.getElementById("menuLateral").innerHTML="<ul><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/la_sala_vincon.htm');\">Exposici&oacute;n Actual</a></li><li>&nbsp;</li><li class='titulo'><p>HIST&Oacute;RICO</p></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/historico.htm');\" >Exposici&oacute;n 2006</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/expo_sala_001_050.htm');\">Expo 001-050</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/expo_sala_051_100.htm');\" >Expo 051-100</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/expo_sala_101_150.htm');\" >Expo 101-150</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/expo_sala_151_200.htm');\" >Expo 151-200</a></li><li><a href=\"javascript:loadintoIframe('contenidoIF','http://www.vincon.com/web/es/html/SALA/expo_sala_201_250.htm');\" >Expo 201-250</a></li></ul>";
	}
}

/* Selecciona un menu (de 1 a 'numeroMenus') y lo muestra. Oculta el resto*/
/* Los ID de los menus deben ser menu0.. MenuN */
function eligeMenu(nmenu)
{
try
{
	for (i=0; i<numeroMenus; i++)
	{
		idMenu = "menu"+i;
		if(nmenu==i){
			res=document.getElementById(idMenu).style.left='0px';
			}
		else{
			res=document.getElementById(idMenu).style.left='-9000px';
			}
	}
}
catch(e){alert(e);}
}


/* CSS SelectorBrowser */

var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
		aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 

/*Open PopUp*/
function MM_openBrWindow(theURL,winName,features) {
	var nombreVariable = "Adwords";
	if ( getURLParam(nombreVariable) != "yes" )
	{
		window.open(theURL,winName,features);
	}
}










