﻿// JavaScript Document
var videos=null;
var favorites=null;
var nbVideos=0;
var lastVideo=-1;
var sources=['videos_home','videos_home','videos_home','videos_home','videos_home','videos_home','videos_home','videos_home','videos_home'];
var keyw='';
var barstatus=0;
var category=-1;
var page=1;
var selectedSeaarchCat="";
var videoList=null;
var actualTestimony=0;
var cptTestimony=0;
var totalTestimony=0;
var dest='';

jQuery.fn.blindToggle = function(speed, easing, callback,state) {
var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
barstatus=state;
//return this.animate({marginTop: parseInt(this.css('marginTop')) <offset ? offset : offset-h+20}, speed, easing, callback);  
return this.animate({marginTop: parseInt(this.css('marginTop')) <0 ? 0 : 0-h}, speed, easing, callback);  
};

jQuery.fn.blindOn = function(speed, easing, callback,state) {
var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
barstatus=state;
//return this.animate({marginTop: parseInt(this.css('marginTop')) <offset ? offset : offset-h+20}, speed, easing, callback);  
return this.animate({marginTop: 0 }, speed, easing, callback);  
};

jQuery.fn.blindOff = function(speed, easing, callback,state) {
var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
barstatus=state;
//return this.animate({marginTop: parseInt(this.css('marginTop')) <offset ? offset : offset-h+20}, speed, easing, callback);  
return this.animate({marginTop:  0-h}, speed, easing, callback);  
};

function waitPhoto(duree)
{
	if (duree>0)
	{
		var total=duree-1;
		window.setTimeout('waitPhoto('+total+')',100);
	}
}

function updateNextPrev(dir)
{
	
	lastVideo+=dir;
	var i=lastVideo;
	
	
		var description2=videos.items[i].description;
		var title=videos.items[i].title;
		if ($('#upTitle')) {
			$('#upTitle').html(title);
			$('#innerTicker').html('<marquee scrollamount="2" behavior="scroll" direction="left" width="230">NOW PLAYING: <strong>'+title+'</strong></marquee>');
			placeMarquee();
		}
		var thumb=videos.items[i].logoUrl;
		if (!thumb)
		{
			thumb='http://www.bezoom.be/admin/thumbnails/logos/'+videos.items[i].customerId+'.jpg';
		}
		var url=videos.items[i].website;
		if ((!url)||(url==''))
		url='#';
		try {
		$('title').html(title);
		} catch (ex) {}
		var order=videos.items[i].order;
		var code=videos.items[i].customerId;
		var website=videos.items[i].website;
		var email=videos.items[i].email;
		var tel=videos.items[i].tel;
		var fax=videos.items[i].fax;
		var fileurl=videos.items[i].fileUrl;
		var tgpurl=fileurl.replace('.flv','.3gp').replace('.m4v','.3gp').replace('.mp4','.3gp');
		var testurl=tgpurl
		tgpurl=tgpurl.replace('http://video.proximedia.com/','http://www.bezoom.tv/3gp.asp?TheName='+escape(title)+'&TheFile=D:/MMS/bezoom/');
		testurl=testurl.replace('http://video.proximedia.com/','http://www.bezoom.tv/Services/3gp.asp?My3gpPath=D:/MMS/bezoom/');
		
		
		
		var tgpdata1='';
		var tgpdata2='';
		
		var tgpresult=0;
		
		tgpresult = $.ajax({
  			async: false, 
  			url: '/fr/test-gsm',
			data: 'url='+escape(testurl)
 }).responseText;
		
		if (tgpresult==1) {
		
			tpgurl = $.ajax({
				async: false,
				url: '/fr/test-gsm',
				data: 'url='+escape(tgpurl)
	 }).responseText;
			
			if (tpgurl!='')
			{
				tgpdata1='<a href="'+tgpurl+'" target="_blank">'+txt_telecharger+' <img src="/media/images/picto3gp.png" class="inlineBlock"  border="0" alt="'+txt_telecharger+'" title="'+txt_telecharger+'"/></a> ';
					tgpdata2='<a href="'+tgpurl+'" target="_blank"><img src="/media/v2/images/share-3g.png" class="inlineBlock"  border="0" alt="'+txt_telecharger+'" title="'+txt_telecharger+'"/> '+txt_telecharger+'</a> ';
			}
		
		}
		
		

		updateCloud(i);
		
		
		//alert('a');
		try {
		if ((lastVideo-dir)!=-1)
		{
			//document.getElementById('playlistItem'+lastVideo).style.backgroundImage='url(/media/images/background-playlist-off.png)';
			document.getElementById('playlistItem'+(lastVideo+1)).style.backgroundColor='#141414';
		
			$('#playlistItem'+(lastVideo-dir)).css('border-bottom','1px solid #262626');
			$('#playlistItem'+(lastVideo-dir)+' strong').css('color','#07cdff');
			$('#playlistItem'+(lastVideo-dir)+' span').css('color','white');
		}
		document.getElementById('playlistItem'+lastVideo).style.backgroundColor='#454444';
		
			$('#playlistItem'+lastVideo).css('border-bottom','1px solid #262626');
		//document.getElementById('playlistItem'+lastVideo).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		$('#playlistItem'+lastVideo+' strong').css('color','#07cdff');
		$('#playlistItem'+lastVideo+' span').css('color','white');
		} catch (ex)
		{
		}
		
		
		if (url=='#')
			$('#thumbLink').attr('target','_self');	
		else
			$('#thumbLink').attr('target','_blank');	
		$('#thumbLink').attr('href',url);
		$('#thumbPhoto').css('display','inline-block');

		//var tmpPhoto = new Image(); 
		//tmpPhoto.src = thumb; 
		//$('#thumbPhoto').attr('src',thumb);
		$('#thumbPhoto').attr('src','/fr/resizer?url='+thumb);
		//waitPhoto(5);
		
		//if (tmpPhoto.width>=60)
		//{
			//$('#thumbPhoto').css('width','60px');
			//$('#thumbPhoto').attr('src',thumb);
		//}
		//else
		//{
			//$('#thumbPhoto').css('width',tmpPhoto.width+'px');
			//$('#thumbPhoto').attr('src',thumb);
		//}

		//waitPhoto(5);
		//$('#thumbPhoto').attr('alt',title);
		$('#thumbPhoto').attr('title',title);
		$('#thumbTitle').html(title);
		if (thumb!='http://medias.bezoom.tv/')
		{
			 $('#thumbLink').css('display','block');
			$('#thumbBorders').css('border-color','#3c3c3c');
		}
		else
		{
			 $('#thumbLink').css('display','none');
			$('#thumbBorders').css('border-color','#111111');
		}
		if ($('#titleMap')) $('#titleMap').html(title);
	
		if(document.getElementById('GoogleApiMap')) {
			//document.getElementById('GoogleApiMap').style.display='block';
			loadgmap(i,videos,category);
		}
		
				
				
				
		/*var host=document.location.href;
		host=host.split('?');
		host=host[0];*/
		
		var host=document.location.href;
		host=host.split('/');
		host=host[0]+'//'+host[2];
		
				
		var tmpVid={'id':videos.items[i].customerId, 'order':videos.items[i].order, 'url':videos.items[i].fileUrl, 'position':i, 'count':videos.items.length,'idvodep':videos.items[i].id};
		
		
		
		$('#linklist').html('<div id="topitem"><a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'\',\''+videos.items[i].thumbUrl+'\'); " href="javascript:void(0);">'+txt_ami+' <img src="/media/images/pictoAmi.png"  style="border:0;" alt="'+txt_ami+'" title="'+txt_ami+'" class="inlineBlock"/></a> '+tgpdata1+'<a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'&t=Bezoom.tv&d=Beezom" target="blank_">'+txt_facebook+' <img src="/media/images/pictofb.png"  style="border:0;" alt="'+txt_facebook+'" title="'+txt_facebook+'" class="inlineBlock"/></a></div>');
		
		
		
		if ($('#quickLinks'))
		{
			$('#quickLinks').html('<img src="/media/v2/images/top-share.png" alt="" title="" style="display:block;"/><a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'&t=Bezoom.tv&d=Beezom" target="blank_"><img src="/media/v2/images/share-facebook.png"  style="border:0;" alt="'+txt_facebook+'" title="'+txt_facebook+'" class="inlineBlock"/> Facebook</a> <a class="addthis_button_twitter" addthis:url="'+host+'?id='+videos.items[i].id+'"><img src="/media/v2/images/share-twitter.png"  style="border:0;" alt="'+txt_twitter+'" title="'+txt_twitter+'" class="inlineBlock"/> Twitter</a> <a href="javascript:void(0);" onclick="embed(\''+escape(JSON.stringify(tmpVid))+'\');" ><img src="/media/v2/images/share-embed.png"  style="border:0;" alt="" title="" class="inlineBlock"/> Embed</a> <a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'\',\''+videos.items[i].thumbUrl+'\'); " href="javascript:void(0);"><img src="/media/v2/images/share-email.png" style="border:0;" alt="'+txt_ami+'" title="'+txt_ami+'" class="inlineBlock"/> '+txt_email_video+'</a>  '+tgpdata2+'<a href="javascript:void(0);" onclick="addFavorite();"><img src="/media/v2/images/share-favorite.png" class="inlineBlock"  border="0" alt="'+txt_add_favoris+'" title="'+txt_add_favoris+'"/> '+txt_add_favoris+'</a><img src="/media/v2/images/bottom-share.png" alt="" title="" style="display:block;"/><div style="background-color:#111111; padding-top:9px;"><div style="background-color:#1c1c1c; background: url(/media/v2/images/background-share.png) repeat-y;"><img src="/media/v2/images/top-share.png" alt="" title="" style="display:block;"/><a href="javascript:void(0);" onclick="createFavorite();"><img src="/media/v2/images/createFavoris.png" class="inlineBlock"  border="0" alt="'+txt_create_favoris+'" title="'+txt_create_favoris+'"/> '+txt_create_favoris+'</a><img src="/media/v2/images/bottom-share.png" alt="" title="" style="display:block;"/></div></div>');
			var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
		try {
			if (addthis) addthis.init();
			} catch (ex) {
			}
		}
		
		
		$("#content").bind("mousemove", function(e) { 
			var o=$('#innerVideo').offset();
			if (o) {
			var test1=parseInt($('#topitem').css('margin-top'))==0;
			var test2=(e.pageX>o.left);
			var test3=(e.pageX<(o.left+$('#innerVideo').width()));
			var test4=(e.pageY>o.top);
			var test5=(e.pageY<(o.top+$('#innerVideo').height()));
			var test6=!(test2&&test3&&test4&&test5);
			var test7=test6&&test1;
			if (test7)
			{
				
				if (barstatus==1) $('#topitem').blindOff('normal','linear',swapBarStatus2(''),0);	
			}
			if ((test6==false)&&(parseInt($('#topitem').css('margin-top'))==-46))
			{	
				if (barstatus==0) $('#topitem').blindOn('normal','linear',swapBarStatus(''),1);
				//$('#info').html('test'+e.pageX+' '+barstatus);
			}
			}
		});
		
		$('#description').html('');
		try {
		document.getElementById('description').innerHTML=''; 
		} catch (ex) {}
		if ((description2)&&(description2!=null)&&(description2!='null'))
		{
			$('#description').html(description2);
		    if ((keyw!='')&&(keyw))
			{	
				
				var ohtml=$('#description').html();
				var ex=new RegExp('('+keyw.replace(/\s/gi,'|')+')','gi');
	 			var nhtml=ohtml.replace(ex,'<span style="background-color:#00ccff;">$1</span>');
	    		$('#description').html(nhtml);
				$('input.keyword').each(function(i) {
						this.value=keyw;							 
				});
			}
			else
			{
				$('#description').html(description2);
			}	
		}
		else
		{
			$('#description').html('');
		}
		if ((videos.items[i].street)&&(videos.items[i].street!=null)&&(videos.items[i].street!='null')&&(videos.items[i].postcode)&&(videos.items[i].postcode!=null)&&(videos.items[i].postcode!='null')&&(videos.items[i].city)&&(videos.items[i].city!=null)&&(videos.items[i].city!='null')&&(videos.items[i].country)&&(videos.items[i].country!=null)&&(videos.items[i].country!='null'))
		{
			$('#addres').html(videos.items[i].street+'<br/>'+videos.items[i].postcode+' '+videos.items[i].city+'<br/>'+videos.items[i].country);
		}
		else
			$('#addres').html('');
		var linksHTML="";
		if ((tel)&&(tel!=null)&&(tel!='null'))
		{
			linksHTML+=' tel:'+tel+'<br/>';
		}
		if ((fax)&&(fax!=null)&&(fax!='null'))
		{
			linksHTML+=' fax:'+fax+'<br/>';
		}
		if ((website)&&(website!=null)&&(website!='null'))
		{
			
			if (website.search(/http/i)>-1)
			{
				linksHTML+='<a href="'+website+'" class="inlineBlock" target="_blank" >'+website+'</a>';
			}
			else
				linksHTML+='<a href=http://"'+website+'" class="inlineBlock" target="_blank" >'+website+'</a>';
		}
		if ((email)&&(email!=null)&&(email!='null'))
		{
			linksHTML+='<a href="mailto:'+email+'"  class="inlineBlock">'+email+'</a>'
		}
		$('#links').html(linksHTML);
	
	

		var vidObj={'id':code, 'order':order, 'url':fileurl, 'position':lastVideo, 'count':videos.items.length};	


	
		return vidObj;
}

function next()
{
	if (lastVideo<videos.items.length-1)
	{
		return updateNextPrev(1);
	}
	else
	{
		lastVideo=0;
		swapVideo(0);
	}
	return null;
}

function previous()
{
	if (lastVideo>0)
	{
		return updateNextPrev(-1);
	}
	return null;
}



function updateCloud(vid)
{
	try {
	if ($('#tagcloud'))
	{
	
		var taghtml='';
		var tags=videos.items[vid].keywords;
		
		var updateClickKey='';
		var updateClickForm='';
		
		updateClickKey='keyword2';
		updateClickForm='videoForm';
		
		var detecting=document.location.href;
		var reg=/http:\/\/([a-zA-Z0-9.-]+)\/(en|fr|nl|de)\/search\?keyword=(.*)&catv=([0-9]*)/gi
		if (m=reg.exec(detecting))
		{
			updateClickKey='keyword2';
			updateClickForm='videoForm';
		}
		
		if (tags!=null)
		{

			for(var i=0;i<tags.length;i++)
			{
				
				taghtml+='<a href="javascript:void(0);" onclick="javascript:$(\'#'+updateClickKey+'\').attr(\'value\',\''+tags[i].tag+'\'); document.forms[\''+updateClickForm+'\'].submit();" class="tag'+tags[i].indice+'">'+((tags[i].tag==activeKeyword1)||(tags[i].tag==activeKeyword2)?'<strong>':'')+tags[i].tag+((tags[i].tag==activeKeyword1)||(tags[i].tag==activeKeyword2)?'</strong>':'')+'</a> (<span>'+tags[i].frequency+'</span>) &nbsp;';
			}
			//taghtml+=tags;
			
		}
		
		if ((taghtml!='<a href="javascript:void(0);" onclick="javascript:$(\'#'+updateClickKey+'\').attr(\'value\',\'\'); document.forms[\''+updateClickForm+'\'].submit();" class="tag1"></a> (<span></span>) &nbsp;')&&(taghtml!=''))
		{
			$('#tagcloud').css('display','inline-block');
		
		}
		else
		{
			//$('#tagcloud').css('display','none');
			$('#tagcloud').css('display','inline-block');
			taghtml='<a href="javascript:void(0);" onclick="javascript:$(\'#keyword2\').attr(\'value\',\'video\'); document.forms[\'videoForm\'].submit();" class="tag3">video</a> (<span>3</span>) &nbsp;<a href="javascript:void(0);" onclick="javascript:$(\'#keyword2\').attr(\'value\',\'corporate\'); document.forms[\'videoForm\'].submit();" class="tag3">corporate</a> (<span>3</span>) &nbsp;<a href="javascript:void(0);" onclick="javascript:$(\'#keyword2\').attr(\'value\',\'bezoom\'); document.forms[\'videoForm\'].submit();" class="tag5">bezoom</a> (<span>5</span>) &nbsp;<a href="javascript:void(0);" onclick="javascript:$(\'#keyword2\').attr(\'value\',\'tv\'); document.forms[\'videoForm\'].submit();" class="tag2">tv</a> (<span>2</span>) &nbsp;';
		}
		taghtml='<img src="/media/v2/images/top-cloud.png" style="border:0; display:block;" width="310" height="16"/><div>'+taghtml+'</div><img src="/media/v2/images/bottom-cloud.png" style="border:0; display:block;" width="310" height="5"/>';
		$('#tagcloud').html(taghtml);
		
	}
	}
	catch (ex) {
		//alert('error updating tagcloud');
	}
}

function getTagsCloud(vid)
{
	try {
	document.write('<section id="tagcloud">');
	document.write('</section>');
	//$.getJSON('/fr/getTags',function(tags) {
	updateCloud(vid);
	//});
	}
	catch (ex) {
		//alert('error getting tagcloud');
	}
}


function startCategory(vids,source)
{
	
	try {
	category=source;
	videos=vids;
		var html="";
  barstatus=0;
  	$('nav#categoryNav a').removeClass('on');
	   

	$('nav#categoryNav a#nav'+source).addClass('on');



					nbVideos=videos.items.length;
					$('#thumblist').html('');

					html+='<div class="plsmall" id="pl">';
					
					for(var i=0;i<videos.items.length;i++)
					{
						
						var customer='';
						try {
							customer=videos.items[i].customer.name;
							customer=customer.replace('\'','&rsquo;');
						}
						catch(ex) {
							customer='';
						}
						var img='';
						if (videos.items[i].thumbUrl)
							img='<img src="'+videos.items[i].thumbUrl+'" width="96" height="53"  id="imgvid'+i+'" onerror=" this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\'; " align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';
						else
							img='<img src="/media/v2/images/nothumb.png" width="96" height="53"  id="imgvid'+i+'" onerror="  this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\'; " align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';
						html+='<div class="pli inlineBlock" id="playlistItem'+i+'" onclick="swapVideo('+i+');" onmouseover="playlist_on('+i+',event);" onmouseout="playlist_off('+i+',event);"><div class="subbar" onclick="annulEvent(event);"><a href="javascript:void(0);" onclick="swapVideo('+i+');"><img src="/media/v2/images/info.png" alt="'+txt_info+'" title="'+txt_info+'"  style="border:0;"/></a><a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'\',\''+videos.items[i].thumbUrl+'\'); " href="javascript:void(0);"><img src="/media/v2/images/send-mail.png" alt="'+txt_email_video+'" title="'+txt_email_video+'" style="border:0;"/></a><a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'&t=Bezoom.tv&d=Beezom" target="_blank"><img src="/media/v2/images/send-facebook.png" alt="'+txt_facebook+'" title="'+txt_facebook+'"/></a><a class="addthis_button_twitter" addthis:url="'+host+'?id='+videos.items[i].id+'"><img src="/media/v2/images/send-twitter.png"  style="border:0;" alt="'+txt_twitter+'" title="'+txt_twitter+'"/></a></div>'+img+'<div class="inlineBlock playListTitle"><strong  onmouseout="annulEvent(event)" onmouseover="annulEvent(event)">';
						var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
	try {
	if (addthis) addthis.init();
	} catch (ex) {
	}
						var titletest='';
						
						
						
						
						//if (videos.items[i].customerName)
						//	titletest=videos.items[i].customerName;
						//else
							titletest=videos.items[i].title.replace('\'','&rsquo;');
						html+=titletest;
						html+='</strong>';
						//if (titletest!=videos.items[i].title.replace('\'','&rsquo;'))
						//{
							html+='<span  onmouseout="annulEvent(event)">';
							try {
							html+='<br/>'+videos.items[i].shortdescr.replace('\'','&rsquo;').substr(0,60);
							}
							catch (ex)
							{
							}
							html+='</span>';
						//}
						html+='</div>';
						html+='</div>';
					}
					if (videos.totalVideos>videos.items.length)
					{
						html+='<div id="playlistItem'+(i+1)+'" style=" color:white !important;  width:290px; padding-top:30px; height:43px;  background-color:\'#141414\'; border-bottom: 1px solid #262626; line-height:12px; vertical-align:middle; text-align:center;"  align="center"><strong>';
						if (videos.page>1) html+='<a href="javascript:void(0);" style="color:white !important; text-decoration:none;" onclick="change_list('+source+','+(parseInt(videos.page)-1)+');"><img style="border:0" src="/media/v2/images/prev20.png"/></a>';
						var tpage=Math.ceil(videos.totalVideos/20);
						//html+='<span style="color:white !important;">&nbsp;&nbsp;SEE&nbsp;&nbsp;</span>';
						
						
						if (videos.page<tpage) html+='<a href="javascript:void(0);" style="color:white !important; text-decoration:none;" onclick="change_list('+source+','+(parseInt(videos.page)+1)+');"><img style="border:0" src="/media/v2/images/next20.png"/></a>';
						
						html+='</strong></div>';
						page=videos.page;
						
					}
					html+='</div>';
										
					$('#playList').html(html);
					
					playlist_clean();
					document.getElementById('playlistItem'+0).style.backgroundColor='#454444'; 
					
					//document.getElementById('playlistItem'+0).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		$('#playlistItem'+0).css('border-bottom','1px solid #262626');
		$('#playlistItem'+0+' strong').css('color','#07cdff');
		$('#playlistItem'+0+' span').css('color','white');
		lastVideo=0;
		
	}
	catch(ex) {
		//alert('error strating category');
	}
}

function swapCategory(source)
{
	try 
	{
	//alert('/fr/getCorporate?source='+source);
	$.getJSON('/'+lng+'/getCorporate?source='+source, function(vids) {
	
		startCategory(vids,source);
		$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 61});
		
		swapVideo(0);
	
	});
	}
	catch (ex)
	{
		//alert('error swaping category');
	}
}

