// Homepage image cycle

$(document).ready(function() { 
	$("#s4") 
	.cycle({ 
    	fx:     'fade', 
    	speed:  500,
    	startingSlide: 4, 
    	timeout: 0,
		pager:  '#home-nav',
		pagerAnchorBuilder: function(idx, slide) { 
       		return '#home-nav li:eq(' + idx + ') a'; 
    	}
	});
		
$('.feature').click(function() {
	$(document).scrollTo(0,500);
});
});

// Thumbnail rollovers for About Us page 

 $(document).ready(function(){
   $(".aboutus-thumb").hover(function() {
    $(this).find('img').stop().animate({ opacity: "0.3"}, {queue:false,duration:160});
   },function() {
      $(this).find('img').stop().animate({ opacity: "1.0" }, {queue:false,duration:160});
     });
  });
  
// Share this bar

 $(function() {
	$("#sharethisBar").click(function(){
	return false;
	});
	$(".specifications .block").css("display","none");
	$(".specifications .toggleDrop").click(function() {
           $(".specifications .block").slideToggle();
		   $(".specifications .toggleDrop .sh_icon").toggleClass("active");
		   return false;
    });
	
	$(".awards .block").css("display","none");
	$(".awards .toggleDrop").click(function() {
           $(".awards .block").slideToggle();
		   $(".awards .toggleDrop .sh_icon").toggleClass("active");
		   return false;
    });
});

// Font resizer
  
$(document).ready(function() {
    $('.project-content').fontResizer({minFont:10,maxFont:16});
});

// Google Analytics Tracking 

$(document).ready(function() {
if (typeof jQuery != 'undefined') {
    jQuery(document).ready(function($) {
        var filetypes = /\.(zip|exe|pdf|doc*|xls*|ppt*|mp3)$/i;
        var baseHref = '';
        if (jQuery('base').attr('href') != undefined)
            baseHref = jQuery('base').attr('href');
        jQuery('a').each(function() {
            var href = jQuery(this).attr('href');
            if (href && (href.match(/^https?\:/i)) && (!href.match(document.domain))) {
                jQuery(this).click(function() {
                    var extLink = href.replace(/^https?\:\/\//i, '');
                    _gaq.push(['_trackEvent', 'External', 'Click', extLink]);
                    if (jQuery(this).attr('target') != undefined && jQuery(this).attr('target').toLowerCase() != '_blank') {
                        setTimeout(function() { location.href = href; }, 200);
                        return false;
                    }
                });
            }
            else if (href && href.match(/^mailto\:/i)) {
                jQuery(this).click(function() {
                    var mailLink = href.replace(/^mailto\:/i, '');
                    _gaq.push(['_trackEvent', 'Email', 'Click', mailLink]);
                });
            }
            else if (href && href.match(filetypes)) {
                jQuery(this).click(function() {
                    var extension = (/[.]/.exec(href)) ? /[^.]+$/.exec(href) : undefined;
                    var filePath = href;
                    _gaq.push(['_trackEvent', 'Download', 'Click-' + extension, filePath]);
                    if (jQuery(this).attr('target') != undefined && jQuery(this).attr('target').toLowerCase() != '_blank') {
                        setTimeout(function() { location.href = baseHref + href; }, 200);
                        return false;
                    }
                });
            }
        });
    });
}
});
