// create ajax request object
function ajax_createRequestObject() 
	{
    var ro;
    var browser=navigator.appName;
    
	if(browser=="Microsoft Internet Explorer")
		{
        ro=new ActiveXObject("Microsoft.XMLHTTP");
    	}
	else
		{
        ro=new XMLHttpRequest();
    	}
    
	return ro;
	}


// initiate request object
var http = ajax_createRequestObject();


// getElementById() cross-browser
function gEBI(eID)
	{ 
  	var element = null; 


	if(document.getElementById)
		{ 
    	element = document.getElementById(eID);
		}
	else if(document.layers)
		{
		element = document.layers[eID];
		}
	else if(document.all)
		{
		element = document.all[eID];
		}	
	
	return element; 
	} 


// ajax get heading content
function ajax_getHeadingContent(gID) 
	{
	http.open('get','http://www.ulna.fr/ajax_getHeadingContent.php?group='+gID);
    http.onreadystatechange=function()
    	{
		if(http.readyState==4)
			{
	   		gEBI("headingcontent").innerHTML = http.responseText;
			}  
		}
    http.send(null);
	}
	
// change button status
var arrayChoices = new Array('choice1','choice2','choice3','choice4');


function changeButtonStatus(bID)
	{
	for (i=0; i < arrayChoices.length; i++)
  		{
		gEBI(arrayChoices[i]).className = "sousmenu1";     
		}
	gEBI(bID).className = "sousmenu1_selected";
	gEBI(bID).blur();
	}	
	
// get heading content
function getHeadingContent(gID,bID)
	{
	ajax_getHeadingContent(gID);
	changeButtonStatus(bID);
	}	


function showVideo(width,height,url,flvID)
	{
	var content = null;
	content = '<object type="application/x-shockwave-flash" data="http://www.ulna.fr/mediatheque/player.swf" width="'+width+'" height="'+height+'">';
	content += '<param name="movie" value="http://www.ulna.fr/mediatheque/player.swf" />';
	content += '<param name="FlashVars" value="width='+width+'&height='+height+'&flv='+url+flvID+'&margin=0&showplayer=never&autoplay=1&loop=1&buffermessage=_n_&&playercolor=E4E4E4&videobgcolor=ffffff&buffershowbg=0" />';
    content += '<param name="wmode" value="transparent" />';
    content += '</object>';
    gEBI("flashcontent").innerHTML = content;
    gEBI("flashcontent").focus();
    //alert(content);
	}
	
function showImage(width,height,url,pixID)
	{
	var content = null;
	content = '<img src="'+url+pixID+'" width="'+width+'" height="'+height+'" />';
    gEBI("imagecontent").innerHTML = content;
    gEBI("imagecontent").focus();
    //alert(content);
	}
	
function showVideo2(width,height,url,flvID,cID,cAll)
	{		

	for(i=1; i <=cAll; i++) {
			if (i!= cID) {
			gEBI("chapter"+i).className = "chapter-off";
			}
		    else {gEBI("chapter"+cID).className = "chapter-on";
			}
	   }

	var content = null;
	content = '<object type="application/x-shockwave-flash" data="mediatheque/player.swf" width="'+width+'" height="'+height+'">';
	content += '<param name="movie" value="mediatheque/player.swf" />';
	content += '<param name="FlashVars" value="width='+width+'&height='+height+'&flv='+url+flvID+'&margin=0&showplayer=never&autoplay=1&loop=1&buffermessage=_n_&&playercolor=E4E4E4&videobgcolor=ffffff&buffershowbg=0" />';
    content += '<param name="wmode" value="transparent" />';
    content += '</object>';
    gEBI("flashcontent").innerHTML = content;
    gEBI("flashcontent").focus();
    //alert(content);   
	}
	
function showVideoAccueil()
	{
	var content = null;
	content = '<object type="application/x-shockwave-flash" data="http://www.ulna.fr/mediatheque/player.swf" width="480" height="360">';
	content += '<param name="movie" value="http://www.ulna.fr/mediatheque/player.swf" />';
	content += '<param name="FlashVars" value="width=480&height=360&flv=http://www.ulna.fr/mediatheque/accueil/accueil_new.flv&margin=0&showplayer=never&autoplay=1&loop=1&buffermessage=_n_&&playercolor=E4E4E4&videobgcolor=ffffff&buffershowbg=0" />';
    content += '<param name="wmode" value="transparent" />';
    content += '</object>';
    gEBI("videohome").innerHTML = content;
    gEBI("videohome").focus();
    //alert(content);
	}

function showVideoTemoignages(fichier)
	{
	var content = null;
	content = '<object type="application/x-shockwave-flash" data="http://www.ulna.fr/mediatheque/player.swf" width="320" height="240">';
	content += '<param name="movie" value="http://www.ulna.fr/mediatheque/player.swf" />';
	content += '<param name="FlashVars" value="width=320&height=240&flv=http://www.ulna.fr/mediatheque/temoignages/'+fichier+'.flv&margin=0&showplayer=never&autoplay=1&loop=1&buffermessage=_n_&&playercolor=E4E4E4&videobgcolor=ffffff&buffershowbg=0" />';
    content += '<param name="wmode" value="transparent" />';
    content += '</object>';
    gEBI("player-temoignages").innerHTML = content;
    gEBI("player-temoignages").focus();
    //alert(content);
	}
	
