jQuery.noConflict();


jQuery(document).ready(function() {
	if(location.hash == "#wpsbw"){
			jQuery('#showNewsletter').show();
			jQuery('#closeNews').show();

	}

   jQuery("div.svwp").prepend("<img src='images/svwloader.gif' class='ldrgif' alt='loading...'/ >"); //change with YOUR loader image path   



	picShow('#chef', '#image1');
	picShow('#director', '#image2');
	picShow('#peter', '#image3');
	picShow('#marketImages #1a', '#Store #image1');
	picShow('#marketImages #2', '#Store #image2');
	picShow('#marketImages #3', '#Store #image3');
	picShow('#storeImages #1a', '#Drinks #image1');
	picShow('#storeImages #2', '#Drinks #image2');
	picShow('#storeImages #3', '#Drinks #image3');

	jQuery('#description').hide();
	jQuery('#infoNavPanel a').each( function(){
		initMouseOver(this);
		});
	initPopup('#news', '#newsPanel', '#twitterPanel', '-49px -240px', '-49px -200px', '#twitter', '-9px -200px');
	initClose('#newsPanel');
	
					 
	// slideshow frontpage
 	var Pslide1 = jQuery("#slide-1");
	var panelWidth = Pslide1.css("width");
	var panelPaddingLeft = Pslide1.css("paddingLeft");
	var panelPaddingRight = Pslide1.css("paddingRight");
	panelWidth = parseFloat(panelWidth, 10);
	panelPaddingLeft = parseFloat(panelPaddingLeft, 10);
	panelPaddingRight = parseFloat(panelPaddingRight, 10);
	panelWidth = panelWidth + panelPaddingLeft + panelPaddingRight;
	var numPanels = jQuery(".slide").length;
	var tooFar = -(panelWidth * numPanels);
	var totalMoverwidth = numPanels * panelWidth;
	jQuery("#mover").css("width", totalMoverwidth);
	jQuery("#slider").append('<a href="#" id="slider-stopper">Stop</a>');
			sliderIntervalID = setInterval(function(){
				doMove(panelWidth, tooFar);
			}, delayLength);
	jQuery("#slider-stopper").click(function(){
				if (jQuery(this).text() == "Stop") {
				clearInterval(sliderIntervalID);
		 		jQuery(this).text("Start");
				} else {
				sliderIntervalID = setInterval(function(){
					doMove(panelWidth, tooFar);
					}, 	delayLength);
		 		jQuery(this).text("Stop");
			} 
			});
	// scroll bars for pages
	var el = document.getElementById("Scroller-1");
	scroller = new Scrolling.Scroller(el, 400, 200);
 	jQuery(".Scrollbar-Up").mouseover(function() { scroller.startScroll(0, -5);})
		.mouseout(function() {	scroller.stopScroll();});	
	jQuery(".Scrollbar-Down").mouseover(function() { scroller.startScroll(0, 5);})
		.mouseout(function() { scroller.stopScroll();});	

	
		quickShow(".newsLetter", "#showNewsletter");
	quickShow("#searchNow", "#searchform");
	jQuery('#closeNews').click(function(){
		jQuery('#showNewsletter').hide();
   
			

});


});



function quickShow(n, f){
	jQuery(n).click(function(){
		jQuery(f).show();
	});
	
}


function initMouseOver(name) {
	 	var message = jQuery(name).attr('title');
	 	jQuery(name).mouseover(function() { 	
			jQuery("#description").css('display','block');
			jQuery("#description").html(message);
		}).mouseout(function() {	
			jQuery("#description").css('display','none');

		});	
}
function initShow(n){
  jQuery('#bs_'+ n).click(function() {
	 jQuery(".Scroller-Container").find('div').css('display', 'none');
	 jQuery("#scrollContentNav").find('a').css('color', '#322302');
	 jQuery("#scrollContentNav").find('a').css('background', 'none');
	 jQuery("#scrollContentNav").find('#bs_'+ n  ).css('color', '#e16a19');
	 jQuery(".Scroller-Container").find('#' + n).css('display', 'block');
	 jQuery(".Scroller-Container").css('top', '0px');	
	});			

}
function picShow(name, pic){
  jQuery(name).click(function() { 	
			jQuery(pic).show('slow');
		});
	jQuery(pic).click(function() {	
			jQuery(pic).hide('slow');

		});		

}

