// #################################
// IMAGE SLIDESHOW START ///////////

// Title: Tigra Fader
// URL: http://www.softcomplex.com/products/tigra_fader/
// Version: 1.0 (commented source)
// Date: 07/23/2007
// Notes: This script is free. Visit official site for further details.

// See comments marked: //##ADDED
//	- a_captions
function tFader (a_items, a_tpl, a_captions, a_delays, iMaxCaptionLines)//, sDummyPlaceholderImage)
{

	// validate parameters and set defaults
	if (!a_items) return alert("items structure is missing");
	if (typeof(a_items) != 'object') return alert("format of the items structure is incorrect");
	if (a_items[a_items.length - 1] == null) return alert("last element of the items structure is undefined");
	if (!a_tpl) a_tpl = [];
	for (var i = 0; i < A_TSLIDEDEFS.length; i += 2)
		if (a_tpl[A_TSLIDEDEFS[i]] == null)
			a_tpl[A_TSLIDEDEFS[i]] = A_TSLIDEDEFS[i + 1];

	// save config parameters in the slider object
	this.a_tpl   = a_tpl;
	this.a_items = a_tpl.random ? tslide_randomize(a_items) : a_items;

	// initialize parameters, assign methods	
	this.n_currentSlide = 0;
	this.f_goto  = tslide_goto;
	this.f_run   = function () { this.b_running = 1; this.f_goto(); };
	this.f_stop  = function () { this.b_running = 0; clearTimeout(this.o_timerS); };
	this.f_fadeIn  = tslide_fadeIn;
	this.f_fadeOut = tslide_fadeOut;
	this.f_slideOp = tslide_slideOp;
	
	//##ADDED
	this.a_captions = a_captions;
	this.a_delays = a_delays;
	this.f_HideAllCaptions = tslide_HideAllCaptions;
	//##ADDED

	// register in the global collection	
	if (!window.A_SLIDES)
		window.A_SLIDES = [];
	this.n_id = window.A_SLIDES.length;
	window.A_SLIDES[this.n_id] = this;

	// generate control's HTML
	var s_attributes = ' '
		+ (a_tpl['css']    ? ' class="'  + a_tpl['css']    + '"' : '')
		+ (a_tpl['width']  ? ' width="'  + a_tpl['width']  + '"' : '')
		+ (a_tpl['height'] ? ' height="' + a_tpl['height'] + '"' : '')
		+ (a_tpl['alt']    ? ' title="'  + a_tpl['alt']    + '" alt="' + a_tpl['alt'] + '"' : '');


	//##ADDED
	if(a_captions)
	{
		this.a_captionRefs = [];
		for (var i = 0; i < this.a_items.length; i++)
		{
			document.write('<b><font color="#000099"><i><a style="display:none;position:absolute;" name="tcaption', this.n_id, '_', i, '" />', this.a_captions[i], '</a></i></font></b>');
		//	document.write('<a href="http://www.test.com" style="display:none;position:absolute;" name="tcaption', this.n_id, '_', i, '" />', this.a_captions[i], '</a>');
			if(iebrowser)
				this.a_captionRefs[i] = document.anchors('tcaption' + this.n_id + '_' + i);
			else
				this.a_captionRefs[i] = document.anchors['tcaption' + this.n_id + '_' + i];
		}//i

		// Hide the placeholder
	//	if(sDummyPlaceholderImage != "")
	//	{
		//	var e_DummyPlaceholderImage = document.getElementById(sDummyPlaceholderImage);
		//	e_DummyPlaceholderImage.style.visibility = "hidden";
		//	alert(e_DummyPlaceholderImage.id);
	//	}
		
		// Show the first caption
		this.a_captionRefs[0].style.display = "";
		
		// Add as many CRs as you like
		for (var i = 0; i < iMaxCaptionLines; i++)
		{
			document.write ('<BR/>');
		}
	}

//	alert(1);


	//##ADDED

	
	document.write ('<a href="buy.htm"><img alt="music notation software image" border="0" src="', this.a_items[0] , '"', s_attributes, ' name="tslide', this.n_id, '_0"  /></a>');


	this.a_imgRefs = [];
	this.a_imgRefs[0] = document.images['tslide' + this.n_id + '_0'];
	this.n_currentSlide = 0;
	


	// exit on old browsers
	if (!this.a_imgRefs[0] || !this.a_imgRefs[0].style || this.a_imgRefs[0].style.marginLeft == null)
		return;

	for (var i = 1; i < this.a_items.length; i++)
	{
		document.write('<a href="buy.htm"><img alt="music notation software image" border="0" src="', this.a_items[i] , '"', s_attributes, ' name="tslide', this.n_id, '_', i, '" style="position:absolute;z-index:-1;filter:alpha(opacity=100);" /></a>');
			
		this.a_imgRefs[i] = document.images['tslide' + this.n_id + '_' + i];
		this.a_imgRefs[i].style.marginLeft = '-' + this.a_tpl.width + 'px';
		this.f_slideOp(i, 0);
		this.a_imgRefs[i].style.zIndex = i;
	}

	// calculate transition variables
	this.n_timeDec = Math.round(this.a_tpl['transtime'] * 1e3 / this.a_tpl['steps']);
	this.n_opacDec = Math.round(100 / this.a_tpl['steps']);

	// run this sucker
	this.f_run();
}

