﻿$(document).ready(
	function($)
	{
	$.nyroModalSettings({
		processHandler: function(settings) {
			var url = settings.url;
			if (url && url.indexOf('http://www.youtube.com/watch?v=') == 0) {
				$.nyroModalSettings({
					type: 'swf',
					height: 450,
					width: 630,
					url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
				});
			}
			if (url && url.indexOf('http://www.vimeo.com/watch?v=') == 0) {
				$.nyroModalSettings({
					type: 'swf',
					height: 450,
					width: 630,
					url: url.replace(new RegExp("watch\\?v=", "i"), 'v/')
				});
			}
		},
		endShowContent: function(elts, settings) {
			$('.resizeLink', elts.contentWrapper).click(function(e) {
				e.preventDefault();
				$.nyroModalSettings({
					width: Math.random()*1000,
					height: Math.random()*1000
				});
				return false;
			});
			$('.bgLink', elts.contentWrapper).click(function(e) {
				e.preventDefault();
				$.nyroModalSettings({
					bgColor: '#'+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)+parseInt(255*Math.random()).toString(16)
				});
				return false;
			});
		}
	});
});

