/*
Stylish Select 0.3 - $ plugin to replace a select drop down box with a stylable unordered list
http://scottdarby.com/

Copyright (c) 2009 Scott Darby

Requires: $ 1.3

Licensed under the GPL license:
http://www.gnu.org/licenses/gpl.html
*/
(function($)
{
    $('html').addClass('js');
    Array.prototype.indexOf = function(obj, start)
    {
        for (var i = (start || 0); i < this.length; i++)
        {
            if (this[i] == obj)
            {
                return i;
            }
        }
    }
    $.fn.extend({
        getSetSSValue: function(v)
        {
            var el = this[0];
            if (v)
            {
                return this.each(function(idx)
                {
                    var i = 0;
                    $('option', this).each(function(idx) { if (this.value == v) { i = idx } });
                    this.selectedIndex = i;
                    $(this).change();
                })

            } else
            {
                return el.options[el.selectedIndex].value;
            }
        },
        resetSS: function()
        {
            $this = $(this);
            $this.next().remove();
            $this.unbind().sSelect();
        }
    });

    $.fn.sSelect = function(options)
    {
        return this.each(function()
        {
            var defaults = {
                defaultText: 'Please select',
                animationSpeed: 0,
                ddMaxHeight: ''
            };
            var $input = $(this);
            var opts = $.extend(defaults, options),
				$containerDivText = $('<div class="selectedTxt"></div>'),
				$containerDiv = $('<div class="newListSelected" tabindex="0"></div>'),
				$newUl = $('<ul class="newList"></ul>'),
				itemIndex = -1,
				currentIndex = -1,
				keys = [],
				prevKey = false,
				newListItems = '',
				prevented = false;
            $containerDiv.insertAfter($input);
            $containerDivText.prependTo($containerDiv);
            $newUl.appendTo($containerDiv);
            $input.hide();
            $input.addClass('styled');
            if ($input.attr('id')) { $containerDiv.addClass($input.attr('id')); }
            if ($input.children('optgroup').length == 0)
            {
                $input.children().each(function(i)
                {
                    var option = $(this).text();
                    keys.push(option.charAt(0).toLowerCase());
                    if ($(this).attr('selected') == true)
                    {
                        opts.defaultText = option;
                        currentIndex = i;
                    }
                    newListItems += '<li>' + option + '</li>';
                });
                $newUl.html(newListItems);
                newListItems = '';
                var $newLi = $newUl.children();

            } else
            {
                $input.children('optgroup').each(function(i)
                {
                    var optionTitle = $(this).attr('label'),
					$optGroup = $('<li class="newListOptionTitle">' + optionTitle + '</li>');
                    $optGroup.appendTo($newUl);
                    var $optGroupList = $('<ul></ul>');
                    $optGroupList.appendTo($optGroup);
                    $(this).children().each(function()
                    {
                        ++itemIndex;
                        var option = $(this).text();
                        //add first letter of each word to array
                        keys.push(option.charAt(0).toLowerCase());
                        if ($(this).attr('selected') == true)
                        {
                            opts.defaultText = option;
                            currentIndex = itemIndex;
                        }
                        newListItems += '<li>' + option + '</li>';
                    })
                    $optGroupList.html(newListItems);
                    newListItems = '';
                });
                var $newLi = $newUl.find('ul li');
            }
            var newUlHeight = $newUl.height() + 3,
				containerHeight = $containerDiv.height() + 3,
				newLiLength = $newLi.length;
            if (currentIndex != -1)
            {
                navigateList(currentIndex, true);
            } else
            {
                $containerDivText.text(opts.defaultText);
            }
            function newUlPos()
            {
                var containerPosY = $containerDiv.offset().top,
				docHeight = jQuery(window).height(),
				scrollTop = jQuery(window).scrollTop();
                if (newUlHeight > parseInt(opts.ddMaxHeight))
                {
                    newUlHeight = parseInt(opts.ddMaxHeight);
                    $newUl.addClass('tooHigh')
                }
                containerPosY = containerPosY - scrollTop;
                if (containerPosY + newUlHeight >= docHeight)
                {
                    $newUl.css({ top: '-' + newUlHeight + 'px', height: newUlHeight });
                    $input.onTop = true;
                } else
                {
                    $newUl.css({ top: containerHeight + 'px', height: newUlHeight });
                    $input.onTop = false;
                }
            }
            newUlPos();
            $(window).resize(function()
            {
                newUlPos();
            });
            $(window).scroll(function()
            {
                newUlPos();
            });
            function positionFix()
            {
                $containerDiv.css('position', 'relative');
            }
            function positionHideFix()
            {
                $containerDiv.css('position', 'static');
            }
            $containerDivText.click(function()
            {
                if ($newUl.is(':visible'))
                {
                    $newUl.hide();
                    positionHideFix()
                    return false;
                }
                $containerDiv.focus();
                $newUl.slideDown(opts.animationSpeed);
                positionFix();
                $newUl.scrollTop($input.liOffsetTop);
            });
            $newLi.hover(
			  function(e)
			  {
			      var $hoveredLi = $(e.target);
			      $hoveredLi.addClass('newListHover');
			  },
			  function(e)
			  {
			      var $hoveredLi = $(e.target);
			      $hoveredLi.removeClass('newListHover');
			  }
			);
            $newLi.click(function(e)
            {
                var $clickedLi = $(e.target);
                currentIndex = $newLi.index($clickedLi);
                prevented = true;
                navigateList(currentIndex);
                prevented = false;
                $newUl.hide();
                $containerDiv.css('position', 'static'); //ie
            });
            function navigateList(currentIndex, init)
            {
                var containerOffsetTop = $containerDiv.offset().top,
					liOffsetTop = $newLi.eq(currentIndex).offset().top,
					ulScrollTop = $newUl.scrollTop();
                if ($input.onTop == true)
                {
                    $input.liOffsetTop = (((liOffsetTop - containerOffsetTop) - containerHeight) + ulScrollTop) + parseInt(opts.ddMaxHeight);
                } else
                {
                    $input.liOffsetTop = ((liOffsetTop - containerOffsetTop) - containerHeight) + ulScrollTop;
                }
                $newUl.scrollTop($input.liOffsetTop);
                $newLi.removeClass('hiLite')
					.eq(currentIndex)
					.addClass('hiLite');
                var text = $newLi.eq(currentIndex).text();
                if (init == true)
                {
                    $containerDivText.text(text);
                    return false;
                }
                $input[0].selectedIndex = currentIndex;
                $input.change();
                if (opts.changeSiblings)
                {
                    $input.siblings('select').getSetSSValue($input.val());
                }
                $containerDivText.text(text);
            };

            $input.change(function(event)
            {
                $targetInput = $(event.target);
                if (prevented == true)
                {
                    prevented = false;
                    return false;
                }
                $currentOpt = $targetInput.find(':selected');
                currentIndex = $targetInput.find('option').index($currentOpt);
                navigateList(currentIndex, true);
            }
			);
            function keyPress(element)
            {
                element.onkeydown = function(e)
                {
                    if (e == null)
                    {
                        var keycode = event.keyCode;
                    } else
                    {
                        var keycode = e.which;
                    }
                    prevented = true;
                    switch (keycode)
                    {
                        case 40: //down
                        case 39: //right
                            incrementList();
                            prevented = false;
                            return false;
                            break;
                        case 38: //up
                        case 37: //left
                            decrementList();
                            prevented = false;
                            return false;
                            break;
                        case 33: //page up
                        case 36: //home
                            gotoFirst();
                            prevented = false;
                            return false;
                            break;
                        case 34: //page down
                        case 35: //end
                            gotoLast();
                            prevented = false;
                            return false;
                            break;
                        case 13:
                        case 27:
                            $newUl.hide();
                            positionHideFix();
                            prevented = false;
                            return false;
                            break;
                    }
                    keyPressed = String.fromCharCode(keycode).toLowerCase();
                    var currentKeyIndex = keys.indexOf(keyPressed);
                    if (typeof currentKeyIndex != 'undefined')
                    {
                        ++currentIndex;
                        currentIndex = keys.indexOf(keyPressed, currentIndex);
                        if (currentIndex == -1 || currentIndex == null || prevKey != keyPressed) currentIndex = keys.indexOf(keyPressed);
                        navigateList(currentIndex);
                        prevKey = keyPressed;
                        prevented = false;
                        return false;
                    }
                    prevented = false;
                }
            }
            function incrementList()
            {
                if (currentIndex < (newLiLength - 1))
                {
                    ++currentIndex;
                    navigateList(currentIndex);
                }
            }
            function decrementList()
            {
                if (currentIndex > 0)
                {
                    --currentIndex;
                    navigateList(currentIndex);
                }
            }
            function gotoFirst()
            {
                currentIndex = 0;
                navigateList(currentIndex);
            }
            function gotoLast()
            {
                currentIndex = newLiLength - 1;
                navigateList(currentIndex);
            }
            $containerDiv.click(function()
            {
                keyPress(this);
            });
            $containerDiv.focus(function()
            {
                $(this).addClass('newListSelFocus');
                keyPress(this);
            });
            $containerDiv.blur(function()
            {
                $(this).removeClass('newListSelFocus');
                $newUl.hide();
                positionHideFix();
            });
            $containerDivText.hover(function(e)
            {
                var $hoveredTxt = $(e.target);
                $hoveredTxt.parent().addClass('newListSelHover');
            },
			  function(e)
			  {
			      var $hoveredTxt = $(e.target);
			      $hoveredTxt.parent().removeClass('newListSelHover');
			  }
			);
            $newUl.css('left', '0').hide();
        });
    };
})(jQuery);
/* Copyright (c) 2006 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.js 19 2008-11-13 06:00:09Z kelvin.luck $
 */

