// Verification de l'email
function verifie_email()
{
	var_verif = false;
	var_mail = document.inscription.email.value;
	if (var_mail.length != 0) {
		if (var_mail.search("^[a-zA-Z0-9]([-_.]?[a-zA-Z0-9])*@[a-zA-Z0-9]([-.]?[a-zA-Z0-9])*[.]([-.]?([a-z]{2,5}))+$")!=-1)
			var_verif = true;
	}
	if(var_verif)
	{
		document.getElementById('envoi').style.display = "inline";
		document.getElementById('envoi').disabled = false;
	}
	else
	{
		document.getElementById('envoi').style.display = "none";
		document.getElementById('envoi').disabled = true;
	}
}

//Ajouter aux favoris
function favoris() {
	if ( navigator.appName == 'Microsoft Internet Explorer' )
	{
		window.external.AddFavorite("http://www.transat650.org","La Charente-Maritime - Bahia");
	}
	else  if (navigator.appName=='Netscape')
	{
		window.sidebar.addPanel("La Charente-Maritime - Bahia","http://www.transat650.org","");
	}
	else if (navigator.appName=='Opera')
	{
		alert('Vous utilisez Opéra. Pour ajouter à  vos Favoris le site de la Charente-Maritime - Bahia, faites la combinaison de touches [CLTR] + D');
	}
	else
	{
		alert('Pour ajouter à vos Favoris le site de la Charente-Maritime - Bahia, faites la combinaison de touches [CMD] + D');
	}
	return 0;
}

function pageDemarrage() {

	switch(navigator.appName)
	{
		case "Netscape":
			alert ('Utilisateur de Firefox ou Safari, glissez l\'icone à  gauche de l\'adresse url dans la petite maison de démarrage' );
		break;
 		case "Opera":
 			alert ('Utilisateur d\'Opéra, tapez [CLTR] F12 puis tapez l\'adresse "http://www.transat650.org/" dans le champs prévu à cet effet' );
		break; 		

 		
 	}
	return false;
}


//Version de la plateforme du visiteur
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

//Page de dï¿½marrage
function verif () {
	switch(BrowserDetect.browser)
	{
	case "Firefox":
	alert ('Utilisateur de Firefox, glissez l\'icone Ã  gauche de l\'adresse url dans la petite maison de dÃ©marrage' );
	break;

	case "Opera":
	alert ('Utilisateur d\'OpÃ©ra, tapez [CLTR] F12 puis tapez l\'adresse  "http://www.vendeeglobe.org" dans le champs prÃ©vu Ã  cet effet' );
	break;

	case "Safari":
	alert ('Utilisateur de Safari, glissez l\'icon Ã  gauche de l\'adresse url dans la petite maison de dÃ©marrage' );
	break;
	}
}





function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}


//Ouverture d'une popup
function gotoSite(url)
{
	newsite =
	window.open(url, "Partenaires", "width=300,height=200,scrollbars");
	newsite.focus();
}

// Taille du texte
function textePlus()
{
	if(document.getElementById('chapo'))
		document.getElementById('chapo').style.fontSize = "130%";
	if(document.getElementById('corps'))
		document.getElementById('corps').style.fontSize = "130%";
	if(document.getElementById('corps2'))
		document.getElementById('corps2').style.fontSize = "130%";
	if(document.getElementById('corps3'))
		document.getElementById('corps3').style.fontSize = "130%";
	if(document.getElementById('txtskipper'))
		document.getElementById('txtskipper').style.fontSize = "130%";
	if(document.getElementById('txtpalmares'))
		document.getElementById('txtpalmares').style.fontSize = "130%";
	if(document.getElementById('txtbateau'))
		document.getElementById('txtbateau').style.fontSize = "130%";
	if(document.getElementById('txtcartech'))
		document.getElementById('txtcartech').style.fontSize = "130%";
	if(document.getElementById('txtparten'))
		document.getElementById('txtparten').style.fontSize = "130%";
}

function texteNormal()
{
	if(document.getElementById('chapo') && document.getElementById('chapo').style.fontSize != "100%")
		document.getElementById('chapo').style.fontSize = "100%";
	if(document.getElementById('corps') && document.getElementById('corps').style.fontSize != "100%")
		document.getElementById('corps').style.fontSize = "100%";
	if(document.getElementById('corps2') && document.getElementById('corps2').style.fontSize != "100%")
		document.getElementById('corps2').style.fontSize = "100%";
	if(document.getElementById('corps3') && document.getElementById('corps3').style.fontSize != "100%")
		document.getElementById('corps3').style.fontSize = "100%";
	if(document.getElementById('txtskipper') && document.getElementById('txtskipper').style.fontSize != "100%")
		document.getElementById('txtskipper').style.fontSize = "100%";
	if(document.getElementById('txtpalmares') && document.getElementById('txtpalmares').style.fontSize != "100%")
		document.getElementById('txtpalmares').style.fontSize = "100%";
	if(document.getElementById('txtbateau') && document.getElementById('txtbateau').style.fontSize != "100%")
		document.getElementById('txtbateau').style.fontSize = "100%";
	if(document.getElementById('txtcartech') && document.getElementById('txtcartech').style.fontSize != "100%")
		document.getElementById('txtcartech').style.fontSize = "100%";
	if(document.getElementById('txtparten') && document.getElementById('txtparten').style.fontSize != "100%")
		document.getElementById('txtparten').style.fontSize = "100%";
}

//Popup centree
function PopupCentrer(page,largeur,hauteur,options)
{
	var top = (screen.height-hauteur)/2;
	var left = (screen.width-largeur)/2;
	window.open(page,"popup","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function PopupCentrerHome(page,nom,largeur,hauteur,options) {
	var top = (screen.height-hauteur)/2;
	var left = (screen.width-largeur)/2;
	window.open(page,nom,"top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

// issu de maj/_js/mediatheque/mediatheque.js
function setEltAfterUpload (val,obj1,obj2) {

	if(document.getElementById) {

		document.getElementById(obj1).value=val;

		//document.getElementById(obj2).innerHTML ='<img src="/upload/images/mini/last_uploaded_mini.jpg?t='+Math.random()+'" />';

	}

}

//Alerte de confirmation de suppression - admin
function confirmDelete()
{
	var agree = confirm ("Voulez-vous rÃ©ellement supprimer cet Ã©lÃ©ment de la base ?");
	if (agree)
		return true ;
	else
		return false ;
}