/* Jquery for MMOs */
$(document).ready(function() {
	var showTextTwo='(+)';
	var hideTextTwo='(-)';
	$('a.showMore').text(showTextTwo);
	$('div.MMOtracklisting ul').hide();
	$('a.showMore').toggle(
	function () {
		$(this).parent().next('ul').show("slow");
		$(this).text(hideTextTwo);
	},
	function () {
		$(this).parent().next('ul').hide("slow");
		$(this).text(showTextTwo);
	});
	
});


function swap(pic,n)
{
if(n == 1)
{ pic.src="http://www.forsyths.co.uk/images/HeaderLogoHome250x90.gif"; window.status = "MouseOver"; }

if(n == 0)
{ pic.src="http://www.forsyths.co.uk/images/HeaderLogoEst250x90.gif"; window.status = "MouseOut"; }
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		pianoMain_thumbR_over = newImage("");
		pianoMain_thumbL_over = newImage("");
		preloadFlag = true;
	}
}

var imgTags = document.getElementsByTagName("img");
for(var i = 0; i < imgTags.length; i++) {
if(imgTags[i].getAttribute("src") === "")
imgTags[i].parentNode.removeChild(imgTags[i]);
}



/* contact us jquery */

$(document).ready(function() {
	$('dd.INTL').hide();
	$('dl.byPhone').before('<p class="phoneMsg">For International Numbers, </p><a href="#" class="phoneToggle">click here</a>');
	$('a.phoneToggle').toggle(
		function(event) {
			$('p.phoneMsg').text('For UK Numbers, ');
			$('dd.UK').hide();
			$('dd.INTL').show();
			return false;
			},
		function(event) {
			$('p.phoneMsg').text('For International Numbers, ');
			$('dd.INTL').hide();
			$('dd.UK').show();
			return false;
		});

		
	$('div#content div#contactFormText dl dd').addClass('toggle');
	$('div#content div#contactFormText dl dt').toggle(
		function(event) {
			//$('div#content dl dd').show();
			},
		function(event) {
			//$('div#content dl dd').hide();
		});		

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='(+)';
var hideText='(-)';
var toggleTextState;

// append show/hide links to the element directly preceding the element with a class of "toggle"
$('.toggle').prev('dt').addClass('toggleLink').append('<a href="#" class="toggleText">'+showText+'</a>');

// hide all of the elements with a class of 'toggle'
$('.toggle').hide();

// capture clicks on the toggle links
$('.toggleLink').click(function() {

	// change the link depending on whether the element is shown or hidden
	toggleTextState=$(this).next('a').html();
	console.log(toggleTextState);
	toggleTextState==hideText ? $(this).next('a').html(showText) : $(this).next('a').html(hideText);
	
	// toggle the display - uncomment the next line for a basic "accordion" style
	//$('.toggle').hide();$('a.toggleLink').html(showText);
	$(this).next('.toggle').toggle('slow');
	
	// return false so any link destination is not followed
	return false;

});

});


/* jQuery for guitar pictures */
/* jQuery for sheet music search */


/* Jquery for hiding unfilled details on the piano page*/
$(document).ready(function() {
	$('dd:empty').prev('dt').remove();

	$("strong:contains('TBC')").text("£TBC")
});