(function(A){A.jScrollPane={active:[]};A.fn.jScrollPane=function(C){C=A.extend({},A.fn.jScrollPane.defaults,C);var B=function(){return false};return this.each(function(){var O=A(this);O.css("overflow","hidden");var X=this;if(A(this).parent().is(".jScrollPaneContainer")){var Ac=C.maintainPosition?O.position().top:0;var L=A(this).parent();var d=L.innerWidth();var Ad=L.outerHeight();var M=Ad;A(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown",L).remove();O.css({top:0})}else{var Ac=0;this.originalPadding=O.css("paddingTop")+" "+O.css("paddingRight")+" "+O.css("paddingBottom")+" "+O.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(O.css("paddingLeft"))||0)+(parseInt(O.css("paddingRight"))||0);var d=O.innerWidth();var Ad=O.innerHeight();var M=Ad;O.wrap(A("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:Ad+"px",width:d+"px"}));A(document).bind("emchange",function(Ae,Af,p){O.jScrollPane(C)})}if(C.reinitialiseOnImageLoad){var N=A.data(X,"jScrollPaneImagesToLoad")||A("img",O);var G=[];if(N.length){N.each(function(p,Ae){A(this).bind("load",function(){if(A.inArray(p,G)==-1){G.push(Ae);N=A.grep(N,function(Ag,Af){return Ag!=Ae});A.data(X,"jScrollPaneImagesToLoad",N);C.reinitialiseOnImageLoad=false;O.jScrollPane(C)}}).each(function(Af,Ag){if(this.complete||this.complete===undefined){this.src=this.src}})})}}var o=this.originalSidePaddingTotal;var l={height:"auto",width:d-C.scrollbarWidth-C.scrollbarMargin-o+"px"};if(C.scrollbarOnLeft){l.paddingLeft=C.scrollbarMargin+C.scrollbarWidth+"px"}else{l.paddingRight=C.scrollbarMargin+"px"}O.css(l);var m=O.outerHeight();var i=Ad/m;if(i<0.99){var H=O.parent();H.append(A("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:C.scrollbarWidth+"px"}).append(A("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:C.scrollbarWidth+"px"}),A("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:C.scrollbarWidth+"px"}))));var z=A(">.jScrollPaneTrack",H);var P=A(">.jScrollPaneTrack .jScrollPaneDrag",H);if(C.showArrows){var g;var Ab;var S;var r;var j=function(){if(r>4||r%4==0){y(u+Ab*b)}r++};var K=function(p){A("html").unbind("mouseup",K);g.removeClass("jScrollActiveArrowButton");clearInterval(S)};var Z=function(){A("html").bind("mouseup",K);g.addClass("jScrollActiveArrowButton");r=0;j();S=setInterval(j,100)};H.append(A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp"}).css({width:C.scrollbarWidth+"px"}).html("Scroll up").bind("mousedown",function(){g=A(this);Ab=-1;Z();this.blur();return false}).bind("click",B),A("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown"}).css({width:C.scrollbarWidth+"px"}).html("Scroll down").bind("mousedown",function(){g=A(this);Ab=1;Z();this.blur();return false}).bind("click",B));var Q=A(">.jScrollArrowUp",H);var J=A(">.jScrollArrowDown",H);if(C.arrowSize){M=Ad-C.arrowSize-C.arrowSize;z.css({height:M+"px",top:C.arrowSize+"px"})}else{var s=Q.height();C.arrowSize=s;M=Ad-s-J.height();z.css({height:M+"px",top:s+"px"})}}var w=A(this).css({position:"absolute",overflow:"visible"});var D;var Y;var b;var u=0;var V=i*Ad/2;var a=function(Ae,Ag){var Af=Ag=="X"?"Left":"Top";return Ae["page"+Ag]||(Ae["client"+Ag]+(document.documentElement["scroll"+Af]||document.body["scroll"+Af]))||0};var f=function(){return false};var v=function(){n();D=P.offset(false);D.top-=u;Y=M-P[0].offsetHeight;b=2*C.wheelSpeed*Y/m};var E=function(p){v();V=a(p,"Y")-u-D.top;A("html").bind("mouseup",T).bind("mousemove",h);if(A.browser.msie){A("html").bind("dragstart",f).bind("selectstart",f)}return false};var T=function(){A("html").unbind("mouseup",T).unbind("mousemove",h);V=i*Ad/2;if(A.browser.msie){A("html").unbind("dragstart",f).unbind("selectstart",f)}};var y=function(Ae){Ae=Ae<0?0:(Ae>Y?Y:Ae);u=Ae;P.css({top:Ae+"px"});var Af=Ae/Y;w.css({top:((Ad-m)*Af)+"px"});O.trigger("scroll");if(C.showArrows){Q[Ae==0?"addClass":"removeClass"]("disabled");J[Ae==Y?"addClass":"removeClass"]("disabled")}};var h=function(p){y(a(p,"Y")-D.top-V)};var q=Math.max(Math.min(i*(Ad-C.arrowSize*2),C.dragMaxHeight),C.dragMinHeight);P.css({height:q+"px"}).bind("mousedown",E);var k;var R;var I;var t=function(){if(R>8||R%4==0){y((u-((u-I)/2)))}R++};var Aa=function(){clearInterval(k);A("html").unbind("mouseup",Aa).unbind("mousemove",e)};var e=function(p){I=a(p,"Y")-D.top-V};var U=function(p){v();e(p);R=0;A("html").bind("mouseup",Aa).bind("mousemove",e);k=setInterval(t,100);t()};z.bind("mousedown",U);H.bind("mousewheel",function(Ae,Ag){v();n();var Af=u;y(u-Ag*b);var p=Af!=u;return !p});var F;var W;function c(){var p=(F-u)/C.animateStep;if(p>1||p<-1){y(u+p)}else{y(F);n()}}var n=function(){if(W){clearInterval(W);delete F}};var x=function(Af,p){if(typeof Af=="string"){$e=A(Af,O);if(!$e.length){return}Af=$e.offset().top-O.offset().top}H.scrollTop(0);n();var Ae=-Af/(Ad-m)*Y;if(p||!C.animateTo){y(Ae)}else{F=Ae;W=setInterval(c,C.animateInterval)}};O[0].scrollTo=x;O[0].scrollBy=function(Ae){var p=-parseInt(w.css("top"))||0;x(p+Ae)};v();x(-Ac,true);A("*",this).bind("focus",function(Ah){var Ag=A(this);var Aj=0;while(Ag[0]!=O[0]){Aj+=Ag.position().top;Ag=Ag.offsetParent()}var p=-parseInt(w.css("top"))||0;var Ai=p+Ad;var Af=Aj>p&&Aj<Ai;if(!Af){var Ae=Aj-C.scrollbarMargin;if(Aj>p){Ae+=A(this).height()+15+C.scrollbarMargin-Ad}x(Ae)}});if(location.hash){x(location.hash)}A(document).bind("click",function(Ae){$target=A(Ae.target);if($target.is("a")){var p=$target.attr("href");if(p.length>1 && p.substr(0,1)=="#"){x(p)}}});A.jScrollPane.active.push(O[0])}else{O.css({height:Ad+"px",width:d-this.originalSidePaddingTotal+"px",padding:this.originalPadding});O.parent().unbind("mousewheel")}})};A.fn.jScrollPane.defaults={scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:true,scrollbarOnLeft:false,reinitialiseOnImageLoad:false};A(window).bind("unload",function(){var C=A.jScrollPane.active;for(var B=0;B<C.length;B++){C[B].scrollTo=C[B].scrollBy=null}})})(jQuery);
//"	
/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.2
 * 
 * Requires: 1.2.2+
 */
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);


