// JavaScript Document

function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function langue(langue){
	setCookie('langue',langue,365);
	window.location.reload();
}


if(getCookie('langue')){ var lang = getCookie('langue'); }else{ if(document.domain == 'www.prise1.com'){ var lang = 'en'; }else{ var lang = 'fr'; } }


var timeOutMessage;
var divMessage;
var divMessageRemplacement = '';
var divMessageDisplay = 'none';
function afficherMessage(){
	
	if(afficherMessage.arguments[0] && afficherMessage.arguments[1]){
		clearTimeout(timeOutMessage);
		document.getElementById(afficherMessage.arguments[0]).innerHTML = afficherMessage.arguments[1];
		if(afficherMessage.arguments[3]){ display = afficherMessage.arguments[3]; }else{ display = 'block'; }
		document.getElementById(afficherMessage.arguments[0]).style.display = display;
		divMessage = afficherMessage.arguments[0];
		if(afficherMessage.arguments[2]){ timeout = afficherMessage.arguments[2]; }else{ timeout = 5000; }
		timeOutMessage = setTimeout('afficherMessage('+afficherMessage.arguments[0]+')', timeout);
		if(afficherMessage.arguments[4]){ divMessageRemplacement = afficherMessage.arguments[4]; }
		if(afficherMessage.arguments[5]){ divMessageDisplay = afficherMessage.arguments[5]; }
	}else{
		//if(afficherMessage.arguments[0]){ divMessage = afficherMessage.arguments[0]; }
		document.getElementById(divMessage).style.display = divMessageDisplay;
		document.getElementById(divMessage).innerHTML = divMessageRemplacement;
	}
	
}

function afficherCacher(id){

	if(document.getElementById(id)){
		if(document.getElementById(id).style.display == 'block' || document.getElementById(id).style.display == 'undefined'){
			document.getElementById(id).style.display = 'none';
		}else{
			document.getElementById(id).style.display = 'block';
		}
	}
}

//--- 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;
}


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 ---------//


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

function initialisation(){
	imgLoad();
	prise1Com();
	//boutonFisheye();
	//jwplayerError();
	setTimeout('getRelated()', 100);
	setTimeout('FisheyeAction()', 200);
	overPartageElements();
}

function prise1Com(){
	if(document.domain == 'www.prise1.com'){
		if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("MSIE")!=-1 || navigator.userAgent.indexOf("Chrome")!=-1 || navigator.userAgent.indexOf("Safari")!=-1 || navigator.userAgent.indexOf("Opera")!=-1){
			var lien = document.getElementsByTagName("a");
			for (i=0;i<lien.length;i++){
				lien[i].href = lien[i].href.replace(/prise1\.com/g, 'prise1.ca');
			}
		}
	}
}

var overVideoPartage = 0;

function envoyerVideo(langue){
	
	var courrielVisiteur = document.getElementById('courrielVisiteur').value;
	var courrielsAmis = document.getElementById('courrielsAmis').value
	var titre = document.getElementById('videoTitre').innerHTML;
	var description = document.getElementById('videoDescription').innerHTML;
	var url = document.getElementById('videoUrl').value;
	
	message1 = 'Envois de la vidéos en cours...';
	
	if(langue == 'en'){
		message1 = 'Posts in progress...'; 
	}

	afficherMessage('messagePartage', message1, 10000);
	
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) 
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) 
		{
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }
 
	xhr.onreadystatechange  = function()
	{ 
		 if(xhr.readyState  == 4)
		 {
				if(xhr.status  == 200){ 
					
					if(xhr.responseText!=''){
						
						afficherCacher('partager');
						afficherMessage('messagePartage', xhr.responseText);
						
						if(overVideoPartage == 1){ 
							afficherMessage('alternative', '<span style="margin-top:20px;font-weight:bold">'+xhr.responseText+'</span>');
						}
						
					}

				}
		 }
	}; 
	
	xhr.open( "POST", "ajax/envoyerVideo.php",  true); 
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("courrielVisiteur="+courrielVisiteur+"&courrielsAmis="+courrielsAmis+"&titre="+titre+"&description="+description+"&url="+url+"&langue="+langue); 


}


