var __URL_BASE = 'http://www.osasuna.es/dev/';
var __ajax_loader = '<span id="ajax_loader"><img src="images/ajax-loader.gif" />loading...</span>';

var __NO_FLASH = '';
// Inicializamos funciones
function init() {
	navHover();
}


//Activacion de los submenus en IE
navHover = function() {
	if (document.all&&document.getElementById) {
	var lis = document.getElementById("navmenu").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
	}
}



//Activacion de los submenus en IE
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}


__tamano_texto = 2;
function tamano_texto (suma)
{
	__tamano_texto += suma;
	if (__tamano_texto > 4) __tamano_texto = 4;
	if (__tamano_texto < 1) __tamano_texto = 1;
	var estilo = document.getElementById('css_tamanos');
	estilo.href = __URL_BASE + 'css/tamanos_' + __tamano_texto + '.css';
	createCookie ('text', __tamano_texto, 365);
	return;
}

function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return ""; 
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length; 
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

//cookies cabecera


// Popup
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


// galeria de fotos

var galeria_lienzo;

function galeria_cambia (id, contenedor)
{
	galeria_lienzo = contenedor;
	var anchura = $(galeria_lienzo).width;
	var altura = $(galeria_lienzo).height;
	$(galeria_lienzo).src = '';
	$('galeria_foto_cont').style.width = anchura;
	$('galeria_foto_cont').style.height = altura;
	//$(galeria_lienzo).style.padding = ((altura/2) - 6) + 'px ' + ((anchura/2) - 6) + 'px'
	var url = __URL_BASE + 'ajax/index.php';
	var pars = 'o=galeria_cambia&id=' + id;
	var myAjax = new Ajax.Request(
			url, 
			{
				method: 'get', 
				parameters: pars, 
				onFailure: reportError,
				onComplete: galeria_cambia_res
			});

}

function galeria_cambia_res (originalRequest)
{
	$(galeria_lienzo).src = originalRequest.responseText;
	//$(galeria_lienzo).style.padding = '0';
	//$('galeria_foto_cont').style.width = anchura;
	//$('galeria_foto_cont').style.height = altura;
}

function reportError (e)
{
	alert (e);
}
function go(box)
{
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

window.onload =  init;
