// JavaScript Document

function menu(etat, no){ 
	if(navigator.appVersion.indexOf('MSIE 8.0') != -1){
		//
	} else {
		var obj2 = document.getElementById("im_" + no);
		if(etat == 1) {
			obj2.style.visibility="visible";
		} else {
			obj2.style.visibility="hidden";
		}
	}
}

function zoom(path){
	var url="view_photo.php?path=" + path;
	window.open(url, 'pop', 'toolbar=0, location=0,  directories=0, status=0, scrollbars=0, resizable=1, copyhistory=0, menuBar=0, width=600, height=450');
}


function addToFavorites(anchor) 
{ 
if (window.external) 
{ 
window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title')); 
} 
} 


function addNewsletter(){
	alert('Vous avez été inscrit à la newsletter de la Navix Compagnie des Îles');
	email = document.getElementById("emailNewsletter").value;
	document.location.href='index.php?email='+email;
}

var MAX_WIDTH = 500; //the biggest width the select is allowed to be 
function biggestOption(elem) { 
var biggest = 0; 
for (var i=0;i<elem.options.length;i++) { 
if ( elem.options[i].innerHTML.length > biggest ) { 
biggest = elem.options[i].innerHTML.length; 
} 
} 
return roughPixelSize(biggest); 
} 
function roughPixelSize(charLength) { 
//this is far from perfect charLength to pixel 
//but it works for proof of concept 
roughSize =  30 + (charLength * 6); 
if (roughSize > MAX_WIDTH) { 
return MAX_WIDTH; 
} else { 
return roughSize; 
} 
} 
function resizeToBiggest(elem) { 
elem.style.width = biggestOption(elem); 
} 
function resizeToSelected(elem) { 
elem.style.width = roughPixelSize(elem.options[elem.selectedIndex].innerHTML.length); 
} 
