
// remap jQuery to $
(function($){
var container = $( "#container" ),
	header = 	container.children( "header" ),
	main = 		container.children( "#main" ),
	footer = 	container.children( "footer" );
	
main.find(".content.merch").ariaLightbox({
	imageArray: "a.merchbox",		
	// text strings		
	altText: function() {
		// $(this) is the triggered element (in this case the link element)
		return $(this).find("img").attr("alt");
	},
	descText: function() {
		var img = $(this).find("img");
		return img.attr("title") || img.attr("alt");
	},		
	titleText: function() {
		return $(this).parent().find("h3").text();
	},
	prevText: "Zurück",
	nextText: "Vor",
	pictureText: "",
	ofText: "von",
	closeText: "Schließen [ESC]",
	// positioning
	pos: "auto",
	autoHeight: 30,
	// disable lightbox if screens below:
	disableWidth: 800,
	disableHeight: 600,
	zIndex: 1010
});		

footer.find( "a.dialog" ).each(function() {
	var link = $(this);
	var href = link.attr("href");
	var msg = $("<div />", {
		title: link.text()
	});	
	link.click( function() {
		$.ajax({
			url: href,
			dataType: "html",
			success: function(data) {
				msg.html(data);		
				msg.dialog({ 
					modal: true,
					width: 600,
					height: 500
				});
			},
			error: function(){
				window.location.href = href;
			},
			complete: function() {
				pageLoaded = true;
				// console.log("complete");
			}
		});
		return false;
	});
});



main.find(".content .desc a").add( footer.find( "a" ) ).hover(
	function(){		
		$(this).addClass( "hover", "fast" );
	},
	function(){
		$(this).removeClass( "hover", "fast" );
	}
);

footer.find( "a.email" ).hover(
	function(){		
		$(this).fadeTo(	"fast", 0.5 );
	},
	function(){
		$(this).fadeTo(	"fast", 1 );
	}
);

 



})(this.jQuery);



// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};



// catch all document.write() calls
(function(doc){
  var write = doc.write;
  doc.write = function(q){ 
    log('document.write(): ',arguments); 
    if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments);  
  };
})(document);



