// JavaScript Document

// Changement de menu ce fait ici...
///////////////////////////////////////////
var submenus = [
		[
		["Mini Cottages","mini-cot_en.html"],
		["Cottages 1 &frac12;","cot1_en.html"],
		 ["Cottages 2 &frac12;","cot2_en.html"],
		 ["Cottages 3 &frac12;","cot3_en.html"],
		 ["Cottages 4 &frac12;","cot4_en.html"]
		],
		[
		 ["Lodges 2 &frac12;","lod2_en.html"],
		 ["Lodges 3 &frac12;","lod3_en.html"],
		 ["Lodges 4 &frac12;","lod4_en.html"],
		 ["Lodges 6 &frac12;","camp_en.html"],
		 ["Rooms ","chambres_en.html"]
		],
		[
		
		],
		[
		 ["Interior Photos","photo_int_en.html"],
		 ["Exterior Photos","photo_ext_en.html"],
		 ["Activities Photos","photo_act_en.html"],
		 ["Videos","videos_en.html"],
		 ["Videos Coucoushee","videoscou_en.html"]
		],
		[
		 ["Activities","activite_en.html"],
		 ["Spa and Sauna","spa_en.html"]
		],
		[
		 ["Maps","cartes_en.html"],
		 ["Development Plan","develop_en.html"]
		],
		[
		 ["Rental Prices","prix_en.html"],
		 ["Sale Prices","vente_en.html"],
		 ["Important Notes","notes_en.html"]
		],
]

var cha1_text = [
	'Room Nb. 1',
	'max. 2 persons',
	'Queen-size bed',
	'Refrigerator',
	'Table and chairs',
	'Wardrobe',
	'Television, radio,',
	'Telephone, internet access',
	'Washroom (sink, shower-bath, toilet)',
	'Shared access to kitchen,',
	'living room and patio.',
	'Air conditioned'
	]
var cha2_text = [
	'Room Nb. 2',
	'max. 3 persons',
	'Queen-size bed',
	'Single bed',
	'Refrigerator',
	'Small table and chair',
	'Wardrobe',
	'Television, radio,',
	'Telephone, internet access',
	'Washroom (sink, shower',
	'toilet, free standing bath)',
	'Armchair with',
	'foot rest',
	'Shared access to kitchen,',
	'living room and patio.',
	'Air conditioned'
	]
var cha3_text = [
	'Room Nb. 3',
	'max. 3 persons',
	'Queen-size bed',
	'Refrigerator',
	'Table and chairs',
	'Wardrobe',
	'Television, radio,',
	'Telephone, internet access',
	'Washroom (sink, shower-bath, toilet)',
	'Shared access to kitchen,',
	'living room and patio.',
	'Air conditioned'
	]	

//alert(submenus[1][0][1]);

function init_menus() {
	for (var ic = 1;ic <= 7;ic++) {		
		document.getElementById('spc_'+ic).style.display = 'none';
		document.getElementById('smh_'+ic).innerHTML = "";
		document.getElementById('smh_'+ic).href = '';
	}
}
function set_submenus(mid) {
	init_menus();
	var temp_arr = submenus[mid];
	if (temp_arr != null) {
		var howmany = temp_arr.length;
		var hid = 0;
		
		for (var ic=0;ic < howmany; ic++) {
			hid = ic + 1;
			document.getElementById('smh_'+hid).innerHTML = temp_arr[ic][0];
			document.getElementById('smh_'+hid).href = temp_arr[ic][1];
			
			if (ic < howmany) {
				document.getElementById('spc_'+hid).style.display = 'block';
			}
		}
		
		if (mid >= 0 && mid < 2) {
			document.getElementById("submenualign").style.textAlign = "left";
		}
		
		if (mid >= 2 && mid < 5) {
			document.getElementById("submenualign").style.textAlign = "center";
		}
		if (mid >= 5) {
			document.getElementById("submenualign").style.textAlign = "right";
		}
	}
}

