﻿jQuery.noConflict();

/* */
(function ($) {
    /* anything slider */
    $.anythingSlider = function (el, options) {
        var base = this; base.$el = $(el); base.el = el; base.currentPage = 1; base.timer = null; base.playing = false; base.$el.data("AnythingSlider", base); base.init = function () {
            base.options = $.extend({}, $.anythingSlider.defaults, options); base.$wrapper = base.$el.find('> div:first').css('overflow', 'hidden'); base.$slider = base.$wrapper.find('> ul'); base.$items = base.$slider.find('> li'); base.$single = base.$items.filter(':first'); base.$sliderNav = base.$el.find('div.sliderNav'); base.singleWidth = base.$single.outerWidth(); base.pages = base.$items.length; if (base.pages === 1) { base.options.autoPlay = false; }
            base.buildNavigation(); var $itemClone = base.$items.filter(':last').clone().addClass('cloned'); if ($itemClone.attr("id") != "") { base.$items.filter(':first').before($itemClone.attr('id', ($itemClone.attr('id') + "-cloned"))); } else { base.$items.filter(':first').before($itemClone); }
            $itemClone = base.$items.filter(':first').clone().addClass('cloned'); if ($itemClone.attr("id") != '') { base.$items.filter(':last').after($itemClone.attr('id', ($itemClone.attr('id') + "-cloned"))); } else { base.$items.filter(':last').after($itemClone); }
            base.$items = base.$slider.find('> li'); if (base.pages > 1) { base.buildNextBackButtons(); }
            if (base.options.autoPlay) { base.playing = !base.options.startStopped; base.buildAutoPlay(); }; if (base.options.pauseOnHover) { base.$el.hover(function () { base.clearTimer(); }, function () { base.startStop(base.playing); }); }
            if ((base.options.hashTags == true && !base.gotoHash()) || base.options.hashTags == false) { base.setCurrentPage(1); };
        }; base.gotoPage = function (page, autoplay) { if (autoplay !== true) autoplay = false; if (!autoplay) base.startStop(false); if (typeof (page) == "undefined" || page == null) { page = 1; base.setCurrentPage(1); }; if (page > base.pages + 1) page = base.pages; if (page < 0) page = 1; var dir = page < base.currentPage ? -1 : 1, n = Math.abs(base.currentPage - page), left = base.singleWidth * dir * n; base.$wrapper.filter(':not(:animated)').animate({ scrollLeft: '+=' + left }, base.options.animationTime, base.options.easing, function () { if (page == 0) { base.$wrapper.scrollLeft(base.singleWidth * base.pages); page = base.pages; } else if (page > base.pages) { base.$wrapper.scrollLeft(base.singleWidth); page = 1; }; base.setCurrentPage(page); }); }; base.setCurrentPage = function (page, move) { if (base.options.buildNavigation) { base.$nav.find('.cur').removeClass('cur'); $(base.$navLinks[page - 1]).addClass('cur'); }; if (move !== false) base.$wrapper.scrollLeft(base.singleWidth * page); base.currentPage = page; }; base.goForward = function (autoplay) { if (autoplay !== true) autoplay = false; base.gotoPage(base.currentPage + 1, autoplay); }; base.goBack = function () { base.gotoPage(base.currentPage - 1); }; base.gotoHash = function () { if (/^#?panel-\d+$/.test(window.location.hash)) { var index = parseInt(window.location.hash.substr(7)); var $item = base.$items.filter(':eq(' + index + ')'); if ($item.length != 0) { base.setCurrentPage(index); return true; }; }; return false; }; base.buildNavigation = function () {
            base.$nav = $("<div class='thumbNav'><ul/></div>").prependTo(base.$sliderNav); if (base.options.buildNavigation && (base.pages > 1)) {
                base.$items.each(function (i, el) {
                    var index = i + 1; var $a = $("<a href='#'></a>"); if (typeof (base.options.navigationFormatter) == "function") { $a.html(base.options.navigationFormatter(index, $(this))); } else { $a.text(index); }
                    $a.click(function (e) { base.gotoPage(index); if (base.options.hashTags) base.setHash('panel-' + index); e.preventDefault(); }); $("ul", base.$nav).append($a); $a.wrap("<li />");
                }); base.$navLinks = base.$nav.find('li > a');
            } 
        }; base.buildNextBackButtons = function () { var $forward = $(''), $back = $(''); $back.click(function (e) { base.goBack(); e.preventDefault(); }); $forward.click(function (e) { base.goForward(); e.preventDefault(); }); $("ul", base.$nav).prepend($back).append($forward); }; base.buildAutoPlay = function () { base.$startStop = $(); base.$el.prepend(base.$startStop); base.$startStop.click(function (e) { base.startStop(!base.playing); e.preventDefault(); }); base.startStop(base.playing); }; base.startStop = function (playing) { if (playing !== true) playing = false; base.playing = playing; if (base.options.autoPlay) base.$startStop.toggleClass("playing", playing).html(playing ? base.options.stopText : base.options.startText); if (playing) { base.clearTimer(); base.timer = window.setInterval(function () { base.goForward(true); }, base.options.delay); } else { base.clearTimer(); }; }; base.clearTimer = function () { if (base.timer) window.clearInterval(base.timer); }; base.setHash = function (hash) { if (typeof window.location.hash !== 'undefined') { if (window.location.hash !== hash) { window.location.hash = hash; }; } else if (location.hash !== hash) { location.hash = hash; }; return hash; }; base.init();
    }; $.anythingSlider.defaults = { easing: "swing", autoPlay: true, startStopped: false, delay: 3000, animationTime: 600, hashTags: true, buildNavigation: true, pauseOnHover: true, startText: "Start", stopText: "Stop", navigationFormatter: null, forwardText: ">", backText: "<" }; $.fn.anythingSlider = function (options) { if (typeof (options) == "object") { return this.each(function (i) { (new $.anythingSlider(this, options)); options.hashTags = false; }); } else if (typeof (options) == "number") { return this.each(function (i) { var anySlide = $(this).data('AnythingSlider'); if (anySlide) { anySlide.gotoPage(options); } }); } };

    /* belated png*/
    if($.browser.msie && $.browser.version=="6.0") {
        var DD_belatedPNG={ns:'DD_belatedPNG',imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,'urn:schemas-microsoft-com:vml');}},createVmlStyleSheet:function(){var screenStyleSheet,printStyleSheet;screenStyleSheet=document.createElement('style');screenStyleSheet.setAttribute('media','screen');document.documentElement.firstChild.insertBefore(screenStyleSheet,document.documentElement.firstChild.firstChild);if(screenStyleSheet.styleSheet){screenStyleSheet=screenStyleSheet.styleSheet;screenStyleSheet.addRule(this.ns+'\\:*','{behavior:url(#default#VML)}');screenStyleSheet.addRule(this.ns+'\\:shape','position:absolute;');screenStyleSheet.addRule('img.'+this.ns+'_sizeFinder','behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;');this.screenStyleSheet=screenStyleSheet;printStyleSheet=document.createElement('style');printStyleSheet.setAttribute('media','print');document.documentElement.firstChild.insertBefore(printStyleSheet,document.documentElement.firstChild.firstChild);printStyleSheet=printStyleSheet.styleSheet;printStyleSheet.addRule(this.ns+'\\:*','{display: none !important;}');printStyleSheet.addRule('img.'+this.ns+'_sizeFinder','{display: none !important;}');}},readPropertyChange:function(){var el,display,v;el=event.srcElement;if(!el.vmlInitiated){return;}
        if(event.propertyName.search('background')!=-1||event.propertyName.search('border')!=-1){DD_belatedPNG.applyVML(el);}
        if(event.propertyName=='style.display'){display=(el.currentStyle.display=='none')?'none':'block';for(v in el.vml){if(el.vml.hasOwnProperty(v)){el.vml[v].shape.style.display=display;}}}
        if(event.propertyName.search('filter')!=-1){DD_belatedPNG.vmlOpacity(el);}},vmlOpacity:function(el){if(el.currentStyle.filter.search('lpha')!=-1){var trans=el.currentStyle.filter;trans=parseInt(trans.substring(trans.lastIndexOf('=')+1,trans.lastIndexOf(')')),10)/100;el.vml.color.shape.style.filter=el.currentStyle.filter;el.vml.image.fill.opacity=trans;}},handlePseudoHover:function(el){setTimeout(function(){DD_belatedPNG.applyVML(el);},1);},fix:function(selector){if(this.screenStyleSheet){var selectors,i;selectors=selector.split(',');for(i=0;i<selectors.length;i++){this.screenStyleSheet.addRule(selectors[i],'behavior:expression(DD_belatedPNG.fixPng(this))');}}},applyVML:function(el){el.runtimeStyle.cssText='';this.vmlFill(el);this.vmlOffsets(el);this.vmlOpacity(el);if(el.isImg){this.copyImageBorders(el);}},attachHandlers:function(el){var self,handlers,handler,moreForAs,a,h;self=this;handlers={resize:'vmlOffsets',move:'vmlOffsets'};if(el.nodeName=='A'){moreForAs={mouseleave:'handlePseudoHover',mouseenter:'handlePseudoHover',focus:'handlePseudoHover',blur:'handlePseudoHover'};for(a in moreForAs){if(moreForAs.hasOwnProperty(a)){handlers[a]=moreForAs[a];}}}
        for(h in handlers){if(handlers.hasOwnProperty(h)){handler=function(){self[handlers[h]](el);};el.attachEvent('on'+h,handler);}}
        el.attachEvent('onpropertychange',this.readPropertyChange);},giveLayout:function(el){el.style.zoom=1;if(el.currentStyle.position=='static'){el.style.position='relative';}},copyImageBorders:function(el){var styles,s;styles={'borderStyle':true,'borderWidth':true,'borderColor':true};for(s in styles){if(styles.hasOwnProperty(s)){el.vml.color.shape.style[s]=el.currentStyle[s];}}},vmlFill:function(el){if(!el.currentStyle){return;}else{var elStyle,noImg,lib,v,img,imgLoaded;elStyle=el.currentStyle;}
        for(v in el.vml){if(el.vml.hasOwnProperty(v)){el.vml[v].shape.style.zIndex=elStyle.zIndex;}}
        el.runtimeStyle.backgroundColor='';el.runtimeStyle.backgroundImage='';noImg=true;if(elStyle.backgroundImage!='none'||el.isImg){if(!el.isImg){el.vmlBg=elStyle.backgroundImage;el.vmlBg=el.vmlBg.substr(5,el.vmlBg.lastIndexOf('")')-5);}
        else{el.vmlBg=el.src;}
        lib=this;if(!lib.imgSize[el.vmlBg]){img=document.createElement('img');lib.imgSize[el.vmlBg]=img;img.className=lib.ns+'_sizeFinder';img.runtimeStyle.cssText='behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;';imgLoaded=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;lib.vmlOffsets(el);};img.attachEvent('onload',imgLoaded);img.src=el.vmlBg;img.removeAttribute('width');img.removeAttribute('height');document.body.insertBefore(img,document.body.firstChild);}
        el.vml.image.fill.src=el.vmlBg;noImg=false;}
        el.vml.image.fill.on=!noImg;el.vml.image.fill.color='none';el.vml.color.shape.style.backgroundColor=elStyle.backgroundColor;el.runtimeStyle.backgroundImage='none';el.runtimeStyle.backgroundColor='transparent';},vmlOffsets:function(el){var thisStyle,size,fudge,makeVisible,bg,bgR,dC,altC,b,c,v;thisStyle=el.currentStyle;size={'W':el.clientWidth+1,'H':el.clientHeight+1,'w':this.imgSize[el.vmlBg].width,'h':this.imgSize[el.vmlBg].height,'L':el.offsetLeft,'T':el.offsetTop,'bLW':el.clientLeft,'bTW':el.clientTop};fudge=(size.L+size.bLW==1)?1:0;makeVisible=function(vml,l,t,w,h,o){vml.coordsize=w+','+h;vml.coordorigin=o+','+o;vml.path='m0,0l'+w+',0l'+w+','+h+'l0,'+h+' xe';vml.style.width=w+'px';vml.style.height=h+'px';vml.style.left=l+'px';vml.style.top=t+'px';};makeVisible(el.vml.color.shape,(size.L+(el.isImg?0:size.bLW)),(size.T+(el.isImg?0:size.bTW)),(size.W-1),(size.H-1),0);makeVisible(el.vml.image.shape,(size.L+size.bLW),(size.T+size.bTW),(size.W),(size.H),1);bg={'X':0,'Y':0};if(el.isImg){bg.X=parseInt(thisStyle.paddingLeft,10)+1;bg.Y=parseInt(thisStyle.paddingTop,10)+1;}
        else{for(b in bg){if(bg.hasOwnProperty(b)){this.figurePercentage(bg,size,b,thisStyle['backgroundPosition'+b]);}}}
        el.vml.image.fill.position=(bg.X/size.W)+','+(bg.Y/size.H);bgR=thisStyle.backgroundRepeat;dC={'T':1,'R':size.W+fudge,'B':size.H,'L':1+fudge};altC={'X':{'b1':'L','b2':'R','d':'W'},'Y':{'b1':'T','b2':'B','d':'H'}};if(bgR!='repeat'||el.isImg){c={'T':(bg.Y),'R':(bg.X+size.w),'B':(bg.Y+size.h),'L':(bg.X)};if(bgR.search('repeat-')!=-1){v=bgR.split('repeat-')[1].toUpperCase();c[altC[v].b1]=1;c[altC[v].b2]=size[altC[v].d];}
        if(c.B>size.H){c.B=size.H;}
        el.vml.image.shape.style.clip='rect('+c.T+'px '+(c.R+fudge)+'px '+c.B+'px '+(c.L+fudge)+'px)';}
        else{el.vml.image.shape.style.clip='rect('+dC.T+'px '+dC.R+'px '+dC.B+'px '+dC.L+'px)';}},figurePercentage:function(bg,size,axis,position){var horizontal,fraction;fraction=true;horizontal=(axis=='X');switch(position){case'left':case'top':bg[axis]=0;break;case'center':bg[axis]=0.5;break;case'right':case'bottom':bg[axis]=1;break;default:if(position.search('%')!=-1){bg[axis]=parseInt(position,10)/100;}
        else{fraction=false;}}
        bg[axis]=Math.ceil(fraction?((size[horizontal?'W':'H']*bg[axis])-(size[horizontal?'w':'h']*bg[axis])):parseInt(position,10));if(bg[axis]%2===0){bg[axis]++;}
        return bg[axis];},fixPng:function(el){el.style.behavior='none';var lib,els,nodeStr,v,e;if(el.nodeName=='BODY'||el.nodeName=='TD'||el.nodeName=='TR'){return;}
        el.isImg=false;if(el.nodeName=='IMG'){if(el.src.toLowerCase().search(/\.png$/)!=-1){el.isImg=true;el.style.visibility='hidden';}
        else{return;}}
        else if(el.currentStyle.backgroundImage.toLowerCase().search('.png')==-1){return;}
        lib=DD_belatedPNG;el.vml={color:{},image:{}};els={shape:{},fill:{}};for(v in el.vml){if(el.vml.hasOwnProperty(v)){for(e in els){if(els.hasOwnProperty(e)){nodeStr=lib.ns+':'+e;el.vml[v][e]=document.createElement(nodeStr);}}
        el.vml[v].shape.stroked=false;el.vml[v].shape.appendChild(el.vml[v].fill);el.parentNode.insertBefore(el.vml[v].shape,el);}}
        el.vml.image.shape.fillcolor='none';el.vml.image.fill.type='tile';el.vml.color.fill.on=false;lib.attachHandlers(el);lib.giveLayout(el);lib.giveLayout(el.offsetParent);el.vmlInitiated=true;lib.applyVML(el);}};try{document.execCommand("BackgroundImageCache",false,true);}catch(r){}
        DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet();
    }

