var this_domain = 'ikissedcharles.nl';


$(document).ready(function() {
	preparelinks(this_domain);
	
	
	
	if ($("#picture").length > 0) {
		$("#picture h1").after('<p><a class="picture_backlink" href="#">Click here to go back</a></p>');
		$(".picture_backlink").click(function() {
			window.history.back();
			return false;
		});
	}
	
	
	if ($("#pictures").length > 0) {
		function formatTitle(title, currentArray, currentIndex, currentOpts) {
			 var href = currentOpts.href;
			 
			 
			 /* ID zit in class originele link */
			 var xid = $("a[href='"+href+"']").attr('class').split('_');
			 var id = xid[1];
			 comment_url = '/media/?pid=' + id;
			 return '<div id="tip7-title">'  + (title && title.length ? '<b>' + title + '</b> | ' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + ' | <a href="'+comment_url+'">Comment</a></div>';

		}
				
	}
	
	
	if ($("#jquery_jplayer").length > 0) {
		
		
	var playItem = 0;

	
	
var _0x27be=["\x4D\x79\x20\x48\x65\x61\x72\x74\x20\x47\x6F\x65\x73\x20\x42\x6F\x6F\x6D\x20\x28\x50\x72\x65\x20\x54\x6F\x75\x72\x20\x50\x65\x70\x74\x61\x6C\x6B\x29","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x69\x6B\x69\x73\x73\x65\x64\x63\x68\x61\x72\x6C\x65\x73\x2E\x63\x6F\x6D\x2F\x6D\x70\x33\x2F\x3F\x49\x44\x3D\x39\x65\x30\x32\x64\x32\x37\x30\x32\x32\x30\x62\x65\x31\x63\x38\x65\x62\x34\x61\x35\x62\x64\x63\x62\x38\x32\x65\x32\x62\x32\x32","\x4C\x65\x74\x27\x73\x20\x46\x72\x65\x6E\x63\x68\x20\x54\x6F\x6E\x69\x67\x68\x74","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x69\x6B\x69\x73\x73\x65\x64\x63\x68\x61\x72\x6C\x65\x73\x2E\x63\x6F\x6D\x2F\x6D\x70\x33\x2F\x3F\x49\x44\x3D\x61\x63\x34\x35\x39\x34\x37\x39\x35\x66\x33\x65\x64\x39\x63\x30\x32\x61\x32\x61\x33\x64\x66\x34\x61\x33\x64\x61\x62\x37\x65\x38","\x4F\x76\x65\x72\x20\x42\x65\x66\x6F\x72\x65\x20\x49\x74\x20\x48\x61\x64\x20\x53\x74\x61\x72\x74\x65\x64\x20\x59\x65\x74","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x69\x6B\x69\x73\x73\x65\x64\x63\x68\x61\x72\x6C\x65\x73\x2E\x63\x6F\x6D\x2F\x6D\x70\x33\x2F\x3F\x49\x44\x3D\x66\x61\x30\x33\x34\x38\x65\x31\x38\x34\x33\x35\x66\x61\x61\x66\x64\x39\x37\x32\x39\x39\x65\x64\x35\x39\x66\x33\x30\x34\x38\x34"];var myPlayList=[{name:_0x27be[0],mp3:_0x27be[1]},{name:_0x27be[2],mp3:_0x27be[3]},{name:_0x27be[4],mp3:_0x27be[5]}];
	
	// Local copy of jQuery selectors, for performance.
	var jpPlayTime = $("#jplayer_play_time");
	var jpTotalTime = $("#jplayer_total_time");

		$("#jquery_jplayer").jPlayer({
			ready: function () {
				
				displayPlayList();
				playListConfig(0);
				

	    },

		  nativeSupport: false,
		  oggSupport: false,
		  customCssIds: false,
		  swfPath: '../jplayer',
		  errorAlerts: false,
		  warningAlerts: false
		})

	.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
		//$('.jp-progress').css('visibility','visible');
		jpPlayTime.text($.jPlayer.convertTime(playedTime));
		jpTotalTime.text($.jPlayer.convertTime(totalTime));

	})
	.jPlayer("onSoundComplete", function() {
		playListNext();
	});

		
		
	
	$("#jplayer_previous").click( function() {
		playListPrev();
		return false;
	});

	$("#jplayer_next").click( function() {
		playListNext();
		return false;
	});

	function displayPlayList() {
		if ($("#jplayer_playlist ul").length == 0) {
			$("#jplayer_playlist").append("<ul></ul>");
			for (i=0; i < myPlayList.length; i++) {
				$("#jplayer_playlist ul").append("<li id='jplayer_playlist_item_"+i+"'>"+ myPlayList[i].name +"</li>");
				$("#jplayer_playlist_item_"+i).data( "index", i ).click( function() {
					var index = $(this).data("index");
					if (playItem != index) {
						playListChange( index );
					} else {
						$("#jquery_jplayer").jPlayer("play");
					}
				});
			}
		}
	}

	function playListInit(autoplay) {
		if(autoplay) {
			playListChange( playItem );
			
		} else {
			playListChange( playItem );
			$("#jquery_jplayer").jPlayer("pause");
		}
	}

	function playListConfig( index ) {
		$("#jplayer_playlist_item_"+playItem).removeClass("jplayer_playlist_current");
		$("#jplayer_playlist_item_"+index).addClass("jplayer_playlist_current");
		playItem = index;
		$("#jquery_jplayer").jPlayer("setFile", myPlayList[playItem].mp3, myPlayList[playItem].ogg);
	}

	function playListChange( index ) {
		playListConfig( index );
		$("#jquery_jplayer").jPlayer("play");
	}

	function playListNext() {
		var index = (playItem+1 < myPlayList.length) ? playItem+1 : 0;
		playListChange( index );
	}

	function playListPrev() {
		var index = (playItem-1 >= 0) ? playItem-1 : myPlayList.length-1;
		playListChange( index );
	}
		
	//hover states on the static widgets
	$('ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); },
		function() { $(this).removeClass('ui-state-hover'); }
	);

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
});




function preparelinks(this_domain) {
  $("a[href^='http']").each(function() {
	  	if ($(this).attr('class').indexOf("newwindow") != -1 || $(this).attr('href').indexOf(this_domain) == -1)  {
	      
	      $(this).click(function() {
	        window.open($(this).attr('href'));
	        return false;
	      });
	    }
  });
}
	
