
	$(document).ready(function(){
		$('a.videoPlayer[href^=#]').click(function() {
		    var popID = $(this).attr('rel'); 
		    var popURL = $(this).attr('href'); 
		    var query= popURL.split('?');
		    var dim= query[1].split('&');
		    var popWidth = dim[0].split('=')[1];
		
		    //Fade in the Popup and add close button
		    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="videoClose">Close</a>');
		
		    var popMargTop = ($('#' + popID).height() + 80) / 2;
		    var popMargLeft = ($('#' + popID).width() + 80) / 2;
		
		    $('#' + popID).css({
		        'margin-top' : -popMargTop,
		        'margin-left' : -popMargLeft
		    });
		
		    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
		
		    return false;
		});
		
		//Close
		$('a.videoClose, #fade').live('click', function() { //When clicking on the close or fade layer...
		    $('#fade , .videoPop, .requestPop').fadeOut(function() {
		        $('#fade, a.videoClose').remove();  //fade them both out
		    });
		    return false;
		});	
	});

	$(document).ready(function(){
		$('a.image[href^=#]').click(function() {
		    var popID = $(this).attr('rel'); 
		    var popURL = $(this).attr('href'); 
		    var query= popURL.split('?');
		    var dim= query[1].split('&');
		    var popWidth = dim[0].split('=')[1];
		
		    //Fade in the Popup and add close button
		    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="requestClose">Close</a>');
		
		    var popMargTop = ($('#' + popID).height() + 80) / 2;
		    var popMargLeft = ($('#' + popID).width() + 80) / 2;
		
		    $('#' + popID).css({
		        'margin-top' : -popMargTop,
		        'margin-left' : -popMargLeft
		    });
		
		    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 
		
		    return false;
		});
		
		//Close
		$('a.requestClose, #fade').live('click', function() { //When clicking on the close or fade layer...
		    $('#fade , .requestPop').fadeOut(function() {
		        $('#fade, a.requestClose').remove();  //fade them both out
		    });
		    return false;
		});	
	});
	