/*
 * jQuery ifixpng plugin
 * (previously known as pngfix)
 * Version 2.0  (04/11/2007)
 * @requires jQuery v1.1.3 or above
 *
 * Examples at: http://jquery.khurshid.com
 * Copyright (c) 2007 Kush M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
 
 /**
  *
  * @example
  *
  * optional if location of pixel.gif if different to default which is images/pixel.gif
  * $.ifixpng('media/pixel.gif');
  *
  * $('img[@src$=.png], #panel').ifixpng();
  *
  * @apply hack to all png images and #panel which icluded png img in its css
  *
  * @name ifixpng
  * @type jQuery
  * @cat Plugins/Image
  * @return jQuery
  * @author jQuery Community
  */
 
(function($) {

	/**
	 * helper variables and function
	 */
	$.ifixpng = function(customPixel) {
		$.ifixpng.pixel = customPixel;
	};
	
	$.ifixpng.getPixel = function() {
		return $.ifixpng.pixel || '/images/spacer.gif';
	};
	
	var hack = {
		ltie7  : $.browser.msie && $.browser.version < 7,
		filter : function(src) {
			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
		}
	};
	
	/**
	 * Applies ie png hack to selected dom elements
	 *
	 * $('img[@src$=.png]').ifixpng();
	 * @desc apply hack to all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').ifixpng();
	 * @desc apply hack to element #panel and all images with png extensions
	 *
	 * @name ifixpng
	 */
	 
	$.fn.ifixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var base = $('base').attr('href'); // need to use this in case you are using rewriting urls
			if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
				if ($$.attr('src')) {
					if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
						// use source tag value if set 
						var source = (base && $$.attr('src').substring(0,1)!='/') ? base + $$.attr('src') : $$.attr('src');
						// apply filter
						$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
						  .attr({src:$.ifixpng.getPixel()})
						  .positionFix();
					}
				}
			} else { // hack png css properties present inside css
				//var image = $$.css('backgroundImage');
				//if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
				//	image = RegExp.$1;
				//	$$.css({backgroundImage:'none', filter:hack.filter(image)})
				//	  .children().children().positionFix();
				//}
			}
		});
	} : function() { return this; };
	
	/**
	 * Removes any png hack that may have been applied previously
	 *
	 * $('img[@src$=.png]').iunfixpng();
	 * @desc revert hack on all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').iunfixpng();
	 * @desc revert hack on element #panel and all images with png extensions
	 *
	 * @name iunfixpng
	 */
	 
	$.fn.iunfixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var src = $$.css('filter');
			if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
				src = RegExp.$1;
				if ($$.is('img') || $$.is('input')) {
					$$.attr({src:src}).css({filter:''});
				} else {
					$$.css({filter:'', background:'url('+src+')'});
				}
			}
		});
	} : function() { return this; };
	
	/**
	 * positions selected item relatively
	 */
	 
	$.fn.positionFix = function() {
		return this.each(function() {
			var $$ = $(this);
			var position = $$.css('position');
			if (position != 'absolute' && position != 'relative') {
				$$.css({position:'relative'});
			}
		});
	};

})(jQuery);

