$(document).ready(function() {
	jQuery("#main-content a[target^=_blank]").addClass("external_link");
	jQuery('#main-content a[target^=_blank] img').parent().removeClass("external_link");
	
	// Add a search field focus/blur event
	jQuery("#search-field").focus(function() {
		if( this.value == this.defaultValue)
			this.value = "";
	}).blur(function() {
		if( !this.value.length)
			this.value = this.defaultValue;
	});
	
	// Add hover effect on language selector flags
	jQuery("#language-selector a img").hover(
		function () {
			var image_name = this.src;
			this.src = image_name.replace("_out","_over");
		},
		function () {
			var image_name = this.src;

			this.src = image_name.replace("_over","_out");
		}
	);
	
	/* Mark up the first child of global nav (sigh IE6) */
    jQuery("#global-nav li:first").addClass("first-child");
	
	jQuery(".crisis_box a.read_more").click(function (){
		jQuery(".crisis_box").hide();
		jQuery("body").removeClass("crisis");
	});
	
	/* slideshow */
	jQuery('#section-id-ct').cycle({ 
		height: 333,
		delay: 3000,
		speed: 1200
	});	
	
	jQuery("a.print_icon").click(function() {
		window.print();
		return false;
	});
	/* Fadeout crisis stuff */
	//jQuery("body.crisis #current-website, body.crisis #adspace img").fadeTo("slow",0.33);
	
	
	jQuery("a.fancybox").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Bild ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
});
