$j = jQuery.noConflict();

Oshoplang = { 

RemoveError: 			'This item has now been removed from your cart.', 
Added: 				' item(s) added to your <a href="/OrderRetrievev2.aspx">shopping cart</a>. Your cart summary is displayed in the right-hand side menu panel &raquo;',
OutOfStock:			'Sorry, this item is not available or is out of stock.',
PreOrder: 				' item(s) on pre-order in your <a href="/OrderRetrievev2.aspx">shopping cart</a>. Your cart summary is displayed in the top menu bar.',
InvalidQuantity: 		'Oops, it looks like you entered an invalid quantity. Please try again.',
CartEmpty: 			'Your shopping cart has been emptied successfully. <a id="CartEmptiedLink" href="Javascript:window.history.back(1)">Continue shopping?</a>',
CartUpdateSuccess: 		'Your order has been updated successfully.',
InvalidShip: 			'Oops, you forgot to select a Shipping Option. Please select and try again.',
ChooseState: 			'Please choose an area/state before you continue.',
EnterZip: 				'Please enter your Post Code/Zip Code.',
ChooseShip: 			'Please select a Shipping Option first.',
IncorrectGForm: 		'Oops, there seems to be something wrong with our Gift Voucher System. Please try again.',
EnterGName: 			'Oops, you need to add a persons name for this to work.',
InvalidGEmail: 			'Oops, the email address appears to be incorrect. Please check and try again.',
EnterGMessage: 		'Oops, you forgot to add a message for the recipient. Please enter and try again.' 
}

// Loading Plugins
	$j.lazy({ src: '/js/plugins/jquery.hoverIntent.minified.js', name: 'hoverIntent',cache: true });
	$j.lazy({ src: '/js/plugins/facebox/facebox.js', name: 'facebox',cache: true });
	$j.lazy({ src: '/js/plugins/jquery.cycle.all.min.js', name: 'cycle',cache: true });
	$j.lazy({ src: '/js/plugins/jquery.tipTip.minified.js', name: 'tipTip',cache: true });
	$j.lazy({ src: '/js/plugins/jquery.prettyPhoto.js', name: 'prettyPhoto',cache: false });
	//$j.lazy({ src: '/js/plugins/jquery.jquery.confirmit.js', name: 'confirmit',cache: false });
	
	
// End of plugins