function swt_menu(m_id,swt,side) {
	var tempid = document.getElementById('mn'+m_id);
	// Reset tout les menus
	for (var i = 0; i <= 7; i++) { document.getElementById('mn'+i).className='mainmenu'; }
	document.getElementById('m_l_img').src = 'images/mainmenu/left-menu-bg.jpg';
	document.getElementById('m_r_img').src = 'images/mainmenu/right-menu-bg.jpg';
	// End reset
	
	if (swt == '1') { 
		tempid.className = 'mainmenuON';
		set_submenus(m_id);
	} else {
		tempid.className = 'mainmenu';
	}
	
	if (side) {
		var temppic = document.getElementById('m_'+side+'_img');
		if (side == 'l') {
			if (swt == '1') { temppic.src = 'images/mainmenu/left-menuON-bg.jpg'; }
		} else {
			if (swt == '1') { temppic.src = 'images/mainmenu/right-menuON-bg.jpg'; }
		}
	}
}

function chgsides(swt,whid) {
	for (var i=1;i <= 8;i++) {
		document.getElementById('sml_'+i).className = 'submn';
		document.getElementById('smr_'+i).className = 'submn';
	}
	
	if (swt == '1') {
		document.getElementById('sml_'+whid).className = 'subml';
		document.getElementById('smr_'+whid).className = 'submr';
	} else {
		document.getElementById('sml_'+whid).className = 'submn';
		document.getElementById('smr_'+whid).className = 'submn';
	}
}

// PANOS
var picmargin = 0; // Global pour movement de pano.
// Section Pano
function moveLeft() {
	TID=setInterval("MovingPic('left')", 100);
}

function moveRight() {
	TID=setInterval("MovingPic('right')", 100);
}

function stoppic() {
	clearInterval(TID);
}

function MovingPic(whichway){
	if (whichway == 'left') {
		var picw = this.document.getElementById('PANOIMAGE').width; 	// example 568px;
		var varea = top.document.getElementById('PANO').width; 		// example 364px;
		var maxmargin = Number(picw) - Number(varea);				// example 204px;
		
		if (picmargin >= -maxmargin) {
		if (maxmargin - picmargin < 10) {
			picmargin = (maxmargin - picmargin) - 10;
		} else {
			picmargin = picmargin - 10;
		}
		document.getElementById("PANOIMAGE").style.marginLeft=picmargin + 'px';
		// alert(document.all['PANOIMAGE'].style.marginLeft);
		}
	} else {
		if (picmargin < 0) {
		picmargin = picmargin + 10;
		// alert(document.all['PANOIMAGE'].style.marginLeft);
		document.getElementById("PANOIMAGE").style.marginLeft=picmargin + 'px';
		}
	}
}

// Chambres menu, and rollovers, etc...
var cur_ch = 1;
function chon(wh) {
	for(var i=1;i<=3;i++) {
		document.getElementById('ch'+i).className='ch_menu';
	}
	document.getElementById('ch'+wh).className='ch_menuON';
	
	document.getElementById('chpic').src = 'images/chambres/cha'+wh+'-pic.jpg';
	document.getElementById('chcut').src = 'images/chambres/cha'+wh+'-cut.jpg';
	if (wh == '1') { document.getElementById('chtext').innerHTML = 'Vue lat&eacute;rale'; }
	if (wh == '2') { document.getElementById('chtext').innerHTML = 'Vue panoramique'; }
	if (wh == '3') { document.getElementById('chtext').innerHTML = 'Vue arri&egrave;re'; }
}

function reset_chon() {
	for(var i=1;i<=3;i++) {
		document.getElementById('ch'+i).className='ch_menu';
	}
	document.getElementById('ch'+cur_ch).className='ch_menuON';
	
	document.getElementById('chpic').src = 'images/chambres/cha'+cur_ch+'-pic.jpg';
	document.getElementById('chcut').src = 'images/chambres/cha'+cur_ch+'-cut.jpg';
	if (cur_ch == '1') { document.getElementById('chtext').innerHTML = 'Vue lat&eacute;rale'; }
	if (cur_ch == '2') { document.getElementById('chtext').innerHTML = 'Vue panoramique'; }
	if (cur_ch == '3') { document.getElementById('chtext').innerHTML = 'Vue arri&egrave;re'; }
	set_chtext(cur_ch);
}

