

$(document).ready(function(){

  //--------------- Cufón Fonts --------------------// 	
   	Cufon.replace('h3');
   	//Cufon.replace('h2.title');
   	Cufon.replace('h2.title_portfolio');
   	//Cufon.replace('.butt_bgwhite', { hover:true });
   	//Cufon.replace('.toggle_container .block span')  

  //--------------- ScrollTo --------------------//	
  	$('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target
      || $('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body')
        .animate({scrollTop: targetOffset}, 1000);
       return false;
      }
    }
  	});
  
  	//--------------- Tooltip --------------------//	
  	$(".with-tooltip").simpletooltip();
  
 	//--------------- Topbar --------------------//
  
	//Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h2.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
	});
	
   //--------------- Arrow more info --------------------//  
	
	 $(".btn-slide").click(function(){
	 $("#panel").slideToggle("slow");
	 $(this).toggleClass("active"); return false;
	 });
	 
  //--------------- Arrow Webdesign --------------------//  
	
	 $(".btn-slide-webdesign").click(function(){
	 $("#panel_webdesign").slideToggle("slow");
	 $(this).toggleClass("active"); return false;
	 });

	//--------------- Arrow Brand Identity --------------------//  
	
	 $(".btn-slide-brand").click(function(){
	 $("#panel_brand").slideToggle("slow");
	 $(this).toggleClass("active"); return false;
	 });
	 
	 //--------------- Arrow Video --------------------//  
	
	 $(".btn-slide-video").click(function(){
	 $("#panel_video").slideToggle("slow");
	 $(this).toggleClass("active"); return false;
	 });
	
	 
   //--------------- Fade Images ------------------// 
	 
	 if ($.browser.msie && $.browser.version < 7) return; // Don't execute code if it's IE6 or below cause it doesn't support it.

		$(".fade").fadeTo(1, 1);
		$(".fade").hover(
		function () {
		$(this).fadeTo("fast", 0.33);
		},
		function () {
		$(this).fadeTo("slow", 1);
		}
		); 
	
	//--------------- Gallery Pretty Photos ------------------// 
	
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			opacity: 0.80, /* Value between 0 and 1 */
			showTitle: true /* true/false */
		});
		
	//--------------- Nivo Slider --------------------//  

	 $('#slider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500, //Slide transition speed
		pauseTime:3000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:false, //Only show on hover
		controlNav:true, //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:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	 
	//--------------- Google Maps --------------------// 
	 
});

/**
*
*	simpleTooltip jQuery plugin, by Marius ILIE
*	visit http://dev.mariusilie.net for details
*
**/
(function($){ $.fn.simpletooltip = function(){
	return this.each(function() {
		var text = $(this).attr("title");
		$(this).attr("title", "");
		if(text != undefined) {
			$(this).hover(function(e){
				var tipX = e.pageX + 12;
				var tipY = e.pageY + 12;
				$(this).attr("title", ""); 
				$("body").append("<div id='simpleTooltip' style='position: absolute; z-index: 100; display: none;'>" + text + "</div>");
				if($.browser.msie) var tipWidth = $("#simpleTooltip").outerWidth(true)
				else var tipWidth = $("#simpleTooltip").width()
				$("#simpleTooltip").width(tipWidth);
				$("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			}, function(){
				$("#simpleTooltip").remove();
				$(this).attr("title", text);
			});
			$(this).mousemove(function(e){
				var tipX = e.pageX + 12;
				var tipY = e.pageY + 12;
				var tipWidth = $("#simpleTooltip").outerWidth(true);
				var tipHeight = $("#simpleTooltip").outerHeight(true);
				if(tipX + tipWidth > $(window).scrollLeft() + $(window).width()) tipX = e.pageX - tipWidth;
				if($(window).height()+$(window).scrollTop() < tipY + tipHeight) tipY = e.pageY - tipHeight;
				$("#simpleTooltip").css("left", tipX).css("top", tipY).fadeIn("medium");
			});
		}
	});
}})(jQuery);


//--------------- External Links passed Validation--------------------//

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;

//--------------- Navigation Active--------------------//

function selected(obj){
var lilist = document.getElementById('menu');
var alist = lilist.getElementsByTagName('a');
for (i=0; i<alist.length; i++ )
{
alist[i].className="";
}
obj.className="active";
}


