// verification du cookie du sondage
function checkCook() {
	if (((document.cookie.indexOf("sond=fait")) == -1) && (navigator.userAgent.indexOf("Mozilla/") != -1) && (location.hostname == "media.macm.org")) {
		document.cookie = "page=" + location + "; path=/; expires=Mon, 13 Jan 2024 16:21:47 GMT";
		location.replace("/MEDIA.html");
	}
}

// fonctions MacroMedia

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}


// fonction d'ouverture de fenetres diverses

function openHelpWindow() {
  var theURL='http://media.macm.org/f/aide/recher.html',winName='aide',features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=580,height=400';
  window.open(theURL,winName,features);
}

function openHelpWindow2() {
  var theURL='http://media.macm.org/e/aide/recher.html',winName='help',features='toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=580,height=400';
  window.open(theURL,winName,features);
}

function VideoWindow(theURL) {
  var winName='Video',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=360,height=296';
  window.open(theURL,winName,features);
}

function VideoWindow2(theURL) {
  var winName='Video',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=258';
  window.open(theURL,winName,features);
}

function AudioCollWindow(theURL) {
	var winName='collaudio',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=360,height=180';
	var audioWin = window.open(theURL,winName,features);
	audioWin.focus();
}

function ExpoWindow(theNum) {
//  var winName='Exposition' + theNum,features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400';  // systeme a plusieurs fenetres
  var winName='Exposition',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=500';
  var theWindow = window.open('',winName,features);
  var newContent = '<html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><title>Affiche</title></head><body bgcolor="#dcdcd0" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td valign="middle" align="center"><a href="javascript:window.close();"><img src="/im/expo/' + theNum + '.jpg" border="0"></a></td></tr></table></body></html>';
  theWindow.focus() // systeme a une fenetre
  theWindow.document.write(newContent)
  theWindow.document.close()
  theWindow.document.title = "Affiche"
}

function ExpoWindowE(theNum) {
//  var winName='Exposition' + theNum,features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400';  // systeme a plusieurs fenetres
  var winName='Exposition',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=500';
  var theWindow = window.open('',winName,features);
  var newContent = '<html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><title>Poster</title></head><body bgcolor="#dcdcd0" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td valign="middle" align="center"><a href="javascript:window.close();"><img src="/im/expo/' + theNum + '.jpg" border="0"></a></td></tr></table></body></html>';
  theWindow.focus() // systeme a une fenetre
  theWindow.document.write(newContent)
  theWindow.document.close()
  theWindow.document.title = "Poster"
}

function ExpoBann(theNum, lang) {
//  if (lang == 'e') {
  if (location.pathname.indexOf("/e/") == 0) {
  	title = 'Banner';
  } else {
  	title = 'Bannière';
  }
  var winName='Banniere',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=640,height=500';
  var theBann = window.open('',winName,features);
  var newContent = '<html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><title>' + title + '</title></head><body bgcolor="#dcdcd0" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td valign="middle" align="center"><a href="javascript:window.close();"><img src="/im/expo/' + theNum + '.jpg" border="0"></a></td></tr></table></body></html>';
  theBann.focus()
  theBann.document.write(newContent)
  theBann.document.close()
  theBann.document.title = title
}

function ExpoInvit(theNum) {
  if (location.pathname.indexOf("/e/") == 0) {
  	title = 'Invitation';
  } else {
  	title = 'Carton d\'invitation';
  }
  var winName='Invitation',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=500';
  var theInvit = window.open('',winName,features);
  var newContent = '<html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><title>' + title + '</title></head><body bgcolor="#dcdcd0" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td valign="middle" align="center"><a href="javascript:window.close();"><img src="/im/invitations/' + theNum + '.jpg" border="0"></a></td></tr></table></body></html>';
  theInvit.focus()
  theInvit.document.write(newContent)
  theInvit.document.close()
  theInvit.document.title = title
}

function ExpoVues(vues, credits, dir) {
  if (location.pathname.indexOf("/e/") == 0) {
  	title = 'Images';
  	credTitle = 'Photo credits: ';
  } else {
  	title = 'Images';
  	credTitle = 'Crédits photo&nbsp;: ';
  }
  if (!dir) {
    dir = 'vues_salle';
  }
  var winName='Vues',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=690,height=690';
  var theVues = window.open('',winName,features);
  var newContent = '<html><head><meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><title>' + title + '</title></head><body bgcolor="#dcdcd0" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr>';
  vues = vues.split(',');
  for (i = 0; i < vues.length; i++) {
    newContent += '<td valign="middle" align="center"><a href="javascript:window.close();"><img src="/im/' + dir + '/' + vues[i] + '.jpg" border="0" style="margin: 0 10px;"></a></td>';
  }
  
  newContent += '</tr>';
  if (credits) {
    newContent += '<tr><td style="color:#666666;padding: 0 0 15px 20px;font-size:10px;font-family:Verdana,Arial,Helvetica,Geneva;">' + credTitle + credits + '</td></tr>';
  }
  newContent +='</table></body></html>';
  theVues.focus();
  theVues.document.write(newContent);
  theVues.document.close();
  theVues.document.title = title;
}

function ExpoPress(theNum, theTitle, theYear) {
  var winName='Presse',features='toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=450';
  theNum = '/expo/' + theNum + '.html';
  var thePress = window.open(theNum,winName,features);
  winTitle = theTitle;
  winYear = theYear;
  thePress.focus()
}

function insTitle() {
	if (opener.winTitle) {
		document.write('<span class="lien">' + unescape(opener.winTitle) + '</span><br><span class="rep">' + opener.winYear + '</span>');
	}
	if (opener.location.pathname.indexOf('/e/') != -1) document.title = "Press Review";
}



var nouvelles = function() {
    var annonce = $('annonce');
    var box = $('box');
    var sub = $('subtext');
    var moveAnnonce = new Fx.Move(annonce, {
                            duration: 8000,
                            transition: Fx.Transitions.Sine.easeOut,
                            relativeTo: box,
                            position: 'upperLeft',
                            edge: 'upperRight'
                        });
    moveAnnonce.addEvent('onComplete', function() {
        sub.reveal();
    });
    
    var start = function() {
        moveAnnonce.start();
    }
    
    var scroll = function(first) {
        sub.hide();
        annonce.position({
            relativeTo: box,
            position: 'upperRight',
            edge: 'upperLeft',
            offset: {x: 100, y: 0}
        });
        if (first === true) {
            start();
        } else {
            start.delay(5000);
        }
    }
    
    scroll(true);
    scrollInterval = scroll.periodical(25000);

    box.addEvent('click', function() {
        $clear(scrollInterval);
    });
        
}    