function envoyerVideoOutlook(){
	
	var courrielsAmis = document.getElementById('courrielsAmis').value
	courrielsAmis = courrielsAmis.replace(/\n/g, ';');
	courrielsAmis = courrielsAmis.replace(/,/g, ';');
	courrielsAmis = courrielsAmis.replace(/ /g, ';');
	courrielsAmis = courrielsAmis.replace(/;;;/g, ';');
	courrielsAmis = courrielsAmis.replace(/;;/g, ';');
	var titre = document.getElementById('videoTitre').innerHTML;
	
	message = 'Envois de la vidéos en cours...';
	afficherMessage('messagePartage', message);
	
	subject = 'Regarder cette video sur Prise1';

	if(langue == 'en'){
		subject = 'View this video on Prise1';
	}

	document.location.href = 'mailto:?to='+courrielsAmis+'&amp;subject='+subject+'&amp;body='+titre+'%0d%0a'+document.location.toString()+'&amp;cc=archive@prise1.ca';

}

function etoileVideo(note){
	
	document.getElementById('noteVideo').value = note;
	document.getElementById('noteForm').submit();
	
}


function flag(type, action, id){
	
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) 
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) 
		{
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }
 
	xhr.onreadystatechange  = function()
	{ 
		 if(xhr.readyState  == 4)
		 {
				if(xhr.status  == 200){ 
					
					if(xhr.responseText!=''){
						
						afficherMessage('messageAdmin', xhr.responseText);
						
					}

				}
		 }
	}; 
	
	xhr.open( "POST", "ajax/flag.php",  true); 
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send("type="+type+"&action="+action+"&id="+id); 

}


function addShare(){
	
	var title;
	var metas = document.getElementsByTagName('meta');
	for (var x=0,y=metas.length; x<y; x++) {
  		if (metas[x].name.toLowerCase() == 'title') {
    		title = metas[x];
  		}
	}
	
	url = encodeURIComponent(document.location.toString());
	share = 'http://sharertool.nerdzblog.com/partager.php?sharer=';
	opt = 'rel="nofollow" target="_blank"';
	title = title.content.replace('"', '&quot;');
	title = encodeURIComponent(title.replace("'", "\'"));
	document.getElementById('topShare').innerHTML = '<ul><li class="premier"><a '+opt+' class="facebook" href="'+share+'facebook&amp;url='+url+'">facebook</a></li><li><a '+opt+' class="twitter" href="'+share+'twitter&amp;url='+url+'&amp;title='+title+'">Twitter</a></li><li><a '+opt+' class="live" href="'+share+'live&amp;url='+url+'" target="_blank">Live</a></li><li><a '+opt+' class="buzz" href="'+share+'buzz&amp;url='+url+'">Buzz</a></li><li><a '+opt+' class="myspace" href="'+share+'myspace&amp;url='+url+'">Myspace</a></li><li><a '+opt+' class="digg" href="'+share+'digg&amp;url='+url+'">Digg</a></li><li><a '+opt+' class="sharertool" href="http://sharertool.nerdzblog.com/index.php?url='+url+'">Plus...</a></li></ul>';

}

function jaime(){
	
	url = encodeURIComponent(document.location.toString());
	obj = document.getElementById('jaime');
	obj.innerHTML = '<div style="text-align:left;width:120px;margin-left:468px;"><a rel="nofollow" href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="Prise1ca">Tweet</a></div><div style="margin-top:-27px;"><iframe src="http://www.facebook.com/plugins/like.php?href='+url+'&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=dark&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe></div>';
	
	obj.onmouseover = function(){ this.style.overflow = 'visible'; }//this.style.marginBottom = '-55px';
	obj.onmouseout = function(){ this.style.overflow = 'hidden'; }//this.style.marginBottom = '0px';
	js=document.createElement('script');
	js.setAttribute('type','text/javascript'); 
	js.setAttribute('src','http://platform.twitter.com/widgets.js'); 
	obj.parentNode.insertBefore(js, obj.nextSibling);
	
}


function onclickShare(sharer, url){
	window.open('http://sharertool.nerdzblog.com/partager.php?sharer='+sharer+'&amp;url='+url, '_blank');
}

