$(document).ready(function () {
	
	var link;
	$('#content a[@href^="http://"]').each(function(){
		link=$(this).html();
		$(this).html(link+'<span class="externallink">&nbsp;</span>');
		//console.log($(this).html());
	})
	
	$('#content a[@href$=".pdf"]').each(function(){
		link=$(this).html();
		$(this).html('<span class="pdflink">&nbsp;</span>'+link);
		//console.log($(this).html());
	})
	
	$('#content a[@href^="mailto:"]').each(function(){
		link=$(this).html();
		$(this).html('<span class="mailto"></span>'+link);
		//console.log($(this).html());
	})
	
	//$('h1').sifr({path:'uploads/i/',font:'HelveticaNeueLight', height:30});
	//$('h2').sifr({path:'uploads/i/',font:'HelveticaNeueLight', height:25});

	$('.fadein').hide();
	$('.fadein').fadeIn('slow');
	
	$('a:contains("Google Maps")').each(function(){
		$(this).parent().after('<div class="googlemap"><iframe width="100%" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'+$(this).attr('href')+'"></iframe></div>');
		$(this).parent().hide();
	});
	
	$('a:contains("YouTube")').each(function(){
		$(this).parent().after('<div class="youtube"><object width="425" height="344"><param name="movie" value="'+$(this).attr('href')+'"></param><embed src="'+$(this).attr('href')+'" type="application/x-shockwave-flash" width="425" height="344"></embed></object></div>');
		$(this).parent().hide();
	});
	
	$('a[@href$="flv"]').flash(
		{ src: 'appear/flvplayer.swf', height: 524, width: 672 },
		{ version: 7 },
		function(htmlOptions) {
			$this = $(this);
			htmlOptions.flashvars.file = $this.attr('href');
			htmlOptions.flashvars.image = $this.attr('href')+'.jpg';
			htmlOptions.flashvars.width = '672';
			htmlOptions.flashvars.height = '524';
			$this.before($.fn.flash.transform(htmlOptions));
			$('a[@href$="flv"]').hide();
		}
	);
	
	$('#analyse').submit(function(){
		var url=$('#url').val();
		$(this).parent().html('<p id="temp">Even geduld, de analyse wordt nu uitgevoerd... Dit kan enkele minuten duren. Als de analyse voltooid is, verschijnt de link hier.<br /><img src="appear/i/spinner.gif" alt="" /></p>');
		//$.get('http://www.pearwebsites.com/extra.php?url='+url, function(thehtml){
		//	$(this).parent().html(thehtml);
		//});		
		$('#temp').load('http://www.pearwebsites.com/extra.php?url='+url);
		return false;
	});
	
	
	
	var path = location.pathname.substring(1);
	var path2=location.pathname;
	// Set your homepage here, eg. /index.php or /
	var home = "./";
	// Check the home link against the path and set the navigation accordingly. 
	if (path == home || path2 == "/") {
		// Note that the jQuery selector matches *only* the home link
		var nav=$('a[@href="' + home + '"]');
	} else {
		var nav=$('a[@href$="' + path + '"]');
	}
	
	nav.addClass('active');
	
	$('#portfolio').cycle({fx:'fade',speed:300,timeout:3000,pause:1,random:1});	
});
