var i = -1;//counter
var mySwitch = 0;
var t;//this var will hold the setTimeout() function
var imgPath_1 = '<img src="images/slideshow_home_inc5000.jpg" />';
var imgPath_2 = '<img src="images/slideshow_home_1.jpg" />';
var imgPath_3 = '<img src="images/slideshow_home_4.jpg" />';
//old one var imgPath_3 = '<img src="images/slideshow_home_3.jpg" />';
var imgPath_4 = '<img src="images/rapp_header.jpg" />';

var thumbs = ["slideshow_home_inc5000_btn.png","slideshow_home_newomg.png","slideshow_home_nfib.png","slideshow_home_rapp.png",""];
var currentSlideBtn = ["slideshow_home_inc5000_btn_over.png","slideshow_home_newomg_over.png","slideshow_home_nfib_over.png","slideshow_home_rapp_over.png",""]

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

function timerFunction()
{
	i = i+1;//add 1 every time this function is executed
	
	if (i == 0)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (i == 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>OMG! The Inc.5000</h1>OMG National is featured on the Inc.5000 list of America&#39;s fastest growing companies.<br><br><span class="SlideshowLinks"><a href="subsections/inc5000.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 (i == 10)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (i == 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>The New OMG</h1>OMG National has come a long way in the past two decades. OMG National&#39;s Chief Creative Officer, Michael Rappaport, provides insight on the company&#39;s future direction.<br><br><span class="SlideshowLinks"><a href="articles/newomg.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 (i == 20)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (i == 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>NFIB Affinity Partner</h1>OMG National and the NFIB have partnered to provide Telephone On-Hold messages to 300,000+ members. Check out the latest from one of the leading marketing companies in the industry.<br><br><span class="SlideshowLinks"><a href="articles/nfib.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 (i == 30)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (i == 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>The Rapp Sheet: A Second Chance</h1>A compelling look at Mike Rappaport&acute;s recovery from the edge of death. Tune in weekly as Mike offers updates and information from his recovery and his new outlook on life.<br><br><span class="SlideshowLinks"><a href="articles/rappsheet.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 (i == 40)
	{
		//fade out current slide
		MM_effectAppearFade('imageContainer', 500, 100, 0, false);
		MM_effectAppearFade('myDov', 500, 100, 0, false);
	}
	else if (i == 41)//if the counter reaches 25, reset it to -1
	{
		i = 0;
	}
	
	if (mySwitch == 0)
	{
		setTimeout("timerFunction()",900);//do this function every x(00) seconds ie 500 = 5sec 900=9sec
	} 
	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 i=1; i<5; i++)
	{
		document.getElementById('slide'+i+'_btn').innerHTML = '<img src="images/'+thumbs[i-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")
	{
		i = -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 = '<h1>OMG! The Inc.5000</h1>OMG National is featured on the Inc.5000 list of America&#39;s fastest growing companies.<br><br><span class="SlideshowLinks"><a href="subsections/inc5000.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	else if (btn == "slide2_btn")
	{
		i = 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">The New OMG</span><br><br>OMG National has come a long way in the past two decades. OMG National&acute;s Chief Creative Officer, Michael Rappaport, provides insight on the company&acute;s future direction.<br><br><span class="SlideshowLinks"><a href="articles/newomg.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	else if (btn == "slide3_btn")
	{
		i = 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">NFIB Affinity Partner</span><br><br>OMG National and the NFIB have partnered to provide Telephone On-Hold messages to 300,000+ members. Check out the latest from one of the leading marketing companies in the industry.<br><br><span class="SlideshowLinks"><a href="articles/silenceisnotgolden.php">Learn More<img src="images/learnarrow.jpg" border="0" align="absmiddle" /></a></span>';
		}
		
	}
	else if (btn == "slide4_btn")
	{
		i = 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">The Rapp Sheet: A Second Chance</span><br><br>A compelling look at Mike Rappaport&acute;s recovery from the edge of death. Tune in weekly as Mike offers updates and information from his recovery and his new outlook on life.<br><br><span class="SlideshowLinks"><a href="articles/rappsheet.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];}
}