function addShareLateral(){
	
	var title;
	var metas = document.getElementsByTagName('meta');
	for (var x=0,y=metas.length; x<y; x++) {
  		if (metas[x].name.toLowerCase() == 'title') {
    		title = metas[x];
  		}
	}
	
	title = title.content.replace('"', '&quot;');
	title = encodeURIComponent(title.replace("'", "\'"));
	
	if(document.body.offsetWidth<1054){ document.getElementById('sharer').style.display = 'none'; }
	url = encodeURIComponent(document.location.toString());
	
	var sharer = new Array('facebook', 'myspace', 'buzz', 'twitter', 'digg');
	inner = '';
	for(i=0;i<5;i++){
		if(sharer[i] == 'twitter'){ t = '&amp;title='+title; }else{ t = ''; }	
		inner += '<a rel="nofollow" href="http://sharertool.nerdzblog.com/partager.php?sharer='+sharer[i]+'&amp;url='+url+t+'" target="_blank"><img src="images/ico2/'+sharer[i]+'.png" alt="'+sharer[i]+'" /></a><br />';
	}
	document.getElementById('sharer').innerHTML = inner;
	
	if(navigator.userAgent.indexOf("Firefox")==-1){
		addShareLateral2();
	}
	
}

function addShareLateral2(){
	
	url = encodeURIComponent(document.location.toString());

	s1 = document.getElementById('sharer');
	
	js=document.createElement('ul');
	js.setAttribute('id','sharebar');
	js.setAttribute('style','display:none;');
	if(document.body.offsetWidth<1080){ js.setAttribute('style','display:none'); }else{ js.setAttribute('style','display:block'); }
	s1.parentNode.insertBefore(js, s1);
	
	if(document.getElementById('videoTitre')){ 
		bodyMail = document.getElementById('videoTitre').innerHTML+'%0d%0a'+document.location.toString(); 
	}else{
		bodyMail = document.location.toString();
	}
	
	if(document.getElementsByTagName('html')[0].getAttribute('lang') == 'en'){
		subject = 'View this video on Prise1';
	}else{
		subject = 'Regarder cette video sur Prise1';
	}
	
	
	js.innerHTML = '<li id="sbTw"><a target="_blank" href="http://twitter.com/share" class="twitter-share-button" data-count="vertical" data-via="Prise1ca">Tweet</a></li><li id="sbFb"><a target="_blank" name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php?u='+url+'">Share</a></li><li id="sbSt"><iframe src="http://www.stumbleupon.com/badge/embed/5/?url='+url+'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:50px; height: 60px;" allowTransparency="true"></iframe></li><li id="sbDi"><a target="_blank" class="DiggThisButton DiggMedium"></a></li><li id="sbBu"><a target="_blank" title="Post to Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count"></a></li><li><a href="mailto:?subject='+subject+'&amp;body='+bodyMail+'&amp;cc=archive@prise1.ca" class="sharebar-button email">Email</a></li>';

	//document.getElementById('sharebar').style.display = 'block';	
	
	var jsSrc = new Array('http://platform.twitter.com/widgets.js', 'http://www.stumbleupon.com/hostedbadge.php?s=5', 'http://widgets.digg.com/buttons.js', 'http://www.google.com/buzz/api/button.js');
	
	var jsID = new Array('sbTw', 'sbSt', 'sbDi', 'sbBu');
	
	for(i=0;i<jsSrc.length;i++){
	
		js=document.createElement('script');
		js.setAttribute('type','text/javascript'); 
		js.setAttribute('src',jsSrc[i]); 
		js.setAttribute('async',true);
		s1 = document.getElementById(jsID[i]);
		s1.parentNode.insertBefore(js, s1);
		
	}
	
	if( document.documentElement ){
		doc = document.documentElement;
	}else{
		doc = document.body;
	}

	//<script type="text/javascript">jQuery(document).ready(function($) { $('.sharebar').sharebar({horizontal:'false',swidth:'65',minwidth:1000,position:'left',leftOffset:20,rightOffset:10}); });</s cript>

	
}

if( document.documentElement ){
	doc = document.documentElement;
}else{
	doc = document.body;
}

