$(document).ready(function() {
$('#sub-nav-web').addClass('active');
});

$(function() {

//External Lnks
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 Scrolling
$("#direction-top").click(function() { $.scrollTo("#header", {duration: 800}); return false; });
$("#nav-about, #direction-about").click(function() { $.scrollTo("#about", {duration: 800}); return false; });
$("#nav-web, #sub-nav-web, #nav-illu, #sub-nav-illu, #nav-print, #sub-nav-print, #nav-other, #sub-nav-other").click(function() { $.scrollTo("#work", {duration: 800}); return false; });
$("#nav-contact, #direction-contact").click(function() { $.scrollTo("#contact", {duration: 800}); return false; });
$('#nav-web').click(function(){$('#sub-nav li:eq(0) a').trigger('click');}); 
$('#nav-illu').click(function(){$('#sub-nav li:eq(1) a').trigger('click');}); 
$('#nav-print').click(function(){$('#sub-nav li:eq(2) a').trigger('click');});
$('#nav-other').click(function(){$('#sub-nav li:eq(3) a').trigger('click');}); 

//Sub-Nav Active
$("#sub-nav-web").click(function() {
$('#sub-nav-web').addClass('active');
$('#sub-nav-illu, #sub-nav-print, #sub-nav-other').removeClass('active');
});

$("#sub-nav-illu").click(function() {
$('#sub-nav-illu').addClass('active');
$('#sub-nav-web, #sub-nav-print, #sub-nav-other').removeClass('active');
});

$("#sub-nav-print").click(function() {
$('#sub-nav-print').addClass('active');
$('#sub-nav-web, #sub-nav-illu, #sub-nav-other').removeClass('active');
});

$("#sub-nav-other").click(function() {
$('#sub-nav-other').addClass('active');
$('#sub-nav-web, #sub-nav-print, #sub-nav-illu').removeClass('active');
});

//Work Rotation
$('#work-container').cycle({
fx:     'fade',
speed:  'default',
timeout: 0,
easing: 'easeInOutCubic',
pager:  '#sub-nav',
pagerAnchorBuilder: function(idx, slide) {return '#sub-nav li:eq(' + (idx) + ') a';}
});

$('#content-web').cycle({
fx:     'scrollUp',
speed:  'default',
timeout: 0,
easing: 'easeInOutCubic',
pager:  '#work-nav-web',
pagerAnchorBuilder: function(idx, slide) {return '#work-nav-web li:eq(' + (idx) + ') a';}
});

$('#content-illustration').cycle({
fx:     'scrollUp',
speed:  'default',
timeout: 0,
easing: 'easeInOutCubic',
pager:  '#work-nav-illustration',
pagerAnchorBuilder: function(idx, slide) {return '#work-nav-illustration li:eq(' + (idx) + ') a';}
});

$('#content-print-id').cycle({
fx:     'scrollUp',
speed:  'default',
timeout: 0,
easing: 'easeInOutCubic',
pager:  '#work-nav-print-id',
pagerAnchorBuilder: function(idx, slide) {return '#work-nav-print-id li:eq(' + (idx) + ') a';}
});

$('#content-other').cycle({
fx:     'scrollUp',
speed:  'default',
timeout: 0,
easing: 'easeInOutCubic',
pager:  '#work-nav-other',
pagerAnchorBuilder: function(idx, slide) {return '#work-nav-other li:eq(' + (idx) + ') a';}
});
});

//Form Values
//$(document).ready(function(){
//$('#form-name').autofill({value: 'Mr. Magoo',defaultTextColor: '#999999',activeTextColor: '#222222'});
//$('#form-email').autofill({value: 'example@example.com',defaultTextColor: '#999999',activeTextColor: '#222222'});
//$('#form-time').autofill({value: '4 weeks',defaultTextColor: '#999999',activeTextColor: '#222222'});
//$('#form-budget').autofill({value: '$1,000,000',defaultTextColor: '#999999',activeTextColor: '#222222'});
//});
