
function chgimg(i, d, b, m, s, c)
{
	$("#"+i).attr('src', m);
	$("#"+d).text(s);
	$("#"+b).attr('href', c);
}

function chgimg2(i)
{
	$('#prodbigimages div').hide();
	$('#'+i).show();
}

function add_sth_done(loc)
{
	$.prettyPhoto.close();
	if ( loc ) document.location = loc;
}

function deliveryChanged(el)
{
	var da = $(el).find('option:selected').val();

	$.getJSON('?do=basket&a=getJSONTotal&da=' + da, function(j) {
		$('#baskettotal').text(j.total);
		if ( j.delivery_cost > 0 ) {
			$('#deliverycost').html('&pound;' + j.delivery_cost);
		}
		else {
			$('#deliverycost').html('<em>free</em>');
		}
	});

	/*
	if ( da == -1 ) {
		$('#order_a').val('email');
		$('#order_info').show();
		$('#order_submit_paypal').hide();
		$('#order_submit_email').show();
	}
	else {
		$('#order_a').val('wps');
		$('#order_info').hide();
		$('#order_submit_paypal').show();
		$('#order_submit_email').hide();
	}
	*/
}




$(document).ready(function() { 


	$("#contactMessage").prettyComments({animate: true, maxHeight:200});

	$('#productListForm select').change(function() {
		$('#productListForm').submit();
	});

	if ( $('#paypalform').length > 0 ) {
		$('#paypalform').submit();
	}


	// $('.sub2').hide ({});
    
	/*
    $('.Mason', this).masonry({
      itemSelector: '.sub2-item',
	  isFitWidth: true,
	  columnWidth : 195
    });
*/

	$('.sub1-item').hover(
		function () {
			//show its submenu
			$('.sub2', this).fadeIn(0);
			$(this).css('background-color', '#137cb3');
			 $('.Mason', this).masonry({
				itemSelector: '.sub2-item',
			  isFitWidth: true,
			  columnWidth : 195
			 });
		}, 
		function () {
			//hide its submenu
			$('.sub2', this).fadeOut(0);
			$(this).css('background', 'none');
		}
	);
	
	/*
 $("ul.sf-menu").supersubs({ 
            minWidth:    12,   // minimum width of sub-menus in em units 
            maxWidth:    80,   // maximum width of sub-menus in em units 
            extraWidth:  2     // extra width can ensure lines don't sometimes turn over 
                               // due to slight rounding differences and font-family 
        }).superfish({ 
            delay:       0,                            // one second delay on mouseout 
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
            speed:       'fast',                          // faster animation speed 
            autoArrows:  true,                           // disable generation of arrow mark-up 
            dropShadows: true                            // disable drop shadows 
        });  			 // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason.
*/


	$(".rdCorner").corner("10px");
	$(".rdCrSml").corner("6px");	
	$(".LoginBar").corner("bottom 10px");
	$(".rdTopCorner").corner("top 10px");
	
	$("a[rel^='prettyPhoto']").prettyPhoto({
										   autoplay_slideshow: false,
										   show_title: false,
										   social_tools:false
										   });

		$('.slideshow').cycle({ 
			fx:      	'fade',
		    speed:    	1000,
			timeout:  	4000,
			sync:   	0
		});

$('.slideshowTop').cycle({ 
			fx:      	'fade',
		    speed:    	500,
			timeout:  	6000,
			sync:   	0,
		    next:   '#nextSlide', 
		    prev:   '#prevSlide',
			pause:  	1
		});
		$('.mdSlider').cycle({ 
			fx:      	'scrollHorz',
		    speed:    	1000,
			timeout:  	0,
			sync:   	1,
		    next:   '#nextSlideBlue', 
		    prev:   '#prevSlideBlue'
		});
		$('.mnBtAdSlider').cycle({ 
			fx:      	'scrollHorz',
		    speed:    	1000,
			timeout:  	0,
			sync:   	1,
		    next:   '#nextSlideBtAd', 
		    prev:   '#prevSlideBtAd'
		});
		$('.feedbackSlider').cycle({ 
			fx:      	'scrollHorz',
		    speed:    	1000,
			timeout:  	8000,
			sync:   	1,
		    next:   '#nextSlideFeedback', 
		    prev:   '#prevSlideFeedback'
		});
		$('.WidthColSlider').cycle({ 
			fx:      	'scrollHorz',
		    speed:    	1000,
			timeout:  	8000,
			sync:   	1,
		    next:   '#nextSlideWidthCol', 
		    prev:   '#prevSlideWidthCol'
		});



		$(".fadeFx").fadeTo("slow", 1.0); // This sets the opacity of the thumbs to 100% when the page loads
		$(".fadeFx").hover(function(){
			$(this).fadeTo("fast", 0.4); // This should set the opacity to 60% on hover
			},function(){
			$(this).fadeTo("slow", 1.0); // This should set the opacity back to 1000% on mouseout
			});



/*Since all the tabs are hidden with css we are displaying the tab with class .active_tab using fadeIn()
function. If you just want it to show with no effect, just put show() instead of fadeIn() */
        $('.active_tab').fadeIn();
        
        //when a tab link is clicked...
        $('.tab_link').live('click', function(event){
            
            /*...prevent the default behaviour...*/
            event.preventDefault();
            
            /* ...remove the tab_link_selected class from current active link... */
            $('.tab_link_selected').removeClass('tab_link_selected');
            
            /* ...and add it to the new active link */
            $(this).addClass('tab_link_selected');
        
            /*...get the title attribute (which corensponds to the id of the needed text container),
            but you can use any attribute you want*/
            var container_id = $(this).attr('title');
            
            //...animate the current active_tab by changing it's height and opacity ...'
            $('.active_tab').animate({ 
                
                height : 'toggle' , opacity : 'toggle' 
                
            //...and when that animation ends...
            },function(){
            
                //...remove the active_tab class from the current active tab...
                $(this).removeClass('active_tab');
                
                //...and add that class to the tab that corensponds the clicked link...
                $(container_id).addClass('active_tab');
                
                //...and animate the new active_tab by using toggle on height and opacity again...
                $('.active_tab').animate({
                   
                    height : 'toggle' , opacity : 'toggle'
                    
                });
            });
            
        });            





}); 
		$(function () {
			$('.preload').hide();//hide all the images on the page
		});
		
		var i = 0;//initialize
		var int=0;//Internet Explorer Fix
		$(window).bind("load", function() {//The load event will only fire if the entire page or document is fully loaded
			var int = setInterval("doThis(i)",200);//500 is the fade in speed in milliseconds
		});
 
		function doThis() {
			var imgs = $('.preload').length;//count the number of images on the page
			if (i >= imgs) {// Loop the images
				clearInterval(int);//When it reaches the last image the loop ends
			}
			$('.preload:hidden').eq(0).fadeIn(200);//fades in the hidden images one by one
			i++;//add 1 to the count
		}