(function($){   
 $.fn.pngFix = function(){
	 return this.each(function() {
		$('img[src$=.png], input[type="image"][src$=.png]',this).not('.flags img, .current_flag img, .product_image img').ifixpng();
	})
 }
})(jQuery);


(function($){   
 $.fn.make_tabs = function(opts) {  
    var defaults = {  
		item_selector:'.info_item',
		link_selector:'.info_heading',
		content_selector:'.info_content',
		showing:''
    };   
    var o = $.extend(defaults, opts); 
	
    return this.each(function() { 
		var selfref=$(this);
		var tabend=$('<span class="tab_end"><img alt="" src="/images/spacer.gif"/></span>')
		var links=	$(o.link_selector +' h3',selfref).each(function(){
			var t=$(this);
			if(!(t.children('span:last-child').hasClass('tab_end'))){
				t.append(tabend);
			}
		});
		if(links.length>1){
			links.css('cursor','pointer');
		}
		selfref.displayHolder = $('<div class="tab_display"></div>');
		$(o.item_selector+':first',selfref).addClass("first").after(selfref.displayHolder);
		if($(o.item_selector).length>1){
			$(o.item_selector+':last',selfref).addClass("last").after(selfref.displayHolder);
		}
		selfref.showItem = function(toShow){		
			$(o.item_selector,this).removeClass("tab_open").addClass("tab_closed");
			$(o.content_selector,this).css('display','none');
			$(toShow).addClass("tab_open").removeClass("tab_closed");
			if(o.showing.length>0){
				o.showing.append($(o.content_selector,this.displayHolder).hide());
			}
			this.displayHolder.append($(o.content_selector,toShow).show());
			o.showing=toShow;
		} 
		$(o.item_selector,selfref).each(function(i){
			var me	= $(this);
			$(o.link_selector, this).click(function(){selfref.showItem(me);return false;});
		;});
		
		selfref.showItem($($(o.item_selector,selfref)[0]));
    }); 	
 };   
})(jQuery);