function showVideoPresse(fichier)
	{
	var content = null;
	content = '<object type="application/x-shockwave-flash" data="http://www.ulna.fr/mediatheque/player.swf" width="320" height="240">';
	content += '<param name="movie" value="http://www.ulna.fr/mediatheque/player.swf" />';
	content += '<param name="FlashVars" value="width=320&height=240&flv=http://www.ulna.fr/mediatheque/presse-television/'+fichier+'/'+fichier+'.flv&margin=0&showplayer=never&autoplay=1&loop=1&buffermessage=_n_&&playercolor=E4E4E4&videobgcolor=ffffff&buffershowbg=0" />';
    content += '<param name="wmode" value="transparent" />';
    content += '</object>';
    gEBI("player-presse").innerHTML = content;
    gEBI("player-presse").focus();
    //alert(content);
	}
	
function showVideoClients(fichier)
	{
	var content = null;
	content = '<object type="application/x-shockwave-flash" data="http://www.ulna.fr/mediatheque/player.swf" width="320" height="240">';
	content += '<param name="movie" value="http://www.ulna.fr/mediatheque/player.swf" />';
	content += '<param name="FlashVars" value="width=320&height=240&flv=http://www.ulna.fr/mediatheque/clients/notices-videos/'+fichier+'.flv&margin=0&showplayer=never&autoplay=1&loop=1&buffermessage=_n_&&playercolor=E4E4E4&videobgcolor=ffffff&buffershowbg=0" />';
    content += '<param name="wmode" value="transparent" />';
    content += '</object>';
    gEBI("player-presse").innerHTML = content;
    gEBI("player-presse").focus();
    //alert(content);
	}
	
function showArticlePresse(fichier)
	{
		
	var content = null;
	content = '<a href="#" onclick="newWindow(\'http://www.ulna.fr/mediatheque/presse-ecrite/'+fichier+'/'+fichier+'_zoom.jpg\',\'\',\'900\',\'600\',\'resizable,scrollbars,toolbar\')"><img src="http://www.ulna.fr/mediatheque/presse-ecrite/'+fichier+'/'+fichier+'.jpg"/></a>';
    gEBI("player-ecrite").innerHTML = content;
    gEBI("player-ecrite").focus();
    //alert(content);
	}

function showArticleClients(fichier)
	{
		
	var content = null;
	content = '<img src="http://www.ulna.fr/mediatheque/clients/notices-pdf/'+fichier+'.jpg"/>';
    gEBI("player-ecrite").innerHTML = content;
    gEBI("player-ecrite").focus();
    //alert(content);
	}
	
function showRadioPresse(fichier)
	{
		
	var content = null;
	content ='<embed type="video/quicktime" src="http://www.ulna.fr/mediatheque/presse-radio/'+fichier+'/'+fichier+'.mp3" height="0px" width="0px" autoplay="true" controller="no" loop="false"/>';
    gEBI("player-radio").innerHTML = content;
    gEBI("player-radio").focus();
    //alert(content);
	}
	
function VerifMail()


{ 
        if(document.formcontact.prenom.value == "") 
			{
		    alert ('Vous devez remplir le champ Prenom.'); 
		    document.formcontact.prenom.focus(); 
		    return false; 
		    }	
        if(document.formcontact.nom == "") 
			{ 
		    alert ('Vous devez remplir le champ Nom.'); 
		    document.formcontact.nom.focus(); 
		    return false; 
		  	}	    
		if(document.formcontact.courriel.value.search(/^[_a-z0-9-]+(.[_a-z0-9-]+)*[^._-]@[a-z0-9-]+(.[a-z0-9]{2,4})*$/) == -1)
        	{ 
            alert ('Veuillez entrer une adresse e-mail valide.'); 
            document.formcontact.courriel.focus(); 
            return false; 
        	} 
        if(document.formcontact.etablissement.value == "") 
			{ 
		    alert ('Vous devez remplir le champ Etablissement.'); 
		    document.formcontact.etablissement.focus(); 
		    return false; 
		  	}	 	
		return true;
}	

function CheckMail()


{ 
        if(document.formcontact.prenom.value == "") 
			{
		    alert ('Please type your name.'); 
		    document.formcontact.prenom.focus(); 
		    return false; 
		    }	
        if(document.formcontact.nom == "") 
			{ 
		    alert ('Please type your first name.'); 
		    document.formcontact.nom.focus(); 
		    return false; 
		  	}	    
		if(document.formcontact.courriel.value.search(/^[_a-z0-9-]+(.[_a-z0-9-]+)*[^._-]@[a-z0-9-]+(.[a-z0-9]{2,4})*$/) == -1)
        	{ 
            alert ('Please enter a valid e-mail address.'); 
            document.formcontact.courriel.focus(); 
            return false; 
        	} 
        if(document.formcontact.etablissement.value == "") 
			{ 
		    alert ('Please type your establishment.'); 
		    document.formcontact.etablissement.focus(); 
		    return false; 
		  	}	 	
		return true;
}	


var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}

   function PopupPic(sPicURL) {
     window.open( "popup.htm?"+sPicURL, "",  
     "resizable=1,HEIGHT=200,WIDTH=200");
   }