$(document).ready(function() {

//*** Form Validation
$("#send-email").validate({
	messages: {
			name: "- Could you tell me your name, please?",
			email: {
                required: "- Need your email to get back to you : )",
                email: "Your email doesn't seem to be valid."
            },
			subject: "- Just saying \"Hi\" perhaps?",
			message: "- Would love to hear from you so please do leave me a message : )"
	}
});


//*** Accordion
$("#process").accordion({ header: "h5", icons: { 'header': 'accordion-plus', 'headerSelected': 'accordion-minus' }, autoHeight: false });

//*** Form Auto Resize
$('textarea#message').autoResize({
    // On resize:
    onResize : function() {
        $(this).css({opacity:0.8});
    },
    // After resize:
    animateCallback : function() {
        $(this).css({opacity:1});
    },
    // Quite slow animation:
    animateDuration : 300,
    // More extra space:
    extraSpace : 10
});

//*** Overlay
function animateOverlay(element, direction) {
    switch(direction)
    {
    case "up":
      topVal = "60px";
      break;
    case "down":
      topVal = "470px";
      break;
    }
  $(element).children('.details').animate({ top: topVal}, {queue:false, duration:150} );
}

$('.slides').hover( function() {
  	$(this).addClass('hover');
  	animateOverlay($(this), 'up');
},
  function () {
	$(this).removeClass("hover");
	animateOverlay($(this), 'down');
  }
);
  
//*** Fancybox
$("a.fancy").fancybox({
	'opacity'		: true,
	'titlePosition'	: 'inside',
	'transitionIn'	: 'elastic',
	'transitionOut'	: 'none',
	'overlayColor'	: '#000',
	'overlayOpacity': 0.8,
	'titleFromAlt'	: true 
});

$(".says-what").fancybox({
	'width'				: '75%',
	'height'			: '75%',
	'autoScale'			: false,
	'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'titleShow'			: false,
	'showNavArrows'		: false
});

$("a[rel=sbdk-stanley_black_and_decker-sea]").click(function() {
		$.fancybox([
		'../images/portfolio/website-sbdk-stanley_black_and_decker-sea-ss01.jpg',
		'../images/portfolio/website-sbdk-stanley_black_and_decker-sea-ss02.jpg',
		'../images/portfolio/website-sbdk-stanley_black_and_decker-sea-ss03.jpg',
		'../images/portfolio/website-sbdk-stanley_black_and_decker-sea-ss04.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'sbdk-stanley_black_and_decker-sea']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>Stanley Black &amp; Decker</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<br /><a href="http://sea.stanleyblackanddecker.com/">Visit Website</a></p>';
		  }
		});
});

$("a[rel=sbdk-black_and_decker-sea]").click(function() {
		$.fancybox([
		'../images/portfolio/website-sbdk-black_and_decker-sea-ss01.jpg',
		'../images/portfolio/website-sbdk-black_and_decker-sea-ss02.jpg',
		'../images/portfolio/website-sbdk-black_and_decker-sea-ss03.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'sbdk-black_and_decker-sea']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>Black &amp; Decker</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<br /><a href="http://sea.stanleyblackanddecker.com/blackanddecker/">Visit Website</a></p>';
		  }
		});
});

$("a[rel=nie-iot]").click(function() {
		$.fancybox([
		'../images/portfolio/website-nie-images_of_teaching-ss01.jpg',
		'../images/portfolio/website-nie-images_of_teaching-ss02.jpg',
		'../images/portfolio/website-nie-images_of_teaching-ss03.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'nie-iot']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>NIE - Images of Teaching</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<br /><a href="http://imagesofteaching.nie.edu.sg/">Visit Website</a></p>';
		  }
		});
});

$("a[rel=nie-muse]").click(function() {
		$.fancybox([
		'../images/portfolio/website-nie-muse-ss01.jpg',
		'../images/portfolio/website-nie-muse-ss02.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'nie-muse']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>NIE - MUSE</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<br /><a href="http://muse.nie.edu.sg/">Visit Website</a></p>';
		  }
		});
});

$("a[rel=cosmoprof]").click(function() {
		$.fancybox([
		'../images/portfolio/website-cosmoprof-ss01.jpg',
		'../images/portfolio/website-cosmoprof-ss02.jpg',
		'../images/portfolio/website-cosmoprof-ss03.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'cosmoprof']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>Cosmoprof</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<br /><a href="http://www.cosmoprof.com.sg/">Visit Website</a></p>';
		  }
		});
});

$("a[rel=frieslandcampina-friso]").click(function() {
		$.fancybox([
		'../images/portfolio/website-frieslandcampina-friso-ss01.jpg',
		'../images/portfolio/website-frieslandcampina-friso-ss02.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'frieslandcampina-friso']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>FrieslandCampina - Friso</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '<br /><a href="http://www.friso.com.sg/">Visit Website</a></p>';
		  }
		});
});

$("a[rel=edm-kotex-wow]").click(function() {
		$.fancybox([
		'../images/portfolio/edm-kotex-wow-member-ss01.jpg',
		'../images/portfolio/edm-kotex-wow-friend-ss01.jpg',
		'../images/portfolio/edm-kotex-wow-announcement-ss01.jpg'
		], {
		  'onComplete':function(){_gaq.push(['_trackEvent','folio-lightbox','view-slide', 'edm-kotex-wow']);},
		  'type' 				: 'image', 
		  'transitionIn'		: 'elastic',
		  'transitionOut'		: 'none',
		  'titlePosition' 		: 'inside',
		  'titleFormat'			: function(title, currentArray, currentIndex, currentOpts) {
			  return '<h5>Kotex - WOW</h5> <p>slide ' + (currentIndex + 1) + ' out of ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</p>';
		  }
		});
});



//*** Change email addresses
var myName = "merry";
$('#email-me').html( myName + ' at shodaburp');
$('#email-me').hover(function(){
        var sendGo = "mailto:";
        var myName = "merry";
        var atSymbol = '&#64;';
        var myDomain = "shodaburp";
        var domainExt = ".com";
    	$(this).html('<a href="'+ sendGo + myName + atSymbol + myDomain + domainExt + '">' + myName + atSymbol + myDomain + domainExt + '</a>'); },
      function(){
		var myName = "merry";
        $(this).html( myName + ' at shodaburp'); }
);

$('#msn-me').hover(
  function(){ $(this).html('shodaburp@hotmail.com'); },
  function(){ $(this).html('shodaburp at hotmail'); }
);

//*** Nivo Slider
$('#mini-slide').nivoSlider({
	'effect' 		: 'fade',
	'pauseTime'		: 5000,
	'controlNav' 	: false,
	'captionOpacity': 0
});

});


