/*

Title:		Moda 360
Author: 	Darian Rawson, darianr@eview360.com
Copyright:	(c) 2011 Eview 360, Moda 360

*/

$(document).ready(function() {

	// navigation scrolling and highlighting
	$('#nav').onePageNav({
		currentClass: 'current',
		changeHash: false,
		scrollSpeed: 750
	});	
    
    // Turn vertial mouse wheel scrolling into horizontal scrolling
	$(function() {
        $("html, body").mousewheel(function(event, delta) {
            this.scrollLeft -= (delta * 30);
            event.preventDefault();
        });
    });
    
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'featured') {
			$('ul#fancyGallery li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			
			$('ul#fancyGallery li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}
		
		return false;
	});
	
	$("a#buyNow").fancybox({
	'autoDimensions'	: false,
	'width'				: 720,
	'height'			: 460,
	'overlayColor'		: '#000',
	'overlayOpacity'	: .85,
	'padding'			: 0,
	'margin'			: 0		
	});
	
	$("a.fancyGallery").fancybox({
		'titlePosition'		: 'outside',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.9
	});
	
    $('a.ourprocess').click(function(){
        $.scrollTo( {top:'0px',left:'3500px'}, 800 );
        return false;
    });
	
    $('a.scoreboard').click(function(){
        $.scrollTo( {top:'0px',left:'6300px'}, 800 );
        return false;
    });
    
    $('#findOurMoreLinkClick').click(function(){
        $.scrollTo( {top:'0px',left:'10740px'}, 800 );
        return false;
    });
    
    $('#scrollMore1').click(function(){
        $.scrollTo( {top:'0px',left:'+=1050px'}, 800 );
        return false;
    });
    $('#scrollMore2').click(function(){
        $.scrollTo( {top:'0px',left:'+=500px'}, 800 );
        return false;
    });
    $('#scrollMore3').click(function(){
        $.scrollTo( {top:'0px',left:'+=1000px'}, 800 );
        return false;
    });
    $('#scrollMore4').click(function(){
        $.scrollTo( '#gallery', 800 );
        return false;
    });
    $('#scrollMore5').click(function(){
        $.scrollTo( {top:'0px',left:'+=900px'}, 800 );
        return false;
    });
});

/* modernizr-test.js
 * Daniel Ott
 * 3 March 2011
 * Custom Tests using Modernizr's addTest API
 */

/* iOS
 * There may be times when we need a quick way to reference whether iOS is in play or not.
 * While a primative means, will be helpful for that.
 */
Modernizr.addTest('ipad', function () {
  return !!navigator.userAgent.match(/iPad/i);
});

Modernizr.addTest('iphone', function () {
  return !!navigator.userAgent.match(/iPhone/i);
});

Modernizr.addTest('ipod', function () {
  return !!navigator.userAgent.match(/iPod/i);
});

Modernizr.addTest('appleios', function () {
  return (Modernizr.ipad || Modernizr.ipod || Modernizr.iphone);
});

/* CSS position:fixed
 * Not supported in older IE browsers, nor on Apple's iOS devices.
 * Actually the token example on the Modernizr docs. http://www.modernizr.com/docs/
 */
Modernizr.addTest('positionfixed', function () {
    var test    = document.createElement('div'),
        control = test.cloneNode(false),
        fake = false,
        root = document.body || (function () {
            fake = true;
            return document.documentElement.appendChild(document.createElement('body'));
        }());

    var oldCssText = root.style.cssText;
    root.style.cssText = 'padding:0;margin:0';
    test.style.cssText = 'position:fixed;top:42px'; 
    root.appendChild(test);
    root.appendChild(control);
    
    var ret = test.offsetTop !== control.offsetTop;

    root.removeChild(test);
    root.removeChild(control);
    root.style.cssText = oldCssText;
    
    if (fake) {
        document.documentElement.removeChild(root);
    }
    
    /* Uh-oh. iOS would return a false positive here.
     * If it's about to return true, we'll explicitly test for known iOS User Agent strings.
     * "UA Sniffing is bad practice" you say. Agreeable, but sadly this feature has made it to
     * Modernizr's list of undectables, so we're reduced to having to use this. */
    return ret && !Modernizr.appleios;
});
