
	function changeImageFromParent(uri,_this)
		{/*{{{*/
			if (!uri) return false;

			if (_this && _this.firstChild && _this.firstChild.tagName && _this.firstChild.tagName.toLowerCase) //DOM ?
				{
					if (_this.firstChild.tagName.toLowerCase() == 'img') // <img... ?
					_this.firstChild.src = uri;//set src="...">
					return true;
				}

			//IE 4+ (?)
			if (!window || !window.event || !window.event.srcElement || !window.event.srcElement.tagName) return false;
			if (window.event.srcElement.tagName.toLowerCase() != 'img') return false;
			window.event.srcElement.src = uri;
			return true;
		}/*}}}*/
	function changeImageFromSubmit(uri,_this)
		{/*{{{*/
			if (uri && _this && _this.src) _this.src = uri;
		}/*}}}*/
		
	
	function openProject(section,cat,file_id, id) {
		return (fillLayer(section,cat,file_id, id, 0));
	}
	
	function nextProject(section,cat,file_id, id) {
		return (fillLayer(section,cat,file_id, id, 1));
	}
	
	function prevProject(section,cat,file_id, id) {
		return (fillLayer(section,cat,file_id, id, -1));
	}
	
	function fillLayer(section,cat,file_id, id, pos) {
		var myDate	=	new Date();
		
		var url;
		
		switch(pos) {
			case -1:
				url = "/page/getpreviousproject/section/"+section+"/cat/"+cat+"/file_id/"+file_id+"/id/"+id+"/&t="+myDate.getMilliseconds();
				break;
			case 0:
				url = "/page/getproject/section/"+section+"/cat/"+cat+"/file_id/"+file_id+"/id/"+id+"/&t="+myDate.getMilliseconds();
				break;
			case 1:
				url = "/page/getnextproject/section/"+section+"/cat/"+cat+"/file_id/"+file_id+"/id/"+id+"/&t="+myDate.getMilliseconds();
				break;
			default:
				url = "/page/getproject/section/"+section+"/cat/"+cat+"/file_id/"+file_id+"/id/"+id+"/&t="+myDate.getMilliseconds();
				break;
		}
		 
		 $.ajax({
		 	type:			"GET",
		 	cache:			"false",
		 	url:			url,
		 	contentType:            "application/json; charset=utf-8",
			dataType:		"json",
			success: function(data) {
		 		for (i=0; i<data.length; i++) {
		 			var gallery;
		 			
		 			var prevImg			=	new Object;
		 				prevImg.file_id         =	data[0].file_id;
		 				prevImg.id		=	data[0].id;
		 				prevImg.first           =	true;
		 			var nextImg			=	new Object;
		 				nextImg.file_id         =	data[0].file_id;
		 				nextImg.id		=	data[0].id;
		 				nextImg.last            =	true;

		 				if (i>0) {
		 					prevImg.file_id	=	data[i-1].file_id;
		 					prevImg.id	=	data[i-1].id;
		 					prevImg.first	=	false;
		 				}
		 				
		 				if (i<data.length-1) {
		 					nextImg.file_id	=	data[i+1].file_id;
		 					nextImg.id	=	data[i+1].id;
		 					nextImg.last	=	false;
		 				}

		 			
		 			if (i==0) {
		 				$('#bigImage').html('<img src="/prev/584x584'+data[i].full_path+data[i].full_file+'" id="bigImg'+data[i].id+'" />');
		 				$('#projectTitle').html(data[i].title);
		 				$('#projectTitle').hide();
		 				
		 				infos = new Array();
		 				$('dl.default_02 > dt').each(function(){infos[infos.length] = this.className;});

		 				for (j=0; j<infos.length; j++) {
		 					if ($('dd.'+infos[j]).size()) {

		 						if (data[i][infos[j]]) {
			 						$('dd.'+infos[j]).html(data[i][infos[j]]);
			 						$('.'+infos[j]).show();
			 					} else {
			 						$('dd.'+infos[j]).html("&nbsp;");
			 						$('.'+infos[j]).hide();
			 					}
			 				}
		 				}
				 		
				 		if (i>0) {
				 			$('#prevProject').html('<a href="#" onclick="return updateLayer(\''+section+'\',\''+cat+'\',\''+data[i-1].file_id+'\',\''+data[i-1].id+'\');" class="invertPrevButton"><span>Previous</span></a>');
				 		} else {
				 			$('#prevProject').html('<a href="#" onclick="return prevProject(\''+section+'\',\''+cat+'\',\''+data[i].file_id+'\',\''+data[i].id+'\');" class="invertPrevButton"><span>Previous</span></a>');
				 		}
				 		
				 		if (i < data.length-1) {
				 			$('#nextProject').html('<a href="#" onclick="return updateLayer(\''+section+'\',\''+cat+'\',\''+data[i+1].file_id+'\',\''+data[i+1].id+'\');" class="invertNextButton"><span>Next</span></a>');
				 		} else {
				 			$('#nextProject').html('<a href="#" onclick="return nextProject(\''+section+'\',\''+cat+'\',\''+data[i].file_id+'\',\''+data[i].id+'\');" class="invertNextButton"><span>Next</span></a>');
						}
						
						gallery = '<a href="#" onclick="updateLayer(\''+section+'\',\''+cat+'\',\''+data[i].file_id+'\',\''+data[i].id+'\');"><img src="/prev/x64'+data[i].full_path+data[i].full_file+'" id="thumbnail'+data[i].id+'" rel="'+prevImg.file_id+'|'+prevImg.id+'|'+prevImg.first+'" ref="'+nextImg.file_id+'|'+nextImg.id+'|'+nextImg.last+'" /></a>';
						
		 			} else {
		 				gallery += '<div class="whiteSpace">&nbsp;</div>';
	 					gallery += '<a href="#" onclick="updateLayer(\''+section+'\',\''+cat+'\',\''+data[i].file_id+'\',\''+data[i].id+'\');"><img src="/prev/x64'+data[i].full_path+data[i].full_file+'" id="thumbnail'+data[i].id+'" rel="'+prevImg.file_id+'|'+prevImg.id+'|'+prevImg.first+'" ref="'+nextImg.file_id+'|'+nextImg.id+'|'+nextImg.last+'" /></a>';
		 			}
		 			$('#gallery').html(gallery);
		 		}
		 		$('#modalContent').fadeIn("fast");
		 	}
		 });
		 
		 return false;
	}
	
	function updateLayer(section,cat,file_id, id) {
		var myDate	=	new Date();
		
	    var url = "/page/getobject/section/"+section+"/cat/"+cat+"/file_id/"+file_id+"/id/"+id+"/&t="+myDate.getMilliseconds();
	    
		$('#bigImage > img').fadeOut("fast");
		//$('#projectTitle').fadeOut("fast");
		$('#projectTitle').hide();
		$('dl.default_02').fadeOut("fast");
			
		$.ajax({
		 	type:			"GET",
		 	cache:			"false",
		 	url:			url,
		 	contentType:	"application/json; charset=utf-8",
			dataType:		"json",
			success: function(data) {
				
				$('#projectTitle').html(data.title);
				
				thumbnail	=	$('#thumbnail'+id);
				prevInfos	=	thumbnail.attr("rel").split("|");
				nextInfos	=	thumbnail.attr("ref").split("|");
				
				if (prevInfos[2]=='false') {
					$('#prevProject').html('<a href="#" onclick="return updateLayer(\''+section+'\',\''+cat+'\',\''+prevInfos[0]+'\',\''+prevInfos[1]+'\');" class="invertPrevButton"><span>Previous</span></a>');
				} else {
					$('#prevProject').html('<a href="#" onclick="return prevProject(\''+section+'\',\''+cat+'\',\''+file_id+'\',\''+id+'\');" class="invertPrevButton"><span>Previous</span></a>');
				}
				
				if (nextInfos[2]=='false') {
					$('#nextProject').html('<a href="#" onclick="return updateLayer(\''+section+'\',\''+cat+'\',\''+nextInfos[0]+'\',\''+nextInfos[1]+'\');" class="invertNextButton"><span>Next</span></a>');
				} else {
					$('#nextProject').html('<a href="#" onclick="return nextProject(\''+section+'\',\''+cat+'\',\''+nextInfos[0]+'\',\''+nextInfos[1]+'\');" class="invertNextButton"><span>Next</span></a>');
				}
				
				$('#bigImage').html('<img src="/prev/584x584'+data.full_path+data.full_file+'" />');
 				
 				infos = new Array();
		 		$('dl.default_02 > dt').each(function(){infos[infos.length] = this.className;});

 				for (j=0; j<infos.length; j++) {
 					if ($('dd.'+infos[j]).size()) {
	 					if (data[infos[j]]) {
	 						$('dd.'+infos[j]).html(data[infos[j]]);
	 						$('.'+infos[j]).show();
	 					} else {
	 						$('dd.'+infos[j]).html("&nbsp;");
	 						$('.'+infos[j]).hide();
	 					}
	 				}
 				}
 				$('#bigImage > img').fadeIn("fast");
 				//$('#projectTitle').fadeIn("fast");
  				$('dl.default_02').fadeIn("fast");
		 	}
		 });

		 return false;
	}
	
	// initialise plugins
	jQuery(document).ready(function() { 
		$('ul.sub_menu').superfish();
		

		/*$('.gateLayer')
			.click(function() {
				$('#modalContent').show();
			});
		*/
			
		$('.closeButton')
			.click(function() {
				$('#modalContent').fadeOut("fast");
			});	
			
			
		jQuery(function() {
		   jQuery('#slideshow1').cycle({
		   	timeout:7000,
		   	width:684,
		   	height:487,
                        next:   '#next2',
                        prev:   '#prev2'
		   });
		   jQuery('#slideshow2').cycle({
		   	timeout:7000,
		   	cleartype:  1,
                        next:   '#next2',
                        prev:   '#prev2'
		   });
		    
		});	
			
	});