// wp-theme for vakant.net functions by http://noburo.net 2009
//
// smothscroll functions by Karl Swedberg. major changes by Paul Armstrong and Zachary Johnson
// MM Forms functions by Tom Belmans and Takayuki Miyoshi. (c)2007-2008, GNU GPL 2+ license. improved by http://noburo.net 2009
// jQuery Default Value Plugin by Paul Campbell. (c)2007, MIT license. improved by Zachary Johnson 2009

var themeUrl='/wp/wp-content/themes/vakant/';var podcastFeed='http://vakant.net/category/podcast/feed/';var logoNight=themeUrl+'images/logo.png';var bg='/background/main_piece.jpg';var bgNight='/background/main_piece_dark.jpg';var fpHeight="30px";var ajaxError="<p>sorry, we cannot fullfill your request.<br/>please use the navigation or the search to locate the page you are looking for.</p>";var podcastplayerWidth='457';var podcastplayerHeight='614';var whatpeopleplayerWidth='457';var whatpeopleplayerHeight='614';var tsexpressinstall=themeUrl+'flash/expressinstall.swf';function tsInit(){$('.tsbox').removeAttr('style').css({display:'block',width:'100%',height:'auto'});$('.tsbox object').attr('width','100%').attr('height','360');$('#homepage .tsbox object').attr('height','220')}var vvqflashvars={};var vvqparams={wmode:'transparent',allowfullscreen:'true',allowscriptacess:'always'};var vvqattributes={};var vvqexpressinstall=themeUrl+'flash/expressinstall.swf';function vvqInit(){$('.vvqbox').removeAttr('style').css({display:'block',width:'100%'});$('.vvqbox object, .vvqbox img').attr('width','100%')}function mmfExclusiveCheckbox(e){$(e.form).find('input:checkbox[@name="'+e.name+'"]').not(e).removeAttr('checked')}function mmfToggleSubmit(form){var submit=$(form).find('input:submit');if(!submit.length){return}var acceptances=$(form).find('input:checkbox.mmf-acceptance');if(!acceptances.length){return}submit.removeAttr('disabled');acceptances.each(function(i,n){n=$(n);if(n.hasClass('mmf-invert')&&n.is(':checked')||!n.hasClass('mmf-invert')&&!n.is(':checked')){submit.attr('disabled','disabled')}})}function mmfClearResponseOutput(){$('div.mmf-response-output').slideUp().empty().removeClass('mmf-mail-sent-ok mmf-mail-sent-ng mmf-validation-errors mmf-spam-blocked');$('span.mmf-not-valid-tip').remove();$('img.ajax-loader').css({visibility:'hidden'})}function mmfBeforeSubmit(formData,jqForm,options){mmfClearResponseOutput();$('img.ajax-loader',jqForm[0]).css({visibility:'visible'});formData.push({name:'_mmf_is_ajax_call',value:1});return true}function mmfNotValidTip(into,message){$(into).append('<span class="mmf-not-valid-tip">'+message+'</span>');$(into).find(':input').live('click',function(){$(into).find('.mmf-not-valid-tip').not(':hidden').fadeOut(100)})}function mmfProcessJson(data){var mmfResponseOutput=$(data.into).find('div.mmf-response-output');mmfClearResponseOutput();if(data.invalids){$.each(data.invalids,function(i,n){mmfNotValidTip($(data.into).find(n.into),n.message)});mmfResponseOutput.addClass('mmf-validation-errors')}if(data.captcha){$.each(data.captcha,function(i,n){$(data.into).find(':input[@name="'+i+'"]').clearFields();$(data.into).find('img.mmf-captcha-'+i).attr('src',n);var match=/([0-9]+).(png|gif|jpeg)$/.exec(n);$(data.into).find('input:hidden[@name="_mmf_captcha_challenge_'+i+'"]').attr('value',match[1])})}if(1==data.spam){mmfResponseOutput.addClass('mmf-spam-blocked')}if(1==data.mailSent){$(data.into).find('form').resetForm().clearForm();mmfResponseOutput.addClass('mmf-mail-sent-ok')}else{mmfResponseOutput.addClass('mmf-mail-sent-ng')}mmfResponseOutput.append(data.message).slideDown(200);if(data.message.toLowerCase().indexOf('thanks')>=0){setTimeout("mmfResponseOutput.slideUp(200);",2000)}}function mmfInit(){$('div.mmf > form').ajaxForm({beforeSubmit:mmfBeforeSubmit,dataType:'json',success:mmfProcessJson});$('div.mmf > form').each(function(i,n){mmfToggleSubmit($(n))})}var now=new Date();function daytime(){var hour=now.getHours();if((hour>"8")&&(hour<"20")){now='day';$('body').removeClass('night').addClass('day')}else{now='night';$('body').removeClass('day').addClass('night');$('#header h1 a').html('<img src="'+logoNight+'" alt="Vakant"/>')}}function popUp(url,width,height,scrolling){if(typeof(popUpWindow)=='undefined'||popUpWindow.closed){popUpWindow=window.open(url,"popUpWindow","width="+width+",height="+height+",scrollbars="+scrolling);if(!$.browser.msie){popUpWindow.moveTo(screen.availWidth-width,"10")}popUpWindow.focus()}else{popUpWindow.location.href=url;popUpWindow.focus()}}function fpInit(){$("a[href*='whatpeopleplay.com/player/player.php?track_id='],a[href*='http://www.whatpeopleplay.com/whatpeopleplayer/showExternal.php?p='], #whatpeopleplayer").addClass('whatpeopleplayer');$("a[href$='.mp3']").css('width','46em');$("#homepage a[href$='.mp3']").css('width','35.9em');$("a[href$='.mp3']").text(' ').css({display:'inline-block',margin:'-0.5em 0 0.95em -0.5em',height:fpHeight,border:'0'}).flowplayer(themeUrl+'flash/flowplayer.swf',{plugins:{audio:{url:themeUrl+'flash/flowplayer.audio.swf'},controls:{url:themeUrl+'flash/flowplayer.controls.swf',fullscreen:false,mute:false,stop:false,time:false,volume:false,top:0,height:fpHeight,backgroundColor:'transparent',backgroundGradient:'none',progressColor:'#aaaaaa',bufferColor:'#cccccc',sliderColor:'#cccccc',buttonColor:'#00AEEF',buttonOverColor:'#00AEEF',width:'100%'}},clip:{autoPlay:false,seekableOnBegin:true},canvas:{backgroundColor:'transparent',backgroundGradient:'none'}});if($('#player').length>0){$('#player').css({display:'inline-block',width:'100%',height:fpHeight});$f('player',themeUrl+'flash/flowplayer.swf',{playlist:'http://vakant.net/category/podcast/feed/',plugins:{audio:{url:themeUrl+'flash/flowplayer.audio.swf'},controls:{url:themeUrl+'flash/flowplayer.controls.swf',playlist:true,fullscreen:false,mute:false,stop:false,time:false,volume:false,top:0,height:fpHeight,backgroundColor:'transparent',backgroundGradient:'none',progressColor:'#aaaaaa',bufferColor:'#bbbbbb',sliderColor:'#cccccc',buttonColor:'#00AEEF',buttonOverColor:'#00AEEF',width:'100%'}},clip:{autoPlay:false,seekableOnBegin:true}}).playlist('#playlist:first',{loop:true});setTimeout("$('#playlist').slideDown(200);",7200)}}(function($){$.fn.defaultVal=function(){var elements=this;var args=arguments;var c=0;return(elements.each(function(){var el=$(this);var value=args[c++];if(el.val()===''){el.val(value)}el.focus(function(){if(el.val()===value){el.val('')}el.blur(function(){if(el.val()===''){el.val(value)}})})}))}})(jQuery);function DOMing(){$('#header .title').hide();$("body:not(#homepage) #news").remove();$('#news a, a.permalink').attr('target','_blank');$(".category-news:not(.category-releases):not(.category-podcast):not(.category-gallery):not(.category-events)").prepend("<h6 class='kind'>news flash:</h6>");$("#homepage .category-releases").prepend("<h6 class='kind'>new release:</h6>");$("#homepage .category-podcast").prepend("<h6 class='kind'>new podcast:</h6>");$("#homepage .category-gallery").prepend("<h6 class='kind'>new gallery:</h6>");$("#searchresults .category-releases, body.tag .category-releases").prepend("<h6 class='kind'>release:</h6>");$("#searchresults .category-podcast, body.tag .category-podcast").prepend("<h6 class='kind'>podcast:</h6>");$("#searchresults .category-gallery, body.tag .category-gallery").prepend("<h6 class='kind'>gallery:</h6>");$("#searchresults .category-press, body.tag .category-press").prepend("<h6 class='kind'>press:</h6>");$("#searchresults .category-downloads, body.tag .category-downloads").prepend("<h6 class='kind'>downloads:</h6>");$("input[type='text']").addClass('text');$("input[type='submit']").addClass('submit');$("a[href*='_PR.pdf']").addClass('pr');$("a[href*='.pdf']").addClass('pdf');$("img[src*='pdf.png']").parents('dl.attachments').addClass('pdf');$("a[href*='.zip']").addClass('zip');$("img[src*='zip.png']").parents('dl.attachments').addClass('zip');$("a[href*='.jpg'], a[href*='.jpeg']").addClass('jpg');$("img[src*='jpg.png'],img[src*='jpeg.png'],img[src*='default.png'],img[src*='png.png'],img[src*='gif.png'],img[src*='tif.png']").parents('dl.attachments').addClass('jpg');$('#widgets h4').css('display','none');$("a[href*='soundcloud.com']").addClass('soundcloud');$("#widgets a[href*='facebook.com']").addClass('facebook');$("#widgets a[href*='myspace.com']").addClass('myspace');$("#widgets a[href*='flickr.com']").addClass('flickr');$("#widgets a[href*='delicious.com']").addClass('delicious');$("#widgets a[href*='twitter.com']").addClass('twitter');$("#widgets a[href*='youtube.com']").addClass('youtube');$("a[href*='whatpeopleplay.com/player/player.php?track_id='],a[href*='http://www.whatpeopleplay.com/whatpeopleplayer/showExternal.php?p=']").addClass('whatpeopleplayer');$("a[href*='whatpeopleplay.com/player/player.php?track_id='],a[href*='http://www.whatpeopleplay.com/whatpeopleplayer/showExternal.php?p=']").parents('ol').addClass('whatpeopleplayer');$('#podcastplayer #header, #podcastplayer #menu, #podcastplayer #meta, #podcastplayer #widgets, #podcastplayer #footer').css('display','none');$('#podcastplayer .page h3.header ').html('podcast player');$('.vcard .url, .vcard .type').css('display','none');$('.vcard .fon').prepend('<em>fon: </em>');$('.vcard .fax').prepend('<em>fax: </em>');$('.post.category-events .meta, .post.tag-vakant .meta').remove();$.ajax({type:'GET',url:themeUrl+'javascripts/jquery.expander.js',success:function(){$('.post .section').each(function(){var more=[];var thisE=$(this);more.push(thisE.children('.more'));thisE.children('.more:first').before("<div class='expander'></div>");thisE.children('.more').remove();for(i=0;i<more.length+1;i++){thisE.children('.expander').append(more[i]);thisE.children('.expander > *').removeClass('more')}thisE.children('.expander p:eq(0)').css('display','inline-block');var $elementHeight=thisE.children('.expander').height();thisE.children('.expander .details').css({height:$elementHeight});thisE.children('.expander').expander({slicePoint:0,expandPrefix:'',expandText:'read on',expandEffect:'slideDown',expandSpeed:200,userCollapse:true,userCollapseText:'^'})})},dataType:'script',cache:true});fpInit();mmfInit();tsInit();vvqInit();$('#form_mailinglist-email, #s').defaultVal('search','enter your email')}function enable_smooth_scroll(link){function filterPath(string){return string.replace(/^\//,'').replace(/(index|default).[a-zA-Z]{3,4}$/,'').replace(/\/$/,'')}var locationPath=filterPath(location.pathname);var scrollElement='html, body';$('html, body').each(function(){var initScrollTop=$(this).attr('scrollTop');$(this).attr('scrollTop',initScrollTop+1);if($(this).attr('scrollTop')==initScrollTop+1){scrollElement=this.nodeName.toLowerCase();$(this).attr('scrollTop',initScrollTop);return false}});$(link).each(function(){var thisPath=filterPath(this.pathname)||locationPath;if(locationPath==thisPath&&(location.hostname==this.hostname||!this.hostname)&&this.hash.replace(/#/,'')){if($(this.hash).length){$(this).click(function(event){var targetOffset=$(this.hash).offset().top;var target=this.hash;event.preventDefault();$(scrollElement).animate({scrollTop:targetOffset},400,'swing',function(){return false})})}}})}function cssLinks(){var links=document.getElementsByTagName('link');for(var i=0;i<links.length;i++){if(links[i].title=='enhanced'){links[i].disabled=true;links[i].disabled=false;links[i].rel='stylesheet'}}}function aa(hash){if(hash){var slug=[];var cat='';var tag='';var bodyID='';slug=hash.split('/');var type=slug[slug.length-3];if(type=='category'){cat=slug[slug.length-2]}if(type=='tag'){tag=slug[slug.length-2]}if(hash.indexOf('?s=')>0){bodyID='search';hash='/wp'+hash}if((hash=='/')||(hash=='/wp')||(hash=='/wp/')){bodyID='homepage'}slug=slug[slug.length-2];$('#menu li, #meta li').removeClass('current-cat');if($('#submenu li').length==0){$("#menu a[href*='"+cat+"']").parent().addClass('current-cat');}$.ajax({url:hash,cache:true,beforeSend:function(){$('#news, #articles').fadeOut(100);$('#widgets').after("<div class='loading'></div>");$('body').css('cursor','wait')},success:function(html){var ajaxArticle=$(html).find('#articles').html();var ajaxSubmenu=$(html).find('#submenu').html();var ajaxTitle=$(html).find('#header .title').text();if(bodyID=='homepage'){document.title='Vakant'}else{document.title='Vakant -'+ajaxTitle}$('body').attr('id',bodyID);$('body').attr('class',cat).addClass(tag).addClass(now);if(type=='tag'){$('body').addClass('tag')}$('#submenu').html(ajaxSubmenu);if($('#submenu .current-cat').length>0){$('#menu .cat-item-39').addClass('current-cat')}$('#articles').html(ajaxArticle);DOMing();$('.loading').hide().remove();$('#articles').fadeIn(200);if(bodyID=='homepage'){$('#news').fadeIn(200)}$('body').css('cursor','auto');if(cat=='gallery'){var postUrl=$('.post.category-gallery:first .header a').attr('href');var post=$('.post.category-gallery:first');$.ajax({url:postUrl,cache:true,beforeSend:function(){$('body').css('cursor','wait');post.children('.header').append("<span class='wait'></span>");post.append("<div class='section'></div>");post.children('.section').hide()},success:function(html){var ajaxSection=$(html).find('.post .section').html();post.children('.section').html(ajaxSection);tsInit();vvqInit();$('.wait').hide().remove();post.children('.section').slideDown(400,'swing');$('body').css('cursor','auto')},error:function(){post.children('.section').html("<div class='section error'>"+ajaxError+"</div>");$('.wait').hide().remove();post.children('.section').hide().slideDown(200,'swing');$('body').css('cursor','auto')}})}},error:function(){$('#articles').html("<div class='post error'><div class='section'>"+ajaxError+"</div></div>").fadeIn(200);$('.loading').hide().remove();$('body').css('cursor','auto')}})}else{location.href='http://vakant.net/'}}function aaInit(){$.ajax({type:'GET',url:themeUrl+'javascripts/jquery.history.js',success:function(){$.historyInit(aa);$('#menu a, #meta a, #submenu a, .meta a, #footer .imprint a').live('click',function(event){event.preventDefault();var hash=this.href.replace(/^.*#/,'');hash=hash.split(location.hostname);hash=hash[1];$.historyLoad(hash);return false});$('.post.category-gallery .header a').live('click',function(event){event.preventDefault();var postUrl=this.href;var post=$(this).parents('.post');if(post.children('.section').length>0){post.children('.section').slideUp(200,'swing').remove()}else{$.ajax({url:postUrl,cache:true,beforeSend:function(){$('body').css('cursor','wait');post.children('.header').append("<span class='wait'></span>");post.append("<div class='section'></div>");post.children('.section').hide()},success:function(html){var ajaxSection=$(html).find('.post .section').html();post.children('.section').html(ajaxSection);tsInit();vvqInit();post.children('.section').slideDown(400,'swing');$('.wait').hide().remove();$('body').css('cursor','auto')},error:function(){post.children('.section').html("<div class='section error'>"+ajaxError+"</div>");$('.wait').hide().remove();post.children('.section').hide().slideDown(200,'swing');$('body').css('cursor','auto')}})}return false});$('html, body').css('cursor','auto');$('#throbber').remove();$('#page').animate({opacity:'1'},200)},dataType:'script',cache:true})}var loader={init:function(){document.getElementsByTagName('html')[0].style.cursor='wait';document.getElementsByTagName('html')[0].style.visibility='hidden';loader.check()},check:function(){var attempts=5;if(typeof window.jQuery=='undefined'){if(--attempts>0){window.setTimeout(arguments.callee,100)}else{loader.fail()}}else{if($.browser.msie){loader.fail()}else{loader.success()}}},success:function(){cssLinks();$.ajaxSetup({cache:true});$(document).ready(function(){$('html').css({visibility:'visible',height:'100.1%'});$('#page').css({opacity:'0'});$('body').css({cursor:'wait',height:'100%'}).append('<div id="throbber"><div>');daytime();enable_smooth_scroll('.toplink a');$("a[href*='whatpeopleplay.com/player/player.php?track_id='],a[href*='http://www.whatpeopleplay.com/whatpeopleplayer/showExternal.php?p='], #whatpeopleplayer").live('click',function(event){event.preventDefault();var url=this.href;popUp(url,whatpeopleplayerWidth,whatpeopleplayerHeight,'0');return false});$('#widgets #podcastplayer').live('click',function(event){event.preventDefault();var url=this.href;popUp(url,podcastplayerWidth,podcastplayerHeight,'1');return false});$('body').append("<div id='background'></div>");if(now=='day'){$('#background').append("<img src='"+bg+"'/>")}else{$('#background').append("<img src='"+bgNight+"'/>")}});$(window).load(function(){$.ajax({type:'GET',url:themeUrl+'javascripts/jquery.flowplayer.js',success:function(){$.ajax({type:'GET',url:themeUrl+'javascripts/jquery.form.js',success:function(){DOMing();aaInit();},dataType:'script',cache:true})},dataType:'script',cache:true})})},fail:function(){document.getElementsByTagName('html')[0].style.cursor='auto';document.getElementsByTagName('html')[0].style.visibility='visible'}};loader.init();