function map_list(source,vids,index)
{
	try {
		
	mainChange(vids,source);
	videos=vids;
	applyPanel();
	swapVideo(index);
	} catch (ex)
	{
		//alert('error mapping list');
	}
}

function mainChange(videos2,source,fav)
{
	//try {
	var html="";
  
	
	$('#playList').html('');
	
	nbVideos=videos2.items.length;
	$('#thumblist').html('');
	html+='<div class="plsmall" id="pl">';
					

	for(var i=0;i<videos2.items.length;i++)
	{
		var customer='';
		try {
			customer=videos2.items[i].customer.name;
			customer=customer.replace('\'','&rsquo;');
		}
		catch(ex) {
			customer='';
		}
		var img='';
		if (videos2.items[i].thumbUrl)
			img='<img src="'+videos2.items[i].thumbUrl+'" width="96"  height="53"  id="imgvid'+i+'"  onerror="  this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\';"   align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';
		else
			img='<img src="/media/v2/images/nothumb.png" width="96"  height="53"  id="imgvid'+i+'"  onerror=" this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\';"   align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';	
		if (fav==true)
		{
			img+='<a href="javascript:void(0);" onclick="removeFavoris('+i+'); annulEvent(event);" class="dlicone"><img src="/media/v2/images/delicone.png" title="'+txt_remove_from_fav+'" ></a>';
		}
		html+='<div class="pli inlineBlock" id="playlistItem'+i+'" onclick="swapVideo('+i+');" onmouseover="playlist_on('+i+',event);" onmouseout="playlist_off('+i+',event);"><div class="subbar" onclick="annulEvent(event);"><a href="javascript:void(0);" onclick="swapVideo('+i+');"><img src="/media/v2/images/info.png" alt="'+txt_info+'" title="'+txt_info+'"  style="border:0;"/></a><a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos2.items[i].id+'\',\''+videos2.items[i].thumbUrl+'\'); " href="javascript:void(0);"><img src="/media/v2/images/send-mail.png" alt="'+txt_email_video+'" title="'+txt_email_video+'" style="border:0;"/></a><a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos2.items[i].id+'&t=Bezoom.tv&d=Beezom" target="_blank"><img src="/media/v2/images/send-facebook.png" alt="'+txt_facebook+'" title="'+txt_facebook+'"/></a><a class="addthis_button_twitter" addthis:url="'+host+'?id='+videos2.items[i].id+'"><img src="/media/v2/images/send-twitter.png"  style="border:0;" alt="'+txt_twitter+'" title="'+txt_twitter+'"/></a></div>'+img+'<div class="inlineBlock playListTitle"><strong  onmouseout="annulEvent(event)" onmouseover="annulEvent(event)">';
		var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
	try {
	if (addthis) addthis.init();
	} catch (ex) {
	}
		var titletest='';
		
		titletest=videos2.items[i].title.replace('\'','&rsquo;');
		html+=titletest;
		html+='</strong>';
		html+='<span  onmouseout="annulEvent(event)">';
		try {
			html+='<br/>'+videos2.items[i].shortdescr.replace('\'','&rsquo;').substr(0,60);
		}
		catch (ex)
		{
		}
		html+='</span>';
		
		html+='</div>';
		html+='</div>';
	}
	
	html+='</div>';
	$('#playList').html(html);
					
	playlist_clean();
					
	document.getElementById('playlistItem'+0).style.backgroundColor='#454444'; 
					
					
	$('#playlistItem'+0).css('border-bottom','1px solid #262626');
				
	$('#playlistItem'+0+' strong').css('color','#07cdff');
	$('#playlistItem'+0+' span').css('color','white');
	lastVideo=0;
}

