// JavaScript Document



if (document.body.__defineGetter__) {
	if (HTMLElement) {
		var element = HTMLElement.prototype;
		if (element.__defineGetter__) {
			element.__defineGetter__("outerHTML",
			function () {

				var p=this.parentNode;
				if (p==null)
				{ 
					var el = document.createElement("div");
					el.appendChild(this);
				}
				else
					el=p;
				var shtml = el.innerHTML;
				return shtml;
				}
			);
		}
		element.__defineSetter__("outerHTML",function(sHTML){
        this.parentNode.innerHTML=sHTML;
        return sHTML;
		});
	}
}

		jQuery(document).ready(function() {
								   
			$('nav.subMenu a[href=/'+lng+'/]').css('color','#00ccff');
			
			placeMarquee();

			
  			placeMenuOver();
			placeSearches();
			
			changeFavIcon();
			var cibled='';
			
			if ((host=='http://30439.frog01.proximedia.com')||(host=='http://www.bezoom.tv')||(host=='http://www.bezoom.be')||(host=='http://www.bezoom.nl')||(host=='http://www.bezoom.com'))
			{
				$('#frurl').attr('src','/media/v2/images/fr-on.png');
				$('#frurl').parent().attr('onmouseover','');
				$('#frurl').parent().attr('onmouseout','');
				country='BE';
				cibled='countryBe';
			}
			
			if (host=='http://www.bezoom.fr')
			{
				$('#nlurl').attr('src','/media/v2/images/nl-on.png');
				$('#nlurl').parent().attr('onmouseover','');
				$('#nlurl').parent().attr('onmouseout','');
				country='FR';
				cibled='countryFr';
			}
			
			if (host=='http://www.bezoom.de')
			{
				$('#deurl').attr('src','/media/v2/images/de-on.png');
				$('#deurl').parent().attr('onmouseover','');
				$('#deurl').parent().attr('onmouseout','');
				country='DE';
				cibled='countryDe';
			}
			
			if (host=='http://www.bezoom.us')
			{
				$('#usurl').attr('src','/media/v2/images/us-on.png');
				$('#usurl').parent().attr('onmouseover','');
				$('#usurl').parent().attr('onmouseout','');
				country='US';
				cibled='countryUs';
			}
			
			//testimonial adendum
			testimonialExec(country,cibled);
			
			eval("eventMaster=window.setInterval('testimonialExec(\""+country+"\",\""+cibled+"\")',5000);");
			//end testimonial
			
			
			$("#formFriend").validationEngine({
				success :  false,
				failure : function() {}
			});
			
			$(".mainMenu a").each(function(i) {
				
				try {
				if (this.href==host+'/'+lng+'/corporate-video')
				{
					
					this.onmouseover=function () {
						var offset=$(this).offset();
						var h=$(this).outerHeight();
						
						$('#categoryNav').css('top',offset.top+h);
						$('#categoryNav').css('left', offset.left);
						$('#categoryNav').css('display','block');
					};
					
					this.onmousemove=function(e) {
						//event = event?event:window.event;
						annulEvent(e);
					};
					
					document.body.onmousemove=function() {
						$('#categoryNav').css('display','none');
						$('#subcat').css('display','none');
					}
				}
				}
				catch (ex) {
				}
				
				
				$(".contentKeyword").mousemove(function(e) {
					//recherche coordoner souris
					//alert(e.pageX+' '+e.pageY);
					//recherch cooerdoner zone
					var offset = $(this).offset();
					if ((e.pageX>(offset.left+151))&&(e.pageY>offset.top))
					{
						if ((e.pageX<(offset.left+151+93))&&(e.pageY<(offset.top+21)))
						{
							$('#subcat').css('top',offset.top+21);
							$('#subcat').css('left',offset.left+151);
							$('#subcat').css('display','block');
						}
					}
					annulEvent(e);
				
			});	
			
			if ($("#subcat"))
			{
				$("#subcat").each(function(i) {
					this.onmousemove=function(e) {
						annulEvent(e);
					}
				});
				
				$("#subcat a").each(function(i) {
					this.onclick=function(e) {
						$(".contentKeyword div").html(this.innerHTML);
						selectedSeaarchCat=this.innerHTML;
						$('#catv').attr('value',this.name.substr(2,this.name.length-2));
						annulEvent(e);
					}
				});
			}
			
			});
			

 		
		
		
		//document.getElementById('playlistItem'+0).style.backgroundImage='url(/media/images/background-playlist-on.png)';
		
		document.getElementById('playlistItem'+0).style.backgroundColor='#454444';
		
		$('#playlistItem'+0+' strong').css('color','#07cdff');
		$('#playlistItem'+0+' span').css('color','white');
		lastVideo=0;
		
		
		$('#thumbTitle').html(videos.items[0].title);
	
		$('#thumbLink').attr('href',videos.items[0].fileUrl);
	
		//var tmpPhoto = new Image(); 
		//tmpPhoto.src = videos.items[0].thumbUrl; 
		//waitPhoto(5);
		//$('#thumbPhoto').attr('src',videos.items[0].thumbUrl);
		$('#thumbPhoto').attr('src','/fr/resizer?url='+videos.items[0].thumbUrl);
		
		//if (tmpPhoto.width>=160)
		//{
		//	$('#thumbPhoto').attr('width',160);
			
		//}
		//else
		//{
		//	$('#thumbPhoto').attr('width',tmpPhoto.width);
			
		//}
		//document.getElementById('thumBorders').style.borderColor='#3c3c3c';
	if (videos.items[0].thumbUrl!='http://medias.bezoom.tv/')
	{
		 $('#thumbLink').css('display','block');
			$('#thumbBorders').css('border-color','#3c3c3c');
	}
		else
		{
			 $('#thumbLink').css('display','none');
			$('#thumbBorders').css('border-color','#111111');
		}
		var found=-1;
		var detecting=document.location.href;
		var reg=/http:\/\/([a-zA-Z0-9.-]+)\/(en|fr|nl|de)?\/?([a-zA-Z0-9_.-]*)\?id=([0-9]*)&section=([0-9-]*)/gi
		
		$('#jScrollPaneContainer').css('height','330px !important');
		
		
		if (m=reg.exec(detecting))
		{
		
				for(var i=0;i<videos.items.length;i++)
				{
					if (videos.items[i].id==m[4])
						found=i;
				}
				
				//placeMenuOver();
				
					$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 61});
					
					
					
					if (found==-1)
					{
						swapVideo(0);
					}
					else
					{
						swapVideo(found);
						//$('#playList').scrollTo(0,64*found);
					}
		}
		else
		{
		
		if ($('#playList'))
			$('#playList').jScrollPane({showArrows:true,scrollbarWidth: 16,dragMaxHeight: 161});
			
			swapVideo(0);
		}

		
		
		window.setTimeout("updatebar()",2000);
		
});
		
