//  Author: rapo
//  Credits: Peter-Paul Koch -  http://www.quircksmode.org
//  Date: 2002-2004


/*
  getDocumentObject
        Description: getDocumentObject function returns THE object
							from the document that has the provided id(name).
        Parameters: name - represents the id of the object
        Returns: the object if found or null (so check if not null!)
*/
function getDocumentObject(name)
{
  //NN6+, IE5+
  if (document.getElementById)
  {
            if(document.getElementById(name)){
                     this.obj = document.getElementById(name);
                     this.style = document.getElementById(name).style;
            }
            else return;
  }
  //IE4
  else if (document.all)
  {
            if(document.all[name]){
                   this.obj = document.all[name];
                   this.style = document.all[name].style;
            }
            else return;
  }
        //NN4
  else if (document.layers)
  {
           this.obj = getObjNN4(document,name);
           this.style = this.obj;
  }
  return this;
}


//used for NN4 to search in nested layers
//created by PPK - untouched by me
function getObjNN4(obj,name)
{
        var x = obj.layers;
        var thereturn;
        for (var i=0;i<x.length;i++)
        {
                if (x[i].id == name)
                         thereturn = x[i];
                else if (x[i].layers.length)
                        var tmp = getObjNN4(x[i],name);
                if (tmp) thereturn = tmp;
        }
        return thereturn;
}


/*
  getObjectProperty
  Description: the function searches for the object with the specified id
  					and if found returns the specified property value
               NOTE: undefined value may be returned if the object is found
               and its property was not explicitly defined
  Parameters: the id(name) of the object and the property of that object
  Returns: the value of the property if object found or null
*/
function getObjectProperty(id, property){
       var object=getDocumentObject(id);
       if(object!=null){
          var styleObject=object.style;
                if(styleObject[property]){
                     return styleObject[property];
                }
       }
       else return;
}

/*
  setObjectProperty
  Description: the function searches for the object with the specified id
               and if found the specified property is updated to value
  Parameters: the id(name) of the object,
              the property of that object,
              the new value for property;
  Returns:true(if succesfull)/false
*/

function setObjectProperty(id, property, value){
       var object=getDocumentObject(id);
       if(object!=null){
          var styleObject=object.style;
                if(styleObject[property]=value) return true;
       }
       else return false;
}


/*
  setPNGBackground
  Description: Applies a PNG image to a layer. The layer must not have a previous background,
  					and the size of the layer must be equal with the size of the background image.
               Speacial created for IE that can't handle translucent PNGs.
  Parameters: the id(name) of the object,
              the path to the PNG image.
  Returns:undefined
*/

function setPNGBackground(divId, path){
	 var foundDiv=getDocumentObject(divId).style;
	 var ua=navigator.userAgent.toLowerCase();
	 var ie=(document.all && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1));
	 if(ie){
    	foundDiv.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path+"', sizingMethod='scale')";
    }
    else{
      foundDiv.backgroundImage = 'url('+path+')';
    }
}




var styleObject=null;
var speed=200;
var step=1;
var max=350;
var course1=300;
var course2=150;
var course3=0;



function move(id,top,left){
  styleObject=getDocumentObject(id).style;
  if(styleObject){
  		styleObject.top=top;
  		styleObject.left=left;
  }
}


function recalculate(){
   course1+=step;
	if(course1<max+140){
		if(course1>max-10){
			setObjectProperty("extraDiv1","width",(150+max-course1)+"px");
		}
   	move("extraDiv1","0px",(course1-3)+"px");
	}
   else{
      course1=0;
      setObjectProperty("extraDiv1","display","none");
      setObjectProperty("extraDiv1","width","150px");
      move("extraDiv1","0px","-150px");
      setObjectProperty("extraDiv1","display","block");
   }

   course2+=step;
	if(course2<max+140){
		if(course2>max-10){
			setObjectProperty("extraDiv2","width",(150+max-course2)+"px");
		}
   	move("extraDiv2","0px",(course2-3)+"px");
	}
   else{
      course2=0;
      setObjectProperty("extraDiv2","display","none");
      setObjectProperty("extraDiv2","width","150px");
      move("extraDiv2","0px","-150px");
      setObjectProperty("extraDiv2","display","block");
   }

   course3+=step;
	if(course3<max+140){
		if(course3>max-10){
			setObjectProperty("extraDiv3","width",(150+max-course3)+"px");
			//move("extraDiv3","0px",course3+"px");
		}
		//else{
	   	move("extraDiv3","0px",(course3-3)+"px");
	   //}
	}
	//reset
   else{
      course3=0;
      setObjectProperty("extraDiv3","display","none");
      setObjectProperty("extraDiv3","width","150px");
      move("extraDiv3","0px","-150px");
      setObjectProperty("extraDiv3","display","block");
   }


	thread=window.setTimeout("recalculate()",speed);
}



window.onload = function()
{

  setObjectProperty("extraDiv4","display","none");
  //setObjectProperty("container","background","transparent");

  setObjectProperty("extraDiv1","display","block");
  setObjectProperty("extraDiv2","display","block");
  setObjectProperty("extraDiv3","display","block");
  if(document.body && document.body.clientWidth){
		max=350;
  }
  //  setPNGBackground("pageHeader","logo.png");
setPNGBackground("leftPane","leftPane.png");
  recalculate();

}
