var mainurl = 'http://library.ie.edu/newsite/';
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function common(selectedmenu, selecteditem)
{
	banner();
	leftcontent(selectedmenu, selecteditem);
	rightcontent();
	bottomcontent();
	
	
	var leftheight =  document.getElementById("leftcontent").offsetHeight;
	var rightheight =  document.getElementById("rightcontent").offsetHeight;
	var centralheight =  document.getElementById("centercontent").offsetHeight;
	
	var contentheight = Math.max(leftheight,rightheight);
	contentheight = Math.max(contentheight, centralheight) + 10;
	document.getElementById("content").style.height = contentheight + "px";
	
	footer();
	document.getElementById("footer").style.display = "block"; 
}

function banner()
{
	html_load("banner", BANNER);
}

function footer()
{
	html = '<br>'+FOOTER;
	html_load("footer", html);
}

function bottomcontent()
{
	html = 	'<table width="100%"><tr><td width="5"></td>';
	html += '<td align="left"><a href="javascript:history.go(-1);"><img src="' + mainurl + 'css/images/flecha-izq.gif"></a></td>';
	html += '<td align="right"><a href="javascript:history.go(1);"><img src="' + mainurl + 'css/images/flecha-dcha.gif"></a></td>';
	html += '<td width="5"></td></tr></table>';
	html += '<h3>'+MEMBERSOF+'</h3>';
    html += '<table width="100%" cellpadding="3"><tr>';
    html += '<td width="25%" align="left"><a href="http://www.crue.org/" target="_BLANK"><img src="' + mainurl + 'images/logocrue.gif" alt="crue" width="60" /></a></td>';
	html += '<td width="25%" align="center"><a href="http://www.rebiun.org/" target="_BLANK"><img src="' + mainurl + 'images/logorebiun.jpg" alt="rebiun" width="60" /></a></td>';  
    html += '<td width="25%" align="center"><a href="http://www.ifla.org/" target="_BLANK"><img src="' + mainurl + 'images/logoifla2.gif" alt="ifla" width="40" /></a></td>';
	html += '<td width="25%" align="right"><a href="http://www.ssrn.com/" target="_BLANK"><img src="' + mainurl + 'images/ssrn_logo_2.jpg" alt="Social Science Research Network" /></a></td>';
    html += '</tr></table>';
	html += '<h3>'+CONTRIBUTORS+'</h3>';
	html += '<table width="100%" cellpadding="3"><tr>';
	html += '<td width="33%" align="left"><a href="http://www.fecyt.es" target="_BLANK"><img src="' + mainurl + 'images/logo_fecyt_mci1.jpg" alt="FECYT. Fundación Española para la Ciencia y la Tecnología. Gobierno de España, Ministerio de ciencia e innovación" width=76 height=52 /></a></td>';
    html += '<td width="33%" align="center"><a href="http://onelog.ie.edu/connection/index.php?id=701&type=0&url=" target="_BLANK"><img src="' + mainurl + 'images/logo-wok(2).jpg" alt="WOK. Web of Knowledge" /></a></td>';
    html += '<td width="33%" align="right"><a href="http://www.westlaw.es" target="_BLANK"><img src="' + mainurl + 'images/westlaw_2.gif" alt="Westlaw" /></a></td>';
    html += '</tr><tr>';    
    html += '<td width="33%" align="left"><a href="http://www.alimarket.es" target="_BLANK"><img src="' + mainurl + 'images/logo_alimarket_4.jpg" alt="Alimarket"></a></td>';
    html += '<td width="33%" align="center"><a href="http://www.docuteria.es" target="_BLANK"><img src="' + mainurl + 'images/docuteria_logo.jpg" alt="Docuteria"></a></td>'; 
    html += '<td width="33%" align="right"><a href="http://repec.org/" target="_BLANK"><img src="' + mainurl + 'images/repec_3.gif" alt="RePEc"></a></td>';
    html += '</tr></table>';
	html_load("bottomcontent", html);
}

function leftcontent(selectedmenu, selecteditem)
{
	/*Menu vertical superior*/
	html = '<div class="leftmenu"><ul>';
	for (menu=0; menu<left_menu.length; menu++) {
		if (menu == 0) html += '<li class="leftmenu_full">';
		else if (selectedmenu == menu) html += '<li class="leftmenu_open">';
		else html += '<li class="leftmenu_close">';
		html += left_menu[menu].title;
		html += '</li>';
		if (selectedmenu == menu) {
			for (submenu=0; submenu<left_menu[menu].links.length; submenu++) {
				if (submenu == selecteditem) html += '<li class="leftmenu_selected">';
				else if (submenu == (left_menu[menu].links.length - 1)) html += '<li class="leftmenu_lastitem">';
				else html += '<li class="leftmenu_item">';
				html += left_menu[menu].links[submenu];
				html += '</li>';
			}
		}
	}
	html += '</ul></div>';
	
	/*Bloques*/
	for (block=0; block<left_blocks.length; block++) {
		html += html_block(left_blocks[block].title, left_blocks[block].links);
	}
	html_load("leftcontent", html);
}

function rightcontent()
{
	/*Menu horizontal superior*/
	html = '<div class="rightmenu"><ul>';
	for (menu=0; menu<right_topmenu.length; menu++) {
		html += '<li>'+right_topmenu[menu]+'</li>';
	}
	html += '</ul></div>';
	
	/*Bloques*/
	for (block=0; block<right_blocks.length; block++) {
		html += html_block(right_blocks[block].title, right_blocks[block].links);
	}
	
	/*Menu horizontal inferior*/
	html += '<div class="rightmenu"><ul>';
	for (menu=0; menu<right_bottommenu.length; menu++) {
		html += '<li>'+right_bottommenu[menu]+'</li>';
	}
	html += '</ul></div>';
	html_load("rightcontent", html);
}

function html_load(div, html)
{
	document.getElementById(div).innerHTML = html;
}

function html_block(title, links)
{
	html  = '<div class="block">';
	html += '<div class="block_ini"></div>';
	html += '<div class="block_content">';
	html += '<h3>'+title+'</h3>';
	html += '<ul>';
	for (link=0; link<links.length; link++) html += '<li>'+links[link]+'</li>';
	html += '</ul>';
	html += '</div>';
	html += '<div class="block_end"></div>';
	html += '</div>';
	return html;
}
