// JavaScript Document

// *Menu buttons behavior  *//
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_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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
///* ****** BANNERS droite - REFRESH ****************************************************************************** */

// Banniere - TOP -  (environ 640x480)
// Image par d&eacute;faut (toujours la garder dans le r&eacute;pertoire images) - bantop.gif
var imagesTop = new Array(); 

imagesTop[0]='<img src="images/big/2006-09-23-Gen.Dallaire.jpg" title="Brass Kamarades avec le G&eacute;n&eacute;ral Dallaire" alt="Brass Kamarades avec le G&eacute;n&eacute;ral Dallaire" width="640" height="480" border=0>'

imagesTop[1]='<img src="images/big/Brass-Kamarades-Canada-Francais-2007-10-10.jpg" title="Brass Kamarades au Canada Fran&ccedil;ais" alt="Brass Kamarades au Canada Fran&ccedil;ais" width="640" height="480" border=0>'

imagesTop[2]='<img src="images/big/2006-08-13-Venise-Michel-Denis.jpg" title="Michel et Denis &agrave; Venise" alt="Michel et Denis &agrave; Venise-en-Qu&eacute;bec" width="640" height="480" border=0>'

imagesTop[3]='<img src="images/big/2006-09-23-BK-Jacques.jpg" title="Brass Kamarades avec Jacques Pichette" alt="Brass Kamarades avec Jacques Pichette" width="640" height="480" border=0>'

imagesTop[4]='<img src="images/big/BK-Graduation-Verdun-2006-06-22-big.jpg" title="Brass Kamarades au Restaurant Le Castillon" alt="Brass Kamarades au Restaurant Le Castillon" width="640" height="480" border=0>'

imagesTop[5]='<img src="images/big/Brass-Kamamarades-Auberge-Les-Trois-Tilleuls-Juin-2007.jpg" title="Brass Kamarades Les Trois Tilleuls" alt="Brass Kamarades Les Trois Tilleuls" width="640" height="480" border=0>'

imagesTop[6]='<img src="images/big/2006-08-13-Venise-BK-Sideview.jpg" title="Brass Kamarades &agrave; Venise-en-Qu&eacute;bec" alt="Brass Kamarades &agrave; Venise-en-Qu&eacute;bec" width="640" height="480" border=0>'

imagesTop[7]='<img src="images/big/BK_LGR007.jpg" title="Brass Kamarades avec Les Go&ucirc;ts R&eacute;unis" alt="Brass Kamarades avec Les Go&ucirc;ts R&eacute;unis" width="640" height="480" border=0>'

imagesTop[8]='<img src="images/big/mariage-30-juillet-2005.jpg" title="Brass Kamarades - Mariage priv&eacute; au Fourquet Fourchette" alt="Brass Kamarades - Mariage priv&eacute; au Fourquet Fourchette" width="640" height="480" border=0>'

imagesTop[9]='<img src="images/big/Quintette-de-cuivre-pour-mariage-auberge-3-tilleuls-juin-2007.jpg" title="Quintette de Cuivres pour mariage - Auberge Les Trois Tilleuls - Juin 2007" alt="Quintette de Cuivres pour mariage - Auberge Les Trois Tilleuls - Juin 2007" width="640" height="480" border=0>'


function ShowImgTop() {
  var number = imagesTop.length;
  var increment = Math.floor(Math.random() * number);
  var strTemp =imagesTop[increment];
  document.write(strTemp);
}
function ShowImg1() {
  var number = imagesDroite1.length;
  var increment = Math.floor(Math.random() * number);
  var strTemp =imagesDroite1[increment];
  document.write(strTemp);
}
function ShowImg2() {
  var number = imagesDroite2.length;
  var increment = Math.floor(Math.random() * number);
  var strTemp =imagesDroite2[increment];
  document.write(strTemp);
}
function ShowImg3() {
  var number = imagesDroite3.length;
  var increment = Math.floor(Math.random() * number);
  var strTemp =imagesDroite3[increment];
  document.write(strTemp);
}
function ShowImg4() {
  var number = imagesDroite4.length;
  var increment = Math.floor(Math.random() * number);
  var strTemp =imagesDroite4[increment];
  document.write(strTemp);
}
/* ****** fin BANNERS droite - REFRESH ************************************************************************** */