function change_list(sourced,page)
{
	source=sourced;
	
	try {
	var videos = $.ajax({
  url: "/"+lng+"/getParams",
  data: 'source='+source,
  async: false
 }).responseText;
	
	var pg='getParams';
	
	pg='getCorporate';	
	//alert('test/'+lng+'/'+pg+'?source='+source+'&page='+page);
		$.getJSON('/'+lng+'/'+pg+'?source='+source+'&page='+page, function(videos2) {
																		 
  		var html="";
  
	
					nbVideos=videos2.items.length;
					$('#thumblist').html('');
					html+='<div class="plsmall" id="pl">';
					//videos2.totalVideos
					

					for(var i=0;i<videos2.items.length;i++)
					{
						var customer='';
						try {
							customer=videos2.items[i].customer.name;
							customer=customer.replace('\'','&rsquo;');
						}
						catch(ex) {
							customer='';
						}
						
						var img=''
						if (videos2.items[i].thumbUrl)
							img='<img src="'+videos2.items[i].thumbUrl+'" width="96"  height="53" id="imgvid'+i+'"  onerror="  this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\';"   align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';
						else
							img='<img src="/media/v2/images/nothumb.png" width="96"  height="53"  id="imgvid'+i+'"  onerror="  this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\';"   align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';	
						html+='<div class="pli inlineBlock" id="playlistItem'+i+'" onclick="swapVideo('+i+');" onmouseover="playlist_on('+i+',event);" onmouseout="playlist_off('+i+',event);"><div class="subbar" onclick="annulEvent(event);"><a href="javascript:void(0);" onclick="swapVideo('+i+');"><img src="/media/v2/images/info.png" alt="'+txt_info+'" title="'+txt_info+'"  style="border:0;"/></a><a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos2.items[i].id+'\',\''+videos2.items[i].thumbUrl+'\'); " href="javascript:void(0);"><img src="/media/v2/images/send-mail.png" alt="'+txt_email_video+'" title="'+txt_email_video+'" style="border:0;"/></a><a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos2.items[i].id+'&t=Bezoom.tv&d=Beezom" target="_blank"><img src="/media/v2/images/send-facebook.png" alt="'+txt_facebook+'" title="'+txt_facebook+'"/></a><a class="addthis_button_twitter" addthis:url="'+host+'?id='+videos2.items[i].id+'"><img src="/media/v2/images/send-twitter.png"  style="border:0;" alt="'+txt_twitter+'" title="'+txt_twitter+'"/></a></div>'+img+'<div class="inlineBlock playListTitle"><strong  onmouseout="annulEvent(event)" onmouseover="annulEvent(event)">';
						var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
	try {
	if (addthis) addthis.init();
	} catch (ex) {
	}
						var titletest='';
						//if (videos2.items[i].customerName)
						//	titletest=videos2.items[i].customerName;
						//else
							titletest=videos2.items[i].title.replace('\'','&rsquo;');
						html+=titletest;
						html+='</strong>';
						//if (titletest!=videos2.items[i].title.replace('\'','&rsquo;'))
						//{
							html+='<span  onmouseout="annulEvent(event)">';
							try {
								
							html+='<br/>'+videos2.items[i].shortdescr.replace('\'','&rsquo;').substr(0,60);
							}
							catch (ex)
							{
							}
							html+='</span>';
						//}
						html+='</div>';
						html+='</div>';
					}
					if (videos2.totalVideos>videos2.items.length)
					{
						html+='<div id="playlistItem'+(i+1)+'" style=" color:white !important;  width:290px;  padding-top:30px; height:43px;  background-color:\'#141414\'; border-bottom: 1px solid #262626; line-height:12px; vertical-align:middle; text-align:center;" align="center" ><strong>';
						if (videos2.page>1) html+='<a href="javascript:void(0);" style="color:white !important; text-decoration:none;" onclick="change_list('+source+','+(parseInt(videos2.page)-1)+');"><img style="border:0" src="/media/v2/images/prev20.png"/></a>';
						var tpage=Math.ceil(videos2.totalVideos/20);
						//html+='<span style="color:white !important;">&nbsp;&nbsp;SEE&nbsp;&nbsp;</span>';
						
						
						if (videos2.page<tpage) html+='<a href="javascript:void(0);" style="color:white !important; text-decoration:none;" onclick="change_list('+source+','+(parseInt(videos2.page)+1)+');"><img style="border:0" src="/media/v2/images/next20.png"/></a>';
						
						html+='</strong></div>';
						page=videos2.page;
					}
					html+='</div>';
					
					$('#playList').html(html);
					
					playlist_clean();
					
					$('#playList')[0].scrollTo(0);
					
					
					document.getElementById('playlistItem'+0).style.backgroundColor='#454444'; 
					
					//document.getElementById('playlistItem'+0).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		$('#playlistItem'+0).css('border-bottom','1px solid #262626');
		$('#playlistItem'+0+' strong').css('color','#07cdff');
		$('#playlistItem'+0+' span').css('color','white');
		lastVideo=0;
  
		swapVideo(0,videos2);
		
	
  
});
	} catch(ex) {
	alert('error changing list');
}
				  
}

function change_searchresult(key,sourced,page)
{
	source=sourced;
	
	try {
	var videos = $.ajax({
  url: "/"+lng+"/getParams",
  data: 'source='+source,
  async: false
 }).responseText;
	
	var pg='getParams';
	
	pg='getSearchResults';	
	//alert('test/'+lng+'/'+pg+'?keyword='+key+'&source='+source+'&page='+page);
		$.getJSON('/'+lng+'/'+pg+'?keyword='+key+'&source='+source+'&page='+page, function(videos2) {
																		 
  		var html="";
  
	
					nbVideos=videos2.items.length;
					$('#thumblist').html('');
					html+='<div class="plsmall" id="pl">';
					//videos2.totalVideos
					

					for(var i=0;i<videos2.items.length;i++)
					{
						var customer='';
						try {
							customer=videos2.items[i].customer.name;
							customer=customer.replace('\'','&rsquo;');
						}
						catch(ex) {
							customer='';
						}
						
						var img=''
						if (videos2.items[i].thumbUrl)
							img='<img src="'+videos2.items[i].thumbUrl+'" width="96"  height="53" id="imgvid'+i+'"  onerror="  this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\';"   align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';
						else
							img='<img src="/media/v2/images/nothumb.png" width="96"  height="53"  id="imgvid'+i+'"  onerror="  this.src=\'/media/v2/images/nothumb.png\'; this.style.border=\'none !important\';"   align="texttop"  class="inlineBlock"/><img src="/media/v2/images/playIcon.png" class="plicone" >';	
						html+='<div class="pli inlineBlock" id="playlistItem'+i+'" onclick="swapVideo('+i+');" onmouseover="playlist_on('+i+',event);" onmouseout="playlist_off('+i+',event);"><div class="subbar" onclick="annulEvent(event);"><a href="javascript:void(0);" onclick="swapVideo('+i+');"><img src="/media/v2/images/info.png" alt="'+txt_info+'" title="'+txt_info+'"  style="border:0;"/></a><a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos2.items[i].id+'\',\''+videos2.items[i].thumbUrl+'\'); " href="javascript:void(0);"><img src="/media/v2/images/send-mail.png" alt="'+txt_email_video+'" title="'+txt_email_video+'" style="border:0;"/></a><a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos2.items[i].id+'&t=Bezoom.tv&d=Beezom" target="_blank"><img src="/media/v2/images/send-facebook.png" alt="'+txt_facebook+'" title="'+txt_facebook+'"/></a><a class="addthis_button_twitter" addthis:url="'+host+'?id='+videos2.items[i].id+'"><img src="/media/v2/images/send-twitter.png"  style="border:0;" alt="'+txt_twitter+'" title="'+txt_twitter+'"/></a></div>'+img+'<div class="inlineBlock playListTitle"><strong  onmouseout="annulEvent(event)" onmouseover="annulEvent(event)">';
						var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
	try {
	if (addthis) addthis.init();
	} catch (ex) {
	}
						var titletest='';
						//if (videos2.items[i].customerName)
						//	titletest=videos2.items[i].customerName;
						//else
							titletest=videos2.items[i].title.replace('\'','&rsquo;');
						html+=titletest;
						html+='</strong>';
						//if (titletest!=videos2.items[i].title.replace('\'','&rsquo;'))
						//{
							html+='<span  onmouseout="annulEvent(event)">';
							try {
								
							html+='<br/>'+videos2.items[i].shortdescr.replace('\'','&rsquo;').substr(0,60);
							}
							catch (ex)
							{
							}
							html+='</span>';
						//}
						html+='</div>';
						html+='</div>';
					}
					if (videos2.totalVideos>videos2.items.length)
					{
						html+='<div id="playlistItem'+(i+1)+'" style=" color:white !important;  width:290px;  padding-top:30px; height:43px;  background-color:\'#141414\'; border-bottom: 1px solid #262626; line-height:12px; vertical-align:middle; text-align:center;" align="center" ><strong>';
						if (videos2.page>1) html+='<a href="javascript:void(0);" style="color:white !important; text-decoration:none;" onclick="change_searchresult(\''+key+'\','+source+','+(parseInt(videos2.page)-1)+');"><img style="border:0" src="/media/v2/images/prev20.png"/></a>';
						var tpage=Math.ceil(videos2.totalVideos/20);
						//html+='<span style="color:white !important;">&nbsp;&nbsp;SEE&nbsp;&nbsp;</span>';
						
						
						if (videos2.page<tpage) html+='<a href="javascript:void(0);" style="color:white !important; text-decoration:none;" onclick="change_searchresult(\''+key+'\','+source+','+(parseInt(videos2.page)+1)+');"><img style="border:0" src="/media/v2/images/next20.png"/></a>';
						
						html+='</strong></div>';
						page=videos2.page;
					}
					html+='</div>';
					
					$('#playList').html(html);
					
					playlist_clean();
					
					$('#playList')[0].scrollTo(0);
					
					
					document.getElementById('playlistItem'+0).style.backgroundColor='#454444'; 
					
					//document.getElementById('playlistItem'+0).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		$('#playlistItem'+0).css('border-bottom','1px solid #262626');
		$('#playlistItem'+0+' strong').css('color','#07cdff');
		$('#playlistItem'+0+' span').css('color','white');
		lastVideo=0;
  
		swapVideo(0,videos2);
		
	
  
});
	} catch(ex) {
	alert('error changing list');
}
				  
}




function playlist_off(name,e)
{
	try {
	if (!e) var e = window.event;
	var relTarg = e.relatedTarget || e.toElement;

	if ((relTarg.nodeName!='SPAN')&&(relTarg.nodeName!='BR')&&(relTarg.nodeName!='STRONG'))
	{
		if (name!=lastVideo)
		{
		document.getElementById('playlistItem'+name).style.backgroundColor='#141414';
		$('#playlistItem'+name).css('border-bottom','1px solid #262626');

		//document.getElementById('playlistItem'+name).style.backgroundImage='url(/media/images/background-playlist-off.png)';
		$('#playlistItem'+name+' strong').css('color','#07cdff');
		$('#playlistItem'+name+' span').css('color','white');
		//$('#thumblist img').css('display','none');
		//$('#imgvid'+name).css('display','none');
		}
	}
	} catch (ex)
	{
		//alert('error playlist off');
	}
}

function playlist_on(name,e)
{
	try {
	playlist_clean();
	if (name!=lastVideo)
	{
		document.getElementById('playlistItem'+name).style.backgroundColor='#454444';
		$('#playlistItem'+name).css('border-bottom','1px solid #262626');
		//document.getElementById('playlistItem'+name).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		$('#playlistItem'+name+' strong').css('color','#07cdff');
		$('#playlistItem'+name+' span').css('color','white');
		//$('#thumblist img').css('display','none');
		
		var p=$('#playlistItem'+name).position();
		var pl=$('#playlistItem0').offset();
		var pltop=$('#video').offset();
		//alert(244-pl.top);
		var posy=(p.top+45-(46+pltop.top-pl.top))-1;
		//alert(posy);
		if ((posy>40)&&(posy<345))
		{
			//$('#imgvid'+name).css('margin-top',posy+'px');
			//$('#imgvid'+name).css('display','block');
		}
	}
	} catch (ex)
	{
		//alert('error playlist on');
	}
}