if(document.getElementById('sharer') && document.getElementById('sharebar')){
	
	window.onscroll = function(){  if(doc.scrollTop<254){ document.getElementById('sharer').style.top = document.getElementById('sharebar').style.top = 254 - doc.scrollTop; } }


	window.onresize = function(){ 
		if(document.body.offsetWidth<1054){ document.getElementById('sharer').style.display = 'none'; }else{ document.getElementById('sharer').style.display = 'block'; } 
		if(document.body.offsetWidth<1080){ document.getElementById('sharebar').style.display = 'none'; }else{ document.getElementById('sharebar').style.display = 'block'; }
	}

}

function overPartageElements(){
	
	if(document.getElementById("alternative")){
		v1 = document.getElementById('courrielVisiteur').value;
		js1=document.createElement('input');
		js1.setAttribute('id','overCourrielVisiteur');
		js1.setAttribute('class', 'overCourrielVisiteur');
		js1.setAttribute('type','text');
		js1.setAttribute('name','overCourrielVisiteur');
		js1.setAttribute('value',v1);
		js1.setAttribute('onblur','if(this.value==\'\'){ this.value = \''+v1+'\'; }');
		js1.setAttribute('onfocus','if(this.value==\''+v1+'\'){ this.value = \'\'; }');
		
		v1 = document.getElementById('courrielsAmis').value;
		js2=document.createElement('textarea');
		js2.setAttribute('id','overCourrielsAmis');
		js2.setAttribute('class', 'overCourrielsAmis');
		js2.setAttribute('name','overCourrielsAmis');
		js2.setAttribute('onblur','if(this.value==\'\'){ this.value = \''+v1+'\'; }');
		js2.setAttribute('onfocus','if(this.value==\''+v1+'\'){ this.value = \'\'; }');
		js2.innerHTML = v1;
		
		v1 = document.getElementById('boutonEnvoyerPHP').value;
		js3=document.createElement('input');
		js3.setAttribute('id','overBoutonEnvoyerPHP');
		js3.setAttribute('class', 'overBoutonEnvoyerPHP');
		js3.setAttribute('type','button');
		js3.setAttribute('name','overBoutonEnvoyerPHP');
		js3.setAttribute('onclick', 'document.getElementById(\'courrielVisiteur\').value = document.getElementById(\'overCourrielVisiteur\').value; document.getElementById(\'courrielsAmis\').value = document.getElementById(\'overCourrielsAmis\').value; envoyerVideo(\''+lang+'\'); setTimeout(\'fermerPartager()\', 2000)');
		js3.setAttribute('value',v1);
			
			
		s1 = document.getElementById('partageVideo');
		js=document.createElement('div');
		js.setAttribute('id','overShareTool');
		js.setAttribute('class','overShareTool');
		s1.parentNode.insertBefore(js, s1);
		
		document.getElementById("overShareTool").innerHTML = '<a href="http://sharertool.nerdzblog.com/partager.php?sharer=facebook&url='+url+'" target="_blank"><img src="images/ico3/facebook.png" border="0"></a> <a href="http://sharertool.nerdzblog.com/partager.php?sharer=twitter&url='+url+'" target="_blank"><img src="images/ico3/twitter.png" border="0"></a> <a href="http://sharertool.nerdzblog.com/partager.php?sharer=buzz&url='+url+'" target="_blank"><img src="images/ico3/buzz.png" border="0"></a> <a href="http://sharertool.nerdzblog.com/partager.php?sharer=myspace&url='+url+'" target="_blank"><img src="images/ico3/myspace.png" border="0"></a> <a href="http://sharertool.nerdzblog.com/partager.php?sharer=digg&url='+url+'" target="_blank"><img src="images/ico3/digg.png" border="0"></a>';
	}
	
}

function fermerPartager(){
	document.getElementById('partager').style.display = 'none';
}


