/** External Links **/

function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; } } window.onload = externalLinks;

/** SuckerFish Menu **/

$(document).ready(function(){ $('.menu ul').superfish({ autoArrows: false }); });

/** Hover Over Image **/

eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.p.q=6(k){2 k=$.x({},$.p.q.y,k);9.J(6(){2 o=$.z?$.x({},k,$(9).z()):k;2 a=$(9);2 b=a.A(\':K\');2 c=a.A(\':L\');5(a.3(\'4\')==\'M\'){a.3(\'4\',\'N\')}a.3(\'O\',\'P\');5(b.3(\'B\')==\'Q\'){b.3(\'B\',\'R\')}c.3({4:\'S\',T:0,U:0,V:0});2 d=c.W();c.3(o.4,-d);5(o.r){c.3(\'s\',0)}a.3(\'C\',a.C());2 e={};e[o.4]=0;e.s=1;2 f={};f.l=(o.7==\'X\')?d:D(o.7);5(o.4==\'E\'){f.l=-f.l}2 g=6(){c.m(8).n(e,o.t,o.u);5(o.7){b.m(8).n(f,o.t,o.u)}};2 h={};h[o.4]=-d;h.s=D(!o.r);2 i={l:0};2 j=6(){c.m(8).n(h,o.v,o.w);5(o.7){b.m(8).n(i,o.v,o.w)}};5(o.F){c.3(e);b.3(f);a.G(j,g)}Y{a.G(g,j)}});Z 9};$.p.q.y={u:\'H\',w:\'H\',r:8,4:\'E\',F:I,7:I,t:\'10\',v:\'11\'}})(12);',62,65,'||var|css|position|if|function|shiftContent|true|this||||||||||||marginTop|stop|animate||fn|hoverup|fade|opacity|speedIn|easingIn|speedOut|easingOut|extend|defaults|metadata|children|display|height|Number|bottom|reverse|hover|swing|false|each|first|last|static|relative|overflow|hidden|inline|block|absolute|left|right|margin|outerHeight|push|else|return|fast|normal|jQuery'.split('|'),0,{}))

$(document).ready(function() { $('.demo').hoverup({ }); });
	

/** Accordion **/

$(document).ready(function(){
	
$('.acc_container').hide(); 
$('.acc_trigger:first').addClass('active').next().show();

$('.acc_trigger').click(function(){
	if( $(this).next().is(':hidden') ) {
		$('.acc_trigger').removeClass('active').next().slideUp();
		$(this).toggleClass('active').next().slideDown();
	}
	return false;
});

});




/** Hover Boxes **/

(function($) { $.fn.imageEffects = function(options)
{
	var easingType = "linear";
	var transitionTimeGo = 200;
	var imageWidth=0;
	var imageHeight=0;
	var totalWidth=[];
	var totalHeight=[];
	var tempLeft=0;
	var left=0;
	var top=0;
	var zoomSize=30;
	var overlaySize=60;
	var defaults = {}, options = $.extend(defaults, options);
	this.each(function() { var $this = $(this);	
	var effectOverlayArray = $(".effectoverlay");
	for (i = 0; i < effectOverlayArray.length; i++) { effectOverlayArray.eq(i).wrap('<div class="overlay" style="position:relative; display:inline-block;"/>'); imageWidth = effectOverlayArray.eq(i).width(); imageHeight = effectOverlayArray.eq(i).height();
	var aux=$(".overlay").eq(i)
	if(effectOverlayArray.eq(i)[0].nodeName==="A")
	{
		imageWidth=effectOverlayArray.attr('width');
		imageHeight=effectOverlayArray.attr('height');
		var aux2=aux.find('.effectoverlay');
		aux2.append('<div class="overlayBg" style="position:absolute; top:0px; left:0px; background: #000 url(http://www.davidwilliambell.com/wp-content/themes/davidwilliambell/images/zoom.png) center center no-repeat; width:' + imageWidth + 'px;height:' + imageHeight + 'px; opacity:0; filter:alpha(opacity=0);"></div>');	 // load overlay images	
		aux=$(".overlay").eq(i).find('.effectoverlay');
	}
	else
	{
		aux.append('<div class="overlayBg" style="position:absolute; top:0px; left:0px; background: #000 url(http://www.davidwilliambell.com/wp-content/themes/davidwilliambell/images/zoom.png) center center no-repeat; width:' + imageWidth + 'px;height:' + imageHeight + 'px; opacity:0; filter:alpha(opacity=0);"></div>');	 // load overlay images	
	}
	$(".overlayImgs").eq(i).css({ 'position': 'absolute','left': (imageWidth/2 - overlaySize/2),'top':(imageHeight/2 - overlaySize/2),'opacity':0});
	aux.mouseover(function(){
	var aux3=$(this).children()
	aux3.eq(1).animate({ opacity: 0.7}, {queue: false, duration: transitionTimeGo})
	aux3.eq(2).animate({ opacity: 1}, {queue: false, duration: transitionTimeGo}) });
	aux.mouseout(function(){
	var aux3=$(this).children()
	aux3.eq(1).animate({ opacity: 0}, {queue: false, duration: transitionTimeGo})
	aux3.eq(2).animate({ opacity: 0}, {queue: false, duration: transitionTimeGo}) });
	} return this; }); }
})(jQuery);
jQuery(window).load(function() { if (jQuery.browser.safari && document.readyState != "complete"){ console.info('done'); setTimeout( arguments.callee, 120 ); return; } 
jQuery('body').imageEffects({ }) })




/** Img Preloaders **/

$(function(){ $("#filmright").preloadify({ imagedelay: 30 }); });
$(function(){ $("#boxescont").preloadify({ imagedelay: 30 }); });
$(function(){ $(".albumcover").preloadify({ imagedelay: 30 }); });
$(function(){ $(".songright").preloadify({ imagedelay: 30 }); });






/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/

// Speed of the automatic slideshow
var slideshowSpeed = 6000;

// Variable to store the images we need to set as background
// which also includes some text and url's.
var photos = [
	{
		"title" : "",
		"image" : "slider/2.jpg",
		"url" : "",
		"firstline" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla interdum turpis, nec fringilla mauris aliquet vitae. Nullam ac luctus libero. Vivamus sapien mauris, aliquam nec feugiat eu, viverra nec ligula."
	},
	{
		"title" : "",
		"image" : "slider/4.jpg",
		"url" : "",
		"firstline" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla interdum turpis, nec fringilla mauris aliquet vitae. Nullam ac luctus libero. Vivamus sapien mauris, aliquam nec feugiat eu, viverra nec ligula."
	},
	{
		"title" : "",
		"image" : "slider/1.jpg",
		"url" : "",
		"firstline" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla interdum turpis, nec fringilla mauris aliquet vitae. Nullam ac luctus libero. Vivamus sapien mauris, aliquam nec feugiat eu, viverra nec ligula."
	},
	{
		"title" : "",
		"image" : "slider/3.jpg",
		"url" : "",
		"firstline" : "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam fringilla interdum turpis, nec fringilla mauris aliquet vitae. Nullam ac luctus libero. Vivamus sapien mauris, aliquam nec feugiat eu, viverra nec ligula."
	}
];



$(document).ready(function() {
		
	// Backwards navigation
	$("#back").click(function() {
		stopAnimation();
		navigate("back");
	});
	
	// Forward navigation
	$("#next").click(function() {
		stopAnimation();
		navigate("next");
	});
	
	var interval;
	$("#control").toggle(function(){
		stopAnimation();
	}, function() {
		// Change the background image to "pause"
		$(this).css({ "background-image" : "url(images/btn_pause.png)" });
		
		// Show the next image
		navigate("next");
		
		// Start playing the animation
		interval = setInterval(function() {
			navigate("next");
		}, slideshowSpeed);
	});
	
	
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
			return;
		}
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
		
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		
		// Make sure the new container is always on the background
		currentZindex--;
		
		// Set the background image of the new active container
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(http://www.davidwilliambell.com/wp-content/themes/davidwilliambell/images/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		
		// Hide the header text
		$("#headertxt").css({"display" : "none"});
		
		// Set the new header text
		$("#firstline").html(photoObject.firstline);
		$("#secondline")
			.attr("href", photoObject.url)
			.html(photoObject.secondline);
		$("#pictureduri")
			.attr("href", photoObject.url)
			.html(photoObject.title);
		
		
		// Fade out the current container
		// and display the header text when animation is complete
		$("#headerimg" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 500);
		});
	};
	
	var stopAnimation = function() {
		// Change the background image to "play"
		$("#control").css({ "background-image" : "url(images/btn_play.png)" });
		
		// Clear the interval
		clearInterval(interval);
	};
	
	// We should statically set the first image
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
});