/**
Hover efect for li mouse over
 * @author Alexander Farkas
 * v. 1.02
 */
(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == 'string') {
                var start = $.curCSS(fx.elem,'backgroundPosition');
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,'0px');
               strg = strg.replace(/right|bottom/g,'100%');
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

            $(function(){
                $('.SideLinks a')
                    .css( {backgroundPosition: "0 7px"} )
                    .mouseover(function(){
                        $(this).stop().animate(
							 { backgroundPosition:"(9px 7px)"},
							 { queue: false,
							   duration: 300,
							   easing: 'easeOutElastic'
						})
                    })
                    .mouseout(function(){
                        $(this).stop().animate({backgroundPosition:"(0 7px)"}, {duration:400, complete:function(){
                            $(this).css({backgroundPosition: "0 7px"})
                        }})
                    })
            });

            $(function(){
                $('.ftCol a')
                    .css( {backgroundPosition: "0 7px"} )
                    .mouseover(function(){
                        $(this).stop().animate(
							 { backgroundPosition:"(9px 7px)"},
							 { queue: false,
							   duration: 300,
							   easing: 'easeOutElastic'
						})
                    })
                    .mouseout(function(){
                        $(this).stop().animate({backgroundPosition:"(0 7px)"}, {duration:400, complete:function(){
                            $(this).css({backgroundPosition: "0 7px"})
                        }})
                    })
            });

/*$(document).ready(function(){
			//Start the snow default options you can also make it snow in certain elements, etc.
			$(document).snowfall({round : true, minSize: 2, maxSize:8})
			});
*/