function playlist_clean()
{
	try {
	for(var i=0;i<nbVideos;i++)
	{
		if (document.getElementById('playlistItem'+i).style.backgroundColor=='#454444')
		{
			if (i!=lastVideo)
			{
				document.getElementById('playlistItem'+i).style.backgroundColor='#141414';
				$('#playlistItem'+i).css('border-bottom','1px solid #262626');
				
				$('#playlistItem'+i).css('border-bottom','1px solid #262626');
				//document.getElementById('playlistItem'+i).style.backgroundImage='url(/media/images/background-playlist-off.png)';
				
			}
		}
		$('#playlistItem'+i+' strong').css('color','#07cdff');
		$('#playlistItem'+i+' span').css('color','white');
	}
	} catch (ex)
	{
		alert('error playlist clean');
	}
}

function applyPanel()
{
	try {
	$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 61});
	} catch (ex)
	{
		alert('error applying panel');
	}
}

		function placeMenuOver()
		{
			try {
			var host=document.location.href;
			host=host.split('/');
			host=host[0]+'//'+host[2];
			var page=window.location.href.split(host);
			page=page[1];
		
		
			var reg=/http:\/\/([a-zA-Z0-9.-]+)\/(en|fr|nl|de)?\/?([a-zA-Z0-9_.-]*)\??(id=)?([0-9]*)(&section=)?([0-9-]*)/gi
			
			if (pg=reg.exec(document.location.href))
			{
				if (pg[2]!='')
					page='/'+pg[2]+'/'+pg[3];
				else
					page='/'+pg[3];
			}
			
		
			//$(".mainMenu a img").each(function(i) {
											  
				//if (page!=$(this).parent().attr('href')) {
					/*this.onmouseover=function() {
						if (this.src.substr(this.src.length-7,7)!='-on.png')
						{
							this.src=this.src.substr(0,this.src.length-4)+'-on.png';
						}	
					};
					
					this.onmouseout=function() {
						if (this.src.substr(this.src.length-7,7)=='-on.png')
						{
							this.src=this.src.substr(0,this.src.length-7)+'.png';
						}
					};*/
					//autoOnOff(this,'png');
					
				//}
				//else
				//{
				//	this.src=this.src.substr(0,this.src.length-4)+'-on.png';
				//}
			//});
			} catch (ex)
	{
		alert('error placing menu over');
	}
		}
// Extension must be .jpg .gif .png ( 3 letters )
function autoOnOff(elem,extension){
	elem.onmouseover=function() {
		if (elem.src.substr(elem.src.length-7,7)!='-on.'+extension)
		{
			elem.src=elem.src.substr(0,elem.src.length-4)+'-on.'+extension;
		}	
	};
	
	elem.onmouseout=function() {
		if (elem.src.substr(elem.src.length-7,7)=='-on.'+extension)
		{
			elem.src=elem.src.substr(0,elem.src.length-7)+'.'+extension;
		}
	};
}

function placeSearches()
{
	$("input.keyword").each(function(i) {
		this.onfocus=function()	{
			if (this.value==kword)
				this.value='';
		}
		this.onblur=function()	{
			if (this.value=='')
				this.value=kword;
		}
	});
	
	$('#subscriber-email').each(function(i) {
		this.onfocus=function() {
			if (this.value=='E-mail')
				this.value='';
		}
		
		this.onblur=function() {
			if (this.value=='')
				this.value='E-mail';
		}
	});
}

function swapBarStatus(source)
{
	//alert(source+' '+barstatus);
	//if (barstatus==1) $("#playingVideo").unbind("mouseover");
	//if (barstatus==0) $("#playingVideo").unbind("mouseout");
	//$("#innerVideo").bind("mouseout", function() { 
	//	return false;
	//});
	barstatus=-1;
	
}

function swapBarStatus2(source)
{
	//alert(source+' '+barstatus);
	//if (barstatus==1) $("#playingVideo").unbind("mouseover");
	//if (barstatus==0) $("#playingVideo").unbind("mouseout");
	barstatus=-1;
}

function updateInfo(text,thumb)
{
	try {
	$('#sendToFriendUrl').attr('value',text);
	$('#sendToFriendThumb').attr('value',thumb);
	
	var html='';
	
	html='<div id="toolbox"><a class="addthis_button_facebook" addthis:url="'+text+'">Facebook</a><a class="addthis_button_twitter" addthis:url="'+text+'">Twitter</a><a class="addthis_button_myspace" addthis:url="'+text+'">Myspace</a><a class="addthis_button_delicious" addthis:url="'+text+'">Del.icio.us</a><a class="addthis_button_digg" addthis:url="'+text+'">Digg</a><a class="addthis_button_flickr" addthis:url="'+text+'">Flickr</a><a class="addthis_button_stumble" addthis:url="'+text+'">Stumble</a></div>';
	
	$('#contentAddThis').html(html);
	
	var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
	try {
	if (addthis) addthis.init();
	} catch (ex) {
	}
	addthis.toolbox("#toolbox");
	
	var buttons = {};
	buttons[txt_send] = function() { 
							$('#formFriend').submit(); 
						};
	buttons[txt_cancel] = function() { 
							$(this).dialog("close"); 
						};					
	$('#sendtofriend').dialog({
					title: 'Share this video',
					modal: true,
					autoOpen: false,
					width: 600,
					buttons: buttons
				});
	//$.ui.dialog.defaults.bgiframe = true;
	//$('#info').dialog({ modal: true, draggable: true, resizeable: false, width:420, zIndex:2 }); 
	$('#sendtofriend').dialog('open');
	return false;
	} catch (ex)
	{
		//alert('error updating info');
	}
}

function anotherPreview(video)
{
	try {
	var o=thisMovie("PreviewPlayerBezoom");
	o.playit(video);
	}
	catch (ex)
	{
	}
}

function anotherVideo(video)
{
	try {
	var o=thisMovie("PlayerBezoom");
	
	o.playit(video);
	}
	catch (ex)
	{
	}
}

function thisMovie(movieName) 
{
	return document.getElementById(movieName);
/*	if (navigator.appName.indexOf("Microsoft") != -1)
		return window[movieName];
	else
		return document[movieName];*/
}

function mode(val)
{
	if (val==1)
	{
		actualMode=1;
	}
	else
	{
		actualMode=0;
	}
	updateSize();
}

function share(video,type)
{
	
	//alert(JSON.stringify(video));
	
	//http://www.bezoom.tv/fr/corporate-video/fr/corporate-video?id=12195
	updateInfo(host+'/'+lng+'/corporate-video?id='+videos.items[lastVideo].id,videos.items[lastVideo].thumbUrl);	
	//window.open('http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video?id='+videos.items[lastVideo].id+'&t=Bezoom.tv&d=Beezom','facebook');
}

function waiter(n)
{
	var tmp=n-1;
	if (tmp<1) return;
	window.setTimeout("waiter("+tmp+")",1000);
	
}

function embed(vid)
{
	//alert("a: "+escape(JSON.stringify(vid)));
	var video=null;
	try {
		if (vid.id!=undefined)
		{
		var test=vid.id;
		video=escape(JSON.stringify(vid));
		}
		else
		{
			video=id;
		}
	}
	catch (ex)
	{
		video=vid;
	}
	//alert(unescape(JSON.stringify(vid)));
	

	$('#videoCodeEmbed').attr('value',video);
	
	var buttonsPopup = {};
		buttonsPopup[txt_cancel] = function() {
			$('#exportEmbed').dialog('close');
		};
        buttonsPopup[txt_generate] = function() { 
		
							//modification code html embed
							
							sizew=$('#selectedSizeEmbed').attr('value');
							sizeh=360*sizew/640;
							var html='';
							var v=$('#videoCodeEmbed').attr('value');
							
							var video=JSON.parse(unescape(v));
							
							var arr=[];
							
							
							html+='<object width="'+sizew+'" height="'+sizeh+'">\n';
							html+='<param name="movie" value="'+host+'/media/flash/Main.swf?pathToConfig='+host+'/media/xml/configweb.xml&video={&amp;quot;id&amp;quot;:&amp;quot;'+video.id+'&amp;quot;, &amp;quot;order&amp;quot;:&amp;quot;'+video.order+'&amp;quot;, &amp;quot;url&amp;quot;:&amp;quot;'+video.url+'&amp;quot;, &amp;quot;position&amp;quot;:'+video.position+',&amp;quot;videoid&amp;quot;:&amp;quot;'+video.videoid+'&amp;quot;}&amp;&iso='+lng+'&mode=2&favorites={}"></param>\n';
							html+='<param name="allowFullScreen" value="true"></param>\n';
							html+='<param name="allowscriptaccess" value="always"></param>\n';
							 html+='<param name="wmode" value="transparent" />\n';
							html+='<embed src="'+host+'/media/flash/Main.swf?pathToConfig='+host+'/media/xml/configweb.xml&video={&amp;quot;id&amp;quot;:&amp;quot;'+video.id+'&amp;quot;, &amp;quot;order&amp;quot;:&amp;quot;'+video.order+'&amp;quot;, &amp;quot;url&amp;quot;:&amp;quot;'+video.url+'&amp;quot;, &amp;quot;position&amp;quot;:'+video.position+',&amp;quot;videoid&amp;quot;:&amp;quot;'+video.videoid+'&amp;quot;}&amp;&iso='+lng+'&mode=2&favorites={}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+sizew+'" height="'+sizeh+'" wmode="transparent"></embed>\n';
							html+='</object>\n';
							popupMessage(textEmbed+'<br/><textarea cols="60" rows="30">'+html+'</textarea>');
							$(this).dialog("close"); 
						};	
		
						
		$('#exportEmbed').dialog({
					title: 'Export',
					modal: true,
					autoOpen: false,
					width: 664,
					buttons: buttonsPopup,
					closeOnEscape: true,
					close: function(event,ui) {
						//$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
						try {
							var o=thisMovie("PreviewPlayerBezoomEmbed");
							o.stopit();
						}
						catch (ex)
						{
						}
					}
				});
		//$.ui.dialog.defaults.bgiframe = true;
		//$('#info').dialog({ modal: true, draggable: true, resizeable: false, width:420, zIndex:2 }); 
		try {
		var o=thisMovie("PlayerBezoom");
		o.stopit();
		}
		catch (ex)
		{
		}
		$('#exportEmbed').dialog('open');
		
		var flashvars = {
			  pathToConfig: "/media/xml/config.xml",
			  iso: lng,
			  mode: "2",
			  video: video,
			  favorites: escape(JSON.stringify([]))
		};
		var params = {
			  menu: "false",
			  quality: "best",
			  wmode: "transparent",
			  allowScriptAccess: "always",
			  allowFullScreen: "true",
			  movie: "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=2&video="+video+"&favorites="+escape(JSON.stringify([]))
		};
		var attributes = {
			  id: "PreviewPlayerBezoomEmbed",
			  name: "PreviewPlayerBezoomEmbed"
		};
		//alert(unescape(video));
		//console.log(unescape(video)); 
	
		if (document.getElementById("previewVideoEmbed"))
		{
			//alert('a');
			swfobject.embedSWF ( "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=2&video="+video+"&favorites="+escape(JSON.stringify([])), "previewVideoEmbed", "640", "360", "10", "/media/flash/expressInstall.swf", flashvars, params, attributes );
		}
		else
		{
			//alert('b');
			try
			{
			var o=thisMovie("PreviewPlayerBezoomEmbed");
			//waiter(20);
			
			o.playit(JSON.parse(unescape(video)));	
			}
			catch(ex)
			{
				swfobject.embedSWF ( "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=2&video="+video+"&favorites="+escape(JSON.stringify([])), "PreviewPlayerBezoomEmbed", "640", "360", "10", "/media/flash/expressInstall.swf", flashvars, params, attributes );
			}
		}
			
	//try {
	//o.playit({"id":"70006568","order":"2","url":"http://video.bezoom.tv/videoentreprise/Bezoom/70006568/70006568_01-1.m4v","position":3,"count":20,"videoid":"13084"});
	//o.stopit();
	//o.playit(unescape(video));
	//}
	//catch (ex)
	//{
	//}
		
}

