//---------------------------------------------------------------------------------
// Top rotating styles

var rotateStyle_old = new Array (
"<a href=\"energystar-award.asp\" class=\"rotate\" title=\"new energy star home plans\"><img src=\"/images/rotating/home-newes.jpg\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of new energy star home plan\" alt=\"image of new energy star home plan\"/></a><br/><a href=\"energystar-award.asp\" class=\"rotate\" title=\"new energy star home plans\">NEW ENERGY STAR</a>",
"<a href=\"ranch-house-plans.asp\" class=\"rotate\" title=\"one-story home plans\"><img src=\"/images/rotating/home-ranch4.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of one-story home plan\" alt=\"image of one-story home plan\"/></a><br/><a href=\"ranch-house-plans.asp\" class=\"rotate\" title=\"one-story house plans\">Ranch/One-Story</a>",
"<a href=\"craftsman-house-plans.asp\" class=\"rotate\" title=\"craftsman house plans\"><img src=\"/images/rotating/home-craftsman3-2259.jpg\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of craftsman house plan\" alt=\"image of craftsman house plan\"/></a><br/><a href=\"craftsman-house-plans.asp\" class=\"rotate\" title=\"craftsman house plans\">Craftsman</a>",
"<a href=\"luxury-house-plans.asp\" class=\"rotate\" title=\"luxury home plans\"><img src=\"/images/rotating/home-luxury3.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of luxury home plan\" alt=\"image of luxury home plans\"/></a><br/><a href=\"luxury-house-plans.asp\" class=\"rotate\" title=\"luxury home plans\">Luxury</a>",
"<a href=\"small-house-plans.asp\" class=\"rotate\" title=\"small house plans\"><img src=\"/images/rotating/home-small7.jpg\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of small house plan\" alt=\"image of small house plan\"/></a><br/><a href=\"small-house-plans.asp\" class=\"rotate\" title=\"small house plans\">Small</a>",
"<a href=\"beach-house-plans.asp\" class=\"rotate\" title=\"beach house plans\"><img src=\"/images/rotating/home-beach1.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of beach house plan\" alt=\"image of beach house plan\"/></a><br/><a href=\"beach-house-plans.asp\" class=\"rotate\" title=\"beach house plans\">Beach</a>",
"<a href=\"narrow-lot-house-plans.asp\" class=\"rotate\" title=\"narrow lot house plans\"><img src=\"/images/rotating/home-narrow3.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of narrow lot house plan\" alt=\"image of narrow lot house plan\"/></a><br/><a href=\"narrow-lot-house-plans.asp\" class=\"rotate\" title=\"narrow lot house plans\">Narrow Lot</a>",
"<a href=\"mediterranean-house-plans.asp\" class=\"rotate\" title=\"mediterranean house designs\"><img src=\"/images/rotating/home-mediterranean5.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of mediterranean house design\" alt=\"image of mediterranean house design\"/></a><br/><a href=\"mediterranean-house-plans.asp\" class=\"rotate\" title=\"mediterranean house design\">Mediterranean</a>",
"<a href=\"sloping-lot-house-plans.asp\" class=\"rotate\" title=\"sloping lot design plans\"><img src=\"/images/rotating/home-sloping-lot4.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of sloping lot design plan\" alt=\"sloping lot design plan\"/></a><br/><a href=\"sloping-lot-house-plans.asp\" class=\"rotate\" title=\"sloping lot design plans\">Sloping Lot</a>",
"<a href=\"country-french-house-plans.asp\" class=\"rotate\" title=\"french country house plans\"><img src=\"/images/rotating/home-country-french3.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of french country house plan\" alt=\"image of french country house plan\"/></a><br/><a href=\"country-french-house-plans.asp\" class=\"rotate\" title=\"french country house plans\">French Country</a>",
"<a href=\"farm-house-plans.asp\" class=\"rotate\" title=\"farm house plans\"><img src=\"/images/rotating/home-farm6.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of farm house plan\" alt=\"image of farm house plan\"/></a><br/><a href=\"farm-house-plans.asp\" class=\"rotate\" title=\"farm house plans\">Farm</a>",
"<a href=\"victorian-house-plans.asp\" class=\"rotate\" title=\"victorian home plans\"><img src=\"/images/rotating/home-victorian3.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of victorian home plan\" alt=\"image of victorian home plan\"/></a><br/><a href=\"victorian-house-plans.asp\" class=\"rotate\" title=\"victorian home plans\">Victorian</a>",
"<a href=\"european-house-plans.asp\" class=\"rotate\" title=\"european house schematic\"><img src=\"/images/rotating/home-european5.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of european home plan\" alt=\"image of european house home plan\"/></a><br/><a href=\"european-house-plans.asp\" class=\"rotate\" title=\"european house schematic\">European</a>",
"<a href=\"southern-house-plans.asp\" class=\"rotate\" title=\"southern design plans\"><img src=\"/images/rotating/home-southern3.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of southern design plan\" alt=\"image of southern design plan\"/></a><br/><a href=\"southern-house-plans.asp\" class=\"rotate\" title=\"southern design plans\">Southern</a>",
"<a href=\"two-story-house-plans.asp\" class=\"rotate\" title=\"two story house plans\"><img src=\"/images/rotating/home-two-story11-8276.jpg\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of two story house plan\" alt=\"image of two story house plan\"/></a><br/><a href=\"two-story-house-plans.asp\" class=\"rotate\" title=\"two story house plans\">Two Story</a>",
"<a href=\"contemporary-house-plans.asp\" class=\"rotate\" title=\"contemporary house plans\"><img src=\"/images/rotating/home-contemporary4.gif\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of contemporary house plan\" alt=\"image of contemporary house plan\"/></a><br/><a href=\"contemporary-house-plans.asp\" class=\"rotate\" title=\"contemporary house plans\">Contemporary</a>",
"<a href=\"exclusive-house-plans.asp\" class=\"rotate\" title=\"exclusive house plans\"><img src=\"/images/rotating/home-excusive-1771.jpg\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of exclusive house plan\" alt=\"image of exclusive house plan\"/></a><br/><a href=\"exclusive-house-plans.asp\" class=\"rotate\" title=\"exclusive house plans\">Exclusive</a>",
"<a href=\"plan_3d_list.asp\" class=\"rotate\" title=\"3D house plans\"><img src=\"/images/rotating/home-3d-5770.jpg\" width=\"167\" height=\"100\" border=\"0\" id=\"rotateimage2\" title=\"image of 3D house plan\" alt=\"image of 3D house plan\"/></a><br/><a href=\"plan_3d_list.asp\" class=\"rotate\" title=\"3D house plans\">3D Plans</a>"
);