function onStopPlayer(){
							
	overVideoPartage = 1;
	
	url = encodeURIComponent(document.location.toString());
	
	if(lang == 'en'){ m='<strong>Share this video with your friends.</strong><br />'; }else{ m='<strong>Partagez cette vidéo avec vos ami(e)s.</strong><br />'; }
	
	document.getElementById("alternative").setAttribute('class', 'overVideoShare');
	document.getElementById("alternative").innerHTML = m;
	document.getElementById("alternative").appendChild(js1);
	document.getElementById("alternative").appendChild(js2);
	document.getElementById("alternative").appendChild(js3);
	document.getElementById("alternative").style.display = 'block';
	document.getElementById("overShareTool").style.display = 'block';
	
	document.getElementById("overCourrielsAmis").blur;
	//'<a href="http://sharertool.nerdzblog.com/partager.php?sharer=facebook&url='+url+'" target="_blank"><img src="images/ico2/facebook.png" border="0"></a> <a href="http://sharertool.nerdzblog.com/partager.php?sharer=twitter&url='+url+'" target="_blank"><img src="images/ico2/twitter.png" border="0"></a>'
	
}


//var videoActive = 0;

function video(id, w, h, a){
	
	//videoActive = 1;
	
	var url = encodeURIComponent(document.location.toString());
	var site = encodeURIComponent('http://www.prise1.ca/');
	
	if(id.length == 11){ 
		
		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",
				wmode: "transparent",
				//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&wmode=transparent" 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';
					}
					

				}
			});
			
			
		}
		
	}else{  
	
		document.getElementById('videoplayer').innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+w+'" height="'+h+'" title="prise1"><param name="movie" value="mediaplayer.swf?v='+id+'"></param><param name="quality" value="high"></param><param name="allowScriptAccess" value="always"></param><param name="allowNetworking" value="all"></param><param name="allowfullscreen" value="true"></param><embed src="mediaplayer.swf?v='+id+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all" allowfullscreen="true" width="'+w+'" height="'+h+'"></embed></object>';
	
	}

	
}

/*
function initVideo(){
	if(videoActive == 0){
		video();
	}
}

setTimeout(video, 2000);
*/

function embed(id){
	
	url = document.location.toString();
	document.getElementById('embed').innerHTML = '<textarea class="form_action" name="codeembed" id="codeembed" title="Code Video [Embed]" onclick="this.focus(); this.select();" onfocus="copyToClipboard(this.value);">&lt;object classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0&quot; width=&quot;450&quot; height=&quot;360&quot; title=&quot;prise1&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.prise1.com/mediaplayer.swf?v='+id+'&quot;&gt;&lt;/param&gt;&lt;param name=&quot;quality&quot; value=&quot;high&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowScriptAccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowNetworking&quot; value=&quot;all&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowfullscreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.prise1.com/mediaplayer.swf?v='+id+'&quot; quality=&quot;high&quot; pluginspage=&quot;http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&quot; type=&quot;application/x-shockwave-flash&quot; allowScriptAccess=&quot;always&quot; allowNetworking=&quot;all&quot; allowfullscreen=&quot;true&quot; width=&quot;450&quot; height=&quot;360&quot;&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style=&quot;text-align:center;background-color:#DFDFDF;border-bottom:1px solid #ABABAB;border-right:1px solid #ABABAB;border-left:1px solid #ABABAB;width:448px&quot;&gt;&lt;a style=&quot;font-family:Arial;color:#000000;text-decoration:none;font-size:10px&quot; href=&quot;'+url+'&quot; target=&quot;_blank&quot; title=&quot;Vid&eacute;os Prise1&quot;&gt;&lt;strong&gt;'+url+'&lt;/strong&gt;&lt;/a&gt;&lt;/div&gt;</textarea>';
	
}

function supplements(v, user, langue){
	
	var xhr; 
	try {  xhr = new ActiveXObject('Msxml2.XMLHTTP');   }
	catch (e) 
	{
		try {   xhr = new ActiveXObject('Microsoft.XMLHTTP');    }
		catch (e2) 
		{
		  try {  xhr = new XMLHttpRequest();     }
		  catch (e3) {  xhr = false;   }
		}
	 }
 
	xhr.onreadystatechange  = function()
	{ 
		 if(xhr.readyState  == 4)
		 {
				if(xhr.status  == 200){ 
					
					if(xhr.responseText!=''){
						
						if(v!=''){ 
							document.getElementById('around_news').innerHTML = xhr.responseText;
						}
						if(user!=''){
							document.getElementById('around_popular').innerHTML = xhr.responseText;
						}
						
					}

				}
		 }
		 
	}; 

   xhr.open( "POST", "ajax/supplements.php",  true); 
   xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   xhr.send("v="+v+"&user="+user+"&langue="+langue); 
	
	
}


