// MAVEN CREATIVE
// WE ARE WATCHING YOU!

$(document).ready(function () {
	
	//SMOOTH SCROLLING
   $('.sss').click(function(){
   		ssl = $(this).attr('href');
		
		$.scrollTo( ssl , 1500, {easing:'easeOutQuint'} );
		
		return false;
	});
   /*
   //QTIPPIN'
   $('#qTippin a[href][title]').qtip({
   content: {
         text: false // Use each elements title attribute
      },
   position: {
      corner: {
         target: 'topMiddle',
         tooltip: 'bottomMiddle'
      }
   },
   style: {
   				 
                  border: {
                     width: 0,
                     radius: 5,
					 color:'black',
                  },
				   background: 'black',
  					color: '#ffdf00',

                  padding: 0, 
                  textAlign: 'center',
                  tip: true, // Give it a speech bubble tip with automatic corner detection
                  name: 'dark' // Style it according to the preset 'cream' style
               },

	
	});
   */
    //set timeout
	var sTimerId = 0;
	var sTime = 300;
		 
   
   //photo swappin'
   $(".iPhoto").mouseenter(function(){
									
			var thisImage = $(this).attr('href');
			var thisTarget =  $(this).attr('target');
			var targetHTML = $(thisTarget).html();
			var newHTML = '<img src="'+thisImage+'">';
			//alert("new :"+newHTML+" = old: "+targetHTML);
								
			sTimerId = setTimeout ( function(){
				if(newHTML != targetHTML)
				{
					$(thisTarget).animate({opacity: 0}, 'fast', switchOut);
				}
			}, sTime);
			function switchOut()
			{	
				$(thisTarget).html(newHTML);
				$(thisTarget).animate({opacity: 1}, 'fast');
			}
			return false;
	});
   
   $(".iPhoto").click(function(){
			return false;
	});
    $(".iPhoto").mouseleave(function(){
			clearTimeout ( sTimerId );
			return false;
	});
	
   //video swappin'
	$(".iVideo").click(function(){
			var myHeight = $(this).attr('height');
			var myWidth = $(this).attr('width');
			var thisVid = $(this).attr('href');
			var thisT =  $(this).attr('target');
			var targetMov = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+myHeight+'" width="'+myWidth+'"><param name="src" value="'+thisVid+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime" height="'+myHeight+'" width="'+myWidth+'"><embed src="'+thisVid+'" height="'+myHeight+'" width="'+myWidth+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></object>';
			
			$(thisT).animate({opacity: 0}, 'fast', switchO);
			function switchO()
			{	
				$(thisT).html(targetMov);
				$(thisT).animate({opacity: 1}, 'fast');
			}
			return false;
	});
	//video change with desc'
	$(".iVD").click(function(){
			var myHeight = $(this).attr('height');
			var myWidth = $(this).attr('width');
			var thisVid = $(this).attr('href');
			var thisT =  $(this).attr('target');
			var targetD = $(this).attr('client');
			var targetMov = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+myHeight+'" width="'+myWidth+'"><param name="src" value="'+thisVid+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime" height="'+myHeight+'" width="'+myWidth+'"><embed src="'+thisVid+'" height="'+myHeight+'" width="'+myWidth+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></object>';
			
			$(thisT).animate({opacity: 0}, 'fast', switchO);
			function switchO()
			{	
				$(thisT).html(targetMov);
				$(thisT).animate({opacity: 1}, 'fast');
				$(".dsCcontainer").html(targetD);
			}
			return false;
	});
});
