Cufon.set('fontFamily', 'Museo');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');
Cufon.replace('div.date');
Cufon.replace('#header .menu ul li a');
Cufon.replace('.gbutton');
Cufon.replace('.button span');
Cufon.replace('.button a', {
	hover : true
});
Cufon.replace('.single .head .date');
Cufon.replace('ul.categorycontent li .text a', {
	hover : true
});
Cufon.replace('.breaking .item a', {
	hover : true
});
Cufon.replace('.kssi', {
	hover : true
});
Cufon.replace('#footer a', {
	hover : true
});
Cufon.replace('.wpcf7-submit', {
	color : '-linear-gradient(#999, 0.45=#666, 0.45=#555, #999)'
});
Cufon.replace('.wpcf7-submit');
Cufon.replace('.wpcf7-submit', {
	color : '-linear-gradient(#999, 0.45=#666, 0.45=#555, #999)'
});
Cufon.replace('.wpcf7-submit');

$(document).ready(function() {
			colorizeThumbnails();
			$(".dpopup").each(function() {
			$(this).click(
				function() {
					$("#" + $(this).attr("rel")).css("display",'block');
					$("#fade").css('display', 'block');
					$(".black_overlay").css('height',	$('body').height() + 'px');
					$(".black_overlay").css('width', $('body').width() + 'px');
					$('html, body').animate({ scrollTop : 0}, 'slow');
				});
			});

			$('input[type="text"], textarea').each(function() {
				$(this).focusin(function() {
					$oldval = $(this).val();
					try {
						if ($(this).attr("rel").length < 1) {
							$(this).val("");
							$(this).attr("rel", $oldval);
						}
					} catch (err) {
						$(this).val("");
						$(this).attr("rel", $oldval);
					}
				});
				$(this).focusout(function() {
					if ($(this).val().length < 1) {
						$(this).val($(this).attr("rel"));
						$(this).attr("rel", '');
					}
				});
			});

			$("div.logo h1").click(function() {
				document.location = '/';
			});

			$("div.gbutton").click(
					function(e) {
						if ($(this).children("a.next") || $(this).children("a.prev") || $(this).children("a.start")) {
							return ngg_ajax_navigation(e, $(this).children("a:first").context.children[0]);
						}
			});

			$("div.button, div.gbutton.na").click(
					function(e) {
						if ($(this).children("a").attr("href").indexOf("javascript:void(0)") != -1) {
							$("#" + $(this).children("a").attr("rel")).css("display", 'block');
							$("#fade").css('display', 'block');
							$(".black_overlay").css('height', $(document).height() + 'px');
							$(".black_overlay").css('width', $('body').width() + 'px');
							$('html, body').animate({scrollTop : 0	}, 'slow');
						} else {
							if(!$(this).hasClass("dl")){
								document.location = $(this).children("a").attr("href");
							}else{
								window.open($(this).children("a").attr("href"));
							}
					}
			});

			if ($.browser.opera) {
				$('.kssi').css('margin-top', '-20px')
				
			}
});


function colorizeThumbnails(){
	
	// Video Getter
	$(".ngg-gallery-thumbnail a").each(
			function(arr) {
					var titleType = $(this).attr("title").substr(0, 5);
				if (titleType == "Video" || titleType == "Audio") {
					var media = titleType;
					$(this).attr("href", "javascript:void(0);");
					var size = $(this).attr("title");
					$(this).children("img").attr("title", "Hier klicken um "+media+" abzuspielen.");
					$(this).click(function(){
						var file=$(this).children("img").attr("alt");
						if(file == null){
							var file=$(this).children("canvas").attr("alt");
						}
						var size = $(this).attr("title").substr(6);
						size = size.substr(6);
						var w = size.substr(0, size.indexOf(";height"));
						var h = size.substr(size.indexOf(";height")+8);
						openFlowPlayer(file, h, w);
					});
				}
	});
	
	// GalleryThumbnail B/W
	$('.ngg-gallery-thumbnail-box img').each(function() {
		$(this).attr("id", new Date().getTime());
		Pixastic.process(this, "desaturate");
		$(this).hover(function() {
		}, function() {
			$('.ngg-gallery-thumbnail-box img').each(function() {
				Pixastic.process(this, "desaturate");
			});
			$('.ngg-gallery-thumbnail-box canvas').each(function() {
				$(this).hover(function() {
					Pixastic.revert(this);
				});
			});
		});
	});
	
	$('.ngg-gallery-thumbnail-box').css("position", "static");
	$('.ngg-gallery-thumbnail-box').css("left", "0");
	
	$('.ngg-gallery-thumbnail-box canvas').each(function() {
		$(this).hover(function() {
			Pixastic.revert(this);
		});
	});
	$('.ngg-gallery-thumbnail-box img').each(function() {
		$(this).hover(function() {
			Pixastic.revert(this);
		}, function() {
			Pixastic.process(this, "desaturate");
		});
	});
}

