
var country;
function init(c) {
	country = c;
	if (country == 'fr') initfr();
	if (country == 'es') inites();
	if (country == 'en') initlux();
}

function displayCenters(reg) {

	var liste = document.getElementById('centres-liste');
	liste.innerHTML = '<span class="titrebleu">'+reg+'</span><br/><br/>';
	var i = 0;
	for (i = 0; i<region.length; i++) {
			if (region[i] == reg) {
				liste.innerHTML += '<span class="textegris">'+nom[i]+'</span><br/>';
				if (adresse[i] != "") {
					liste.innerHTML += '<span class="textegris">'+adresse[i]+'</span><br/>';
				}
				liste.innerHTML += '<span class="textegris">'+tel[i]+'</span><br/>';
				liste.innerHTML += '<a href="mailto:'+email[i]+'">'+email[i]+'</a><br/><br/>';
			}
	}

}

/** Image map management **/

current_overID = "";
last_overID = "";
 
function item (img_name,width,height)
  { 
	img_prefix = img_name;
	this.slide_img = new Image (width,height);
	rep = "images/france/" ;
	if (country=='fr')
		rep = "images/france/";
	if (country=='es')
		rep = "images/espagne/";
	if (country=='en')
		rep = "images/luxembourg/";		
		
	this.slide_img.src = rep + img_prefix + ".jpg";
	//console.log(this.slide_img.src);
  }
 
function new_item (img_name,width,height) 
  { 
	item [img_name] = new item (img_name,width,height);
  }
 
function mouseover (itemID)
  {
	current_overID = itemID;
	if (current_overID != last_overID) {
		document.jrcmap.src = item [current_overID].slide_img.src;
	}
	return true;
}

var item;
function initfr() {
new_item ("carteFR",399,539); 
new_item ("carteFR_01",399,539);
new_item ("carteFR_02",399,539);
new_item ("carteFR_03",399,539);
new_item ("carteFR_04",399,539);
new_item ("carteFR_05",399,539);
new_item ("carteFR_06",399,539);
new_item ("carteFR_07",399,539);
new_item ("carteFR_08",399,539);
new_item ("carteFR_09",399,539);
new_item ("carteFR_10",399,539);
new_item ("carteFR_11",399,539); 
new_item ("carteFR_11b",399,539);
new_item ("carteFR_12",399,539);
new_item ("carteFR_13",399,539);
new_item ("carteFR_14",399,539);
new_item ("carteFR_15",399,539);
new_item ("carteFR_16",399,539);
new_item ("carteFR_17",399,539);
new_item ("carteFR_18",399,539);
new_item ("carteFR_19",399,539);
new_item ("carteFR_20",399,539);
new_item ("carteFR_21",399,539);
new_item ("carteFR_22",399,539);
new_item ("carteFR_23",399,539);
new_item ("carteFR_24",399,539);
}

function initlux() {
new_item ("carte_luxembourg",220,319); 
new_item ("carte_LUX_01",220,319);
new_item ("carte_LUX_02",220,319);
new_item ("carte_LUX_03",220,319);
new_item ("carte_LUX_04",220,319);
new_item ("carte_LUX_05",220,319);
}

function inites() {
new_item ("carte_ES",385,319); 
new_item ("carte_ES_01",385,319);
new_item ("carte_ES_02",385,319);
new_item ("carte_ES_03",385,319);
new_item ("carte_ES_04",385,319);
new_item ("carte_ES_05",385,319);
new_item ("carte_ES_06",385,319);
new_item ("carte_ES_07",385,319);
new_item ("carte_ES_08",385,319);
new_item ("carte_ES_09",385,319);
new_item ("carte_ES_10",385,319);
new_item ("carte_ES_11",385,319); 
new_item ("carte_ES_12",385,319);
new_item ("carte_ES_13",385,319);
new_item ("carte_ES_14",385,319);
new_item ("carte_ES_15",385,319);
new_item ("carte_ES_16",385,319);
}

function helper() {
var areas = document.getElementsByTagName('area');
var cs = new Array('red', 'blue', 'grey', 'green', 'yellow');
var c;
for (var i = 0; i<areas.length; i++) {
c = cs[i%5];
var xyz = areas[i].getAttribute('coords').split(',');
//console.log(xyz[0], xyz[1], xyz[2], c);
drawLine(parseInt(xyz[0])+234, parseInt(xyz[1])+320, parseInt(xyz[2]), c);
}
}


function drawCircle(a, b, r, c) {
w = 1;
h = 1;
o = 100;

				var y = 0;
				for (x = 0; x <= Math.round(r / Math.sqrt(2)); x++) {
					y = Math.sqrt(Math.pow(r, 2) - (Math.pow(x, 2)));
/*						setPx(x + a, y + b, w, h, c, o);
						setPx(a - x, y + b, w, h, c, o);
						setPx(a - x, b - y, w, h, c, o);
						setPx(x + a, b - y, w, h, c, o);
						setPx(y + a, b - x, w, h, c, o);
						setPx(a - y, b - x, w, h, c, o);
						setPx(y + a, x + b, w, h, c, o);
						setPx(a - y, x + b, w, h, c, o);
					*/
						setPx(a - x, y + b, 2 * x, h, c, o);
						setPx(a - x, b - y, 2 * x, h, c, o);
						setPx(a - y, b - x, 2 * y, h, c, o);
						setPx(a - y, x + b, 2 * y, h, c, o);
				}
			}

			function drawLine(x1, y1, x2, y2, w, c, o) {
				var y = x = 0;
				var signX = (x1 - x2) / Math.abs(x1 - x2) * -1;
				var signY = (y1 - y2) / Math.abs(y1 - y2) * -1;
				if (x2 == x1) {
					setPx(Math.min(x1, x2), Math.min(y1, y2), w, Math.abs(y2 - y1), c, o);
				} else if (y1 == y2) {
					setPx(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x2 - x1), w, c, o);
				} else {
					if (Math.abs((y2 - y1) / (x2 - x1)) <= 1) {
						while (x <= Math.abs(x2 - x1)) {
							y = (y2 - y1) / Math.abs(x2 - x1) * x;
							setPx(signX * x + x1, y + y1, w, w, c, o);
							x++;
						}
					} else {
						while (y <= Math.abs(y2 - y1)) {
							x = (x2 - x1) / Math.abs(y2 - y1) * y;
							setPx(x + x1, signY * y + y1, w, w, c, o);
							y++;
						}
					}
				}
			}
			
			function setPx(x, y, w, h, c, o) {
				var px = document.createElement('div');
				px.id = 'px';
				px.style.cssText = 'position:absolute; top:' + y + 'px; left:' + x + 'px; background-color:' + c + '; width:' + w + 'px; height:' + h + 'px; opacity:' + o / 100 + '; filter:alpha(opacity=' + o + ');';
				document.body.appendChild(px);
			}

			function clearPx() {
				while (document.getElementById('px')) {
					document.body.removeChild(document.getElementById('px'));
				}
			}
 