function tslide_HideAllCaptions(total, except)
{
	// Hide all others
//	alert(total);
	for(var i = 0; i < total; i++)
	{
		if(i != except)
		{
			var e_captionOld = this.a_captionRefs[i];
			e_captionOld.style.display = "none";
		}
	}//i
}

function tslide_fadeOut (n_opacity) {
	// new transition
	if (n_opacity == null)
	{
		n_opacity = 99;
		this.f_slideOp(this.n_nextSlide, 99);
	}
	n_opacity -= this.n_opacDec;
	// end of transition
	if (n_opacity < 0) {
		this.f_slideOp(this.n_currentSlide, 0);
		this.n_currentSlide = this.n_nextSlide;
		this.n_nextSlide = null;
		return this.f_run();
	}
	// set transparency
	this.f_slideOp(this.n_currentSlide, n_opacity);

	// cycle
	this.o_timerT = setTimeout('A_SLIDES[' + this.n_id + '].f_fadeOut(' + n_opacity + ')', this.n_timeDec);
}

function tslide_fadeIn (n_opacity) {
	// new transition
	if (n_opacity == null)
	{
		n_opacity = 0;

		//##ADDED
		if(this.a_captions)
		{
			this.f_HideAllCaptions(this.a_captions.length, this.n_nextSlide);
			var e_caption = this.a_captionRefs[this.n_nextSlide];
			e_caption.style.display = "";
		//	alert(this.n_nextSlide);
		}
		//##ADDED
	}

	n_opacity += this.n_opacDec;
	// end of transition
	if (n_opacity > 99) {
		this.f_slideOp(this.n_nextSlide, 99);
		this.f_slideOp(this.n_currentSlide, 0);
		this.n_currentSlide = this.n_nextSlide;
		this.n_nextSlide = null;
		return this.f_run();
	}
	// set transparency
	this.f_slideOp(this.n_nextSlide, n_opacity);

	// cycle
	this.o_timerT = setTimeout('A_SLIDES[' + this.n_id + '].f_fadeIn(' + n_opacity + ')', this.n_timeDec);
}


function tslide_goto (n_slide, b_now) {

	
	// cancel any scheduled transitions	
	if (this.o_timerS) {
		clearTimeout(this.o_timerS);
		this.o_timerS = null;
		if (this.n_nextSlide) {
			this.f_slideOp(this.n_nextSlide, 0);
			this.n_nextSlide = null;
		}
	}

	// determine the next slide
	this.n_nextSlide = (n_slide == null ? this.n_currentSlide + 1 : n_slide) % this.a_items.length;


	if (this.n_nextSlide == this.n_currentSlide) return;

	//##ADDED
	if(this.a_captions)
	{
		this.f_HideAllCaptions(this.a_captions.length, this.n_currentSlide);
		var e_caption = this.a_captionRefs[this.n_currentSlide];
		e_caption.style.display = "";
	}
	//##ADDED
	
	// schedule transition
	this.o_timerS = setTimeout('A_SLIDES[' + this.n_id + '].f_fade'
		+ (this.n_nextSlide > this.n_currentSlide ? 'In' : 'Out') + '()',
	//	 (b_now ? 0 : (slidetime ? this.a_delays[this.n_currentSlide] * 1e3 : this.a_tpl['slidetime'] * 1e3)));
		 (b_now ? 0 : (this.a_delays ? this.a_delays[this.n_currentSlide] * 1e3 : this.a_tpl['slidetime'] * 1e3)));
}


function tslide_slideOp (n_slide, n_opacity) {
	if (!n_slide) return;
	var e_slide = this.a_imgRefs[n_slide];
	tslide_setOpacity(e_slide, n_opacity);
}

