/****************************
* 1. Register Links with behaviour
****************************/

var myrules = {
	'#picture-panel a' : function(el){
		el.onmouseover = function() {
			var baseURI = this.hostname;
			var linkTarget = this.pathname.replace(/^\//,"");

			// Content
			var contentTypeNum = 'type=2529';
			var pictureDiv = 'pictures';
			var pictureURL = "http://"+baseURI+"/"+linkTarget.replace(/\.html/,"")+'?'+contentTypeNum;

			var newContent = new Ajax.Updater(
				pictureDiv,
				pictureURL,
				{method: 'get'}
			);
			return false;
		}
		el.onmouseout = function() {
			
			var pictureDiv = $('pictures');
			/*Effect.Fade('pictures',{duration:0.5,queue:'end'});*/
			pictureDiv.style.display = 'none';
			$('pictures').style.opacity = .8;
			$('pictures').style.filter = 'alpha(opacity=80)';
			pictureDiv.innerHTML = '<img src="fileadmin/templates/images/loading.gif" alt="Loading..." class="center" width="16" height="16" />';
			return false;
		}
		el.onclick = function() {
			return false;
		}
	}

	/*'#subnavigation li a' : function(el){
		el.onclick = function() {

			var baseURI = this.hostname;
			var linkTarget = this.pathname.replace(/^\//,"");

			// Content
			var contentTypeNum = 'type=2529';
			var contentDiv = 'content';
			var contentURL = "http://"+baseURI+"/"+linkTarget.replace(/\.html/,"")+'?'+contentTypeNum;

			var newContent = new Ajax.Updater(
				contentDiv,
				contentURL,
				{method: 'get'}
			);

			// Subnavigation
			
			var subnavTypeNum = 'type=2530';
			var subnavDiv = 'subnavigation';
			var subnavURL = "http://"+baseURI+"/"+linkTarget.replace(/\.html/,"")+'?'+subnavTypeNum;
			alert(subnavURL);
			var newSubnav = new Ajax.Updater(
				subnavDiv,
				subnavURL,
				{method: 'get'}
			);

			// Make sure that the link isn't followed!
			// Strangely retrun false wasn't sufficient in certain cases for IE...(?)
			//this.href = "";
			//return false;
		}
	}*/
};
Behaviour.register(myrules);

/*function getContent(linkLocation) {
		alert(linkLocation);
		var baseURI = linkLocation.baseURI;
		var linkTarget = linkLocation.pathname.replace(/^\//,"");
		var getParams = 'type=2529';
		var putResult = 'content';
		var getUrl = baseURI+linkTarget.replace(/\.html/,"")+'?'+getParams;
		
		var newContent = new Ajax.Updater(
			putResult,
			getUrl,
			{method: 'get'}
		);
		return false;
}*/


Ajax.Responders.register({
	onCreate: function() {
		if($('pictures') && Ajax.activeRequestCount>0) {
			/*Effect.Fade('content',{duration:0.2,queue:'end'});
			Effect.Appear('pictures',{duration:0.2,queue:'end'});*/
			$('pictures').style.display = 'block';
		}
	},
	onComplete: function() {
		if($('pictures') && Ajax.activeRequestCount==0) {
			/*Effect.Fade('busy',{duration:0.5,queue:'end'});
			Effect.Appear('content',{duration:0.5,queue:'end'});
			Effect.Appear('subnavigation',{duration:0.5,queue:'end'});*/
			$('pictures').style.opacity = 1;
			$('pictures').style.filter = 'alpha(opacity=100)';
		}
	}
});