function embedDeprecated(vid)
{
 
 	var video=null;
	try {
		var test=vid.id;
		video=vid;
	}
	catch (ex)
	{
		video=JSON.parse(unescape(vid));
	}

	var arr=[];
	var html='';
	code=video.id;
	order=video.order;
   
		
		html+='<object width="640" height="360">\n';
		html+='<param name="movie" value="'+host+'/media/flash/Main.swf?pathToConfig='+host+'/media/xml/configweb.xml&video={&amp;quot;id&amp;quot;:&amp;quot;'+video.id+'&amp;quot;, &amp;quot;order&amp;quot;:&amp;quot;'+video.order+'&amp;quot;, &amp;quot;url&amp;quot;:&amp;quot;'+video.url+'&amp;quot;, &amp;quot;position&amp;quot;:'+video.position+'}&amp;&iso='+lng+'&mode=0&favorites={}"></param>\n';
		html+='<param name="allowFullScreen" value="true"></param>\n';
		html+='<param name="allowscriptaccess" value="always"></param>\n';
		 html+='<param name="wmode" value="transparent" />\n';
		html+='<embed src="'+host+'/media/flash/Main.swf?pathToConfig='+host+'/media/xml/configweb.xml&video={&amp;quot;id&amp;quot;:&amp;quot;'+video.id+'&amp;quot;, &amp;quot;order&amp;quot;:&amp;quot;'+video.order+'&amp;quot;, &amp;quot;url&amp;quot;:&amp;quot;'+video.url+'&amp;quot;, &amp;quot;position&amp;quot;:'+video.position+'}&amp;&iso='+lng+'&mode=0&favorites={}" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="360" wmode="transparent"></embed>\n';
		html+='</object>\n';
		popupMessage(textEmbed+'<br/><textarea cols="60" rows="30">'+html+'</textarea>');
		
		
}

function DateExpiration (DateExp) 
{
	var aujourdhui = new Date(0);
	var aujourdhuidate = aujourdhui.getTime();
	if (aujourdhuidate > 0)
		DateExp.setTime (DateExp.getTime() - aujourdhuidate);
}

function EcrireCookie(nom, valeur)
{
   
	var argv=EcrireCookie.arguments;
 	var argc=EcrireCookie.arguments.length;
 	var expires=(argc > 2) ? argv[2] : null;
 	var path=(argc > 3) ? argv[3] : null;
 	var domain=(argc > 4) ? argv[4] : null;
 	var secure=(argc > 5) ? argv[5] : false;
 	document.cookie=nom+"="+escape(valeur)+
 	((expires==null) ?  "" : ("; expires="+expires.toGMTString()))+
 	((path==null) ? "" : ("; path="+path))+
 	((domain==null) ? "" : ("; domain="+domain))+
 	((secure==true) ? "; secure" : ""); 
	
}
 
function getCookieVal(offset)
{

	var endstr=document.cookie.indexOf (";", offset);
 	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr)); 
}
 
function LireCookie(nom)
{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
	{
	var j=i+alen;
	if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
	i=document.cookie.indexOf(" ",i)+1;
	if (i==0) break;
	}
	return null; 
}

function EffaceCookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function getVideosItemsList(list)
{
	videoList="";
	for(i=0;i<list.length;i++)
	{
		if (i>0)
			videoList+=",";
		videoList+=list[i];
	}
	url="/"+lng+"/getOneVideo";
		data="lang="+lng+"&videos="+videoList+"&page=1";
					
		var data = $.ajax({
   	    type: 'GET',
  		url: url,
  		data: data,
  		async: false
 		}).responseText;
		
		videoList=JSON.parse(data);
	return videoList;
}

function changeFavIcon()
{
	var favorites=LireCookie('favorites');
	if (favorites!=null)
	{
		favorites=JSON.parse(favorites);
		if (favorites.totalVideos>0)
		{
			$('#favoriteIcon').attr('src','/media/v2/images/favoris.png');
		}
		else
		{
			$('#favoriteIcon').attr('src','/media/v2/images/favorisoff.png');
		}
	}
	else
	{
		$('#favoriteIcon').attr('src','/media/v2/images/favorisoff.png');
	}
}


function favoris()
{
	var favorites=LireCookie('favorites');
	if (favorites!=null)
	{
		
		//recupération de la lsite sous forme videos
		
		favorites=JSON.parse(favorites);
		if (favorites.totalVideos>0)
		{
		videos=getVideosItemsList(favorites.items);
		
		mainChange(videos,null,true);
		swapVideo(0);
		var o=thisMovie("PlayerBezoom");
		var arr=[];
		for(ik=0;ik<videos.items.length;ik++)
		{
			arr.push({'id':videos.items[ik].customerId,'order':videos.items[ik].order,'url':videos.items[ik].fileUrl,'position':ik,'count':videos.length, 'thumb':(videos.items[ik].thumbUrl)?videos.items[ik].thumbUrl:'/media/v2/images/nothumb.png'});
		}
		
		$('#innerTicker').html('<a href="javascript:void(0);" onclick="createFavorite();"; style="text-decoration:none; color:white;"><img  src="/media/v2/images/createFavoris.png" style=" vertical-align: middle; border:0; padding-right:3px;" alt="'+txt_create_favoris+'" title="'+txt_create_favoris+'"/>'+txt_create_favoris+'</a>');
		o.updateFavorites(arr);
		window.setTimeout('updatebar()',2000);
		}
		else
		{
			popupMessage(txt_no_fav);
			/*videos=getVideosItemsList(favorites.items);
			mainChange(videos,null);
			swapVideo(0);
			window.setTimeout('updatebar()',500);*/
		}
		
	}
	else
	{
		//message pas de favoris
		popupMessage(txt_no_fav);
	}
}

function removeFavoris(i)
{
	favorites=LireCookie('favorites');
	if (favorites!=null)
	{
		//recupération de la lsite sous forme videos
		
		favorites=JSON.parse(favorites);
		
		//alert(JSON.stringify(favorites));
		if (favorites.totalVideos>0)
		{
			favorites.totalVideos--;
			favorites.items.splice(i,1);
			var today = new Date(); 
			DateExpiration (today);
			today.setTime (today.getTime() + (365 * 60 * 60 * 1000));
			EcrireCookie('favorites',JSON.stringify(favorites),today,'/');
			
			//alert(JSON.stringify(favorites));
			favoris();
		}
	}
	changeFavIcon();
}

function addFavorite()
{
	favorites=LireCookie('favorites');
	if (favorites==null)
		favorites={'page':1,'totalVideos':0,'items':[]};
	else
		favorites=JSON.parse(favorites);

	var found=0;
	for(i=0;i<favorites.items.length;i++)
	{
		if (favorites.items[i]==videos.items[lastVideo].id)
			found=1;
	}

	if (found==0)
	{
		favorites.totalVideos++;
		favorites.items.push(videos.items[lastVideo].id);
		
		var today = new Date(); 
		DateExpiration (today);
		today.setTime (today.getTime() + (365 * 60 * 60 * 1000));
		EcrireCookie('favorites',JSON.stringify(favorites),today,'/');
		//message ajouté au favoris
		popupMessage(txt_add_fav);
	}
	else
	{
		//message déjà dans les favoris	
		popupMessage(txt_deja_fav);
	}
	changeFavIcon();
	
}

function swapSelect(index)
{
	var val=$('#v_'+index).attr('value');
	if (val==0)
	{
		$('#i_'+index).attr('src','/media/v2/images/checkon.png');
		$('#v_'+index).attr('value',1);
	}
	else
	{
		$('#i_'+index).attr('src','/media/v2/images/checkoff.png');
		$('#v_'+index).attr('value',0);
	}
	
	//check if selectAll must be take of or on
	var total=0;
	for(ik=0;ik<videostmp.items.length;ik++)
	{
		total+=parseInt($('#v_'+ik).attr('value'));
	}
	
	if (total!=videostmp.items.length)
	{
		$('#selectedAll').attr('src','/media/v2/images/checkoff.png');
		$('#selectedAllItem').attr('value',0);
	}
	else
	{
		$('#selectedAll').attr('src','/media/v2/images/checkon.png');
		$('#selectedAllItem').attr('value',1);
	}
	
}

function swapSelectAll() 
{
	var val=$('#selectedAllItem').attr('value');
	if (val==0)
	{
		$('#selectedAll').attr('src','/media/v2/images/checkon.png');
		$('#selectedAllItem').attr('value',1);
		$('#selectPlayList input').attr('value',1);
		$('#selectPlayList .checker').attr('src','/media/v2/images/checkon.png');
	}
	else
	{
		$('#selectedAll').attr('src','/media/v2/images/checkoff.png');
		$('#selectedAllItem').attr('value',0);
	}
}