function initClose(n){
	jQuery('.close').click(function(){
		jQuery(n).hide();
	});


}


function initPopup(n, s, h, p, r_p, n2, p2){
	 jQuery(n).click(function() {	
					jQuery(h).slideUp();
					jQuery(s).slideDown();
					jQuery(n).css('background-position', p)
					jQuery(n2).css('background-position', p2)
		 
	});
}
var delayLength = 10000;	
function doMove(panelWidth, tooFar) {
	var leftValue = jQuery("#mover").css("left");	
	// Fix for IE
	if (leftValue == "auto") { leftValue = 0; };
	var movement = parseFloat(leftValue, 10) - panelWidth;
	if (movement == tooFar) {
		jQuery(".slide a").animate({
			"right": -300
		}, function() {
			jQuery("#mover").animate({
				"left": 0
			}, function() {
				jQuery(".slide a").animate({
					"right": 53
				});
			});
		});
	}
	else {
		jQuery(".slide a").animate({
			"right": -300
		}, function() {
			jQuery("#mover").animate({
				"left": movement
			}, function() {
				jQuery(".slide a").animate({
					"right": 0
				});
			});
		});
	}
}


// Create scrolling variable if it doesn't exist
if (!Scrolling) var Scrolling = {};

//Scroller constructor
Scrolling.Scroller = function (o, w, h, t) {
	//get the container
	var list = o.getElementsByTagName("div");
	for (var i = 0; i < list.length; i++) {
		if (list[i].className.indexOf("Scroller-Container") > -1) {
			o = list[i];
		}
	}
	
	//private variables
	var self  = this;
	var _vwidth   = w;
	var _vheight  = h;
	var _twidth   = o.offsetWidth
	var _theight  = o.offsetHeight;
	var _hasTween = t ? true : false;
	var _timer, _x, _y;
	
	//public variables
	this.onScrollStart = function (){};
	this.onScrollStop  = function (){};
	this.onScroll      = function (){};
	this.scrollSpeed   = 30;
	
	//private functions
	function setPosition (x, y) {
		if (x < _vwidth - _twidth) 
			x = _vwidth - _twidth;
		if (x > 0) x = 0;
		if (y < _vheight - _theight) 
			y = _vheight - _theight;
		if (y > 0) y = 0;
		
		_x = x;
		_y = y;
		
		o.style.left = _x +"px";
		o.style.top  = _y +"px";
	};
	
	//public functions
	this.scrollBy = function (x, y) { 
		setPosition(_x - x, _y - y);
		this.onScroll();
	};
	
	this.scrollTo = function (x, y) { 
		setPosition(-x, -y);
		this.onScroll();
	};
	
	this.startScroll = function (x, y) {
		this.stopScroll();
		this.onScrollStart();
		_timer = window.setInterval(
			function () { self.scrollBy(x, y); }, this.scrollSpeed
		);
	};
		
	this.stopScroll  = function () { 
		if (_timer) window.clearInterval(_timer);
		this.onScrollStop();
	};
	
	this.reset = function () {
		_twidth  = o.offsetWidth
		_theight = o.offsetHeight;
		_x = 0;
		_y = 0;
		
		o.style.left = "0px";
		o.style.top  = "0px";
		
		if (_hasTween) t.apply(this);
	};
	
	this.swapContent = function (c, w, h) {
		o = c;
		var list = o.getElementsByTagName("div");
		for (var i = 0; i < list.length; i++) {
			if (list[i].className.indexOf("Scroller-Container") > -1) {
				o = list[i];
			}
		}
		
		if (w) _vwidth  = w;
		if (h) _vheight = h;
		this.reset();
	};
	
	this.getDimensions = function () {
		return {
			vwidth  : _vwidth,
			vheight : _vheight,
			twidth  : _twidth,
			theight : _theight,
			x : -_x, y : -_y
		};
	};
	
	this.getContent = function () {
		return o;
	};
	
	this.reset();
};

