if ( typeof(Libero) == "undefined" ) {
	Libero = {
		Version: '1.0.1'
    };
}

Libero.Stash = {};

// test prototype library
if ( typeof(Prototype) == "undefined" ) {
	var Class = {
		create: function() {
			return function() {
				this.initialize.apply(this, arguments);
			}
		}
	};
	Object.extend = function(destination, source) {
		for (var property in source) {
			destination[property] = source[property];
  		}
		return destination;
	};
}

// Libero.HF: header footer class utilities  
Libero.HF = Class.create();

Libero.HF.show = function (id) {
	if (document.getElementById) {
		var el = document.getElementById(id);
		if (el) {
			el.style.display = 'block';
		}
	}
}

Libero.HF.hide = function (id) {
	if (document.getElementById) {
		var el = document.getElementById(id);
		if (el) {
			el.style.display = 'none';
		}
	}
}

Libero.HF.toggle = function(id) {
	if (document.getElementById) {
		var el = document.getElementById(id);
		if (el) {
			if (el.style.display == 'block') {
				el.style.display = 'none';
			}
			else {
				el.style.display = 'block';
			}
		}
	}
}

Libero.HF.ariannaSearch = function (url, empty_url, cksrv_a, cksrv_b, cksrv_c, q, encode, target) {
	encode = encode == undefined ? 1 : encode;
	target = target == undefined ? null : target;
	// empty query
	if ( q.match(/^\s*$/) ) {
		if ( empty_url != undefined ) {
			ckSrv(empty_url,cksrv_a,cksrv_b,cksrv_c,target);
			return false; 		
		}
		else 
			return false;
	}
	else {
		ckSrv(url + ( encode ? encodeURIComponent(q) : q ),cksrv_a,cksrv_b,cksrv_c,target);
		return false; 
	}
}

// Adv
function adv_flashDisp (flashobj) {
	if (typeof(flashobj)!='undefined'&&flashobj!='') {
		document.write(flashobj);
	}
}

Libero.HF.setCookie = function (name, value, date, path, domain, secure) {
	var expires = 0;

	// expires is a Date object
	if (date.constructor.toString().match(/function\s+Date\(/)) {
		expires = date;
	}
	// expires is a anonymous Object
	else if (date.constructor.toString().match(/function\s+Object\(/)) {
		date = Object.extend({ day: 0, hour: 0, min: 0, sec: 0 }, date);
		if (date.day == 0 && date.hour == 0 && date.min == 0 && date.sec == 0) {
			expires = 0;
		}
		else {
			expires = new Date();
			Libero.HF.fixDate(expires);
			expires.setTime(expires.getTime() + (((date.day * 24 + date.hour) * 60 + date.min) * 60 + date.sec) * 1000);
		}
	}

	// set cookie
	var curCookie = name + "=" + escape(value) 
		+ ((expires) ? "; expires=" + expires.toGMTString() : "") 
		+ ((path) ? "; path=" + path : "") 
		+ ((domain) ? "; domain=" + domain : "") 
		+ ((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

Libero.HF.getCookie = function (name) {
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1) {
		return null;
	}
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1) {
		cookieEndIndex = document.cookie.length;
	}
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length,cookieEndIndex));
}

Libero.HF.deleteCookie = function (name, path, domain) {
	if (Libero.HF.getCookie(name)) {
		Libero.HF.setCookie(name, '', new Date(0), path, domain);
	}
}

Libero.HF.fixDate = function (date) {
	var base = new Date(0)
	var skew = base.getTime()
	if (skew > 0) {
		date.setTime(date.getTime() - skew);
	}
}
