var xmlhttpFeaturedContent;
var t;
var xmlhttpStarts;
var CurrentState;
var UpdateState;
var StartThenStop;

//**********************************************************************
// Loads the current Room
//**********************************************************************
function InitialLoad(strQuery)
{
CurrentState = 1;
StartThenStop = 0;
FeaturedContent(strQuery);
//alert("Test"+strQuery);
//document.getElementById("PlayPause").innerHTML = "<img src=http://graphics.moneyshow.com/pause-button.png  height=18  />";
}


function StartTime()
{
 t = setTimeout('FeaturedContent()',10000);
	//alert("start");
}


function StopTimer()
{
	clearTimeout(t);
//	alert("stop");
}

function FadeMe()
{
$(document).ready(function() 
	{
  $('#FeaturedContent').cycle({fx: 'fade'});
	});// choose your transition type, ex: fade, scrollUp, shuffle, etc...
}

//**********************************************************************
// This function is used to create the xml Objects
//**********************************************************************

function FeaturedContent(strQuery)
{
xmlhttpFeaturedContent=GetXmlHttpObjectFeaturedContent();
if (xmlhttpFeaturedContent==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

if (CurrentState == 0)
{ 
  //Do stuff that stops it.
	StopTimer();			
	document.getElementById("PlayPause").innerHTML = "<img src=http://graphics.moneyshow.com/play-button.png height=18  />";
	return;
}

var url="/FeaturedModules/FeaturedContentSlide.asp";
url=url+"?"+strQuery;
xmlhttpFeaturedContent.onreadystatechange=stateChanged;
xmlhttpFeaturedContent.open("GET",url,true);
xmlhttpFeaturedContent.send(null);
return;
}


function stateChanged()
{
if (xmlhttpFeaturedContent.readyState==4)
  {
    document.getElementById("FeaturedContent").innerHTML=xmlhttpFeaturedContent.responseText;
    //fade("FeaturedContent");
    if (StartThenStop == 1 )
     {
       document.getElementById("PlayPause").innerHTML = "<img src=http://graphics.moneyshow.com/play-button.png height=18  />";  
       StartThenStop=0;
     }
    else
     {
       document.getElementById("PlayPause").innerHTML = "<img src=http://graphics.moneyshow.com/pause-button.png  height=18  />";  
     }

    StartTime();
    return;
  }
}




function ChangeStateStatus(strQuery)
{
if (CurrentState==1)
  {
   CurrentState=0;  
   StopTimer();
   //Do what you need here to stop the thing
  }
else
  {
   CurrentState=1;   
   FeaturedContent("");
  }
}

function LoadChangeImage()
{
if (CurrentState==1)
  {
   CurrentState=0;   
   document.getElementById("PlayPause").innerHTML = "<img src=http://graphics.moneyshow.com/play-button.png  height=20 border=1 />";
   return;
  }
else
  {
   CurrentState=1;   
			document.getElementById("PlayPause").innerHTML = "<img src=http://graphics.moneyshow.com/pause-button.png  height=20 border=1 />";
   FeaturedContent("");
   return;
  }
}


function ChangeEverythingNumbers(strQuery)
{
  CurrentState=1;
  StartThenStop=1;
  FeaturedContent(strQuery);
  CurrentState=0; 
  return;
}


var TimeToFade = 1000.0;

function fade(eid)
{
  var element = document.getElementById(eid);
  if(element == null)
    return;
   
  if(element.FadeState == null)
  {
    if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
    {
      element.FadeState = 2;
    }
    else
    {
      element.FadeState = -2;
    }
  }
    
  if(element.FadeState == 1 || element.FadeState == -1)
  {
    element.FadeState = element.FadeState == 1 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
  }
  else
  {
    element.FadeState = element.FadeState == 2 ? -1 : 1;
    element.FadeTimeLeft = TimeToFade;
    setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
  }  
}


function GetXmlHttpObjectFeaturedContent()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}


function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
