/*
 * --------------------------------------
 *	General functions and UI
 *	(c)2011 GNV&PARTNERS
 * --------------------------------------
 */

var isiPad = navigator.userAgent.match(/iPad/i) != null;
var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
var isiPod = navigator.userAgent.match(/iPod/i) != null;
var msie6 = $.browser == 'msie' && $.browser.version < 7;
 
jQuery.noConflict();

jQuery(document).ready(function($){
  	
  	/*
  	 * Project Slider
  	 *
  	 */
  	$('.slides').slides({
  		generateNextPrev: true,
  		generatePagination: false,
  		fadeSpeed: 600,
  		slideSpeed: 800
  	});
  	$('#prev_proj').click(function(){
  		$('.slides a.prev').trigger('click');
  	});
  	$('#next_proj').click(function(){
  		$('.slides a.next').trigger('click');
  	});
  	
  	/*
  	 * Tweets
  	 *
  	 */
  	getTwitters('tweet', { 
  		id: 'gnvpartners', 
  		count: 1, 
  		enableLinks: true, 
  		ignoreReplies: true, 
  		clearContents: true,
  		template: '%text% <time datetime="%created_at%"><a href="http://twitter.com/%user_screen_name%/statuses/%id_str%/">%time%</a></time>'
  	});
  	
    /* 
     * Easing type 
     * --------------------------------------
     * See list of all available options at http://gsgd.co.uk/sandbox/jquery/easing/
     *
     */	
    var animation = 'easeOutExpo';
    
    
    /*
     * Scroll to top
     *
     */
	if($('.scrolltop').length > 0) {
		$('.scrolltop').click(function(){
			$('body').scrollTo(0,800,animation);
			$('#site_nav ul:last-child li').removeClass('selected');
			return false;
		});
	}
	
	
	/* 
	 * Scroll to anchor
	 * --------------------------------------
	 * Works with any A tag with the 'scroll' CSS class, scrolls to the DIV 
	 * specified in the 'href' attribute.
	 *
	 */ 
	if($('.scroll').length > 0 && !isiPad && !isiPhone && !isiPod) { /* disable on older and mobile browsers for smoother performance */
		$('.scroll').click(function(){
			var target = $(this).attr('href');
			$('body').scrollTo($(target).offset().top - 180,800,animation);
			$('#site_nav ul:last-child li').removeClass('selected');
			return false;
		});
	}
	
	
	/* 
	 * Sticky menu
	 * --------------------------------------
	 * Keeps the top menu attached to the top edge of the browser window  
	 * and handles the scrolling navigation. 
	 *
	 */
	if($('#site_nav').length > 0 && !isiPad && !isiPhone && !isiPod) { /* disable on older and mobile browsers for smoother performance */
		$('#site_nav ul:last-child li a').click(function() {
			var target = $(this).attr('href');
			$('body').scrollTo($(target).offset().top - 180,800,animation);
			$('#site_nav ul:last-child li').removeClass('selected');
			$(this).parent().addClass('selected');
			return false;
		});
	}	
	 
});
