
$(document).ready(function(){

	$('body').attr('id','js'); 
	   
	if($(".slideshow").length > 0){
	   $('.slideshow').cycle({
		   fx:     'curtainY',
		   sync:    0
	   });  
	}
   /*$('.testimonialBoxBot').cycle({
	   fx: 'fade',
	   timeout: 6000,
	   delay: 5000
   });*/
   
	if($("a[rel='popup']").length > 0){
		$("a[rel='popup']").colorbox();
	}
	// Input Clear Default
	$('input[alt],textarea[alt]').each(function() {
		if($(this).val() === '') {
			$(this).val($(this).attr('alt'));	
		}
		$(this).focus(function() {
			if($(this).val() == $(this).attr('alt')) {
				$(this).val('');	
			}
		});
		$(this).blur(function() {
			if($(this).val() === '') {
				$(this).val($(this).attr('alt'));	
			}
		});
	});
		
	// fix for target='_blank'
	$('.external').attr({
		target: "_blank"
	});
		
	function filterPath(string) {
		return string
		.replace(/^\//,'')
		.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
		.replace(/\/$/,'');
	}
	var locationPath = filterPath(location.pathname);
	var scrollElem = scrollableElement('html', 'body');

	$('.scrollTo').each(function() {
	    var thisPath = filterPath(this.pathname) || locationPath;
	    if (  locationPath == thisPath && (location.hostname == this.hostname || !this.hostname) && this.hash.replace(/#/,'') ) {
	      var $target = $(this.hash), target = this.hash;
	      if (target) {
	        var targetOffset = $target.offset().top;
	        $(this).click(function(event) {
	          event.preventDefault();
	          $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
	            location.hash = target;
	          });
	        });
	      }
	    }
	  });
	  // use the first element that is "scrollable"
	  function scrollableElement(els) {
	    for (var i = 0, argLength = arguments.length; i <argLength; i++) {
	      var el = arguments[i],
	          $scrollElement = $(el);
	      if ($scrollElement.scrollTop()> 0) {
	        return el;
	      } else {
	        $scrollElement.scrollTop(1);
	        var isScrollable = $scrollElement.scrollTop()> 0;
	        $scrollElement.scrollTop(0);
	        if (isScrollable) {
	          return el;
	        }
	      }
	    }
	    return [];
	  }
	
	if($("#tweet").length > 0){
		$("#tweet").tweet({
	        join_text: "auto",
	        username: "microdat",
	        avatar_size: 45,
	        count: 1,
	        auto_join_text_default: "we said,",
	        auto_join_text_ed: "we",
	        auto_join_text_ing: "we were",
	        auto_join_text_reply: "we replied",
	        auto_join_text_url: "we were checking out",
	        loading_text: "loading tweets..."
	    });
	}
	//equalHeight($("#productsList li"));

});


$(window).load(function(){ 
	
	if($("#feature_products").length > 0){
		$("#feature_products").sliderkit({
			mousewheel:false,
			shownavitems:3,
			autospeed: 5000,
			panelbtnshover:true,
			navitemshover:false,
			auto:true,
			circular:true,
			navclipcenter:true,
			navscrollatend:true
		});
	}
	
	if($("#page_pictures").length > 0){
	$("#page_pictures").sliderkit({
		mousewheel:false,
		shownavitems:3,
		autospeed: 5000,
		panelbtnshover:true,
		navitemshover:false,
		auto:true,
		circular:true,
		navclipcenter:true,
		navscrollatend:true
	});
	}
});

