//script para seleccionar lenguaje
function getCookie(NameOfCookie){
// esta la cookie almacenada?
	if (document.cookie.length > 0) { 
		// Second we check to see if the cookie's name is stored in the
		// "document.cookie" object for the page.

		// Since more than one cookie can be set on a
		// single page it is possible that our cookie
		// is not present, even though the "document.cookie" object
		// is not just an empty text.
		// If our cookie name is not present the value -1 is stored
		// in the variable called "begin".

		begin = document.cookie.indexOf(NameOfCookie+"="); 
		if (begin != -1) // Note: != means "is not equal to"
		{ 

			// Our cookie was set. 
			// The value stored in the cookie is returned from the function.

			begin += NameOfCookie.length+1; 
			end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end)); 
		} 
	}
	return null; 
	// Our cookie was not set. 
	// The value "null" is returned from the function.
}

function setCookie(NameOfCookie, value, expiredays) 
{

// Three variables are used to set the new cookie. 
// The name of the cookie, the value to be stored,
// and finally the number of days until the cookie expires.
// The first lines in the function convert 
// the number of days to a valid date.

var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

// The next line stores the cookie, simply by assigning 
// the values to the "document.cookie" object.
// Note the date is converted to Greenwich Mean time using
// the "toGMTstring()" function.

document.cookie = NameOfCookie + "=" + escape(value) + 
((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function idioma() {
		//lenguaje=getCookie('lenguaje');
		//if (lenguaje!=null) {
		//	setActiveStyleSheet(lenguaje);
		//	return;
		//};
		if (navigator.userAgent.indexOf("Opera")!=-1) (language=navigator.language)
		else { if (navigator.appName == "Netscape") (language=navigator.language) 
		else language=navigator.browserLanguage };
		if(language){language=language.substring(0,2);}
		else {language="zz";}
		switch (language) {
			case "es" : lenguaje='espanol'; break;
			case "en" : lenguaje='ingles';break;
			case "de" : lenguaje='aleman';break;
			case "pt" : lenguaje='portugues'; break;
			case "it" : lenguaje='italiano';break;
			case "fr" : lenguaje='frances';break;
			default : lenguaje='ingles'
		} 
		setActiveStyleSheet(lenguaje);
		//setCookie('lenguaje',lenguaje,360);
		return;
}

function idioma_principal() {
		if (navigator.userAgent.indexOf("Opera")!=-1) (language=navigator.language)
		else { if (navigator.appName == "Netscape") (language=navigator.language) 
		else language=navigator.browserLanguage };
		if(language){language=language.substring(0,2);}
		else {language="zz";}
		switch (language) {
			case "es" : document.location.href='http://www.alberguelua.com/index_es.html'; break;
			case "en" : document.location.href='http://www.alberguelua.com/index_in.html'; break;
			case "de" : document.location.href='http://www.alberguelua.com/index_al.html'; break;
			case "pt" : document.location.href='http://www.alberguelua.com/index_po.html';break;
			case "it" : document.location.href='http://www.alberguelua.com/index_it.html';break;
			case "fr" : document.location.href='http://www.alberguelua.com/index_fr.html';break;
			default : document.location.href='http://www.alberguelua.com/index_in.html';
		} 
}

