function showHideText(element,text)
{
	element.value = text;

	element.onfocus = function() {
		if(element.value == text) {
			element.value = '';
		}
	}

	element.onfocusout = function() {
		if(element.value == '')  {
			element.value = text;
		}
	}

	element.onchange = function() {
		if(element.value == '') {
			element.value = text;
		}
	}
}

function PopupImage(img,titre) {
    w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');
    w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
    w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+12,document.images[0].height+30); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
    w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><a href=# onClick='window.close()'><IMG src='"+img+"' border=0 alt='fermer'></a>");
    w.document.write("");
    w.document.write("</BODY></HTML>");
    w.document.close();
}

function addMacaron(idContent,lettre,codeCouleur,baseUrl)
{
	var flashvars = {couleur:codeCouleur,lettre:lettre};
	var params = {menu: "false",wmode:"transparent"};
	var attributes = {id:idContent};

	swfobject.embedSWF(baseUrl+"/public/swf/macaronbc.swf", idContent, "51", "51", "9.0.0",baseUrl+"/public/swf/expressInstall.swf", flashvars, params, attributes);
}

function addBandeSpectacle(idContent,texte,codeCouleur,baseUrl) 
{
	var flashvars = {couleur:codeCouleur,texte:texte};
	var params = {menu: "false",wmode:"transparent"};
	var attributes = {id:idContent};

	swfobject.embedSWF(baseUrl+"/public/swf/bande_spectacles.swf", idContent, "215", "38", "9.0.0",baseUrl+"/public/swf/expressInstall.swf", flashvars, params, attributes);	
}

function startRotation(jsonUrl,baseUrl,content,width,height) {

	if(window['timer_'+content] != undefined) {
		clearInterval(window['timer_'+content]);
	}
	
	$.getJSON(jsonUrl,
	        function(data){
				attacherBandeau(data,baseUrl,content,width,height);

				window['timer_'+content] = setInterval("startRotation('"+jsonUrl+"','"+baseUrl+"','"+content+"','"+width+"','"+height+"')",(data['duration'] * 1000));
	        });

}

function attacherBandeau(data,baseUrl,content,width,height,clear)
{
	//bandeau de type image
	if(data['type'] == 'image') {
		var str = '<img src="'+data['src']+'">';

		if(data['url']) {
			str = str.replace(str,'<a href="'+data['url']+'">'+str+'</a>');
		}

		$('#'+content).html(str);
	} 
	
	//bandeau de type flash SWF
	else if(data['type'] == 'flash') {
		var rand = Math.random();
		$(content).html('<div id="bandeauFlash'+rand+'" class="bandeauFlash">');
		var flashvars = {};
		var params = {menu: "false",wmode:"transparent"};
		var attributes = {};

		swfobject.embedSWF(data['src'], "bandeauFlash"+rand, width, height, "9.0.0",baseUrl+"/public/swf/expressInstall.swf", flashvars, params, attributes);					
	}

	if(clear == true && window['timer_'+content] != undefined) {
		clearInterval(window['timer_'+content]);
	}
}

function playVideo(code) {
	document.getElementById('player').innerHTML = unescape(code);
	window.location = window.location+"#playerVideo";	
}




