

// Set speed (milliseconds)
var speed = 2000

  function foo(  element)
  {
      alert("me");
  }
 function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
   vis.opacity = (vis.opacity==''||vis.opacity=='0')?'1':'0';
   vis.position = (vis.position==''||vis.position=='relative')?'absolute':'relative';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}



  var inFromLeftwidth = 0;
  var OutToLeftwidth = -1000;
  var slideropacity = 0;

function slideInFromLeft(whichLayer)
{
  if( document.getElementById ) {// this is the way the standards work
    elem = document.getElementById( whichLayer );
     elem.style.left = inFromLeftwidth+"px";
     elem.style.opacity =100;
     inFromLeftwidth = inFromLeftwidth+10 ;
     slideropacity = slideropacity+1;
     if(inFromLeftwidth < 180)
     {
        setTimeout("slideInFromLeft('" + whichLayer+"')",5);
     }
     else
     {
       width = 10;
     }
   }
}
function slideOutToLeft(whichLayer)
{


  if( document.getElementById ) {// this is the way the standards work
    elem = document.getElementById( whichLayer );
     if(OutToLeftwidth == -1000)
      {
            x  = elem.style.left.indexOf('px');
             OutToLeftwidth = elem.style.left.substring(0,x);
             alert(OutToLeftwidth);
    }

     OutToLeftwidth = OutToLeftwidth-10;
      elem.style.left = OutToLeftwidth+"px";

     slideropacity = slideropacity+1;
    if(OutToLeftwidth > -800)
     {
        setTimeout("slideOutToLeft('" + whichLayer+"')",5);
     }
     else
     {
        OutToLeftwidth=-1000;
        elem.style.opacity=0;
         elem.style.border="1px xff0000";
         elem.style.left='-800px';
    }

   }
}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}
// Set Picture Array
var KitPic = new Array()

// Set Pics
KitPic[0] = 'img/homepage/kitchen1.JPG'
KitPic[1] = 'img/homepage/kitchen2.JPG'
KitPic[2] = 'img/homepage/kitchen3.JPG'
KitPic[3] = 'img/homepage/kitchen4.JPG'

var t
var j = 0
var p = KitPic.length
var KitchenOpac = 100;

var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = KitPic[i]
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 1;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",( timer *speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
function blendimage(divid, imageid, imagefile, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    
    //set the current image as background
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
    
    //make image transparent
    changeOpac(0, imageid);
    
    //make new image
    document.getElementById(imageid).src = imagefile;

    //fade in image
    for(i = 0; i <= 100; i++) {
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
        timer++;
    }
}
 function currentOpac(id, opacEnd, millisec) {
    //standard opacity is 100
    var currentOpac = 100;
    
    //if the element has an opacity set, get it
    if(document.getElementById(id).style.opacity < 100) {
        currentOpac = document.getElementById(id).style.opacity * 100;
    }

    //call for the function that changes the opacity
    opacity(id, currentOpac, opacEnd, millisec)
}
function runBGSlideShow(){
 if (document.body){

     opacity('sun-image', 0, 100, 5000)

   }
}