/* Swap image */

function set_graphic(x,y)
{
	document.getElementById(x).src= 'images/big' + y; 
	return true;
}

/* On Mouse Over Popup Windows */
// This is the function that will open the
// new window when the mouse is moved over the link
function open_new_window() 
{
new_window = open("","hoverwindow","width=640,height=480,left=10,top=10");

// open new document 
new_window.document.open();

// Text of the new document
// Replace your " with ' or \" or your document.write statements will fail
new_window.document.write('<html><title>JavaScript New Window</title>');
new_window.document.write('<body bgcolor=\'#FFFFFF\'>');
new_window.document.write('This is a new html document created by JavaScript ');
new_window.document.write('statements contained in the previous document.');
new_window.document.write('<br>');
new_window.document.write('</body></html>');

// close the document
new_window.document.close(); 
}

// This is the function that will close the
// new window when the mouse is moved off the link
function close_window() 
{
new_window.close();
}

function mailIt(form) {
  if ( (document.all.Email.value=="") || (document.all.pseudo.value=="") || (document.all.Message.value=="") ) {
    alert("Tous les champs sont obligatoires");
    return false;
  }
  
  sEmail = document.all.Email;
  i=sEmail.value.indexOf("@");	//see if there's an @ sign
  x=sEmail.value.indexOf("@",i+1); //make sure there's not more @ signs
  p=sEmail.value.indexOf(".",i);  //there must be a period 
 
  if ( (i==-1) || (p<(i+2)) || (x>i) || (p >=(sEmail.value.length - 2))) {
      alert("Please enter a valid email address.");
      return false;
   }
  return true;
}

//Motivo

var Motivo



if(Motivo == true){

	// Insert Motivo Image Link

	motivoThumb = new Element('div', {'class': 'motivoImage'}).injectAfter($('arrowDown'));

	motivoThumb.setHTML('<img src="'+thumbArray[0]+'" alt="Motivo Slideshow" />');

	

	// Create a div for eash set and load thumbnails into it

	var scrollHeight = (Math.ceil(thumbArray.length/2)*188);

	var wrapperHeight = 188;

	$('arrowDown').setStyle('margin-top', '188px');

}else{

	// Create a div for eash set and load thumbnails into it

	var scrollHeight = (Math.ceil(thumbArray.length/3)*282);

	var wrapperHeight = 282;

}





// Is there video? 

$('playerDiv').style.visibility = 'hidden';

if (reviewVideo == false){

	

	//Place first image into vplayer div

	$('vplayer').setHTML('');

	new Element('img', {

		'class': 'featureImage',

		'src': largeArray[0],

		'alt': altArray[0]

		}).injectInside($('vplayer'));

	

	// Media Gallery Display Options

	switch(thumbArray.length){

		

		case 0:

			$('mg_frame').setStyle('display', 'none');

			break;

		case 1:

			$('mg_frame').setHTML('<img src="'+oneImage+'" class="largeImage" alt="'+oneImageAlt+'" />');

			$('mg_frame').setStyle('height', '330px');

			break;

		case 2:

		case 3:

			$('vplayer').setStyles({

								 height: '257px',

								 background: 'url(http://i.i.com.com/cnwk.1d/i/vid/mg_background_short.jpg) no-repeat'

								 });

			$('mg_thumbs').setStyles({

								 height: '257px',

								 background: 'url(http://i.i.com.com/cnwk.1d/i/vid/mg_photo_bg_short.gif) no-repeat'

								 });

			$('mg_frame').setStyle('height', '257px');

			break;

	}

	

	

	thumbArray.splice(0,1);

	largeArray.splice(0,1);

	

}else{

	$('playerDiv').style.visibility = 'visible';

	

	if(thumbArray.length == 0){

		$('mg_thumbs').remove();

		$('vplayer').setStyles({

								marginLeft: '68px',

								'float': 'none',

								background: 'none'

								});

		$('mg_frame').setStyle('background', 'url(http://i.i.com.com/cnwk.1d/i/vid/mg_background_large.gif) no-repeat');

	}

}







