CatherineMayer = {};
CatherineMayer.Container;
CatherineMayer.Quotes = [];

	var flashvars = {};
	var params = {};
	var attributes = {};

CatherineMayer.Lightbox = function() {
	$(function () {
		$("a.lightbox").colorbox({
			rel:"lightbox", 
			width:"85%",
			height:"100%",
			opacity:1,
			innerHeight:"55%"
		});
	
		$("a.video-lightbox").click(function(e){
			e.preventDefault();
			openVideo($(this).attr("id"));
		});
		
		$("a.flash-lightbox").click(function(e){
			e.preventDefault();
			openFlash($(this).attr("id"), $(this).attr("href"));
		});
	});
	
	function openVideo(id) {
		$.colorbox({html:'<iframe src="http://player.vimeo.com/video/' + id + '?title=0&amp;byline=0&amp;portrait=0" width="700" height="500" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>'});
	}
	
	function openFlash(id, swf) {
		$.colorbox({html:'<div id="' + id + '" class="flashAsset"></div>'});
		swfobject.embedSWF(swf, id, "650", "475", "9.0.0","expressInstall.swf");
	}
}

CatherineMayer.CreateSWFAsset = function(id, fullSWFPath, thumbImg, caption, title, desc) {
	document.write('<div class="assetContainer">');
	document.write('<div class="asset">');
	document.write('<a id="' + id + '" href="' + fullSWFPath + '" class="flash-lightbox" title="' + title + '"><img class="border" src="' + thumbImg + '" /></a>');
	document.write('<span class="caption">' + caption + '</span>');
	document.write('</div>');
	document.write('</div>');
}

CatherineMayer.CreateAsset = function(fullImg, thumbImg, caption, title, desc) {
	$(function () {		
		var div = $("<div class='assetContainer' />");
		div.append("<div class='asset'><a href='" + fullImg + "' class='lightbox' title='" + title + "'><img class='border' src='" + thumbImg + "' /></a><br/><span class='caption'>" + caption + "</span></div>");

		$(CatherineMayer.Container).append(div);
	});
}

CatherineMayer.CreateNewsVideoAsset = function(fullImg, thumbImg, caption) {
	document.write('<div class="asset">');
	document.write('<a id="' + fullImg + '" class="video-lightbox" href="#"><img class="border" src="' + thumbImg + '" /></a>');
	document.write('<span class="caption">' + caption + '</span>');
	document.write('</div>');
	document.write('<div class="clear"></div>');
}

CatherineMayer.CreateVideoAsset = function(fullImg, thumbImg, caption) {
	document.write('<div class="assetContainer">');
	document.write('<div class="asset">');
	document.write('<a id="' + fullImg + '" class="video-lightbox" href="#"><img class="border" src="' + thumbImg + '" /></a>');
	document.write('<span class="caption">' + caption + '</span>');
	document.write('</div>');
	document.write('</div>');
}

CatherineMayer.AmbientArt = function() {
	new function () {
		$(function () { initialize(); });
	};

	function initialize() {
		$("a.lightbox").click(function(){
			open($(this).attr("id"));
		});
	}
	
	function open(id) {
		$.colorbox({html:'<iframe src="http://player.vimeo.com/video/' + id + '?title=0&amp;byline=0&amp;portrait=0" width="700" height="500" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>'});
	}
}

CatherineMayer.Artist = function() {
	new function () {
		$(function () { initialize(); });
	};

	function initialize() {
		$("div.video-link a").click(function(){
			open($(this).attr("id"));
		});

		$("div.artist-right div.asset a").click(function(){
			open($(this).attr("id"));
		});
	}
	
	function open(id) {
		$.colorbox({html:'<iframe src="http://player.vimeo.com/video/' + id + '?title=0&amp;byline=0&amp;portrait=0" width="700" height="500" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>'});
		//$("div#video-dialog").dialog("open");
		//$("div#video-dialog").html('<iframe src="http://player.vimeo.com/video/' + id + '?title=0&amp;byline=0&amp;portrait=0" width="700" height="500" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>');
	}
}

CatherineMayer.AddQuote = function(quote) {
		CatherineMayer.Quotes.push(quote);
}

CatherineMayer.AnimateQuotes = function() {
	var _index = 0;
	var _quote;
	var _container;
	var _wait;
	
	new function () {
		$(function () { initialize(); });
	};

	function initialize() {
		_container = $("#quotes");
		_index = Math.floor(Math.random() * CatherineMayer.Quotes.length);
		
		fade();
	}
	
	function fade() {
		_quote = $("<img class='quote' src='" + CatherineMayer.Quotes[_index] + "' />");
		
		_container.append(_quote);
		
		_container.fadeIn(1000, out);
	}
	
	function out() {
		_wait = setInterval( function(){
			  clearInterval(_wait);
			  _wait = null;		  
			  _container.fadeOut( 700, next);
		}, 8000);
	}
	
	function next() {
		_index += 1;
		if(_index > CatherineMayer.Quotes.length - 1) _index = 0;
		
		_container.empty();
		fade();
	}
}
