var bcount = -1;//counter
var mySwitch = 0;
var t;//this var will hold the setTimeout() function
var imgPath_1 = '<img src="images/slideshow_audio_1.jpg" />';
var imgPath_2 = '<img src="images/slideshow_audio_2.jpg" />';
var imgPath_3 = '<img src="images/slideshow_audio_3.jpg" />';
var imgPath_4 = '<img src="images/slideshow_home_3.jpg" />';

var thumbs = ["slideshow_audio_equipment_btn.png","slideshow_audio_script_btn.png","slideshow_audio_faces_btn.png","slideshow_home_silence.png",""];
var currentSlideBtn = ["slideshow_audio_equipment_btn_over.png","slideshow_audio_script_btn_over.png","slideshow_audio_faces_btn_over.png","slideshow_home_silence_over.png",""]

//var thumbs = ["slideshow_audio_onhold_btn.png","slideshow_audio_script_btn.png","slideshow_audio_faces_btn.png","slideshow_audio_tom_btn.png",""];
//var currentSlideBtn = ["slideshow_audio_onhold_btn_over.png","slideshow_audio_script_btn_over.png","slideshow_audio_faces_btn_over.png","slideshow_audio_tom_btn_over.png",""]

function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

function timerFunction()
{
	bcount = bcount+1;//add 1 every time this function is executed
	
	if (bcount == 0)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (bcount == 1)
	{
		//fade in slide 1
		MM_effectAppearFade('imageContainer', 500, 0, 100, false);
		MM_effectAppearFade('myDov', 500, 0, 100, false);
		document.getElementById('imageContainer').innerHTML = imgPath_1;
		document.getElementById('myDov').innerHTML = '<h1>Equipment</h1>The type of equipment your On-Hold program utilizes can ultimately have an effect on the creative capacity of the message itself, which can positively or negatively affect the efficacy of your marketing efforts. Make sure you are using the latest equipment the industry has to offer.<br><span class="SlideshowLinks"><a href="subsections/equipment.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		document.getElementById('slide1_btn').innerHTML = '<img src="images/'+currentSlideBtn[0]+'" />';
		//document.getElementById('slide1_btn').style.border = "solid 0px #000000";
		document.getElementById('slide2_btn').innerHTML = '<img src="images/'+thumbs[1]+'" />';
		document.getElementById('slide3_btn').innerHTML = '<img src="images/'+thumbs[2]+'" />';
		document.getElementById('slide4_btn').innerHTML = '<img src="images/'+thumbs[3]+'" />';
	}
	else if (bcount == 10)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (bcount == 11)
	{
		//fade in slide 2
		MM_effectAppearFade('imageContainer', 500, 0, 100, false);
		MM_effectAppearFade('myDov', 500, 0, 100, false);
		document.getElementById('imageContainer').innerHTML = imgPath_2;
		document.getElementById('myDov').innerHTML = '<h1>Insight: The Scriptwriting Process</h1>OMG National makes a move to streamline their systems with hiring of new Creative Director Russ Riba and his technologically-efficient management style.<br><span class="SlideshowLinks"><a href="articles/insightscriptwriting.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';//write text inside the content div
		document.getElementById('slide1_btn').innerHTML = '<img src="images/'+thumbs[0]+'" />';
		document.getElementById('slide2_btn').innerHTML = '<img src="images/'+currentSlideBtn[1]+'" />';
		document.getElementById('slide3_btn').innerHTML = '<img src="images/'+thumbs[2]+'" />';
		document.getElementById('slide4_btn').innerHTML = '<img src="images/'+thumbs[3]+'" />';
	}
	else if (bcount == 20)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (bcount == 21)
	{
		//fade in slide 3
		MM_effectAppearFade('imageContainer', 500, 0, 100, false);
		MM_effectAppearFade('myDov', 500, 0, 100, false);
		document.getElementById('imageContainer').innerHTML = imgPath_3;
		document.getElementById('myDov').innerHTML = '<h1>The Faces of Voice</h1>A profile of one of our most popular talents, Debbie Feldman, and insight as to how she has become the voice of so many.<br><span class="SlideshowLinks"><a href="articles/voicefaces.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';//write text inside the content div
		document.getElementById('slide1_btn').innerHTML = '<img src="images/'+thumbs[0]+'" />';
		document.getElementById('slide2_btn').innerHTML = '<img src="images/'+thumbs[1]+'" />';
		document.getElementById('slide3_btn').innerHTML = '<img src="images/'+currentSlideBtn[2]+'" />';
		document.getElementById('slide4_btn').innerHTML = '<img src="images/'+thumbs[3]+'" />';
	}
	else if (bcount == 30)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (bcount == 31)
	{
		//fade in slide 4
		MM_effectAppearFade('imageContainer', 500, 0, 100, false);
		MM_effectAppearFade('myDov', 500, 0, 100, false);
		document.getElementById('imageContainer').innerHTML = imgPath_4;
		document.getElementById('myDov').innerHTML = '<h1>Silence is NOT Golden</h1>Make profitable use out of those precious on-hold moments. You cannot afford to miss the most opportune time to reach a captive audience.<br><span class="SlideshowLinks"><a href="articles/silenceisnotgolden.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';//write text inside the content div
		//document.getElementById('myDov').innerHTML = '<span class="SlideshowTitleText">TOM: The On-Hold of Tomorrow</span><br><br>The best sale is one that entertains your clients. Join us for an exploration on the newest trend in the On-Hold industry.<br><span class="SlideshowLinks"><a href="articles/tom.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';//write text inside the content div
		document.getElementById('slide1_btn').innerHTML = '<img src="images/'+thumbs[0]+'" />';
		document.getElementById('slide2_btn').innerHTML = '<img src="images/'+thumbs[1]+'" />';
		document.getElementById('slide3_btn').innerHTML = '<img src="images/'+thumbs[2]+'" />';
		document.getElementById('slide4_btn').innerHTML = '<img src="images/'+currentSlideBtn[3]+'" />';
	}
	else if (bcount == 40)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (bcount == 41)//if the counter reaches 25, reset it to -1
	{
		bcount = 0;
	}
	
	if (mySwitch == 0)
	{
		setTimeout("timerFunction()",500);//do this function every second
	} 
	else
	{
		return;
	}
	
}