function createFavorite()
{
	//remplissage favorites list
	var favorites=LireCookie('favorites');
	var toupdateSize=0;
	
	if (favorites!=null)
	{
		
		//recupération de la liste sous forme videos
		
		favorites=JSON.parse(favorites);
		if (favorites.totalVideos>0)
		{
			videostmp=getVideosItemsList(favorites.items);
			toupdateSize=Math.ceil((videostmp.items.length/2))*90;
			$('#itemsList').html('');
			var arr=[];
			for(ik=0;ik<videostmp.items.length;ik++)
			{
				arr.push({'id':videostmp.items[ik].customerId,'order':videostmp.items[ik].order,'url':videostmp.items[ik].fileUrl,'position':ik,'count':videostmp.length, 'thumb':(videostmp.items[ik].thumbUrl)?videostmp.items[ik].thumbUrl:'/media/v2/images/nothumb.png'});
				
				//mise en place élement dans la playlist
				html='<div id="selectItem" class="inlineBlock"><a href="javascript:void(0);" onclick="javascript:updateFavPlayer('+ik+');" style="position:absolute;" ><img style="border:0;" src="'+videostmp.items[ik].thumbUrl+'" alt="" title="" /><img src="/media/v2/images/playIcon.png" alt="" title="" class="findme" style="border:0; position:absolute; margin-top:37px; margin-left:-24px; z-index:10000;"/></a><a href="javascript:void(0);" onclick="swapSelect('+ik+');" style="text-decoration:none; display:block; position: absolute; margin-left:286px; width:10px; height:10px;"><img src="/media/v2/images/checkon.png" class="checker" id="i_'+ik+'" alt="" title="" style="border:0;"/></a><div style="margin-left:100px;"><input type="hidden" id="v_'+ik+'" name="v_'+ik+'" value="1"/>';
				html+='<span style="color:#07cdff; font-size:13px; font-weight:bold;">'+videostmp.items[ik].title.replace('\'','&rsquo;')+'</span>';
				try {
				html+='<br/>'+videostmp.items[ik].shortdescr.replace('\'','&rsquo;').substr(0,60);
				}
				catch (ex)
				{
				}
				html+='</div></div>';
				$('#itemsList').append(html);
			}
			
			
			
			//selection automatique toutes les videos favorites
			$('#selectedAll').attr('src','/media/v2/images/checkon.png');
			$('#selectedAllItem').attr('value',1)
		
		}
		else
		{
			//pas de favoris
			popupMessage(txt_no_fav);
			return;
		}
	}
	else
	{
		//pas de favoris
		popupMessage(txt_no_fav);
		return; 
	}
	//application scrollbar
	//preview flash
	
	var buttonsPopup = {};
        buttonsPopup[txt_gen_fav] = function() { 
		
							//modification code html embed
							
							sizew=$('#selectedSize').attr('value');
							sizeh=360*sizew/640;
							var html='';
							var v={};
							var arr=[];
							for(ik=0;ik<videostmp.items.length;ik++)
							{
								if (ik==0)
									v={'id':videostmp.items[ik].customerId,'order':videostmp.items[ik].order,'url':videostmp.items[ik].fileUrl,'position':ik,'count':videostmp.length, 'thumb':(videostmp.items[ik].thumbUrl)?videostmp.items[ik].thumbUrl:'/media/v2/images/nothumb.png'};
								if ($('#v_'+ik).attr('value')==1)
									arr.push(videostmp.items[ik].id);
									
							}
							
							html+='<object width="'+sizew+'" height="'+sizeh+'">\n';
							html+='<param name="movie" value="'+host+'/media/flash/Main.swf?pathToConfig='+host+'/media/xml/configweb.xml&video={&amp;quot;id&amp;quot;:&amp;quot;'+v.id+'&amp;quot;, &amp;quot;order&amp;quot;:&amp;quot;'+v.order+'&amp;quot;, &amp;quot;url&amp;quot;:&amp;quot;'+v.url+'&amp;quot;, &amp;quot;position&amp;quot;:'+v.position+'}&amp;&iso='+lng+'&mode=2&favorites='+escape(JSON.stringify(arr))+'"></param>\n';
							html+='<param name="allowFullScreen" value="true"></param>\n';
							html+='<param name="allowscriptaccess" value="always"></param>\n';
							 html+='<param name="wmode" value="transparent" />\n';
							html+='<embed src="'+host+'/media/flash/Main.swf?pathToConfig='+host+'/media/xml/configweb.xml&video={&amp;quot;id&amp;quot;:&amp;quot;'+v.id+'&amp;quot;, &amp;quot;order&amp;quot;:&amp;quot;'+v.order+'&amp;quot;, &amp;quot;url&amp;quot;:&amp;quot;'+v.url+'&amp;quot;, &amp;quot;position&amp;quot;:'+v.position+'}&amp;&iso='+lng+'&mode=2&favorites='+escape(JSON.stringify(arr))+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+sizew+'" height="'+sizeh+'" wmode="transparent"></embed>\n';
							html+='</object>\n';
		
							//affichage embed
							popupMessage(textEmbed+'<br/><textarea cols="60" rows="30">'+html+'</textarea>');
							$(this).dialog("close"); 
						};	
						
		$('#exportFavorites').dialog({
					title: '<img  src="/media/v2/images/createFavoris.png" style=" vertical-align: middle; border:0; padding-right:3px;" alt="'+txt_create_favoris+'" title="'+txt_create_favoris+'"/>'+txt_create_favoris,
					modal: true,
					autoOpen: false,
					width: 664,
					buttons: buttonsPopup,
					closeOnEscape: true,
					close: function(event,ui) {
						//$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
						try {
						var o=thisMovie("PreviewPlayerBezoom");
						o.stopit();
						} catch (ex) {
						}
					}
				});
		//$.ui.dialog.defaults.bgiframe = true;
		//$('#info').dialog({ modal: true, draggable: true, resizeable: false, width:420, zIndex:2 }); 
		try {
		var o=thisMovie("PlayerBezoom");
		o.stopit();
		} catch (ex)
		{
		}
		$('#exportFavorites').dialog('open');
		$('#itemsList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
		$('#itemsList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
		
		if (toupdateSize<331)
		{ $('#selectPlayList').css('height',toupdateSize+'px');}
		else
		{
			$('#selectPlayList').css('height','331px');
			$('#selectPlayList .jScrollPaneContainer').css('height','331px');
		}
		//$('#selectPlayList .jScrollPaneContainer').css('height',toupdateSize+'px');
		//$('#itemsList').css('height',toupdateSize+'px');
				
		updateFavPlayer(0);
		
}

function setPreviewSizeEmbed(size)
{
	$('#selectedSizeEmbed').attr('value',size);
	
	$('#sizerEmbed_1').attr('src','/media/v2/images/checkoff.png');
	$('#sizerEmbed_2').attr('src','/media/v2/images/checkoff.png');
	$('#sizerEmbed_3').attr('src','/media/v2/images/checkoff.png');
	
	if (size==320) $('#sizerEmbed_1').attr('src','/media/v2/images/checkon.png');
	if (size==480) $('#sizerEmbed_2').attr('src','/media/v2/images/checkon.png');
	if (size==640) $('#sizerEmbed_3').attr('src','/media/v2/images/checkon.png');
	
	$('#PreviewPlayerBezoomEmbed').attr('width',size);
	$('#PreviewPlayerBezoomEmbed').attr('height',360*size/640);
	var o=thisMovie("PreviewPlayerBezoomEmbed");
	//o.updateSize(size,360*size/640);
	//updateFavPlayer(0,size);
}

function setPreviewSize(size)
{
	$('#selectedSize').attr('value',size);
	
	$('#sizer_1').attr('src','/media/v2/images/checkoff.png');
	$('#sizer_2').attr('src','/media/v2/images/checkoff.png');
	$('#sizer_3').attr('src','/media/v2/images/checkoff.png');
	
	if (size==320) $('#sizer_1').attr('src','/media/v2/images/checkon.png');
	if (size==480) $('#sizer_2').attr('src','/media/v2/images/checkon.png');
	if (size==640) $('#sizer_3').attr('src','/media/v2/images/checkon.png');
	
	$('#PreviewPlayerBezoom').attr('width',size);
	$('#PreviewPlayerBezoom').attr('height',360*size/640);
	var o=thisMovie("PreviewPlayerBezoom");
	//o.updateSize(size,360*size/640);
	//updateFavPlayer(0,size);
}

function updateFavPlayer(index,size)
{
	
	if (videostmp!=null)
	{
		//videostmp=getVideosItemsList(favorites.items);
		var arrFav=[];
		var vObj=null;
		for(ik=0;ik<videostmp.items.length;ik++)
		{
			if ($('#v_'+ik).attr('value')==1)
			{
				if (ik==index)
				{
					
					vObj={'id':videostmp.items[ik].customerId,'order':videostmp.items[ik].order,'url':videostmp.items[ik].fileUrl,'position':ik,'count':videostmp.length, 'thumb':(videostmp.items[ik].thumbUrl)?videostmp.items[ik].thumbUrl:'/media/v2/images/nothumb.png','videoid':videostmp.items[ik].id};
					
				}
				arrFav.push(videostmp.items[ik].id);
			}
		}
		
		var flashvars = {
			  pathToConfig: "/media/xml/config.xml",
			  iso: lng,
			  mode: "2",
			  video: escape(JSON.stringify(vObj)),
			  favorites: escape(JSON.stringify(arrFav))
		};
		var params = {
			  menu: "false",
			  quality: "best",
			  wmode: "transparent",
			  allowScriptAccess: "always",
			  allowFullScreen: "true",
			  movie: "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=2&video="+escape(JSON.stringify(vObj))+"&favorites="+escape(JSON.stringify(arrFav))
		};
		var attributes = {
			  id: "PreviewPlayerBezoom",
			  name: "PreviewPlayerBezoom"
		};
		//alert(JSON.stringify(vObj));
		var bypass=0;
		if ($('#previewVideo').html()!="")
		{
			bypass=1;
		}
			
	   	if (bypass==0) 
		{
			swfobject.embedSWF ( "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=2&video="+escape(JSON.stringify(vObj))+"&favorites="+escape(JSON.stringify(arrFav)), "previewVideo", "640", "360", "10", "/media/flash/expressInstall.swf", flashvars, params, attributes );
		}
		else
		{
			anotherPreview(vObj);
		}
	}
}

function popupMessage(txt) 
{
 $('#infoDivers').html(txt);
 var buttonsPopup = {};
        buttonsPopup[txt_ok] = function() { 
       
       $(this).dialog("close"); 
      }; 
      
  $('#infoDivers').dialog({
     modal: true,
     autoOpen: false,
     width: 600,
     buttons: buttonsPopup,
     closeOnEscape: true,
     close: function(event,ui) {
      $('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
      if ($('#infoDivers').html()==no_vid)
      {
       window.location.href='/'+lng+'/corporate-video';
      }
      
      
     }
    });
  //$.ui.dialog.defaults.bgiframe = true;
  //$('#info').dialog({ modal: true, draggable: true, resizeable: false, width:420, zIndex:2 }); 
  $('#infoDivers').dialog('open');
} 

function updatebar()
{
	$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
}

function placeMarquee()
{
	
	return;
	 $('#innerTicker marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        });			
} 



function swapVideo(i,videos2)
{
	//try {
	if (videos2) videos=videos2;
	//alert(i);
	
	if (videos.items.length==0) {
		
		popupMessage(no_vid);
		
		var videos2 = $.ajax({
  					url: host+'/'+lng+'/getOneVideo/',
					data: 'videos=6122',
  					async: false
 					}).responseText;
		
		eval('videos='+videos2+';');
		
		mainChange(videos,null);
		
	}
	
	var description2=videos.items[i].description;
	var title=videos.items[i].title;
	if ($('#upTitle')) {
		$('#upTitle').html(title);
		$('#innerTicker').html('<marquee scrollamount="2" behavior="scroll" direction="left" width="230">NOW PLAYING: <strong>'+title+'</strong></marquee>');
		placeMarquee();
	}
	var thumb=videos.items[i].logoUrl;
	if (!thumb)
	{
		thumb='http://www.bezoom.be/admin/thumbnails/logos/'+videos.items[i].customerId+'.jpg';
	}
	var url=videos.items[i].website;
	if ((!url)||(url==''))
		url='#';
	try {
	$('title').html(title);
	}
	catch (ex) {}
	var order=videos.items[i].order;
	var code=videos.items[i].customerId;
	var website=videos.items[i].website;
	var email=videos.items[i].email;
	var tel=videos.items[i].tel;
	var fax=videos.items[i].fax;
	var fileurl=videos.items[i].fileUrl;
	var tgpurl=fileurl.replace('.flv','.3gp').replace('.m4v','.3gp').replace('.mp4','.3gp');
	var testurl=tgpurl
	tgpurl=tgpurl.replace('http://video.proximedia.com/','http://www.bezoom.tv/3gp.asp?TheName=test&TheFile=D:/MMS/bezoom/');
	testurl=testurl.replace('http://video.proximedia.com/','http://www.bezoom.tv/Services/3gp.asp?My3gpPath=D:/MMS/bezoom/');
	
	var tgpdata1='';
	var tgpdata2='';
		
	var tgpresult=0;
		
		tgpresult = $.ajax({
  			async: false, 
  			url: '/fr/test-gsm',
			data: 'url='+escape(testurl)
 }).responseText;
		
		
		
		if (tgpresult==1) {	
		
		
	tpgurl = $.ajax({
  			async: false,
  			url: '/fr/test-gsm',
			data: 'url='+escape(tgpurl)
 }).responseText;
		
		if (tpgurl!='')
		{
			tgpdata1='<a href="'+tgpurl+'" target="_blank">'+txt_telecharger+' <img src="/media/images/picto3gp.png" class="inlineBlock"  border="0" alt="'+txt_telecharger+'" title="'+txt_telecharger+'"/></a> ';
				tgpdata2='<a href="'+tgpurl+'" target="_blank"><img src="/media/v2/images/share-3g.png" class="inlineBlock"  border="0" alt="'+txt_telecharger+'" title="'+txt_telecharger+'"/> '+txt_telecharger+'</a> ';
		}
		
		}
		
	var vidObj={'id':code, 'order':order, 'url':fileurl, 'position':i, 'count':videos.items.length, 'videoid':videos.items[i].id};
	var arr=new Array();
	if (favorites)
		for(var ik=0;ik<favorites.items.length;ik++)
		{
			arr.push({'id':favorites.items[ik].customerId,'order':favorites.items[ik].order,'url':favorites.items[ik].fileUrl,'position':ik,'count':favorites.length, 'thumb':(favorites.items[ik].thumbUrl)?favorites.items[ik].thumbUrl:'/media/v2/images/nothumb.png'});
		}
	
	try {
	if (play(vidObj)!=0) {
		//alert('lecture impossible');
		}
	}
	catch (ex) 
	{
	}
	
	
	/*if (!host) host='http://www.bezoom.tv';
	//alert(host);
	var html='';
     html+='<object type="application/x-shockwave-flash" data="'+host+'/media/flash/Main.swf" width="638" height="387" id="PlayerBezoom" align="middle">';
	  html+='<param name="codebase" value="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0" />';
     html+='<param name="allowScriptAccess" value="always" />';
        html+='<param name="allowFullScreen" value="true" />';
        html+='<param id="flashvars" name="flashvars" value="pathToConfig='+host+'/media/xml/configweb.xml&CustomerId='+code+'&CustomerVideo='+order+'&PlayerSkin=Grey&PlayerPlays=yes&PlayerTitles=no&PlayerWidth=638&PlayerHeight=387&CurrentVideo=&PlayerBack=&LogoBezoom=no&Get3gp=&varresult=&PlayerLoop=yes&Video='+escape(JSON.stringify(vidObj))+'&iso='+lng+'&mode=0&favorites='+escape(JSON.stringify(arr))+'" />';
		
        html+='<param name="movie" value="'+host+'/media/flash/Main.swf" />';
	
        html+='<param name="quality" value="best" />';
        html+='<param name="wmode" value="transparent" />';
        html+='<param name="bgcolor" value="#000000" />';
        html+='<embed id="embed" src="'+host+'/media/flash/Main.swf" flashvars="PathToConfig='+host+'/media/xml/configweb.xml&CustomerId='+code+'&CustomerVideo='+order+'&PlayerSkin=Grey&PlayerPlays=yes&PlayerTitles=no&PlayerWidth=638&PlayerHeight=387&CurrentVideo=&PlayerBack=&LogoBezoom=no&Get3gp=&varresult=&PlayerLoop=yes&video='+escape(JSON.stringify(vidObj))+'&iso='+lng+'&mode=0&favorites='+escape(JSON.stringify(arr))+'" quality="best" wmode="transparent" bgcolor="#000000" width="638" height="387" name="PlayerBezoom" align="middle" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        html+='</object>';
//alert(html);
		$('#innerVideo').html(html);
	*/
		
		var flashvars = {
			  pathToConfig: "/media/xml/config.xml",
			  iso: lng,
			  mode: "0",
			  video: (JSON.stringify(vidObj)),
			  favorites: (arr)
			};
			var params = {
			  menu: "false",
			  quality: "best",
			  wmode: "transparent",
			  allowScriptAccess: "always",
			  allowFullScreen: "true",
			  movie: "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=0&video="+escape(JSON.stringify(vidObj))+"&favorites="+escape(JSON.stringify(arr))
			};
			var attributes = {
			  id: "PlayerBezoom",
			  name: "PlayerBezoom"
			};
    		
			bypass=0;
			if ($('#innerVideo').html()!="")
			{
				bypass=1;
			}
			
	   		if (bypass==0) 
			{
				//alert(JSON.stringify(vidObj));
				swfobject.embedSWF ( "/media/flash/Main.swf?pathToConfig=/media/xml/config.xml&iso="+lng+"&mode=0&video="+escape(JSON.stringify(vidObj))+"&favorites="+escape(JSON.stringify(arr)), "innerVideo", "638", "360", "10", "/media/flash/expressInstall.swf", flashvars, params, attributes );
			}
			else
				anotherVideo(vidObj);
			
			
		updateCloud(i);
		//alert('a');
		if (lastVideo!=-1)
		{
			//document.getElementById('playlistItem'+lastVideo).style.backgroundImage='url(/media/images/background-playlist-off.png)';
			document.getElementById('playlistItem'+lastVideo).style.backgroundColor='#141414';
		
			$('#playlistItem'+lastVideo).css('border-bottom','1px solid #262626');
			$('#playlistItem'+lastVideo+' strong').css('color','#07cdff');
			$('#playlistItem'+lastVideo+' span').css('color','white');
		}
		lastVideo=i;
		document.getElementById('playlistItem'+lastVideo).style.backgroundColor='#454444';
		
			$('#playlistItem'+lastVideo).css('border-bottom','1px solid #262626');
		//document.getElementById('playlistItem'+lastVideo).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		$('#playlistItem'+lastVideo+' strong').css('color','#07cdff');
		$('#playlistItem'+lastVideo+' span').css('color','white');
		
		if (url=='#')
			$('#thumbLink').attr('target','_self');	
		else
			$('#thumbLink').attr('target','_blank');	
		$('#thumbLink').attr('href',url);
		$('#thumbPhoto').css('display','inline-block');
		
		
		//var tmpPhoto = new Image(); 
		//tmpPhoto.src = thumb; 
		//waitPhoto(5);
		//$('#thumbPhoto').attr('src',thumb);
		$('#thumbPhoto').attr('src','/fr/resizer?url='+thumb);
		//alert('/fr/resizer?url='+thumb);
		//if (tmpPhoto.width>=160)
		//{
		//	$('#thumbPhoto').attr('width',160);
			
		//}
		//else
		//{
		//	$('#thumbPhoto').attr('width',tmpPhoto.width);
		//}
		
		
		//$('#thumbPhoto').attr('alt',title);
		$('#thumbPhoto').attr('title',title);
		$('#thumbTitle').html(title);
		if (thumb!='http://medias.bezoom.tv/')
		{
			 $('#thumbLink').css('display','block');
			$('#thumbBorders').css('border-color','#3c3c3c');
		}
		else
		{
			 $('#thumbLink').css('display','none');
			$('#thumbBorders').css('border-color','#111111');
		}
		//document.getElementById('thumBorders').style.borderColor='#3c3c3c';
		if ($('#titleMap')) $('#titleMap').html(title);
	
		
		
		if(document.getElementById('GoogleApiMap')) {
			//document.getElementById('GoogleApiMap').style.display='block';
			loadgmap(i,videos,category);
		}
		
		/*var host=document.location.href;
		host=host.split('?');
		host=host[0];*/
		
		var host=document.location.href;
		host=host.split('/');
		host=host[0]+'//'+host[2];
		 
		
	
	var tmpVid={'id':videos.items[i].customerId, 'order':videos.items[i].order, 'url':videos.items[i].fileUrl, 'position':i, 'count':videos.items.length,'videoid':videos.items[i].id};
		
		$('#linklist').html('<div id="topitem"><a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'\',\''+videos.items[i].thumbUrl+'\'); " href="javascript:void(0);">'+txt_email_video+' <img src="/media/images/pictoAmi.png"  style="border:0;" alt="'+txt_email_video+'" title="'+txt_email_video+'" class="inlineBlock"/></a> '+tgpdata1+'<a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'&t=Bezoom.tv&d=Beezom" target="blank_">'+txt_facebook+' <img src="/media/images/pictofb.png"  style="border:0;" alt="'+txt_facebook+'" title="'+txt_facebook+'" class="inlineBlock"/></a></div>');
		
		if ($('#quickLinks'))
		{
			$('#quickLinks').html('<img src="/media/v2/images/top-share.png" alt="" title="" style="display:block;"/><a href="http://www.facebook.com/share.php?u='+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'&t=Bezoom.tv&d=Beezom" target="blank_"><img src="/media/v2/images/share-facebook.png"  style="border:0;" alt="'+txt_facebook+'" title="'+txt_facebook+'" class="inlineBlock"/> Facebook</a> <a class="addthis_button_twitter" addthis:url="'+host+'?id='+videos.items[i].id+'"><img src="/media/v2/images/share-twitter.png"  style="border:0;" alt="'+txt_twitter+'" title="'+txt_twitter+'" class="inlineBlock"/> Twitter</a> <a href="javascript:void(0);" onclick="embed(\''+escape(JSON.stringify(tmpVid))+'\');"><img src="/media/v2/images/share-embed.png"  style="border:0;" alt="" title="" class="inlineBlock"/> Embed</a> <a onclick="javascript:updateInfo(\''+host+'/'+lng+'/corporate-video'+'?id='+videos.items[i].id+'\',\''+videos.items[i].thumbUrl+'\'); " href="javascript:void(0);"><img src="/media/v2/images/share-email.png" style="border:0;" alt="'+txt_email_video+'" title="'+txt_email_video+'" class="inlineBlock"/> '+txt_email_video+'</a>  '+tgpdata2+'<a href="javascript:void(0);" onclick="addFavorite();"><img src="/media/v2/images/share-favorite.png" class="inlineBlock"  border="0" alt="'+txt_add_favoris+'" title="'+txt_add_favoris+'"/> '+txt_add_favoris+'</a><img src="/media/v2/images/bottom-share.png" alt="" title="" style="display:block;"/><div style="background-color:#111111; padding-top:9px;"><div style="background-color:#1c1c1c;  background: url(/media/v2/images/background-share.png) repeat-y;"><img src="/media/v2/images/top-share.png" alt="" title="" style="display:block; "/><a href="javascript:void(0);" onclick="createFavorite();"><img src="/media/v2/images/createFavoris.png" class="inlineBlock"  border="0" alt="'+txt_create_favoris+'" title="'+txt_create_favoris+'"/> '+txt_create_favoris+'</a><img src="/media/v2/images/bottom-share.png" alt="" title="" style="display:block;"/></div></div>');
			var NewScript=document.createElement('script');
	NewScript.src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c654c791c218d89&domready=1&async=true";
	document.body.appendChild(NewScript);
	try {
	if (addthis) addthis.init();
	} catch (ex) {
	}
	
		}
		
		
		
		/*$("#content").bind("mousemove", function(e) { 
			var o=$('#innerVideo').offset();
			var test1=parseInt($('#topitem').css('margin-top'))==0;
			var test2=(e.pageX>o.left);
			var test3=(e.pageX<(o.left+$('#innerVideo').width()));
			var test4=(e.pageY>o.top);
			var test5=(e.pageY<(o.top+$('#innerVideo').height()));
			var test6=!(test2&&test3&&test4&&test5);
			var test7=test6&&test1;
						
			if (test7)
			{
				
				if (barstatus==1) $('#topitem').blindOff('normal','linear',swapBarStatus2(''),0);
				
			}


			if ((test6==false)&&(parseInt($('#topitem').css('margin-top'))==-46))
			{
				
				if (barstatus==0) $('#topitem').blindOn('normal','linear',swapBarStatus(''),1);
				//$('#info').html('test'+e.pageX+' '+barstatus);
			}
		});*/
		
		$('#description').html('');
		try {
		document.getElementById('description').innerHTML='';
		} catch (ex) {
		}
		if ((description2)&&(description2!=null)&&(description2!='null'))
		{
			$('#description').html(description2);
		    if ((keyw!='')&&(keyw))
			{
				
				var ohtml=$('#description').html();
				var ex=new RegExp('('+keyw.replace(/\s/gi,'|')+')','gi');
	 			var nhtml=ohtml.replace(ex,'<span style="background-color:#00ccff;">$1</span>');
	    		$('#description').html(nhtml);
				$('input.keyword').each(function(i) {
						this.value=keyw;							 
				});
			}
			else
			{
				$('#description').html(description2);
			}
			
		}
		else
		{
			$('#description').html('');
		}
		
		if ((videos.items[i].street)&&(videos.items[i].street!=null)&&(videos.items[i].street!='null')&&(videos.items[i].postcode)&&(videos.items[i].postcode!=null)&&(videos.items[i].postcode!='null')&&(videos.items[i].city)&&(videos.items[i].city!=null)&&(videos.items[i].city!='null')&&(videos.items[i].country)&&(videos.items[i].country!=null)&&(videos.items[i].country!='null'))
		{
			$('#addres').html(videos.items[i].street+'<br/>'+videos.items[i].postcode+' '+videos.items[i].city+'<br/>'+videos.items[i].country);
		}
		else
			$('#addres').html('');
		
		var linksHTML="";
		
		if ((tel)&&(tel!=null)&&(tel!='null'))
		{
			linksHTML+=' tel:'+tel+'<br/>';
		}
		
		if ((fax)&&(fax!=null)&&(fax!='null'))
		{
			linksHTML+=' fax:'+fax+'<br/>';
		}
		
		if ((website)&&(website!=null)&&(website!='null'))
		{
			
			if (website.search(/http/i)>-1)
			{
				linksHTML+='<a href="'+website+'" class="inlineBlock"  target="_blank" >'+website+'</a>';
			}
			else
				linksHTML+='<a href="http://'+website+'" class="inlineBlock"  target="_blank" >'+website+'</a>';
		}
		
		if ((email)&&(email!=null)&&(email!='null'))
		{
			linksHTML+='<a href="mailto:'+email+'"  class="inlineBlock">'+email+'</a>'
		}
		
		
		
		$('#links').html(linksHTML);
		
		
	//document.getElementById('flashvars').value='CustomerId='+code+'&CustomerVideo='+order+'&PlayerSkin=Grey&PlayerPlays=no&PlayerTitles=no&PlayerWidth=640&PlayerHeight=380&CurrentVideo=&PlayerBack=&LogoBezoom=no&Get3gp=&varresult=&PlayerLoop=yes';
	
	/*if (document.getElementById('embed')!=null)
	{
		document.getElementById('embed').attributes['flashvars'].value='ustomerId='+code+'&CustomerVideo='+order+'&PlayerSkin=Grey&PlayerPlays=no&PlayerTitles=no&PlayerWidth=640&PlayerHeight=380&CurrentVideo=&PlayerBack=&LogoBezoom=no&Get3gp=&varresult=&PlayerLoop=yes';
	}*/
	
	 //} catch (ex)
	//{
	//	alert('error swaping video');
	//}
	changeFavIcon();
	window.setTimeout('updateSize()',500);
	
}

function updateSize()
{
	//alert(actualMode);
	//alert(actualMenu);
	if (actualMode==1)
	{
		$('#videoTitle').css('width','963px');
		$('#video').css('width','971px');
		$('#playingVideo').css('width','971px');
		$('#PlayerBezoom').attr('width','971');
			
		$('#video').css('height','545px');
		$('#playingVideo').css('height','545px');
		$('#PlayerBezoom').attr('height','545');
		
		if ((actualMenu==13)||(actualMenu==14))
		{
			$('#floatingList').css('margin-top','570px');
			$('#floatingList').css('margin-left','648px');
	
			
			if (ie7==1)
			{
				$('#floatingList').css('margin-left','-318px');
			}
			
			$('#contentInfo').css('margin-left','-463px');
			$('#contentInfo').css('margin-top',$('#contentData').outerHeight()+'px');
			
			$('#contentTag').css('margin-top','380px');
			
			
			var h=($('#contentData').outerHeight()+$('#contentInfo').outerHeight());
			var h2=380+$('#contentTag').outerHeight();
			if (h2>h) h=h2;
			$('#activeTable').css('height',h+'px');
		}
		else
		{
			$('#floatingList').css('margin-top','780px');
			$('#floatingList').css('margin-left','648px');
			$('#rightHome').css('margin-top',(60+parseInt($('#floatingList').outerHeight()))+'px');
	
			if (ie7==1)
			{
				$('#floatingList').css('margin-left','643px');
				$('#floatingList').css('margin-left','-318px');
				
			}
			
			
			//var h=$('#rightHome').outerHeight();
			//$('#activeTable').css('height',h+'px');
		}
		
		
	}
	if (actualMode==0)
	{
		$('#videoTitle').css('width','632px');
        $('#video').css('width','638px');
		$('#playingVideo').css('width','638px');
		$('#PlayerBezoom').attr('width','638');
		
		$('#video').css('height','360px');
		$('#playingVideo').css('height','360px');
		$('#PlayerBezoom').attr('height','360');
		
		if ((actualMenu==13)||(actualMenu==14))
		{
			$('#floatingList').css('margin-top','-20px');
			$('#floatingList').css('margin-left','648px');
			
			
			if (ie7==1)
			{
				//$('#floatingList').css('margin-top','720px');
				$('#floatingList').css('margin-left','12px');
			}
			
			$('#contentInfo').css('margin-left','0px');
			$('#contentInfo').css('margin-top','0px');	
			$('#contentTag').css('margin-top','275px');
			var h2=$('#contentInfo').outerHeight()+$('#contentTag').outerHeight();
			var h=($('#contentData').outerHeight()>h2)?$('#contentData').outerHeight():h2;
			$('#activeTable').css('height',h+'px');
		}
		else
		{
			$('#floatingList').css('margin-top','-20px');
			$('#floatingList').css('margin-left','648px');
			
			if (ie7==1)
			{
				//$('#floatingList').css('margin-top','720px');
				$('#floatingList').css('margin-left','12px');
			}
			
			$('#rightHome').css('margin-top','0px');		
			//var h=$('#rightHome').outerHeight();
			//$('#activeTable').css('height',h+'px');
		}
		
	}
}

function annulEvent(e)
{
    try 
    {
        e.stopPropagation();
    }
    catch (ex)
    {
        window.event.cancelBubble=true;
    }
}

// Extension must be .jpg .gif .png ( 3 letters )
function imgOn(elem,extension)
{
	if (elem.src.substr(elem.src.length-7,7)!='-on.'+extension)
	{
		elem.src=elem.src.substr(0,elem.src.length-4)+'-on.'+extension;
	}	
}
function imgOff(elem,extension)
{	
	if (elem.src.substr(elem.src.length-7,7)=='-on.'+extension)
	{
		elem.src=elem.src.substr(0,elem.src.length-7)+'.'+extension;
	}
}

function initContactPage()
{
	//$('.contactData').css('display','none');
	//$('#databel').css('display','inline');
	
	
	var contactCountrySelected = $('#contactCountryNav a').first().attr('id');
	
	// Google maps URL
	var gmaps = [];
	gmaps['bel'] = "http://maps.google.be/maps?f=q&source=s_q&hl=fr&geocode=&q=Boulevard+de+l'humanit%C3%A9+241,+1620+Drogenbos&sll=50.810003,4.306812&sspn=0.030264,0.067892&ie=UTF8&hq=&hnear=Boulevard+de+l'Humanit%C3%A9+241,+Drogenbos+1620+Drogenbos,+Brabant+Flamand,+Vlaams+Gewest&z=16";
	gmaps['usa'] = "http://maps.google.be/maps?f=q&source=s_q&hl=fr&geocode=&q=2634+North+Fairfax+Drive,+ARLINGTON+VA+22201&mrt=loc&sll=48.904013,2.243362&sspn=0.010184,0.027788&ie=UTF8&hq=&hnear=2634+N+Fairfax+Dr,+Arlington,+Virginia+22201,+%C3%89tats-Unis&z=16";
	gmaps['fra'] = "http://maps.google.be/maps?f=q&source=s_q&hl=fr&geocode=&q=6,+rue+de+la+Ferme,+92250+La+Garenne+Colombes&mrt=loc&sll=48.89089,2.282066&sspn=0.040745,0.111151&ie=UTF8&hq=&hnear=6+Rue+de+la+Ferme,+92250+La+Garenne-Colombes,+Hauts-de-Seine,+Ile-de-France,+France&z=16";
	gmaps['ger'] = "http://maps.google.be/maps?f=q&source=s_q&hl=fr&geocode=&q=Boulevard+de+l'humanit%C3%A9+241,+1620+Drogenbos&sll=50.810003,4.306812&sspn=0.030264,0.067892&ie=UTF8&hq=&hnear=Boulevard+de+l'Humanit%C3%A9+241,+Drogenbos+1620+Drogenbos,+Brabant+Flamand,+Vlaams+Gewest&z=16";
	
	$('#contactCountryNav a img:first-child').mouseenter(function() {
			if(contactCountrySelected == $(this).parent('a').attr('id')) return;
			imgOn($(this)[0],'gif');	
		});	
	$('#contactCountryNav a img:first-child').mouseleave(function() {
			if(contactCountrySelected == $(this).parent('a').attr('id')) return;
			imgOff($(this)[0],'gif');	
		});
	
	$('#contactCountryNav a').click(function(){
		if(contactCountrySelected == 	$(this).attr('id')) return false;							
		imgOff($('a#'+contactCountrySelected+' img:first-child')[0],'gif');								 
		contactCountrySelected = $(this).attr('id');
		$('#contactCountryNav a img.contactMapSelect').hide();	
		$(this).find('img.contactMapSelect').show();
		
		//$('#companyAddress .contactData').css('display','none');
		//$('#companyAddress .contactData').css('display','none');
		//$('#companyAddress #data'+contactCountrySelected).css('display','block');
		document.getElementById('datafra').style.display='none';
		document.getElementById('datager').style.display='none';
		document.getElementById('databel').style.display='none';
		document.getElementById('datausa').style.display='none';
		document.getElementById('data'+contactCountrySelected).style.display='block';
		
		$('#companyMap #map').find('iframe').attr('src',gmaps[contactCountrySelected]+'&output=embed');
		$('#companyMap #map').find('a').attr('href',gmaps[contactCountrySelected]);
		return false;										 
	});
	$('#companyAddress div:not(:first)').hide();

	
}

function testimonialExec(ountry,cibled)
{
	
	$('#testimony').unbind('mouseenter');
	
	$('#testimony').mouseenter(function() {
		eval('window.clearInterval(eventMaster)');
	})
	
	$('#testimony').unbind('mouseleave');
	
	$('#testimony').mouseleave(function() {
		/*if ($('#testimonyInfoLong').attr('mystate')=='opened') {
			$('#testimonyInfoLong').animate({height:0},500,function () {
				$('#testimonyInfoLong').attr('mystate','closed');
				$('#testimonyInfoLong').css({display:'none'});
			});
		}*/
		eval("eventMaster=window.setInterval('testimonialExec(\""+country+"\",\""+cibled+"\")',5000);");	
	})
	
	$.ajax({
			  type: "GET",
			  dataType: "xml",
			  async:true,
			  url: '/media/testimony.xml',
			  data:'',
			  success: function(data, textStatus, jqXHR) {
				cptTestimony=0;
				$(data).find(cibled).each( function(){ 
					$(this).find(lng).each(function () {
							$(this).find('testimonial').each(function () {
								
								
								if (actualTestimony==cptTestimony) {
									var tcompnay = $(this).find('company').text();
									var ttestimony = $(this).find('testimony').text();
									var ttestimonyLong = $(this).find('testimonyLong').text();
									var tname = $(this).find('name').text();
									var tsite = $(this).find('site').text();
									var tvideo = $(this).find('video').text();
									var tlogo = $(this).find('logo').text();
									
									$('#testimonysite'+dest).attr('href','javascript:void(0)');
									$('#testimonyvideo'+dest).attr('href','javascript:void(0)');
									$('#testimonyLogo'+dest).attr('src',tlogo);
									$('#testimonyvideo'+dest).html('<img src="/media/images/g1.png" align="left"  border="0"/>'+ttestimony+'<img src="/media/images/g2.png"  border="0"/>');
									$('#testimonyInfo'+dest).html(tname+'-'+tcompnay);
									var ht='<div><div>'+ttestimonyLong+'<span class="testimonyNameLong">'+tname+'</span><br/><hr/><br/>';
									if (tvideo!='')  ht+='<a class="testimonySiteButton" href="'+tvideo+'"><span>'+voirVideoTxt+'</span></a>';
									if (tsite!='') ht+='<a target="_blank" class="testimonySiteButton" href="'+tsite+'"><span>'+voirSiteTxt+'</span></a>';
									ht+='<br clear="all"/></div></div>';
									$('#testimonyInfoLong'+dest).html(ht);
									
									if (ttestimony!='')
									{
										$('#testimony').css({display:'block'});
										if (dest=='2')
										{
											$('#testimonyRibbon').animate({marginTop:-66+'px'},500,function () {
												$('#testimonysite').attr('href',tsite);
												$('#testimonyvideo').attr('href','javascript:void(0);');
												$('#testimonyLogo').attr('src',tlogo);
												$('#testimonyvideo').html('<img src="/media/images/g1.png" align="left"  border="0"/>'+ttestimony+'<img src="/media/images/g2.png"  border="0"/>');
												$('#testimonyInfo').html(tname+'-'+tcompnay);
												$('#testimonyRibbon').css({marginTop:0});
												var ht='<div><div>'+ttestimonyLong+'<span class="testimonyNameLong">'+tname+'</span><br/><hr/><br/>';
												if (tvideo!='')  
													ht+='<a class="testimonySiteButton" href="'+tvideo+'"><span>'+voirVideoTxt+'</span></a>';
												 if (tsite!='') 
												 	ht+='<a target="_blank" class="testimonySiteButton" href="'+tsite+'"><span>'+voirSiteTxt+'</span></a>';
													 ht+='<br clear="all"/></div></div>';
													$('#testimonyInfoLong').html(ht);
											});
										}
										
										$('#testimonyvideo').unbind('mouseenter');
										
										$('#testimonyvideo').mouseenter(function () {
											if 	($('#testimonyInfoLong').attr('mystate')=='closed') {
												$('#testimonyInfoLong').css({display:'block'});
												$('#testimonyInfoLong').animate({height:'600px'},500,function () {
														$('#testimonyInfoLong').attr('mystate','opened');
												});
											}
										});
										
										$('#testimonysite').unbind('mouseenter');
										
										$('#testimonysite').mouseenter(function () {
											if 	($('#testimonyInfoLong').attr('mystate')=='closed') {
												$('#testimonyInfoLong').css({display:'block'});
												$('#testimonyInfoLong').animate({height:'600px'},500,function () {
														$('#testimonyInfoLong').attr('mystate','opened');
												});
											}
										});
										
										$('#testimonyInfoLong').unbind('mouseleave');
										
										$('#testimonyInfoLong').mouseleave(function () {
											if ($('#testimonyInfoLong').attr('mystate')=='opened') {
												$('#testimonyInfoLong').animate({height:0},500,function () {
														$('#testimonyInfoLong').attr('mystate','closed');
														$('#testimonyInfoLong').css({display:'none'});
												});
											}
										});
										
										$('#testimonyvideo2').unbind('mouseenter');
										
										$('#testimonyvideo2').mouseenter(function () {
											if 	($('#testimonyInfoLong').attr('mystate')=='closed') {
												$('#testimonyInfoLong').css({display:'block'});
												$('#testimonyInfoLong').animate({height:'600px'},500,function () {
														$('#testimonyInfoLong').attr('mystate','opened');
												});
											}
										});
										
										$('#testimonysite2').unbind('mouseenter');
										
										$('#testimonysite2').mouseenter(function () {
											if 	($('#testimonyInfoLong').attr('mystate')=='closed') {
												$('#testimonyInfoLong').css({display:'block'});
												$('#testimonyInfoLong').animate({height:'600px'},500,function () {
														$('#testimonyInfoLong').attr('mystate','opened');
												});
											}
										});
										
										$('#testimonyInfoLong2').unbind('mouseleave');
										
										$('#testimonyInfoLong2').mouseleave(function () {
											if ($('#testimonyInfoLong').attr('mystate')=='opened') {
												$('#testimonyInfoLong').animate({height:0},500,function () {
														$('#testimonyInfoLong').attr('mystate','closed');
														$('#testimonyInfoLong').css({display:'none'});
												});
											}
										});
									}
										
									dest=2;
								}
								cptTestimony++;
							});
					});
				});
				totalTestimony=cptTestimony;
				actualTestimony=Math.floor(Math.random()*cptTestimony);
				/*if (actualTestimony<totalTestimony-1) 
				{
					actualTestimony++;
				}
				else
				{
					actualTestimony=0;
				}*/
			  },
			  complete: function (jqXHR, textStatus) {
				
			  },
			  error: function (jqXHR, textStatus, errorThrown) {
				 
			  }
			  });
}
