MCFC.custom = function (scope) {
	
	if(scope == undefined){
		scope = document;
	}	
	
	// Additional unsemantic elements can be written in for styled links
	$('a.btn:not(._btn)', scope).each(function(){
		var b = $(this);
		b.addClass('_btn');
		var tt = b.html() || b.val();
		b.html('').css({cursor:'pointer'}). prepend('<i></i>').append($('<span>').
		html(tt).append('<i></i><em></em><span></span>'));
	});
		
	/* ------------- Proxy links -------------- */
	// When the link is pressed it "clicks" the button.
	// The initial HTML looks like this:
	// 
	//    <input class="proxy" type="submit" value="Save">
	// 
	// After jQuery has done it's thing it look like this:
	// 
	//    <input type="submit" class="proxy" value="Save" style="display:none">
	//    <a href="#" class="proxy">Save</a>
	$('input.btn', scope).each( function() {
		var input = $(this);
		$('<a href="#"><i></i><span>' + this.value + '<i></i><em></em><span></span></span></a>')
			.attr( 'class', this.className )
			.insertBefore(this)
			.click( function() {
				if(input.attr('type') == 'submit'
				 	&& MCFC.validation 
					&& !MCFC.validation.validate(this)){
						return false;
				}
				input.click();
				return false;
			});
		input.hide();
	});
		
	/* ------------- For dropdowns used as navigation, hide input buttons, unless JS is disabled  -------------- */
	$('.ifjs-hide', scope).hide();
	
	/* ------------- Navigation rounded corners  ---*/
	$('ul#nav-secondary li:first').addClass('first-top-left-corner');
	$('ul#nav-secondary li:last').addClass('bottom-left-corner');
	
	// Fine for nav items where there is a sub list
	//If no sub nab, this class should not be added
	if($('ul#nav-secondary li.active ul')){
		$('ul#nav-secondary li.active ul').parent().next().addClass('top-left-corner');
	}
	
	/* ------------- Reveal hidden tickets content  -------------- */
	$(".tickets-drawer-open").hide();
	$('.tickets-drawer a.handle').toggle(
			function () {
				$(this).removeClass('open');
				$(this).parent().find('div').slideDown();
				$(this).html('Close');
				$(this).addClass('close');
				},
			function () {
				// $(this).prev().slideUp('slow');
				$(this).removeClass('close');
				$(this).parent().find('div').slideUp();
				$(this).html('Prices &amp; release dates');
				$(this).addClass('open');
			}
		);

	
	/* ------------- jqModal boxes -----------------*/
	
	/* all jqmodals should have this method as onShow method */
	if($.jqm){
		var jqModalShow = function (hash) { hash.w.show(); MCFC.fontsizes(hash.w); MCFC.custom(hash.w); };
		$('#shop #allocatetickets', scope).jqm({
			trigger: 'a.trigger-allocatetickets',
			onShow: jqModalShow
		});	
		
		// Size charts
	$('#shop #sizechart', scope).jqm({
		trigger: 'a.trigger-sizechart',
		onShow: jqModalShow
		});	
	}
	
	/* ------------- open new windows using 'rel' attribute -----------------*/
    $("a[rel*='external']").each(function(){
		$(this).attr({ 
          title: "This link will open in a new window"
        });
		// add target attribute to link
        $(this).attr('target','_blank');
    });
};

MCFC.init.add_on_dom_ready(MCFC.custom);