
jQuery(document).ready(function($) {
								
								
	
	
	/* --- NIVO SLIDER --- */
	var nivoDefault = {
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:1,
		animSpeed:300,
		pauseTime:8000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
      	controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:1, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	};
	
	if ($('#slider a').size()>=1) {
		$('#slider').nivoSlider(nivoDefault);	
		// Remove Prev<>Next interface if single slide
		if ($('.nivo-imageLink').size()<=1) {
			$('.nivo-prevNav').remove();	
			$('.nivo-nextNav').remove();	
		}		
	}
	if ($('#projectSlider img').size()>=1) {
		nivoDefault.controlNav = false;
		$('#projectSlider').nivoSlider(nivoDefault);
		// Remove Prev<>Next interface if single slide
		if ($('img.pView').size()<=1) {
			$('.nivo-prevNav').remove();	
			$('.nivo-nextNav').remove();	
		}		
	}	
	
	//
	// Remove Prev<>Next interface if single slide
	if ($('#slider').size()>=1 && $('.nivo-imageLink').size()<=1) {
		$('.nivo-prevNav').remove();	
		$('.nivo-nextNav').remove();	
	}
	
	/* --- SLIDESHOW BUTTONS --- */
	$(".nivo-directionNav").prepend($("#single-vimeo").parent().html());
	$(".nivo-directionNav a").mouseenter(function() {
    	$(this).fadeTo(200, 1);
 	}).mouseleave(function() {
    	$(this).fadeTo(200, 0.5);
  	}).fadeTo(0, 0.5);


	/* --- VIMEO BUTTON --- */
	$('a[rel*=vpl-vimeo]').click(function () {
	   	$('#projectSlider').data('nivo:vars').stop = true; //Stop the Slider

		var meta = $(this).attr("rel").split("|");
		var ref = meta[1];
		var w = meta[2];
		var h = meta[3];
		var html = '<div>';
		html +=	'	<object width="'+w+'" height="'+h+'">';
		html += '	<param name="allowfullscreen" value="true" />';
		html += '	<param name="allowscriptaccess" value="always" />';
		html += '	<param name="bgcolor" value="#000000" />';
		html += '	<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+ref+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00AFDB&amp;fullscreen=1&amp;autoplay=1" />';
		html += '	<embed src="http://vimeo.com/moogaloop.swf?clip_id='+ref+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00AFDB&amp;fullscreen=1&amp;autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+w+'" height="'+h+'" bgcolor="#000000"></embed>';	
		html += '	</object>';										  
		html += '	</div>';	
      	$('#vimeoPlayer').html(html);
      	$('#projectSlider').fadeOut(500, function() {
      		$('#vimeoPlayer').fadeIn(1);
      	});
		
	
		
		return false;
    });

	
	
	
	
	
	

	/* ---TOOLTIPS--- */
	var tooltipHighlight = function()
	{
		$(this).qtip(
		{
			content:  '<a href="'+$(this).attr('href')+'">'+$(this).attr('title')+'</a>', // Give it some content, in this case a simple string
			position: 'center', // Set its position
			hide: {
				fixed: true // Make it fixed so it can be hovered over
			},
			style: { 
				padding:'0 5px',
				background: '#000',
				width: {
					min:150,
					max:295
				},
				color: 'white',
				textAlign: 'center',
				border: {
					width: 1,
					radius: 8,
					color: '#000'
				},
				name: 'dark' // Inherit the rest of the attributes from the preset dark style
			}
		});
		
		//
		// Reset TITLE 
		$(this).attr('title', '');
	}
	$('a.imageLink').each(tooltipHighlight);
	$('a.nivo-imageLink').each(tooltipHighlight);	
	
	
	
	
	
	
	
	
	
	/* --- FOLLOW-US BUTTONS --- */
	$("ul.followus li").mouseenter(function() {
    	$(this).fadeTo(200, 1);
 	}).mouseleave(function() {
    	$(this).fadeTo(200, 0.5);
  	}).fadeTo(0, 0.5);

	
	
	
	/* --- TWITTER --- */
	$('#twitter-title').hide();

	$.each($('#twitter-title'), function(i, val) {
			
		var username = "eldoradoenter";
		var tweets = 3;
		$.getJSON("http://search.twitter.com/search.json?q=from:"+username+"&rpp="+tweets+"&callback=?", function(data){
			if (data.results.length) {
				$('<ul id="tweets"></ul>').insertAfter('#twitter-title');
			
				//
				// EACH LOOP HANDLER
				$.each(data.results, function(i,item){
					var avatar = item.profile_image_url;
					var user = item.from_user;
					var tweet = item.text;
					$('<li><a href="http://www.twitter.com/'+user+'" title="'+user+'@twitter"><img height="48" width="48" src="'+avatar+'" class="tweetimg"></a><span>'+tweet+'</span></li>').appendTo("#tweets");
					$('#twitter-title').show();
				});
				
				$('#tweets').linkify();			
			} else {
				//
				// NO TWEETS
			}
		});
    });
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	/* --- MENU REDIRECTING --- */
	$('#menu-item-555 a:first').attr('href', $('#menu-item-555 ul li:first-child a').attr('href'));
	


	/* --- EXTERNAL LINKS [_BLANK] REDIRECTING --- */
	$('a').each(function() {
	   var a = new RegExp('/' + window.location.host + '/');
	   if(!a.test(this.href)) {
		   $(this).attr({target: "_blank"});
	   }
	});


	


});



