// JavaScript Document

//LAYOUT
var ElGoodies = {

	getDocument: function(){
		return this.ownerDocument;
	},

	getWindow: function(){
		return this.getDocument().getWindow?this.getDocument().getWindow():window;
	},

	dispose: function(){
		return this.parentNode.removeChild(this);
	},

	replaces: function(el){
		if('string'==(typeof el).toLowerCase()) el = document.getElementById(el);
		el.parentNode.replaceChild(this, el);
		return this;
	},

	hasClass: function(className){
		return this.className.contains(className, ' ');
	},

	addClass: function(className){
		if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
		return this;
	},

	removeClass: function(className){
		this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1').clean();
		return this;
	},

	toggleClass: function(className){
		return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
	},

	getComputedStyle: function(property){
		var result = null;
		if (this.currentStyle){
			result = this.currentStyle[property.camelCase()];
		} else {
			var computed = this.getWindow().getComputedStyle(this, null);
			if (computed) result = computed.getPropertyValue([property.hyphenate()]);
		}
		return result;
	},

	isBody: function() {
		return this.tagName.toLowerCase() == 'body';
	},

	getPosition: function(relative){
		function objectize(el) {
			if('string'==(typeof el).toLowerCase()) el = document.getElementById(el);
			return el;
		}
		if (this.isBody()) return {x: 0, y: 0};
		var el = this, position = {x: 0, y: 0};
		while (el){
			position.x += el.offsetLeft;
			position.y += el.offsetTop;
			el = el.offsetParent;
		}
		var rpos = (relative) ? objectize(relative).getPosition() : {x: 0, y: 0};
		return {x: position.x - rpos.x, y: position.y - rpos.y};
	},

	enrich: function(el){
		if(null==el) return;
		if('string'==(typeof el).toLowerCase()) el = document.getElementById(el);
		for( var methodName in this ) {
			if('enrich'==methodName) continue;
			if( 'undefined' == typeof el[methodName] || null == typeof el[methodName] ) {
				el[methodName] = this[methodName];
			}
		}
	}
};



function lit_cook(nom) {
      var deb,fin
      deb = document.cookie.indexOf(nom + "=")
      if (deb >= 0) {
         deb += nom.length + 1
         fin = document.cookie.indexOf(";",deb)
         if (fin < 0) fin = document.cookie.length
         return unescape(document.cookie.substring(deb,fin))
         }
      return ""
}


function maximize(el) {
	if(!el.getPosition) ElGoodies.enrich(el);
	var soFarAway = document.getElementById('soFarAway');
	var farAway = document.getElementById('farAway');
	var lastDiv = (document.getElementsByTagName('div'))[document.getElementsByTagName('div').length-1];
	if( null==soFarAway ) {
		var sfaProps = {
			position:'absolute',
			right:'1px',
			bottom:'1px',
			overflow:'hidden',
			width:'1px',
			height:'1px',
			backgroundColor:'transparent',
			zIndex:'-2'
		};
		soFarAway = document.createElement('div');
		soFarAway.setAttribute('id','soFarAway');
		for( var prop in sfaProps ) soFarAway.style[prop] = sfaProps[prop];
		el.getDocument().body.insertBefore(soFarAway,document.body.firstChild);
		ElGoodies.enrich(soFarAway);
		ElGoodies.enrich(lastDiv);
	}
	lastDiv.pos = lastDiv.getPosition();
	soFarAway.pos = soFarAway.getPosition();
	el.style.width  = Math.max(soFarAway.pos.x+2,el.getDocument().body.clientWidth)+'px';
	//el.style.height = Math.max(soFarAway.pos.y+1,lastDiv.pos.y+lastDiv.offsetHeight)+'px';

	h = Math.max((window.innerHeight?window.innerHeight:0),(document.getElementsByTagName('body'))[0].offsetHeight,(document.getElementsByTagName('html'))[0].offsetHeight)
	el.style.height = h+'px';
	el.style.width = '994px';
	el.style.display = 'block';
}

function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount = limitNum - limitField.value.length;
	}
}

// POP IN OVERLAY

/*
//PNG IE
var bgsleight	= function(){

	function addLoadEvent(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			}
		}
	}

	function fnLoadPngs() {
		var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
		var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);
		for (var i = document.all.length - 1, obj = null; (obj = document.all[i]); i--) {
			if (itsAllGood && obj.currentStyle.backgroundImage.match(/\.png/i) != null) {
				fnFixPng(obj);
				obj.attachEvent("onpropertychange", fnPropertyChanged);
			}
		}
	}

	function fnPropertyChanged() {
		if (window.event.propertyName == "style.backgroundImage") {
			var el = window.event.srcElement;
			if (!el.currentStyle.backgroundImage.match(/x\.gif/i)) {
				var bg	= el.currentStyle.backgroundImage;
				var src = bg.substring(5,bg.length-2);
				el.filters.item(0).src = src;
				el.style.backgroundImage = "url(x.gif)";
			}
		}
	}

	function fnFixPng(obj) {
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		obj.style.backgroundImage = "url(x.gif)";
	}


	return {
		init: function() {
			if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
				addLoadEvent(fnLoadPngs);
			}
		}
	}

}();
bgsleight.init();
*/