// DOM LOAD
$j(function()
{
	$j('#j-warning').addClass("hide").remove();
	preloadImages();
	$j('a[class*=facebox]').facebox();
	linksAndEmails();	isCartFull();
	clearSearch();		imageBorders();
	addDivForMenu();	//registrationLinks();
	megaHoverOver();	megaHoverOut();
	isAvailable();		HideMe();
	copyDetails();		copyDetailsUpgrade();
	
	loggedInState();	
	
	$j(".tooltip").tipTip( { delay: 100, edgeOffset: 1, fadeOut: 400 } );
	$j("a[rel^='prettyPhoto']").prettyPhoto({theme: 'facebook'});
	
	//$j("#validate-form").validationEngine();

	// Menu Elements
	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 10, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 700, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};
	
	$j("ul#nav_643799 li .sub").css({'opacity':'0'});
	$j("ul#nav_643799 li").find("ul").parent().parent().addClass('dropdown');
	$j("ul#nav_643799 li.selected:hover").find("ul").parent().parent().addClass('dropdown');
	$j("ul#nav_643799 li").hoverIntent(config);
	$j('ul#nav_643799 li:has(ul)').mouseout(function(){
	    $j(this).addClass('dropdown');
	});
	
	// Remove margin on every 4th product (end of row)
	//$j('.productItem:nth-child(4n)').css("margin-right", "0");

	// Hero Slides
	$j('#slides').cycle({ 
		fx: 'fade', // string = blindX, blindY, blindZ, growX, growY, curtainX, curtainY, cover, fade, fadeZoom, scrollDown, scrollUp, scrollLeft, scrollRight, scrollHorz, scrollVert, slideX, slideY, shuffle, toss, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom (can even add multiples 'fade,scrollUp,shuffle')
		cleartypeNoBg: true, // boolean = true if clearType corrections should be applied (for IE) 
		delay: -4000, // milliseconds = additional delay for first transition (hint: can be negative)
		timeout: 25000, //  milliseconds between slide transitions (0 to disable auto advance)
		pause: 1, // boolean = 1 pauses the slideshow on mouseOver
		random: 0, // boolean = 0 moves through slides sequentially; 1 moves through slides in random order
		startingSlide: Math.floor(6*Math.random()), // zero-based index of the first slide to be displayed. Simon added random function to choose starting slide each page load (issue = not sure how many slides there are!).
		speed: 6000, // number = millisecond transition speed between slides
		fastOnEvent: 2000, // milliseconds = forces fast transitions when triggered manually
		requeueOnImageNotLoaded: true, // boolean = requeue the slideshow if any image slides are not yet loaded
		pager: '#hero-nav' // id 'string' = name of object located on the page to work with
	});
	
	// Get Rid of CMS Borders
	$j("img").each(function() {
		if ( $j(this).attr("border").length ) {
			$j(this).removeAttr("border")
		}
  	});
	
	if ( $j(".quicklinks").length )
	{
		$j(".quicklinks a").each(function()
			{
				if ( $j(this).text() == "Bookings and Events" || $j(this).text() == "Products" )
				{
					$j(this).replaceWith('<a href="/how-we-help" title="How we help">How We Help</a>');
				}
 		 	}
		);
	}
	
	// Shopping Menu
	/*if ( $j("body.products").length ) {
		//When page loads...
		$j("#bookings-menu").hide().addClass("menu-hidden"); //Hide all content
		//$j("a#product-section").addClass("selected").show(); //Activate first Link
		$j("#catalogus-menu").fadeIn("slow"); //Show first tab content
	}
	else if ( $j("body.bookings").length ) {
		$j("#catalogus-menu").hide().addClass("menu-hidden"); //Hide all content
		//$j("a#booking-section").addClass("selected").show(); //Activate first Link
		$j("#bookings-menu").fadeIn("slow"); //Show first tab content
	}
	if ( $j("body.groups").length ) {
		$j("#catalogus-menu").hide().addClass("menu-hidden"); //Hide all content
		$j("#bookings-menu").fadeIn("slow"); //Show first tab content
	}*/
	
	// Back from Paypal
	/*if ($j('#payment')) {
		getUrlVars();
		var processStatus = getUrlVars()["st"];
		var fullDetails = displayPaymentDetails();
		$j("#pay-status").append( processStatus );
		$j("#payment-details").append( fullDetails );

	}*/
	

	//On Click Event
	$j("a#product-section").click(function() {
		if ( $j("a#product-section").hasClass("selected") ) {
			alert ("This menu is already displayed :)");
			return false;
		}
		$j("#bookings-menu").hide().addClass("menu-hidden");
		$j("a#booking-section").removeClass("selected");
		$j("a#product-section").addClass("selected");
		$j("#catalogus-menu").removeClass("menu-hidden").fadeIn("slow");
		return false;
	});
	
	$j("a#booking-section").click(function() {
		if ( $j("a#booking-section").hasClass("selected") ) {
			alert ("This menu is already displayed :)");
			return false;
		}
		$j("#catalogus-menu").hide().addClass("menu-hidden");
		$j("a#product-section").removeClass("selected");
		$j("a#booking-section").addClass("selected");
		$j("#bookings-menu").removeClass("menu-hidden").fadeIn("slow");
		return false;
	});
								

	$j('#member-field-show').toggle(function() {
	  $j("#purchase-form").find(".hide-1").fadeIn("fast");
	}, function() {
	  $j("#purchase-form").find(".hide-1").fadeOut("fast");
	  
	});	

	//Simon 20-apr-2011 commented out as it hides the default message otherwise
        // : $j("#catCartDetails a.cartLink").remove().after('<div><a class="empty-cart-link" href="/how-we-help" title="How we help"><img src="http://farm3.static.flickr.com/2454/3612149294_bb4d2cc1a5.jpg" alt="Empty cart. Continue Shopping?" /></a><\/div>'); 

	if ($j('#purchase-form')) {
		billToShip();
	}
	
});