(function($){   
 $.fn.paginate = function(opts) {  
    var defaults = {  
		holder_selector:'.CatalogueListing',
		page_selector:'.row',
		numbering_selector:'.PageNumbers',
		nextbutton_selector:'a[title="Next"]',
		backbutton_selector:'a[title="Back"]',
		empty_message:'<p class="msg">No products returned</p>',
		animationSpeed:300,
		page_original_state:'block',
		numbering_original_state:'block',
		navlink_original_state:'inline'
    };   
    var o = $.extend(defaults, opts);
    return this.each(function(){						  
		var selfref=$(this);				
		if(!selfref.hasClass('estar_pages')){			
			selfref.addClass('estar_pages');			
			var currentIdx = -1;
			var nextIdx=0;
			var holder = $(o.holder_selector,this);
			var pages=$(o.page_selector,this);
			o.page_original_state=pages.css('display');
			pages.css('display','none');			
			var numbering=$(o.numbering_selector,this);
			o.numbering_original_state=numbering.css('display');
			var numbering_list=$(o.numbering_selector + ' ul' ,this);
			var numbering_current=$(o.numbering_selector + ' .current',this)
			var numbering_count=$(o.numbering_selector + ' .count',this)			
			function showPage(idx){				
				nextIdx = idx;
				if(nextIdx != currentIdx){
					fadePageOut();
				}
			}
			function fadePageIn(){
				//alert('fadePageId()\ncurrentIdx:'+currentIdx+'\n nextIdx: '+nextIdx);				
				if(currentIdx>-1){	$(pages[currentIdx]).css('display','none'); }
				currentIdx = nextIdx;
				setButtonVisibility();				
				refreshNumbering();
				if(o.animationSpeed>0){
					$(pages[currentIdx]).css({'display':o.page_original_state,'opacity':0}).animate({opacity: 1}, o.animationSpeed, function(){if(jQuery.browser.msie){$(this).get(0).style.removeAttribute('filter');}});	
				}else{
					$(pages[currentIdx]).css({'display':o.page_original_state})						
				}
			} 
			function fadePageOut(){					
				if(currentIdx==-1){					
					fadePageIn();
				}else{					
					if(o.animationSpeed>0){
						$(pages[currentIdx]).animate({opacity: 0}, o.animationSpeed,fadePageIn);
					}else{
						fadePageIn();
					}
				}
			}
			function goNext(){				
				var idx = currentIdx +1;
				if(idx >= pages.length){
					idx -= pages.length
				}
				showPage(idx);				
				return false;
			}			
			function goBack(){				
				var idx = currentIdx -1;
				if(idx < 0){
					idx += pages.length;
				}
				showPage(idx);
				return false;
			}
			
			var nextbutton=$(o.nextbutton_selector,selfref).bind('click',goNext).css('display','none');	
			var backbutton=$(o.backbutton_selector,selfref).bind('click',goBack);
			o.navlink_original_state=backbutton.css('display');
			backbutton.css('display','none');
			function setButtonVisibility(){				
				if(currentIdx > 0){					
					backbutton.css('display',o.navlink_original_state);	
				}else{
					backbutton.css('display','none');
				}
				if(currentIdx + 1 < pages.length){
					nextbutton.css('display',o.navlink_original_state);
				}else{
					nextbutton.css('display','none');
				}
			}
			function refreshNumbering(){				
				if(numbering_list.length>0){
					$($('li',numbering_list).removeClass('On')[currentIdx]).addClass('On')
				}else{					
					numbering_current.html((currentIdx+1).toString());
					numbering_count.html((pages.length).toString());
				}
				if(pages.length>1){
					numbering.css('display',o.numbering_original_state);
				}else{
					nextbutton.css('display','none');
				}
			}
			if(pages.length==0){
				var msg = $(o.empty_message);
				holder.append(msg)
			}else{
				if(numbering_list.length>0){
					pages.each(function(idx){
						var myDisplay=idx+1;
						var myLi = $('<li><a href="#">'+myDisplay+'</a></li>');
						$('a',myLi).bind('click',function(){showPage(myDisplay-1);return false;});
						numbering_list.append(myLi);
					});
				}
				showPage(0);
			}
		}
    }); 	
 };   
})(jQuery);