function setSlideshowButtons()
{
	/*document.getElementById('slide1_btn').innerHTML = imgPath_1;
	document.getElementById('slide2_btn').innerHTML = imgPath_2;
	document.getElementById('slide3_btn').innerHTML = imgPath_3;
	document.getElementById('slide4_btn').innerHTML = imgPath_4;
	document.getElementById('slide5_btn').innerHTML = imgPath_5;*/
	for (var bcount=1; bcount<5; bcount++)
	{
		document.getElementById('slide'+bcount+'_btn').innerHTML = '<img src="images/'+thumbs[bcount-1]+'" />';
	}
}

function slideshowRollover(btnID,event)
{
	if (event.type == "mouseover")
	{
		document.getElementById(btnID).style.cursor = "pointer";
	}
	else if (event.type == "mouseout")
	{
		document.getElementById(btnID).style.cursor = "default";
	}
}

function slideButtonClick(btn)
{
	if (btn == "slide1_btn")
	{
		bcount = -1;
		document.getElementById('slide1_btn').style.border = "solid 0px #000000";
		document.getElementById('slide2_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide3_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide4_btn').style.border = "solid 0px #FFFFFF";
		
		if (mySwitch == 1)
		{
			document.getElementById('imageContainer').innerHTML = imgPath_1;
			document.getElementById('myDov').innerHTML = '<span class="SlideshowTitleText">Equipment</span><br><br>The type of equipment your On-Hold program utilizes can ultimately have an effect on the creative capacity of the message itself, which can positively or negatively affect the efficacy of your marketing efforts. Make sure you are using the latest equipment the industry has to offer.<br><span class="SlideshowLinks"><a href="subsections/equipment.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	else if (btn == "slide2_btn")
	{
		bcount = 9;
		document.getElementById('slide1_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide2_btn').style.border = "solid 0px #000000";
		document.getElementById('slide3_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide4_btn').style.border = "solid 0px #FFFFFF";
		
		if (mySwitch == 1)
		{
			document.getElementById('imageContainer').innerHTML = imgPath_2;
			document.getElementById('myDov').innerHTML = '<span class="SlideshowTitleText">Insight: The Scriptwriting Process</span><br><br>OMG National makes a move to streamline their systems with hiring of new Creative Director Russ Riba and his technologically-efficient management style.<br><span class="SlideshowLinks"><a href="articles/insightscriptwriting.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	else if (btn == "slide3_btn")
	{
		bcount = 19;
		document.getElementById('slide1_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide2_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide3_btn').style.border = "solid 0px #000000";
		document.getElementById('slide4_btn').style.border = "solid 0px #FFFFFF";
		
		if (mySwitch == 1)
		{
			document.getElementById('imageContainer').innerHTML = imgPath_3;
			document.getElementById('myDov').innerHTML = '<span class="SlideshowTitleText">The Faces of Voice</span><br><br>A profile of one of our most popular talents, Debbie Feldman, and insight as to how she has become the voice of so many.<br><span class="SlideshowLinks"><a href="articles/voicefaces.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	else if (btn == "slide4_btn")
	{
		bcount = 29;
		document.getElementById('slide1_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide2_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide3_btn').style.border = "solid 0px #FFFFFF";
		document.getElementById('slide4_btn').style.border = "solid 0px #000000";
		
		if (mySwitch == 1)
		{
			document.getElementById('imageContainer').innerHTML = imgPath_4;
			document.getElementById('myDov').innerHTML = '<span class="SlideshowTitleText">Silence is NOT Golden</span><br><br>Make profitable use out of those precious on-hold moments. You cannot afford to miss the most opportune time to reach a captive audience.<br><span class="SlideshowLinks"><a href="articles/silenceisnotgolden.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	
}

function pausePlaySlideshow()
{
	if (mySwitch == 0)
	{
		mySwitch = 1;
		MM_swapImage('play','','images/slideshow_control_play_blue.png',1);
		
	} else if (mySwitch == 1)
	{
		mySwitch = 0;
		timerFunction();
		MM_swapImgRestore();
	}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
