// JavaScript Document

$.ajaxSetup({async: false});
$.getScript("/resx/scripts/jquery.pngFix.pack.js");
$.getScript("/resx/scripts/jquery.autocolumn.min.js");
$.getScript("/resx/scripts/jquery.easing-1.3.pack.js");
$.getScript("/resx/scripts/jquery.fancybox-1.3.1.pack.js");
$.ajaxSetup({async: true});

$(document).ready(function() {
						   
	$('div.twocols').columnize({ width:300, buildOnce:true });
	
	$("div#contentblock a[href^='http://']:not([href*='" + location.hostname + "'],:has(img))").attr('target', '_blank').addClass('externalLink');
	
	$('table#stillphotos a:has(img)').attr('rel','stillphotos').fancybox({
		'centerOnScroll' : true
	});
	
	$('table#interactivephotos a:has(img)').click(function() {
		var ivpFile=this.href.split("=")[1]+'.ivp';
		var ivpTitle=getNestedImgAttr(this,'title');
		
		$.fancybox({
			'padding' : 0,
			'centerOnScroll' : true,
			'autoScale' : false,
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'title' : ivpTitle,
			'width' : 650,
			'height' : 430,
			'href' : 'PurePlayer.swf',
			'type' : 'swf',
			'swf' : {
				'wmode' : 'transparent',
				'allowfullscreen' : 'true',
				'flashvars' : 'panorama='+ivpFile
			}
		});
		
		return false;
	});
	
	$('table#youtubevids a:has(img)').click(function() {
		var ytTitle=getNestedImgAttr(this,'title');
		
		$.fancybox({
			'padding' : 0,
			'centerOnScroll' : true,
			'autoScale' : false,
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'title' : ytTitle,
			'width' : 640,
			'height' : 385,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		return false;
	});
	
});

function getNestedImgAttr(obj,attr) {
	var nestedImg = $('img:only-child', $(obj));
	return nestedImg.attr(attr);
}