var MivaMerchantDesign={
	init: function(){
		var mivaScreen=document.body.id;
		if(MivaMerchantDesign[mivaScreen]){
			$(document).ready(function(){MivaMerchantDesign[mivaScreen]();}); // ---- If the function exists, run it, otherwise, don't do anything. ---- //
		};
		$(document).ready(function(){
			// ---- Allow Named Anchors To Work Without Full URL ---- //
				$('a[href^="\#"]').click(function(e){e.preventDefault(); document.location.hash=this.href.substr(this.href.indexOf('#')+1);});
			// ---- Back to Top Controls ---- //
				$('a.b2t').click(function(e){$('html, body').animate({scrollTop:'0px'}, 'normal');});
			// ---- Clear Default Input Values ---- //
				$('#searchfield, .clearMe').focus(function(){	if(this.value==this.defaultValue){this.value=''}	}).blur(function(){	if(this.value==''){this.value=this.defaultValue}	});
			// ---- Newsletter Sign-Up Email Validation ---- //
				$('#newsletter-form').submit(function(e){
					var email=$('#signup-email').val();
					if(!isValidEmailAddress(email)){
						$('#newsletter-form .warning-message').text('Please enter your email address.').show().delay(3000).fadeOut('slow');
						$('#signup-email').val('');
						e.preventDefault();
					};
				});
		});
	},
	
	SFNT: function(){
	},
	
	CTGY: function(){
	},
	
	PROD: function(){
	},
	
	PRINTP: function(){
	// ---- Run Print Function On Page Load ---- //
		window.print();
	},
	
	PATR: function(){
	},
	
	BASK: function(){
	// ---- Remove Item From Basket (Compatible down to IE6) ---- //
		$('.basket label').click(function(){
			$(this).next('input').attr('checked','checked');
			if($(this).next('input').is(":checked")){$('#bask-form').submit();}
		});
	},
	
	ACAD: function(){
	},
	
	ACED: function(){
	},
	
	CTUS: function(){
	// ---- Additional Server Security To Help Against Spambots ---- //
		$('#noscript-warning').remove();
		$.get('../php/token.php',function(tkn){
			$('#contact-form').append('<input type="hidden" name="mms" value="'+tkn+'" />');
		});
	},
	
	LOGN: function(){
	// ---- Toggle Show/Hide Password Lookup Form ---- //
		$('#forgot-password').hide(); //Hide Password Lookup Form
		$('#showPW').click(function(e){
			$('#forgot-password').slideToggle(); //slideToggle Password Lookup Form
			e.preventDefault(); // cancel default behavior
		});
	},
	
	OCST: function(){
	// ---- Toggle Show/Hide Log-In Form ---- //
		$('#login-form').hide(); //Hide Log-In Form
		$('#ocst-login').click(function(e){
			$('#login-form').slideToggle(); //slideToggle Show/Hide Log-In Form
			e.preventDefault(); // cancel default behavior
		});
	// ---- Toggle Show/Hide Basket Contents ---- //
		//$('#basket-contents').hide();
		$('#show-basket').click(function(e){
			$('#basket-contents').slideToggle();
			$('#show-basket').text(($('#show-basket').text() == 'Show Basket Contents') ? 'Hide Basket Contents' : 'Show Basket Contents');
			e.preventDefault();
		});
	},
	
	OSEL: function(){
	// ---- Toggle Show/Hide Basket Contents ---- //
		$('#basket-contents').hide(); //Hide Basket Contents
		$('#show-basket').click(function(e){
			$('#basket-contents').slideToggle(); //Show/Hide Basket Contents
			$('#show-basket').text(($('#show-basket').text() == 'Show Basket Contents') ? 'Hide Basket Contents' : 'Show Basket Contents'); //Toggle Link Text
			e.preventDefault(); // cancel default behavior
		});
	},
	
	OUSL: function(){
	// ---- Toggle Show/Hide Log-In Form ---- //
		$('#login-form').hide(); //Hide Log-In Form
		$('#ocst-login').click(function(e){
			$('#login-form').slideToggle(); //slideToggle Show/Hide Log-In Form
			e.preventDefault(); // cancel default behavior
		});
	// ---- Toggle Show/Hide Basket Contents ---- //
		$('#basket-contents').hide(); //Hide Basket Contents
		$('#show-basket').click(function(e){
			$('#basket-contents').toggle(); //Show/Hide Basket Contents
			$('#show-basket').text(($('#show-basket').text() == 'Show Basket Contents') ? 'Hide Basket Contents' : 'Show Basket Contents'); //Toggle Link Text
			e.preventDefault(); // cancel default behavior
		});
	}
};

MivaMerchantDesign.init();