(function($){   
 $.fn.starselect = function(opts) {  
    var defaults = {  
		full_image:'/images/rating_full.gif',
		empty_image:'/images/rating_empty.gif',
		hover_image:'/images/rating_hover.gif',
		holder_class:'starselect'	
    };   
    var o = $.extend(defaults, opts); 
	
    return this.each(function() { 
		var selfref=$(this);
		var el=this;
		var image_base='<img src="'+o.empty_image+'" />' 
		var holder_base='<span class="'+o.holder_class+'"></span>'
		if(el.tagName.toLowerCase()!='select' || selfref.next().hasClass(o.holder_class)){
			return;
		}
		var holder=$(holder_base);
		selfref.after(holder);
		function star_over(img){
			var me=$(img)
			me.prevAll().andSelf().attr('src',o.hover_image);
			me.nextAll().attr({'src':o.empty_image});
		}
		function star_out(img){
			$(img).siblings().andSelf().each(function(){var me=$(this);me.attr('src',me.attr('offimage'))});
		}
		function star_click(img){
			var me=$(img)
			el.selectedIndex=me.attr('idx');
			me.nextAll().attr({'src':o.empty_image,'offimage':o.empty_image});
			me.prevAll().andSelf().attr('offimage',o.full_image);
		}
		$('option',el).each(function(idx){
			var myIdx =  idx+0;
			var image=$(image_base);
			var myText=$(this).text();
			holder.append(image);
			image.attr({'idx':myIdx,'title':myText,'alt':myText,'offimage':o.empty_image});
			image.bind('click',function(){star_click(this)})
			image.hover(function(){star_over(this)},function(){star_out(this)})
			image.css('cursor','pointer');
		})
		selfref.hide();
    }); 	
 };   
})(jQuery);

(function($){   
 $.fn.makeFilterDropdowns = function(opts) {  
    var defaults = {  
		link_list:'ul.Filters',
		display_element:'h3'		
    };   
    var o = $.extend(defaults, opts); 
	function showChildren(el){
		$(el).css('z-index',20).siblings().css('z-index',19);
		$(o.link_list,el).slideDown(200);
	}
	function hideChildren(el){
		$(o.link_list,el).slideUp(200);
	}
    return this.each(function() { 
		var selfref=$(this);
		$(o.link_list, this).css('display','none');
		var disp=$(o.display_element, this);
		disp.html('<span>'+disp.html()+'</span>').css({'cursor':'pointer'}).bind('click',function(){showChildren(selfref)});
		selfref.hover(function(){return},function(){hideChildren(selfref)})
    }); 	
 };   
})(jQuery);

function popup_formpost(formObj){
	var f=$(formObj);
	modal_window.dialog('loadContent',f.attr('action'),f.serialize());
}

function slideOpen(selector){
	try{
		$(selector).removeClass('closed').slideDown(200);		
	}catch(err){}
}
function slideClosed(selector){	
	try{
		$(selector).addClass('closed').slideUp(200);		
	}catch(err){}	
}
function setCurrencyDisplay(clicked){
	try{
		$('#currency_selections a').removeClass('On');
		
		$(clicked).addClass('On');				
		slideClosed('#currency_selections');
		}catch(err){}
	return false;
}
$.extend($.ui.dialog.prototype, {
    'loadContent': function(src, dat, settings) {
        var me = this.element;
		me.dialog('option', 'title', ' ');        
        var c = $('.content:first', me);
        if (src.length > 1 && src.substring(0, 1) == '#') {
            c.html($(src).html());
            me.dialog('refreshDisplay');
        } else {
			c.html('<p>Loading, please wait...</p>');
            if (!dat) { dat = ''; }
            $.ajax({ type: "POST", url: src, data: dat, success: function(a) { c.html(a); me.dialog('refreshDisplay') } });
        }
        me.dialog('open');
    },
    'refreshDisplay': function() {
        var me = this.element;		
        var txt = $($('.content h1:first, .content h2:first', me)[0]).remove().text();
        me.dialog('option', 'title', '<h2>' + txt + '</h2>');
        //$('form',me).each(function(){this.submit=function(){me.dialog('loadContent',$(this).attr('action'),$(this).serialize());return false;}});
        $('.content:first', me).slideDown(100, function() { me.dialog('option', 'position', 'center') });
    }
});
var modal_window=null;
function modal_popup(url,type){	
	var settings='width:490,position:center';
	if(type==2){
		settings='width:846,position:center';
	}
	var arr=settings.split(',');
	for(var i=0;i<arr.length;i++){
		var s=arr[i].split(':');
		if(s.length==2){
			if(!isNaN(parseInt(s[1]))){
				modal_window.dialog('option',s[0],parseInt(s[1]));
			}else{
				modal_window.dialog('option',s[0],s[1]);
			}
		}
	}
	modal_window.dialog('loadContent',url);
}
function selectColour(colourId, clicked)
{
    var toShow = $('.AlternativeViews li.colourway_' + colourId);
    $('.AlternativeViews li[class^="colourway_"]').hide();
    if (toShow.length > 0) { 			
		toShow.show();			
	}else{
		toShow=$('.AlternativeViews li:visible');						
	}
	if(toShow.length>0){
		var activeShowing=false;
		toShow.each(function(){if($(this).hasClass('On')){activeShowing=true}})
		if(!activeShowing){
			try{
			$('a',toShow[0]).trigger('click');
			}catch(err){}
		}
	}
	$('.colour a',document).removeClass('On');
	$(clicked).addClass('On');
	showSizeSelect('sizes_colourway_'+colourId,'.size .newListSelected');
}

