

	function poplightClick(el) {

	    var popID = $(el).readAttribute('rel'); //Get Popup Name

	    //Fade in the Popup and add close button
    	$(popID).appear().insert('<a href="#" onclick="return poplightClose();" class="btn_close">CLOSE <img src="/images/close.gif" class="btn_close" title="Close Window" alt="Close"></a>');

    	//Define margin for center alignment (vertical   horizontal) - we add 80px to the height/width to accomodate for the padding  and border width defined in the css

		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}

    	var popTop = (myHeight - $(popID).getHeight()) / 2;
    	var popLeft = (myWidth - $(popID).getWidth()) / 2;

    	//Apply Margin to Popup
    	$(popID).setStyle({
    	    'top' : popTop,
    	    'left' : popLeft
    	});

    	//Fade in Background
    	if ($('fade'))
			$('fade').remove();

    	document.body.insert('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
    	$('fade').setStyle({'filter' : 'alpha(opacity=80)'}).appear(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    	return false;
	}
	
	function poplightClose() {

		$('fade').fade();
	    $('v-youtube').fade();

    	$$('a.close').each(function(item) { item.remove(); });

    	return false;
	}
	
	function open_youtube(elemento) {

		$(elemento).writeAttribute('rel', 'v-youtube');

		new Ajax.Updater('v-youtube', '/scripts/gallery.php', {

			parameters: { 'id' : $(elemento).readAttribute('href') },
			onComplete: function () {

				poplightClick(elemento);
				
			}

		});
		
	}

