window.addEvent('domready', function() {

	$$('#portfolio .element').each(function(el,i){

		var navFx = new Fx.Tween (el, {duration: 150, link:'cancel', property: 'opacity'});
		navFx.set(".5")

		el.addEvent('mouseenter', function(){
			navFx.start(1);
		});
		
		el.addEvent('mouseleave', function(){
			navFx.start(.5);
		});
		
	});	

	
});

function openGallery(client_id,area_id){
	var request = new Request.JSON({
		url: 'ajax/gallery.php?client_id='+client_id+'&area='+area_id,
		onComplete: function(jsonObj) {
			
			if(typeof(myShow)!="undefined"){
				myShow.destroy("empty");
			}
			var data = jsonObj;
			myShow = new Slideshow('show', data, { 
				captions: false, 
				controller: false, 
				loader: false, 
				width: 640, 
				height: 480,
				slide: 0,
				paused: true,
				thumbnails: true,
				controller: true,
				//transition: Fx.Transitions.easeIn
				overlap: true
			});
			
			new StickyWin.Modal({
			  content: $('showcase'), //a string or a DOM element
	  		  fadeDuration: 500,
			  modalOptions: {
			    modalStyle: {
			      'background-color':'#000000',
			      'opacity':.8
			    }
			  }
			});


		}
	}).send();
}

function loadVideoThumbnails(client_id,user_agent){

	var request = new Request.HTML({
		url: 'ajax/videos.php?client_id='+client_id+'&user_agent_iphone='+user_agent,
		update: $('videos'),
		evalScripts: true
	}).get();
	
	new StickyWin.Modal({
	  content: $('showcase'), //a string or a DOM element
	  modalOptions: {
	    modalStyle: {
	      'background-color':'#000000',
	      'opacity':.8
	    }
	  }
	});

}
function loadVideo(url,image_id,iphone){

	var sticky = new StickyWin.Modal({
	  content: $('showcase'), //a string or a DOM element
	  modalOptions: {
	    modalStyle: {
	      'background-color':'#000000',
	      'opacity':.8
	    }
	  }
	});
	
	$f("player", "include/flowplayer/flowplayer.commercial-3.1.5.swf", { 
		key: '#$972f4404d7c265b4ef7', 
	    clip: { 
	        url: url, 
	        autoPlay: true, 
	        autoBuffering: true,
			onFinish: function(){this.unload(); sticky.hide();},
			onStop: function(){this.unload(); sticky.hide();}
	    },
	    plugins: { 
	        controls: {
			  sliderColor: '#000000',
		      buttonColor: '#7c7c7c',
		      progressGradient: 'medium',
		      progressColor: '#222222',
		      borderRadius: '0px',
		      bufferColor: '#555555',
		      tooltipTextColor: '#ffffff',
		      durationColor: '#ffffff',
		      tooltipColor: '#7c7c7c',
		      backgroundGradient: [0.6,0.3,0,0,0],
		      volumeSliderGradient: 'none',
		      sliderGradient: 'none',
		      timeBgColor: '#555555',
		      backgroundColor: '#222222',
		      volumeSliderColor: '#000000',
		      bufferGradient: 'none',
		      buttonOverColor: '#7c7c7c',
		      timeColor: '#AA0000',
		      height: 24,
		      opacity: 1.0,
			  stop: false
			},
			stopper: { 
		        url: 'flowplayer.controls-3.1.5.swf', 
		 
		        // display properties 
		        top:3, 
				right:4,
				width: 30,
		        backgroundColor: 'transparent', 
		        backgroundGradient: 'none', 
		 		buttonColor: '#999999',
		        // controlbar-specific configuration 
		        fontColor: '#000000', 
		        timeFontColor: '#333333', 
		        autoHide: 'never', 
		 		hideDelay: 100,
				
		        // which buttons are visible and which are not? 
		        all: false,
				stop: true
		     
		    }

	    }
	});
	
	if(iphone!='false'){ 
		loadQuicktime(url,image_id);
		$("player").style.zIndex=40;
	}
	return false;

}

function loadQuicktime(url,image_id){
	var request = new Request.HTML({
		url: 'ajax/quicktime.php?video_id='+image_id+'&url='+url,
		update: $('player')
	}).get();
}