function tslide_randomize (a_source) {
	var n_index,
		a_items = [];
	while (a_source.length) {
		n_index = Math.ceil(Math.random() * a_source.length) - 1;
		a_items[a_items.length] = a_source[n_index];
		a_source[n_index] = a_source[a_source.length - 1];
		a_source.length = a_source.length - 1;
	}
	return a_items;
}

// cross-browser opacity
var s_uaApp  = navigator.userAgent.toLowerCase();
if (s_uaApp.indexOf('opera') != -1 || s_uaApp.indexOf('safari') != -1)
	window.tslide_setOpacity = function (e_element, n_opacity) {
		e_element.style.opacity = n_opacity / 100;
	};
else if (s_uaApp.indexOf('gecko') != -1)
	window.tslide_setOpacity = function (e_element, n_opacity) {
		e_element.style.MozOpacity = n_opacity / 100;
	};
else if (s_uaApp.indexOf('msie') != -1)
	window.tslide_setOpacity = function (e_element, n_opacity) {
		try { e_element.filters.alpha.opacity = n_opacity } catch (e) {};
	};
else
	window.tslide_setOpacity = null;


// defaults
var A_TSLIDEDEFS = [
	'steps', 40,
	'css', '',
	'transtime', 0.5,
	'slidetime', 2
];

// IMAGE SLIDESHOW END /////////////
// #################################









// #################################
// TEXT SCROLLER START /////////////

var scroller_width='100px'
// has to be reduced a little or enlarges navbar height
var scroller_height='83px'
var bgcolor='transparent'
//var bgcolor='rgb(202, 176, 141)'
var pause = 8000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)

// custom added
var degree=5
var speed=50


var scrollercontent=new Array()


//Define scroller contents. Extend or contract array as needed

var sTLink = '<a class=\"link_testimonial\" href=\"testimonials.htm\">'

for(var i = 0; i < 14; i++)
{
	var sText, sAuthor

	if(i == 0)
	{
		sText = 'What are MidiIllustrator customers saying about our notation software?'
		sAuthor = '...'
	}
	else if(i == 1)
	{
		sText = '...a great product with great support behind it'
		sAuthor = 'Harry Williams, UK'
	}
	else if(i == 2)
	{
		sText = 'Beautiful scores always.&nbsp; MI is a wonderful system!'
		sAuthor = 'Agnetha Hansen, Norway'
	}
	else if(i == 3)
	{
		sText = 'I am using [MIDI] exercises with the practice tools... every day'
		sAuthor = 'Bob Diver, Australia'
	}
	else if(i == 4)
	{
		sText = 'My students really benefit from the simplified notation options'
		sAuthor = 'Simon Davies, USA'
	}
	else if(i == 5)
	{
		sText = '...I use MI constantly.&nbsp; Keep up the good work'
		sAuthor = 'Jeff Wood, UK'
	}
	else if(i == 6)
	{
		sText = 'with MI... I am learning the piano again after 10 years away'
		sAuthor = 'Peter Seymour, USA'
	}
	else if(i == 7)
	{
		sText = 'Great value software.'
		sAuthor = 'Andrés Rodriguez, Spain'
	}
	else if(i == 8)
	{
		sText = 'I am enjoying learning all the many things it [MI] can do'
		sAuthor = 'Gijsbert Verbeck, Holland'
	}
	else if(i == 9)
	{
		sText = 'The <i>\"Convert Song to Solo Piano\"</i> option is a stroke of genius!'
		sAuthor = 'Oscar Brown, USA'
	}
	else if(i == 10)
	{
		sText = 'My kids are actually using this program.  Thanks MI Team!'
		sAuthor = 'Karen Walters, USA'
	}
	else if(i == 11)
	{
		sText = '...at last my sight reading is coming on... now with MidiIllustrator'
		sAuthor = 'Phil Sykes, UK'
	}
	else if(i == 12)
	{
		sText = 'Thanks for all your support getting me started with the music'
		sAuthor = 'Axel Adelsvärd, Sweden'
	}
	else if(i == 13)
	{
		sText = 'Who knew there was so much sight reading material?  MI is perfect...'
		sAuthor = 'Lili Stock, Canada'
	}
	else if(i == 14)
	{
		sText = 'Your responsiveness is amazing - [you\'re] creating great software.'
		sAuthor = 'James Bryant, UK'
	}

	scrollercontent[i] = sTLink + sText + '</a><br><br><div align=\"right\">' + sTLink + sAuthor + '</a></div>'
}


