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 (like Jeff).
		}
	},
	
	SFNT: function(){
	// ---- Activate the Slider ---- //
		$('#coda-slider').codaSlider({
			autoHeight:false,
			crossLinking:false,
			dynamicArrows:false,
			dynamicTabs:false,
			dynamicTabsPosition:'bottom',
			slideEaseDuration:0,
			slideEaseFunction:'linear'
		});
	// ---- Tool-Tip Controls in the Slider ---- //
		$('.tooltip').each(function(){
			$(this).qtip({
				content:$('#' + this.id + '-content').html(),
				style:{width:200,name:'light',border:{color:'#007dc1',width:3,radius:5}},
				hide:{fixed:true, delay:250},
				position:{
					adjust:{x:2},
					corner:{target:'center', tooltip:'topMiddle'}
				}
			});
		});
		$('.tooltip-left').each(function(){
			$(this).qtip({
				content:$('#' + this.id + '-content').html(),
				style:{width:316,name:'light',border:{color:'#007dc1',width:3,radius:5}},
				hide:{fixed:true},
				position:{
					adjust:{y:-10},
					corner:{target:'bottomMiddle', tooltip:'topLeft'}
				}
			});
		});
		$('.tooltip-right').each(function(){
			$(this).qtip({
				content:$('#' + this.id + '-content').html(),
				style:{width:316,name:'light',border:{color:'#007dc1',width:3,radius:5}},
				hide:{fixed:true},
				position:{
					adjust:{y:-10},
					corner:{target:'bottomMiddle', tooltip:'topRight'}
				}
			});
		});
	},
	
	PROD: function(){
	// ---- Light-Box Controls ---- //
		$('#helpChoose').colorbox({width:'500px',height:'50%',iframe:true});
		$('#taf').colorbox({width:'500px',height:'50%',iframe:true});
	// ---- Dynamic Product Tabs ---- //
		$('.tab-content').hide(); //Hide all content
		$('ul.tabs li:first').addClass('active').show(); //Activate first tab
		$('.tab-content:first').show(); //Show first tab content
		$('ul.tabs li').click(function(){//On Click Event
			if($(this).hasClass('active')) return false; // Tab already selected
			$('ul.tabs li').removeClass('active'); //Remove any 'active' class
			$(this).addClass('active'); //Add 'active' class to selected tab
			$('.tab-content').hide(); //Hide all tab content
			var activeTab=$(this).find('a').attr('href'); //Find the href attribute value to identify the active tab + content
			activeTab=activeTab.split('#');
			$('#'+activeTab[activeTab.length-1]).fadeIn(); //Show the active ID content (Can use show, fadeIn or slideDown)
			return false;
		});
		$('ul.tabs li a').append('<span>'); //Uncomment to show arrows after links

		function showReviews(){
			$('ul.tabs li').removeClass('active'); //Remove any 'active' class
			$('ul.tabs li#reviews').addClass('active'); //Add 'active' class to selected tab
			$('.tab-content').hide(); //Hide all tab content
			var activeTab=$('ul.tabs li#reviews').find('a').attr('href'); //Find the href attribute value to identify the active tab + content
			activeTab=activeTab.split('#');
			$('#'+activeTab[activeTab.length-1]).fadeIn(); //Show the active ID content (Can use show, fadeIn or slideDown)
			return false;
		}

	// ---- Use AJAX to load Question & Answer content ---- //
		$.ajaxSetup({cache:false});
		$('#qna-content').html('<img src="../images/img_loading.gif" alt="loading..." title="loading..." class="ajax-loading" />').load('../qna/'+qna);
	// ---- Ask A Question Form Controls ---- //
		$('#question-link').click(function(){
			$('#question-form, #close-btn').fadeIn();
			$('#question-form-wrap').slideDown('slow');
			return false;
		});
		$('#close-btn').click(function(){
			$('#question-form')[0].reset();
			$('#question-form, #close-btn').fadeOut();
			$('#question-form-wrap').slideUp('slow');
			return false;
		});
	// ---- Swap Additional Product Image for Product Image ---- //
		$('#add-product-images img').click(function(){
			var imgSRC=$(this).attr('src');
			$('#prod-img').attr('src', $(this).attr('src'));
		});
	},
	
	OCST: function(){
	// ---- Toggle Show/Hide Log-In Form ---- //
		$('#login-form').hide(); //Hide Log-In Form
		$('#ocst-login').click(function(){
			$('#login-form').slideToggle(); //slideToggle Show/Hide Log-In Form
			return false;
		});
	// ---- Toggle Show/Hide Basket Contents ---- //
		$('#basket-contents').hide(); //Hide Basket Contents
		$('#show-basket').click(function(){
			$('#basket-contents').slideToggle(); //slideToggle Show/Hide Basket Contents
			$('#show-basket').text(($('#show-basket').text() == 'Show Basket Contents') ? 'Hide Basket Contents' : 'Show Basket Contents'); //Toggle Link Text
			return false;
		});
	},
	
	OUSL: function(){
	// ---- Toggle Show/Hide Log-In Form ---- //
		$('#login-form').hide(); //Hide Log-In Form
		$('#ocst-login').click(function(){
			$('#login-form').slideToggle(); //slideToggle Show/Hide Log-In Form
			return false;
		});
	// ---- Toggle Show/Hide Basket Contents ---- //
		$('#basket-contents').hide(); //Hide Basket Contents
		$('#show-basket').click(function(){
			$('#basket-contents').slideToggle(); //slideToggle Show/Hide Basket Contents
			$('#show-basket').text(($('#show-basket').text() == 'Show Basket Contents') ? 'Hide Basket Contents' : 'Show Basket Contents'); //Toggle Link Text
			return false;
		});
	}
};

MivaMerchantDesign.init();
