$(function() {
	
	var ua = navigator.userAgent.toLowerCase();
	var bv = (ua.match(/.+(?:rv|webkit|khtml|opera|msie)[\/: ]([\d.]+)/ ) || [0,'0'])[1];
	var isIElt8 = (/msie/.test(ua) && parseInt(bv) < 8);
	var myCloseButton = '<a href="#" class="nyroModalClose" id="closeBut" title="close">[close]</a>';
	if (isIElt8) {
		myCloseButton = '<a href="#" class="nyroModalClose" id="closeBut" title="close">Close</a>';
	};	
	$.nyroModalSettings({
		debug: false,
		addImageDivTitle: false,
		minWidth: 400,
		minHeight: 550,
		closeButton: myCloseButton
	});
	
	$.fn.nyroModal.settings.processHandler = function(settings) {
		var from = settings.from;
		if (from && from.href && from.href.indexOf('http://www.youtube.com/watch?v=') == 0) {
			$.nyroModalSettings({
				type: 'swf',
				height: 355,
				width: 425,
				url: from.href.replace(new RegExp("watch\\?v=", "i"),'v/')
			});
		}
	};
	
	function preloadImg(image) {
		var img = new Image();
		img.src = image;
	};

	preloadImg('nyro/ajaxLoader.gif');
	preloadImg('nyro/prev.gif');
	preloadImg('nyro/next.gif');

});