$(document).ready(function() {
	$('.promotion li:last').addClass('last-child');
	$('.polaroid a').hover(
		function() {
			$(this).siblings('div').show();
			$(this).siblings('span').show();
			var parentSib = $(this).parent().siblings();
			parentSib.children('div').hide();
			parentSib.children('span').hide();
		}
	);
	// IE6 png fix
	if($.browser.msie && $.browser.version=="6.0") {
			DD_belatedPNG.fix('.slider li div, .promotion span');
			$('.sliderNav li:first').addClass('last-child');
			$('.polaroid li:first').addClass('first-child');
		};
});

$(function() {
    $('.slider').anythingSlider({
        easing: "linear",        // Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,          // This turns off the entire FUNCTIONALY, not just if it starts running or not.
        delay: 5000,                    // How long between slide transitions in AutoPlay mode
        startStopped: false,            // If autoPlay is on, this can force it to start stopped
        animationTime: 600,             // How long the slide transition takes
        hashTags: false,                 // Should links change the hashtag in the URL?
        buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        stopAtEnd: true,                // If true & the slideshow is active, the slideshow will stop on the first page after one loop
        startText: "Go",                // Start text
        stopText: "Stop",               // Stop text
        navigationFormatter: function(index, panel) {            
            return "<span></span>" + $(panel).find("h3").text();
        } // Details at the top of the file on this use (advanced use)
    });
});

})(jQuery);

