//jQuery.noConflict();

var url = "";
jQuery(document).ready(function($){
	//setupImages();
	//prettyPhoto.init();
	
	// Get the source directory of this script
	scriptSrc = $('script[@src$=acato.js]').attr('src').replace('js/acato.js', '');
	
	// Search URL what matches the ....
	// Get categories
	jQuery(function() {
		jQuery.ajax({
	
		   type: "GET", 
		   url: "http://www.acato.nu/wp-content/uploads/getImage.php",
		   dataType: "xml",
		   success: function(xml){
				url = xml.getElementsByTagName("url")[0].childNodes[0].nodeValue;
				complete();
			}
		});
	});
	
	
	// Start the sifr replacement
	initSifr(scriptSrc);
});


function complete(){
	var lnk = jQuery(".post:has(a[href$="+ url +"]) .storytitle a").attr("href");
	
	var so = new SWFObject(scriptSrc + "swf/header.swf", "header", "759", "135", "8");
	so.addParam("wmode", "opaque");
	so.addVariable("postLink", lnk);
	so.write("headerSwf");
}

function setupImages(){
	jQuery("a[href$='jpg']").attr('rel','prettyOverlay');
	jQuery("a[href$='gif']").attr('rel','prettyOverlay');
	jQuery("a[href$='png']").attr('rel','prettyOverlay');
}

function initSifr(scriptSrc){

	// Start sifr
	var agfa = {
		src: scriptSrc + 'swf/agfa.swf'
	};

	sIFR.useDomContentLoaded = false;
	sIFR.activate();

	sIFR.replace(agfa, {
		selector: 'h2'
		,wmode: 'transparent'
		,css: {
			'.sIFR-root': { 'color': '#52B3DD', 'font-size': '23px' },
			'a, a:hover': { 'color': '#52B3DD', 'text-decoration': 'none' }
		}
	});

}
