// JavaScript Document
var isSetMenu=false;
var isSetMenuName = "";

function newImage(szImg) {
	if (document.images) {
		szTemp = new Image();
		szTemp.src = szImg;
		return szTemp;
	} 
}

function showover(szID) {
	if(isSetMenu=false) {
		$(szID+"_normal").hide();
		$(szID+"_hover").show();
	} else if(isSetMenu=true && isSetMenuName!=szID) {
		$(szID+"_normal").hide();
		$(szID+"_hover").show();
	}
}


function shownormal(szID) {
	if(isSetMenu=false) {
		$(szID+"_normal").show();
		$(szID+"_hover").hide();
	} else if(isSetMenu=true && isSetMenuName!=szID) {
		$(szID+"_normal").show();
		$(szID+"_hover").hide();
	}
}

function setmenu(szID) {
	$(szID+"_normal").hide();
	$(szID+"_hover").show();
	isSetMenu=  true;
	isSetMenuName = szID;
	/*$(szID+"_hover").setStyle({
		borderBottom:'2px solid #EB6A0C'
	});*/
}
function setmenuselected(szID) {
	$(szID+"_normal").hide();
	$(szID+"_hover").hide();
	$(szID+"_selected").show();
	isSetMenu=  true;
	isSetMenuName = szID;
	/*$(szID+"_hover").setStyle({
		borderBottom:'2px solid #EB6A0C'
	});*/
}

function changeradio(szid,szvalue) {
	$(szid).value=szvalue;
}

function select_rep(szid) {
	//on doit parcourir toutes les map et les mettres a vide
	var allElement = $$('.representant_paragraphe_selected');
	if(allElement.length>0) {
		allElement.each(function(n) {
			$(n).removeClassName("representant_paragraphe_selected");
		});
	}
	
	if(Object.isArray(szid)) {
		for (var index = 0; index < szid.length; ++index) {
			var item = szid[index];
			itemPar = item + "paragraphe";
			$(itemPar).addClassName('representant_paragraphe_selected');	
		}
	} else {
		szidPar = szid + "paragraphe";
		$(szidPar).addClassName('representant_paragraphe_selected');
	}
}

function select_rep_via_id (szid) {
	if(Object.isArray(szid)) {
		$(szid[0]).scrollTo();
		select_rep(szid);
	} else {
		$(szid).scrollTo();
		select_rep(szid);
	}

}

var globalPopup = null;

function show_article(szpage,szOption) {

	if(globalPopup!=null) {
		//globalPopup.focus();
	}
	var test = new Popup.Base(szpage, {focus:true},szOption);
	globalPopup = test;
}


/* ============================== CLASS =============================*/
/* exmple : Popup.open('http://www.google.com/', { focus: true }, { statusbar: 1}); */
var Popup = Object.extend(Object.extend(Enumerable), {
});

Popup.Base = Class.create();
Popup.Base.prototype = {
	// open a popup
	// only mandatory is the url for the popup
	initialize: function() {
		this.url = arguments[0];
		// get the options
		this.options = Object.extend({
			name: 'popup',
			focus: false
		}, arguments[1] || {});

		// get the window options
		this.window_options = $H(Object.extend({
			width: 890,
			height: 480,
			toolbar: 0,
			scrollbars: 1,
			location: 0,
			statusbar: 0,
			menubar: 0,
			resizable: 1
		}, arguments[2] || {}));

		this.window = window.open(this.url, this.options.name, this.window_options.map(function(v, i) {
			return v[0] + '=' + v[1];
		}).join(', '));
		Popup[this.url] = this; // place in the popup object, to be able to iterate over it

		if (this.options.focus) {
			this.focus();
		}
	},

	// close a popup window
	close: function() {
		this.window.close();
		if (this.url in Popup) { // remove from the popup object
			delete Popup[this.url];
		}
	},

	// focus an open popup window
	focus: function() {
		this.window.focus();
	}
};

