/*soundManager.url = '../swf/'; // path to directory containing SM2 SWF

soundManager.useFastPolling = true; // increased JS callback frequency, combined with useHighPerformance = true

threeSixtyPlayer.config.scaleFont = (navigator.userAgent.match(/msie/i)?false:true);
threeSixtyPlayer.config.showHMSTime = true;

// enable some spectrum stuffs

threeSixtyPlayer.config.useWaveformData = true;
threeSixtyPlayer.config.useEQData = true;

// enable this in SM2 as well, as needed

if (threeSixtyPlayer.config.useWaveformData) {
  soundManager.flash9Options.useWaveformData = true;
}
if (threeSixtyPlayer.config.useEQData) {
  soundManager.flash9Options.useEQData = true;
}
if (threeSixtyPlayer.config.usePeakData) {
  soundManager.flash9Options.usePeakData = true;
}

// favicon is expensive CPU-wise, but can be used.
threeSixtyPlayer.config.useFavIcon = false; */

jQuery.fn.imageZoom=function(conf){var config=jQuery.extend({speed:200,dontFadeIn:1,hideClicked:1,imageMargin:15,className:'jquery-image-zoom',loading:'Loading...'},conf);config.doubleSpeed=config.speed/4; return this.click(function(e){$(this).removeClass('shadowhigh'); var clickedElement=jQuery(e.target);var clickedLink=clickedElement.is('a')?clickedElement:clickedElement.parents('a');clickedLink=(clickedLink&&clickedLink.is('a')&&clickedLink.attr('href').search(/(.*)\.(jpg|jpeg|gif|png|bmp|tif|tiff)$/gi)!=-1)?clickedLink:false;var clickedImg=(clickedLink&&clickedLink.find('img').length)?clickedLink.find('img'):false;if(clickedLink){clickedLink.oldText=clickedLink.text();clickedLink.setLoadingImg=function(){if(clickedImg){clickedImg.css({opacity:'0.5'})}else{clickedLink.text(config.loading)}};clickedLink.setNotLoadingImg=function(){if(clickedImg){clickedImg.css({opacity:'1'})}else{clickedLink.text(clickedLink.oldText)}};var displayImgSrc=clickedLink.attr('href');if(jQuery('div.'+config.className+' img[src="'+displayImgSrc+'"]').length){return false}var preloadOnload=function(){clickedLink.setNotLoadingImg();var dimElement=clickedImg?clickedImg:clickedLink;var hideClicked=clickedImg?config.hideClicked:0;var offset=dimElement.offset();var imgzoomBefore={width:dimElement.outerWidth(),height:dimElement.outerHeight(),left:offset.left,top:offset.top};var imgzoom=jQuery('<div><img src="'+displayImgSrc+'" alt="" /></div>').css('position','absolute').appendTo(document.body);var imgzoomAfter={width:imgzoom.outerWidth(),height:imgzoom.outerHeight()};var windowDim={width:jQuery(window).width(),height:jQuery(window).height()};if(imgzoomAfter.width>(windowDim.width-config.imageMargin*2)){var nWidth=windowDim.width-config.imageMargin*2;imgzoomAfter.height=(nWidth/imgzoomAfter.width)*imgzoomAfter.height;imgzoomAfter.width=nWidth}if(imgzoomAfter.height>(windowDim.height-config.imageMargin*2)){var nHeight=windowDim.height-config.imageMargin*2;imgzoomAfter.width=(nHeight/imgzoomAfter.height)*imgzoomAfter.width;imgzoomAfter.height=nHeight}imgzoomAfter.left=(windowDim.width-imgzoomAfter.width)/2+jQuery(window).scrollLeft();imgzoomAfter.top=(windowDim.height-imgzoomAfter.height)/2+jQuery(window).scrollTop();var closeButton=jQuery('<a href="#">Close</a>').appendTo(imgzoom).hide();if(hideClicked){clickedLink.css('visibility','hidden')}imgzoom.addClass(config.className).css(imgzoomBefore).animate(imgzoomAfter,config.speed,function(){closeButton.fadeIn(config.doubleSpeed)});var hideImgzoom=function(){closeButton.fadeOut(config.doubleSpeed,function(){imgzoom.animate(imgzoomBefore,config.speed,function(){clickedLink.css('visibility','visible');imgzoom.remove()})}); $('.image').addClass('shadowhigh');  return false};imgzoom.click(hideImgzoom);closeButton.click(hideImgzoom)};var preload=new Image();preload.src=displayImgSrc;if(preload.complete){preloadOnload()}else{clickedLink.setLoadingImg();preload.onload=preloadOnload}return false}})};$(document).keydown(function(e){if(e.keyCode==27){$('div.jquery-image-zoom a').click()}});