// temp two story "/images/rotating/home-southern3.gif","southern-house-plans.asp","Southern","House Plans",
var numCells = 3;  // Change the number of images to rotate here.
var curCell = 1;
var numItems = rotateStyle.length;
var curStyle = 3;  // Change selected first rotate style here

function rotate(Nextstyle)
{
	//alert("curCell=" + curCell);
	var styleNum = (parseInt(Nextstyle)) + 0;
	var div = document.getElementById("rotate" + curCell);
	div.innerHTML = "";
	//var inner = document.createElement("inner");
	//div.appendChild(inner);
	document.getElementById("rotate" + curCell).style.opacity = 0;
	document.getElementById("rotate" + curCell).style.filter = 'alpha(opacity = ' + (0) + ')';
 	document.getElementById("rotate" + curCell).innerHTML = fillRotate(styleNum);
	fade("rotate" + curCell,"in");

	curCell ++;
	curStyle ++;
	if(curCell > numCells)curCell=1;
	if(curStyle >= numItems)curStyle=0;
	setTimeout("rotate(" + curStyle + ")",3000);
}
function fillRotate(passItem)
{
	var rotateItem = parseInt(passItem);
	//alert(rotateItem);
	if(rotateItem==1)
		document.getElementById("rotate1").style.backgroundColor="#568c51";
	if(rotateItem==3)
		document.getElementById("rotate1").style.backgroundColor="#4b7ea0";
	//alert(rotateStyle[rotateItem]);
	return rotateStyle[rotateItem];// + "<br>"
		//+ "" + rotateStyle[rotateItem+2] + "</a>";
}




var TimeToFade = 1000.0;

function fadeout(eid)
 {
 	fade(eid,"out");
 }
 
function fade(eid,direction)
 {
   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(direction=="out")
	  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 animateFade(lastTick, eid)
 {  
   var curTick = new Date().getTime();
   var elapsedTicks = curTick - lastTick;
   
  var element = document.getElementById(eid);
  
   if(element.FadeTimeLeft <= elapsedTicks)
   {
     element.style.opacity = element.FadeState == 1 ? '1' : '0';
     element.style.filter = 'alpha(opacity = ' 
        + (element.FadeState == 1 ? '100' : '0') + ')';
     element.FadeState = element.FadeState == 1 ? 2 : -2;
     return;
   }
  
   element.FadeTimeLeft -= elapsedTicks;
   var newOpVal = element.FadeTimeLeft/TimeToFade;
   if(element.FadeState == 1)
     newOpVal = 1 - newOpVal;
 
  element.style.opacity = newOpVal;
   element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
   
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
 }
