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();
	navHoverEsp();
}


//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
navHoverEsp = function() {
	if (document.all&&document.getElementById) {
	var lisesp = document.getElementById("navmenuespecial").getElementsByTagName("LI");
	for (var j=0; j<lisesp.length; j++) {
		lisesp[j].onmouseover=function() {
			this.className+=" iehover";
		}
		lisesp[j].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;

/*
var OpenAjaxUI = Class.create (UI.Options, {
	
	options: {
											theme:  "alphacube", 
	                   	shadow: true, 
	                   	width:  760,
	                   	height: 550,
											top: null,
											left: null,
										 	maximize: false,
										 	minimize: false,
										 	resizable: true
	},
  initialize: 		function (el, options) {
                    this.el = el;
										if (options) this.setOptions(options);
										this.url = this.el.href;
										this.options.id = this.el.id;
											
										if (!$(this.options.id)) { // si la ventana no existe abrimos una
											this.createWindow(true);
										} else {
											$(this.options.id).focus ();
										}
  },
	createWindow: 	function (center) {
										this.win = new UI.Window(this.options).setAjaxContent(this.url).show();
										if (center) this.win.center ();
										this.win.focus ();								
	},
	setWinOptions: 	function () { // Conserva los parametros de la ventana
										this.win_bounds = this.win.getBounds ();
										this.options.left = this.win_bounds.left;
										this.options.top = this.win_bounds.top;
										this.options.width = this.win_bounds.width;
										this.options.height = this.win_bounds.height;
 	}
});*/