function showSizeSelect(toShowID,toHideSelector){
	if(toHideSelector){
		$(toHideSelector).css('display','none');
	}
	var sel=$('#'+toShowID);
	if(!sel.hasClass('styled')){
		sel.sSelect({animationSpeed:200,ddMaxHeight:300,changeSiblings:true});
	}else{
		$('.'+toShowID,sel.parent()).css('display','');
	}
}



<!--
/*
Random Image Link Script
By Website Abstraction (http://www.wsabstract.com)
and Java-scripts.net (http://www.java-scripts.net)
*/

function random_imglink(){
 var myimages=new Array()
 //specify random images below. You can have as many as you wish
 myimages[1]="info_background1.jpg"
 myimages[2]="info_background2.jpg"
 myimages[3]="info_background3.jpg"

 var ry=Math.floor(Math.random()*myimages.length)

 if (ry==0)
    ry=1
	 if($(".Catalogue_Page").hasClass('home') ){
  /*document.write('<img src="/images/assetimages/'+myimages[ry]+'" border=0>')*/
   	$(".Catalogue_Page").css('background-image', 'url(/images/assetimages/'+myimages[ry]+')')
   }
}


//-->

$(document).ready(function()
{
    try { $('.AdditionalInfoTextHtml').make_tabs(); } catch (err) { }
    try { $('.AddToCart .amount select, .shopping_cart select').sSelect({ animationSpeed: 200, ddMaxHeight: 300 }); } catch (err) { }
    try { $('.AddToCart .size select:visible').sSelect({ animationSpeed: 200, ddMaxHeight: 300, changeSiblings: true }); } catch (err) { }
    try { $().pngFix(); } catch (err) { }
    try { $('.ratings_reviews').paginate({ holder_selector: '.reviews', page_selector: '.review', numbering_selector: '.read', empty_message: '<p class="msg">This item hasn\'t been reviewed yet.</p>', animationSpeed: 100 }); } catch (err) { }
    try { $('.CatalogueDetails').paginate(); } catch (err) { }
    try { $('#regions').slideUp(20).addClass('closed'); } catch (err) { }
    try { $('.region_selector > a').bind('click', function() { if ($('#regions').hasClass('closed')) { slideOpen('#regions'); } else { slideClosed('#regions'); } return false; }) } catch (err) { }
    try { $('.region_selector').hover(function() { return false; }, function() { if (!$('#regions').hasClass('closed')) { slideClosed('#regions'); } }); } catch (err) { }
    try { $('.Navigation .links > ul').jScrollPane({ scrollbarWidth: 11, showArrows: true, arrowSize: 11, dragMinHeight: 83, dragMaxHeight: 83, scrollbarMargin: 0 }); } catch (err) { }
    try { $('.Navigation .links').slideUp(20).addClass('closed'); } catch (err) { }
    try { $('.NavigationContents').hover(function() { $(this).addClass('over'); }, function() { if (!$('.Navigation .links').hasClass('closed')) { slideClosed('.Navigation .links'); } $(this).removeClass('over'); }); } catch (err) { }
    try { $('.Navigation .heading').bind('click', function() { if ($('.Navigation .links').hasClass('closed')) { slideOpen('.Navigation .links'); } else { slideClosed('.Navigation .links'); } }) } catch (err) { }
    try { $('.colour a.On').click(); } catch (err) { }
    modal_window = $('#modal_popup').dialog({ modal: true, dialogClass: 'estar_modal', width: 490, minHeight: 178, autoOpen: false });

    try { $("tr[id^='edit_form_'] p[class='Colour'] select").change(); } catch (err) { }

    try { $('.result_content').paginate({ holder_selector: '.listing' }); } catch (err) { }
    $('.search_results').make_tabs({ item_selector: '.result_type', link_selector: '.result_heading', content_selector: '.result_content' });
    $('.FilterBy').makeFilterDropdowns(); 
	
	random_imglink()
});







/**************************************************************************************************************
 * 
 * Additional Scripts (S. Frater - 10/11/2009)
 *
 **************************************************************************************************************/

 
 function AddToCart() {
     // Get vars from hidden fields
    var size = $("#AddToCartForm input[name = 'szID']").val();
    var colour = $("#AddToCartForm input[name = 'clID']").val();
    var prod = $("#AddToCartForm input[name = 'pdID']").val();
    var cat = $("#AddToCartForm input[name = 'catID']").val();
    if (isNaN(cat)) {cat = 0;}
    var quantity = $("#AddToCartForm #qty option:selected").val();
    if (quantity && size && colour && quantity > 0 && size >= 0 && colour >= 0) {
        $.ajax({
        type: "GET",
        url: "/default.aspx",
        cache: false,
        data: { z: "c", action: "addspecify", pdID: prod, catID: cat, szID: size, clID: colour, qty: quantity, addpopup: "1", qs: "6" },
        success: ShowAddToCartPopup
        });
    } else {
        alert("Please select the colour and size that you require before adding this item to your cart");
    }
    return false; // Prevent form submit
}