function set_chon(wh) {
	for(var i=1;i<=3;i++) {
		document.getElementById('ch'+i).className='ch_menu';
	}
	document.getElementById('ch'+wh).className='ch_menuON';
	cur_ch = Number(wh);
	document.getElementById('chpic').src = 'images/chambres/cha'+cur_ch+'-pic.jpg';
	document.getElementById('chcut').src = 'images/chambres/cha'+cur_ch+'-cut.jpg';
	if (cur_ch == '1') { document.getElementById('chtext').innerHTML = 'Vue lat&eacute;rale'; }
	if (cur_ch == '2') { document.getElementById('chtext').innerHTML = 'Vue panoramique'; }
	if (cur_ch == '3') { document.getElementById('chtext').innerHTML = 'Vue arri&egrave;re'; }
	
	document.getElementById('chplan').src='images/chambres/cha'+cur_ch+'-plan.jpg';
	set_chtext(cur_ch);
	counter = 0;
	start_arrows();
}

function set_chtext(wh) {
	
	if ( wh == '1') {
		// get array length
		var arrlen = cha1_text.length;
		// Set Header text
		document.getElementById('chatHead').innerHTML = cha1_text[0]+'<br>'+cha1_text[1]+'<BR>';
		var counter = 2;
		var fulltext = "";
		while (counter < arrlen) {
			fulltext = fulltext + cha1_text[counter]+'<br>';
			counter++;
		}
		document.getElementById('chatList').innerHTML = fulltext;
	}
	if ( wh == '2') {
		// get array length
		var arrlen = cha2_text.length;
		// Set Header text
		document.getElementById('chatHead').innerHTML = cha2_text[0]+'<br>'+cha2_text[1]+'<BR>';
		var counter = 2;
		var fulltext = "";
		while (counter < arrlen) {
			fulltext = fulltext + cha2_text[counter]+'<br>';
			counter++;
		}
		document.getElementById('chatList').innerHTML = fulltext;
	}
	if ( wh == '3') {
		// get array length
		var arrlen = cha3_text.length;
		// Set Header text
		document.getElementById('chatHead').innerHTML = cha3_text[0]+'<br>'+cha3_text[1];
		var counter = 2;
		var fulltext = "";
		while (counter < arrlen) {
			fulltext = fulltext + cha3_text[counter]+'<br>';
			counter++;
		}
		document.getElementById('chatList').innerHTML = fulltext;
	}
	
}

// Open a map in cartes.html
function open_map() {
	window.open("mapprint.html", "PMAP","height=521,width=605,toolbar=no, location=no, status=no,menubar=no,scrollbars=no,resizable=no");
}

// Photos - Algo.
// Globale Photos
function parr_over(wh,state) {
	if (wh == '1') {
		if (state == '1') {
			document.getElementById("plarr").src = 'images/photos/pleftOn.jpg';
		} else {
			document.getElementById("plarr").src = 'images/photos/pleftOff.jpg';
		}
	} else {
		if (state == '1') {
			document.getElementById("prarr").src = 'images/photos/prightOn.jpg';
		} else {
			document.getElementById("prarr").src = 'images/photos/prightOff.jpg';
		}
	}
}
// Photos Exterieurs.
function next_img() {
	if (cur_img < total_img) {
		cur_img++;
	} else {
		cur_img = 1;
	}
	document.getElementById("imgview").src = 'images/photos/'+picext+'_'+cur_img+'.jpg';
	if (cur_img < 10) {
		document.getElementById("curNumText").innerHTML = '0'+cur_img;
	} else {
		document.getElementById("curNumText").innerHTML = cur_img;
	}
}
function prev_img() {
	if (cur_img > 1) {
		cur_img--;
	} else {
		cur_img = total_img;
	}
	document.getElementById("imgview").src = 'images/photos/'+picext+'_'+cur_img+'.jpg';
	if (cur_img < 10) {
		document.getElementById("curNumText").innerHTML = '0'+cur_img;
	} else {
		document.getElementById("curNumText").innerHTML = cur_img;
	}
}

function parr_over2(wh,state) {
	if (wh == '1') {
		if (state == '1') {
			document.getElementById("plarr").src = 'images/photos/pleft2On.jpg';
		} else {
			document.getElementById("plarr").src = 'images/photos/pleft2Off.jpg';
		}
	} else {
		if (state == '1') {
			document.getElementById("prarr").src = 'images/photos/pright2On.jpg';
		} else {
			document.getElementById("prarr").src = 'images/photos/pright2Off.jpg';
		}
	}
}