function TranslucentScroller()
{
	if (iebrowser||dom)
		document.write('<div style="position:relative;width:'+scroller_width+';height:'+scroller_height+';overflow:hidden"><div id="canvas0" style="position:absolute;background-color:'+bgcolor+';width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2;"></div><div id="canvas1" style="position:absolute;background-color:'+bgcolor+';width:'+scroller_width+';height:'+scroller_height+';top:'+scroller_height+';filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2;"></div></div>')
	else if (document.layers)
	{
		// Added overflow setting for FF
		document.write('<ilayer id=tickernsmain visibility=hide style="overflow:hidden;" width='+scroller_width+' height='+scroller_height+' bgColor='+bgcolor+'><layer id=tickernssub width='+scroller_width+' height='+scroller_height+' left=0 top=0>'+scrollercontent[0]+'</layer></ilayer>')
	}

// don't override
	if(iebrowser||dom||document.layers)
//		window.onload=TranslucentScroller_Start
		TranslucentScroller_Start();
}

var curpos=scroller_height*(1)
var curcanvas="canvas0"
var curindex=0
var nextindex=1

var bMouse = 0

function moveslide()
{
	if (curpos>0)
	{
		curpos=Math.max(curpos-degree,0)
		tempobj.style.top=curpos+"px"
	}
	else
	{
		clearInterval(dropslide)
		if (crossobj.filters)
			crossobj.filters.alpha.opacity=100
		else if (crossobj.style.MozOpacity)
			crossobj.style.MozOpacity=1
		else
		{
			// CSS 3 for Google Chrome
			crossobj.style.opacity = 1;
		}


		nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"

		// Make the last canvas vanish completely when the other one has scrolled in
		if(curcanvas=="canvas0")
		{
			if(crossobj.filters)
				document.all.canvas0.filters.alpha.opacity = 0
			else if(crossobj.style.MozOpacity)
				document.getElementById("canvas0").style.MozOpacity = .0
			else
			{
				document.getElementById("canvas0").style.opacity = .0;
			}
		}
		else
		{
			if(crossobj.filters)
				document.all.canvas1.filters.alpha.opacity = 0
			else if(crossobj.style.MozOpacity)
				document.getElementById("canvas1").style.MozOpacity = .0
			else
			{
				document.getElementById("canvas1").style.opacity = .0;
			}
		}

		tempobj=iebrowser? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
		tempobj.innerHTML=scrollercontent[curindex]
		nextindex=(nextindex<scrollercontent.length-1)? nextindex+1 : 0
		setTimeout("rotateslide()",pause)
	}
}

function rotateslide()
{

	// If mouse over, do not move onto next item
	//
	var obj =iebrowser? iebrowser["table_testimonials"] : document.getElementById("table_testimonials")
	obj.onmouseover=function(){bMouse=1}
	obj.onmouseout=function(){bMouse=0}

	if(bMouse == 1)
	{
//		curpos = 0
//		crossobj.style.top = 0

		// we have to try again later!
		setTimeout("rotateslide()",pause)
		return
	}

	if (iebrowser||dom)
	{
		resetit(curcanvas)
		crossobj=tempobj=iebrowser? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
		crossobj.style.zIndex++

		if(crossobj.filters)
		{
			document.all.canvas0.filters.alpha.opacity=document.all.canvas1.filters.alpha.opacity = 20
		}
		else if(crossobj.style.MozOpacity)
		{
			document.getElementById("canvas0").style.MozOpacity=document.getElementById("canvas1").style.MozOpacity = .2
		}
		else
		{
			document.getElementById("canvas0").style.opacity = 0.2;
			document.getElementById("canvas1").style.opacity = 0.2;
		}

		// speed of scroll up
		var temp='setInterval("moveslide()",' + speed + ')'
		dropslide=eval(temp)
		curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
	}
	else if (document.layers)
	{
		crossobj.document.write(scrollercontent[curindex])
		crossobj.document.close()
	}
	curindex=(curindex<scrollercontent.length-1)? curindex+1 : 0
}

function resetit(what)
{
	curpos=parseInt(scroller_height)*(1)
	var crossobj=iebrowser? eval("document.all."+what) : document.getElementById(what)
	crossobj.style.top=curpos+"px"
}

function TranslucentScroller_Start()
{
	crossobj=iebrowser? eval("document.all."+curcanvas) : dom? document.getElementById(curcanvas) : document.tickernsmain.document.tickernssub
	if (iebrowser||dom)
	{
		crossobj.innerHTML=scrollercontent[curindex]
		rotateslide()
	}
	else
	{
		document.tickernsmain.visibility='show'
		curindex++
		setInterval("rotateslide()",pause)
	}
}



// TEXT SCROLLER END /////////////
// #################################



