// JavaScript Document


//--- MouseOver Youtube Images ---------//
//--- www.dynamiquegestion.com ---------//
//--- Patrick Potvin -------------------//
//--- Développeur php/js/vb/flash... ---//


var docIMG;
var idIMG;
var numIMG = 1;
var tIMG;	

function imgStatutNumero(){
	var n = new Array(0,3,1,2);
	docIMG.src = 'http://i.ytimg.com/vi/'+idIMG+'/'+n[numIMG]+'.jpg';
	numIMG++;
	imgOver();
}

function imgOver(){

	if(imgOver.arguments.length>=1){
		docIMG = imgOver.arguments[0];
		var reg=new RegExp("[a-zA-Z0-9\-_]{11}","i");
		idIMG = docIMG.src.match(reg);
	}

	if(numIMG>3){
		numIMG = 1;
	}
	tIMG = setTimeout(imgStatutNumero, 600);

}

function imgOut(){
	clearTimeout(tIMG);
	if(docIMG){
		docIMG.src = 'http://i.ytimg.com/vi/'+idIMG+'/2.jpg';
	}
	numIMG=1;
}


if (window.addEventListener){
	window.addEventListener('load', imgLoad, false);
}else if (window.attachEvent){
	window.attachEvent('onload', imgLoad);// IE
}else{
	window.onload = imgLoad();
}

function imgLoad(){
	var obj = new Array();
	var srcIMG = new Array();
	var reg=new RegExp("[a-zA-Z0-9\-_]{11}","i");
	var youtubeImg = document.getElementsByTagName("img");
	for (i=0;i<youtubeImg.length;i++){
		if(youtubeImg[i].src.indexOf('ytimg')!=-1){
			youtubeImg[i].onmouseover = function(){ imgOver(this); };
			youtubeImg[i].onmouseout = function(){ imgOut(); };
		}
	}

}

//--- MouseOver Youtube Images ---------//

function video(id, w, h, a){

	var url = encodeURIComponent(document.location.toString());
	var site = encodeURIComponent('http://www.anti-social.ca/');
	
	
	if(document.getElementById("videoplayer")){

		jwplayer("videoplayer").setup({
			flashplayer: "http://www.prise1.ca/player.swf",
			file: id,
			height: h,
			width: w,
			autostart: true,
			controlbar: "bottom",
			screencolor: "000000",
			allowscriptaccess: "never",
			allowNetworking: "internal",
			//logo: site+"images/playerlogo.png",
			events: {					
			
				onError: function() {
					document.getElementById("alternative").style.display = 'block';
					document.getElementById("videoplayer").style.display = 'none';
					document.getElementById("alternative").innerHTML = '<iframe title="YouTube video player" width="'+w+'" height="'+h+'" src="http://www.youtube.com/embed/'+id+'?rel=0&amp;autoplay=1" frameborder="0" allowfullscreen></iframe>';
					document.getElementById("alternative").style.marginTop = '30px';
				}
				/*,
				
				onComplete: function() {
					onStopPlayer();
				},
				
				onPause: function() {
					onStopPlayer();
				},
				
				onPlay: function() {
					document.getElementById("alternative").style.display = 'none';
					document.getElementById("overShareTool").style.display = 'none';
				}
				*/
				
			}
		});
		
		
	}
		
	

	
}

