/*
	Main JS
	========================================
	Version:	0.1
	Date:		19/08/09
	Website:	http://wwww.anchor.co.nz
	Author:		Aim Proximity
*/

var jsAim 	= window.jsAim || {};

/*	Makes the init run at page load
============================================*/
$(window).load(function() {
	jsAim.initialize();
});

jsAim.initialize = function() {
	// Below rips out all the PNG images in IE6, and uses the filter in an IE6 only stylesheet
	
	// add the campaign lightboxes
    if ($('#b_Campaign')) {
        $('.videos a').click(function() {
            $.fancybox({
                'padding'		: 10,
                'autoScale'		: false,
                'transitionIn'	: 'fast',
                'transitionOut'	: 'fast',
                'width'         : 721,
                'height'		: 443,
                'type'			: 'iframe',
                'href'			: this.href.replace(new RegExp("player\\?v=", "i"), 'v/')
            });

            return false;
        });

        $('#onlineadslider a').click(function() {
            $.fancybox({
                'padding'		: 10,
                'autoScale'		: false,
                'transitionIn'	: 'fast',
                'transitionOut'	: 'fast',
                'width'         : 300,
                'height'		: 253,
                'type'			: 'iframe',
                'href'			: this.href.replace(new RegExp("swfplayer\\?v=", "i"), 'v/')
            });

            return false;
        });

//        $('#adslider a').fancybox({
//            'titleShow':false,
//            'autoScale':false
//        });

//        $('#billboardslider a').fancybox({
//            'titleShow':false
//        });
    }
    
    if ($('#b_Products')) {
        $('#makemilk').click(function() {
            $.fancybox({
                'padding'		: 10,
                'autoScale'		: false,
                'transitionIn'	: 'fast',
                'transitionOut'	: 'fast',
                'width'			: 551,
                'height'		: 521,
                'type'			: 'swf',
                'href'			: this.href,
                'swf'			: {
                    'wmode'		: 'transparent'
                }
            });

            return false;
        });
    }


	/* community lightboxes
    if ($('#b_Community')) {
        $('#slideshow ul li a').fancybox({
            'titleShow':false
        });
    }
    */
   
    // homepage bottle click
    if ($('#b_Home')) {
        $('#b_Home .col_1').click(function() {
            window.location.href = '/products/';
        });
    }
}


jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};


function onBeforeArrows(pnIndex, psElement) {
    if (pnIndex > 0) {
        $('#w_' + psElement + ' a.scr_arrow_left').css({'opacity':'0','cursor':'default'});
        $('#w_' + psElement + ' a.scr_arrow_right').css({'opacity':'0','cursor':'default'});
    }	
}
function onAfterArrows(pnIndex, psElement, pnLength) {
    pnLength = (!pnLength)? 1 : pnLength;
    if (pnIndex == 0) {
        $('#w_' + psElement + ' a.scr_arrow_left').css({'opacity':'0','cursor':'default'});
    } else {
        $('#w_' + psElement + ' a.scr_arrow_left').css({'opacity':'1','cursor':'pointer'});
    }
    if (pnIndex == ($('#' + psElement + '  ul li').length - pnLength)) {
        $('#w_' + psElement + ' a.scr_arrow_right').css({'opacity':'0','cursor':'default'});
    } else {
        $('#w_' + psElement + ' a.scr_arrow_right').css({'opacity':'1','cursor':'pointer'});
    }
}

