$(function() {
	initTooltips();
	initMusicplayer();
	initEvents();
	initVideo();

	Shadowbox.init( {
		skipSetup : true
	});
	Shadowbox.setup("#photolist a", {
		gallery : "Fotos"
	});

	Cufon.replace("h1,h2");
	Cufon.replace("#header-menu li a", {
		hover : true
	});
});

function initEvents() {
	try {
		$("a[rel^='modal']").prettyPhoto( {
			theme : "djdenman"
		});
	} catch (e) {
	}
}

function initTooltips() {
	var title;

	try {
		$.fn.qtip.styles.djdenman = {
			name : "dark",
			background : "#000",
			color : "#fff",
			textAlign : "center",
			border : "#000",
			tip : {
				corner : "bottomRight",
				color : "#000"
			},
			width : {
				max : 300
			}
		};
	} catch (e) {
	}

	$("h1,h2").each(function() {
		title = $(this).attr("title");
		if (title.length > 0) {
			$(this).qtip( {
				content : title,
				show : "mouseover",
				hide : "mouseout",
				position : {
					corner : {
						target : "topLeft",
						tooltip : "bottomRight"
					},
					adjust : {
						x : 6,
						y : 5
					}
				},
				style : "djdenman"
			});
		}
	});
}

function initMusicplayer() {
	var flashvars, params;

	flashvars = {
		//trackURL : "/media/audio/jerome-isma-ae_hold-that-sucker-down-original-mix.mp3",
		//title : "Jerome Isma-Ae - Hold That Sucker Down (Original Mix)",
		trackURL : "/media/audio/dj-denman_house-demo-januari-2010.mp3",
		title : "DJ Denman - House Demo Mix (januari 2010)",
		width : 425,
		height : 26,
		autoPlay : "false",
		autoLoad : "false",
		downloadEnabled : "false",
		loop : "false",
		volume : 0.7,
		//duration : 542000,
		duration : 1456000,
		color1 : "0x3e6518",
		color2 : "0xffffff",
		color3 : "0x578326",
		color4 : "0xffffff",
		color5 : "0x5e20",
		color6 : "0xffffff"
	}

	params = {
		wmode : "transparent"
	};
	
	swfobject.embedSWF("http://www.fxcomponents.com/common/A3_v100.swf", "header-player",
			"425", "26", "9.0.0", false, flashvars, params);
}

function initVideo() {
	var url;
	var player = $("#videoitem-player");
	if (player.length) {
		url = player.find("a").attr("href");
		loadVIdeo(url)
	}
}

function loadVIdeo(url) {
	var flashvars = {
		"rel" : 0,
		"autoplay" : 1,
		"showinfo" : 0,
		"fs" : 0
	};
	swfobject.embedSWF(url, "videoitem-player", "500", "344", "10",
			"expressInstall.swf", flashvars, null, null);
}

$(document).ready(
		function() {
			$("#search-quick label.inlined + input.input-text").each(
					function(type) {

						Event.observe(window, 'load', function() {
							setTimeout(function() {
								if (!input.value.empty()) {
									input.previous().addClassName('has-text');
								}
							}, 200);
						});

						$(this).focus(function() {
							$(this).prev("label.inlined").addClass("focus");
						});

						$(this).keypress(
								function() {
									$(this).prev("label.inlined").addClass("has-text")
											.removeClass("focus");
								});

						$(this).blur(
								function() {
									if ($(this).val() == "") {
										$(this).prev("label.inlined").removeClass("has-text")
												.removeClass("focus");
									}
								});
					});
		});
