$(document).ready(    
	function(){	  		
	
	// Read a page's GET URL variables and return them as an associative array.
	function getUrlVars(urlText)
	{
		var vars = [], hash;
		var hashes = urlText.slice(urlText.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	}

	//$width = getUrlVars($(".video-popup").attr("href"))["width"];
	//$height = getUrlVars($(".video-popup").attr("href"))["height"];	
/*
	$(".video-popup").colorbox({
		innerWidth:getUrlVars($(this).attr("href"))["width"], 
		innerHeight:getUrlVars($(this).attr("href"))["height"], 
		iframe:true
	});
	*/
	
	function getParameterByName(url,name)
	{
	  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
	  var regexS = "[\\?&]" + name + "=([^&#]*)";
	  var regex = new RegExp(regexS);
	  var results = regex.exec(url);
	  if(results == null)
		return "";
	  else
		return decodeURIComponent(results[1].replace(/\+/g, " "));
	}	
		
	$('.video-popup').each(function() { 
		//alert("height: " + getParameterByName($(this).attr("href"), "height") + " - width: " + getParameterByName($(this).attr("href"), "width"));
	
		$(this).colorbox({ 
			height: function(){
				var $height = parseInt(getParameterByName($(this).attr("href"), "height"))  + 65;
				return $height;
			},	
			width: function(){
				var $height = parseInt(getParameterByName($(this).attr("href"), "width"))  + 5;
				return $height;
			},					
			iframe: true
		}); 
	});	

});