function ShowAddToCartPopup(data) {
    var cartPopup = $("#cart_summary_holder");
    // Stop any animations running and timeouts
    cartPopup.stop();
    
    // Set and show data, setup scrolling and fade out
    cartPopup.html(data);
   
    ScrollCartPopup();
    cartPopup.show();
    $(window).scroll(ScrollCartPopup);
}

function ScrollCartPopup() {
    ScrollPopup("#cart_summary_holder > div");
}

// Get popup in view
function ScrollPopup(selector) {
    var y;
    if (self.pageYOffset) {
        y = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        y = document.documentElement.scrollTop;
    } else if (document.body) {
        y = document.body.scrollTop;
    }
    $(selector).css("top", y + "px");
}

// Globals
var handler = "/default.aspx"; //"/support.aspx";

function EditItem(obj, styleCode) {
    try {
        if (obj != null) {
            var itemID = obj.id.replace('editlink_', '');
            var item_area = $('#edit_form_' + itemID);
            if ((itemID > 0) && (item_area != null)) {
                $('table.cart .edit_form').css({ 'display': 'none' });
                $('table.cart .item').css({ 'display': '' });
                clearEditItemContent(itemID);
                setOrderItemContent(item_area, itemID, styleCode);
            }
        }
    } catch (e) { }
    return false;
}

function InsertElementOnPage(target, data, cleanUp) {
    if (cleanUp == 1) {
        $(target).html("&nbsp;");
        if (data != '') { $(target).empty(); }
    }
    $(target).append(data);
}

function clearEditItemContent(id) {
    if (id > 0) {
        InsertElementOnPage(document.getElementById('edit_form_' + id), '&nbsp', 1);
    }
}

function setOrderItemContent(obj, itemID, styleCode) {
    if (obj != null && !isNaN(itemID)) {
        $("#item_" + itemID).css({ 'display': 'none' });
        var url = handler;
        var data = { "Z": "c", "action": "edititem", "cs": styleCode, "lc": itemID }
        jQuery.ajax({
            "url": url,
            "data": data,
            "success": function(data) { ShowEditItemForm(data, itemID); },
            "cache": false
        });
    }
}

function ShowEditItemForm(data, itemID) {
    try {
        var editItem = $('#edit_form_' + itemID);
        editItem.stop();
        editItem.html(data);
        var colour = $("#changeClID_" + itemID).val();
        editItem.css({ 'display': '' });
        try { $('.shopping_cart select:visible').sSelect({animationSpeed:200,ddMaxHeight:300,changeSiblings:true}); } catch (err) { }
        fn_ShowSizes(colour, itemID); 
    } catch (e) {
        CancelUpdateItem(itemID);
    }
}

function UpdateItem(itemID) {
    var colour = $('input#changeClID_' + itemID).val();
    var size = $('input#changeSzid_' + itemID).val();
    var qty = $('input#changeQuantity_' + itemID).val();
    if (qty && size && colour && qty > 0 && size >= 0 && colour >= 0) {
        $("#frmPost_" + itemID).submit();
    } else {
        alert("Please select the colour and size that you require before adding this item to your cart");
    }
}

function CancelUpdateItem(itemID) {
    $("#edit_form_" + itemID).css({ 'display': 'none' });
    $("#item_" + itemID).css({ 'display': '' }); ;
    clearEditItemContent(itemID);
}

function setChangedSize(clicked, itemID) {
    var iSz = clicked.options[clicked.selectedIndex].value;
    $('input#changeSzid_' + itemID).val(iSz);
    $("select[id^='changeSizes_" + itemID + "' ]").each(function() {
        $(this).val(iSz);
        //if ($(this).val() != iSz) { $(this).val(""); }
    });
    setChangedPrice(itemID);
}

function setChangedColour(clicked, itemID)
{
    var iCl = clicked.options[clicked.selectedIndex].value;
    fn_ShowSizes(iCl, itemID);
    $('input#changeClID_' + itemID).val(iCl);
    setChangedPrice(itemID);
}

function fn_ShowSizes(cid, itemID)
{ 
	var toShowID='changeSizes_'+itemID;
	if(cid){
		toShowID += '_'+cid
	}
	showSizeSelect(toShowID,'#edit_form_' + itemID +' .Size .newListSelected');
	$('input#changeSzid_' + itemID).val($('#' + toShowID).val());
}

function setChangedQty(clicked, itemID) {
    var iQty = clicked.options[clicked.selectedIndex].value;
    $('input#changeQuantity_' + itemID).val(iQty);
}

function setChangedPrice(itemID)
{
    var colour = $('input#changeClID_' + itemID).val();
    var size = $('input#changeSzid_' + itemID).val();
    $("span.item_price").hide();
    $("#selection_price_" + colour + "_" + size).show();
}