function getRelated(){
	
	if(document.getElementById('around_news')){
		var div = document.getElementById('around_news');
		if(div.getElementsByTagName('img')){
			var img = div.getElementsByTagName('img');
			var listeVid = '';
			var y = 0;
			for(i=0;i<img.length;i++){
				if(img[i].rel){ url = img[i].rel; }else{ url = 'http://www.prise1.ca/'+img[i].src.match(/[a-zA-Z0-9\-_]{11}/); }
				listeVid += '<a class="fisheyeItem" href="'+url+'" title="'+img[i].alt+'"><img src="'+img[i].src+'" alt="'+img[i].alt+'" /><span>&nbsp;</span></a>'; y++;
				if(i>10){ break; }
			}
			if(y>=1){ 
				obj = document.getElementById('themaVideo');
				div=document.createElement('div');
				div.setAttribute('id','fisheye'); 
				div.setAttribute('class','fisheye'); 
				obj.parentNode.insertBefore(div, obj.nextSibling);
				document.getElementById('fisheye').innerHTML = '<div id="listeVid" class="fisheyeContainter">'+listeVid+'</div>';
			}
		}
		
		var videoTitre = document.getElementById('videoTitre').innerHTML;
		var div = document.getElementById('listeVid');
		var img = div.getElementsByTagName('img');
		for(i=0;i<img.length;i++){
			img[i].onmouseover = function(){ document.getElementById('videoTitre').innerHTML = this.alt; };
			img[i].onmouseout = function(){ document.getElementById('videoTitre').innerHTML = videoTitre; };
		}
		
	}else{
		setTimeout('getRelated()', 100);
		setTimeout('FisheyeAction()', 200);
	}
	
}

function getUser(){
	
	if(document.getElementById('around_popular')){
		var div = document.getElementById('around_popular');
		if(div.getElementsByTagName('img')){
			var img = div.getElementsByTagName('img');
			var listeVid = '';
			var y = 0;
			for(i=0;i<img.length;i++){
				if(img[i].rel){ url = img[i].rel; }else{ url = 'http://www.prise1.ca/'+img[i].src.match(/[a-zA-Z0-9\-_]{11}/); }
				listeVid += '<a class="fisheyeItem" href="'+url+'" title="'+img[i].alt+'"><img src="'+img[i].src+'" alt="'+img[i].alt+'" /><span>&nbsp;</span></a>'; y++;
				if(i>10){ break; }
			}
			if(y>=1){ 
				document.getElementById('listeVid').innerHTML = listeVid;
			}
		}
		
		var videoTitre = document.getElementById('videoTitre').innerHTML;
		var div = document.getElementById('listeVid');
		var img = div.getElementsByTagName('img');
		for(i=0;i<img.length;i++){
			img[i].onmouseover = function(){ document.getElementById('videoTitre').innerHTML = this.alt; };
			img[i].onmouseout = function(){ document.getElementById('videoTitre').innerHTML = videoTitre; };
		}
		
	}else{
		setTimeout('getRelated()', 100);
		setTimeout('FisheyeAction()', 200);
	}
	
}

function FisheyeAction()
{
	jQuery('#fisheye').Fisheye(
		{
		maxWidth: 80,
		items: 'a',
		itemsText: 'span',
		container: '.fisheyeContainter',
		itemWidth: 40,
		proximity: 20,
		halign : 'center'
		}
	)
	imgLoad();
}

function boutonFisheye(){
	
	elm = document.getElementById('themaVideo');
	div=document.createElement('div');
	div.setAttribute('id','boutonFisheye'); 
	obj.parentNode.insertBefore(div, obj.nextSibling);
	document.getElementById('boutonFisheye').innerHTML = '<a href="javascript:;" onclick="getUser()">User</a>';
	
}