function openFlowPlayer(file, height, width){
	$("#flowplayerpopup .inner").html('<div id="player" style="width: '+width+'px; height: '+height+'px;"></div>');
	flowplayer("player", "http://www.iventnet.de/accounts/iventmedia/wp-content/plugins/wordtube-flowplayer/flowplayer_commercial/flowplayer.commercial-3.2.5.swf", {
			key: "#$ddce2d11eaafdc7035b", 
			clip:{url: file, autoPlay: true, autoBuffering: false, bufferLength: 6 },
			play: { height: 60, width: 60 },
//			logo:{url:"http://www.iventnet.de/accounts/iventmedia/wp-content/uploads/iventmedialogo.png",fullscreenOnly: false, top: 2, right :2, displayTime :10 },
			plugins:{ 
				controls:{ 
						bottom :0, borderRadius : "0px", timeColor: "#ffffff", bufferGradient: "none", slowForward: true, backgroundColor: "rgba(100, 100, 100, 0.2)", volumeSliderGradient: "none",slowBackward: false, timeBorderRadius: 0, time: true, progressGradient: "none", height:20, volumeColor: "rgba(0, 204, 255, 1)",
						tooltips:{marginBottom:5, volume:true, scrubber: true, buttons: false},
						fastBackward:false, opacity: 1, bufferColor: "#0a0a0a", border: "0px", volumeSliderColor: "#000000", buttonColor: "#000000", mute: true, 
						autoHide:{ enabled: true, hideDelay: 500, mouseOutDelay: 500, hideStyle: "fade", hideDuration: 400, fullscreenOnly: false},
						backgroundGradient: "medium", width:"100pct", display: "block",buttonOverColor: "rgba(0, 204, 255, 1)", fullscreen:true, timeBgColor: "transparent", scrubberBarHeightRatio: 0.22,"stop":false, zIndex:1, sliderColor: "#cccccc", scrubberHeightRatio: 0.86, tooltipTextColor: "rgba(0, 204, 255, 1)",sliderGradient: "none", 
						spacing:{all: 0},timeBgHeightRatio:0,volumeSliderHeightRatio:0.4,name:"controls",volumeBarHeightRatio:0.5,left:"50pct",tooltipColor:"#C9C9C9",playlist:false, durationColor:"#333333",play:true, fastForward:true, progressColor:"rgba(0, 204, 255, 1)", timeBorder:"1px solid rgba(0, 0, 0, 0.3)",volumeBorderRadius:0, scrubberBorderRadius:0,volume:true,scrubber:true, builtIn: false, margins:[0,0,0,0]
				}
			},
			canvas:{ backgroundGradient:[0,0], border:"0px solid #000000"},
			playerId:"flowplayer18",
			playlist:[{url: file, autoPlay:true,autoBuffering:false,bufferLength:6}]
	});
	$("#flowplayerpopup .inner").css("height", height+"px").css("width", width+"px").css("margin", "0");
	var layerheight = 25+parseInt(height);
	$("#flowplayerpopup").css("height", layerheight+"px").css("width", width+"px").css("display", 'block').css("left", ($(window).width() / 2) - (width /2)+"px").css("top", "140px");
	$("#fade").css('display', 'block');
	var docHeight = $(document).height();
	if ($.browser.msie) {
		docHeight = docHeight -5;
	}
	$(".black_overlay").css('height', docHeight + 'px');
	$(".black_overlay").css('width', $('body').width() + 'px');
	$("#flowplayerpopup").css("display", 'block');
	$('html, body').animate({ scrollTop : 0}, 'slow');
}

function closePlayer(){
	$f().stop();
	$("#flowplayerpopup").css("display", "none");
	$("#fade").css("display", "none");
}
									
function scrollTop(){
	$('html, body').animate({ scrollTop : 0}, 'slow');
}								