if(thumbArray.length > 0){

	//Create thumbnails

	new Element('div', {

					'id': 'thumbScroller',

					'styles':{

						'width': '130px',

						'height': scrollHeight+'px',

						'overflow': 'hidden'

					}

					}).injectInside(new Element('div', {

										'id': 'thumbs',

										'styles':{

											'position': 'absolute',

											'height': wrapperHeight+'px',

											'width': '130px',

											'overflow': 'hidden'

										}

										}).injectAfter($('arrowUp')));

	

	

	for(a=0;a<thumbArray.length;a++){

		new Element('img', {

			'id': 'thumb'+a, 

			'class': 'imageTips',

			'src': thumbArray[a],

			'enlarge': largeArray[a],

			'alt': altArray[a]

			}).injectInside($('thumbScroller'));

	}





	// Scrolling

	if(thumbArray.length>3){

		$('arrowDown').setStyle('visibility', 'visible');

	}

	

	var scrollThumbs = new Fx.Scroll($('thumbs'), {

										wait: false,

										duration: 500,

										offset: {'x': 0, 'y': 0}

									 });

	

	var scrollGroup = 0;

	

	$('scrollDown').addEvent('click', function(event) {

		event = new Event(event).stop();

		

		if(Motivo == true){

			if(scrollGroup<(Math.ceil(thumbArray.length/2)-1)) scrollGroup+=1;

			else $('arrowDown').setStyle('visibility', 'hidden');

		}else{

			(scrollGroup<(Math.ceil(thumbArray.length/3)-1)) ? scrollGroup+=1 : scrollGroup=scrollGroup;

			if(scrollGroup == (Math.ceil(thumbArray.length/3)-1)) $('arrowDown').setStyle('visibility', 'hidden');

		}

		

		scrollThumbs.scrollTo(0, (wrapperHeight*scrollGroup));

		

		$('arrowUp').setStyle('visibility', 'visible');

	});

	

	$('scrollUp').addEvent('click', function(event) {

		event = new Event(event).stop();

		

		if(scrollGroup>0) scrollGroup-=1;

	

		scrollThumbs.scrollTo(0, (wrapperHeight*scrollGroup));

		

		$('arrowDown').setStyle('visibility', 'visible');

		if(scrollGroup == 0) $('arrowUp').setStyle('visibility', 'hidden');

	});



}

// pop up window for Photo Gallery
function openPDWindow(url1,url2) {
	// popUpWin = window.open('','productdemo','width=330,height=550,status=no,scrollbars=no,resizable=no,toolbar=no,left=200,screenX=200,top=100,screenY=100');
	popUpWin = window.open('','','width=640,height=480,status=no,scrollbars=yes,resizable=yes,toolbar=no,left=0,screenX=0,top=0,screenY=0');
	url = url1 + escape(url2);
	popUpWin.location = url;
	if (navigator.appName == 'Netscape') {
		popUpWin.focus();
	}
}

function popWin(url)
         {
         spawn = window.open(url,'newWin','width=640,height=480,top=0,left=0,location=no,toolbar=no,status=false,scrollbars=yes,resizable=no,fullscreen=no,menubar=no,directories=no');
         spawn.focus();
         }

function popWin2(url)
         {
         spawn = window.open(url,'newWin','width=480,height=640,top=0,left=0,location=no,toolbar=no,status=false,scrollbars=yes,resizable=no,fullscreen=no,menubar=no,directories=no');
         spawn.focus();
         }