function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

initFlash = function(lang, cat, playIntro) {

	var flashObjectAvantages = new Swiff(
			'/themes/stleonard/flash/AvantagesGroupeE.swf', {
				width : '330',
				height : '250',
				id : 'flashObject1',
				params : {
					align : 'middle',
					allowScriptAccess : 'always',
					play : 'true',
					pluginspage : 'http://www.adobe.com/go/getflashplayer',
					quality : 'high'
				},
				vars : {
					lang : lang,
					cat : cat
				}

			});
	var flashObjectSponsor = new Swiff(
			'/themes/stleonard/flash/SponsorDisplay.swf', {
				width : '860',
				height : '223',
				id : 'flashObject2',
				params : {
					align : 'middle',
					allowScriptAccess : 'always',
					play : 'true',
					pluginspage : 'http://www.adobe.com/go/getflashplayer',
					quality : 'high'
				},
				vars : {
					lang : lang
				}

			});

	// remplace HTML with flashobject
	flashObjectAvantages.replaces($('flashAdvantages'));
	flashObjectSponsor.replaces($('flashSponsor'));
	
	if(playIntro && readCookie('firstVisit') == null) {
		switch(lang) {
			case "fr":
			   var str= '/files/videos/videoGroupeE_FR.swf';
			break;
			case "de":
				var str=  '/files/videos/videoGroupeE_DE.swf';
				break;
		}
		Videobox.open(str, '', 'vidbox');
	}
};