(function($) {
	$.fn.placeholder = function(opt) {

		var options = $.extend({}, $.fn.placeholder.defaultOptions, opt);
		return this.each(function(){
			var $item = $(this);
			if ($item.val() == '') {
			  setHolder($item, options);
			}
			$item.blur(function(){
				if($item.val() == '') {
					setHolder($item, options);
				}
			});
			$item.focus(function(){
				if($item.val() == ($item.attr("placeholder") || options.message)) {
					$item.val('');
				}
				$item.removeClass(options.style);
			});
			// this is a very hackish way to append to the event bubble
			$item.parents("form:first").one('submit', function(event) {
				$(this).submit(function(){
					setHolder($item, options);
				});
				event.stopImmediatePropagation();
				$(this).trigger('submit');
				return false;
			});
			$item.parents("form:first").submit(function(event){
				if($item.val() == ($item.attr("placeholder") || options.message)) {
					$item.val('');
				}
			});
		});
	};
	function setHolder(obj, opts) {
		obj.val(obj.attr("placeholder") || opts.message);
		obj.addClass(opts.style);
	}
	$.fn.placeholder.defaultOptions = {
		message: "click to enter..",
		style: "placeholder"
	}
})(jQuery);

jQuery.log = function(message) {
	if(window.console) {
		console.debug(message);
	} else {
		alert(message);
	}
};

$(document).ready(function() {

	$('#feedbackForm').submit(function() {
		var formdata = $(this).serialize();
		$('#sendbutton').fadeOut(100);
		$.ajax({
			type: "POST",
			url: "mail.php",
			data: formdata,
			success: function(msg){
				$('#sendbutton').fadeIn(100);
				$('#sendmsg').html('Message sended.<br />Thanks for your feedback.');
			}
		});
		return false;
	});
	
	$('#social_services ul li,.album_shops ul li').css('opacity','0.5');
	$('#social_services ul li,.album_shops ul li').mouseover(function() {
		$(this).css('opacity','1');
	});
	
	$('#social_services ul li,.album_shops ul li').mouseout(function() {
		$(this).css('opacity','0.5');
	});
	
	$('.about_menu').click(function() {
		var id = $(this).attr('id');
		$('.info').hide();
		$('.'+id).fadeIn(60);
		$('.about_menu').removeClass('active');
		$(this).addClass('active');
		return false;
	});
	
	$('h1,.album_demo,.album_demo2,div.close_demo a').click(function() {
		if (!$('#logo').hasClass('disabled')) {
			if ($('#logo').hasClass('active')) {
				$('#demomusic').hide();
				logo_position(100);
				$('#logo').removeClass('active');
				$('#cube').animate({'left': 400,'top': 200,'width': 204, 'height': 204},1000,'easeInOutElastic');
				$('.zoom').show();
				soundManager.pause('ui360Sound');
			} else {
				cube_default();
				$('#logo').addClass('active').animate({top: 50},1000,'easeInOutElastic');
				$('#cube').animate({'left': 150,'top': 20,'width': 700,'height': 530},1000,'easeInOutElastic',function() { $('#demomusic').fadeIn(2000); });
				$('.zoom').hide();
	
			}
		}
		return false;
	});
	
	$('#cubeMenu ul li').click(function() {
		var id = $(this).html();
		$('.fringe').hide();
		$('#cubeMenu ul li').removeClass('activeTab');
		$('#'+id).fadeIn();
		$(this).addClass('activeTab');
	});
	
	$('.image').imageZoom();
});
