// JavaScript Document
function actFloatLayer(Margin, slideTime, layerName, Type, browser)
{  

   //===== initial the properties ===== begin =====

   

   switch(browser)

   {

      case (1):

                  find = (Type < 3) ? document.body.clientHeight : document.body.clientWidth;

                  current = (Type < 3) ? eval(layerName + ".style.pixelTop") : eval(layerName + ".style.pixelLeft");

                  scrollAt = (Type < 3) ? document.body.scrollTop : document.body.scrollLeft;

                  break;



      case (2): 

                  find = (Type < 3) ? window.innerHeight : window.innerWidth;

                  current = (Type < 3) ? eval("document." + layerName + ".top") : eval("document." + layerName + ".left");

                  scrollAt = (Type < 3) ? window.pageYOffset : window.pageXOffset;

                  break;



      case (3): 

                  find = (Type < 3) ? window.innerHeight : window.innerWidth;

                  current = (Type < 3) ? parseInt(eval("document.getElementById('" + layerName + "').style.top")) : parseInt(eval("document.getElementById('" + layerName + "').style.left")); 

                  scrollAt = (Type < 3) ? window.scrollY : window.scrollX;

                  break;

   }



   //===== initial the properties ===== end =====

 



   //========== Main Trigger ========== begin =====

   

   switch(Type)

   {

      case (1): case (3): //Type : top and left

         newTarget = scrollAt + Margin;

         break;

      case (2): case (4): //Type : bottom and right

         newTarget = scrollAt + find - Margin;

         break;

   }

   

   if ( current != newTarget ) 

   {        

      if (newTarget !=  this.target ) 

      { 

         //========== Start Float ========== begin =====



         target = newTarget;



         now = new Date();

         Mul = target - current;

         Wave = Math.PI / ( 2 * slideTime );

         Pass = now.getTime();



         if (Math.abs(Mul) > find) 

         { 

            

            Dis = (Mul > 0) ? target - find : target + find ;

            Mul = (Mul > 0) ? find : -find ;

         }

   

         else 	 

            Dis = current 



         //========== Start Float ========== end =====

      } 

      

      //========== Animator ========== begin =====



      now = new Date();

      newPosition = Mul * Math.sin( Wave * ( now.getTime() - Pass ) ) + Dis;



      newPosition = Math.round(newPosition);



      if (( Mul > 0 && newPosition > current ) || ( Mul < 0 && newPosition < current )) 

      { 

         switch(browser)

         {

            case (1):

                        (Type < 3) ? eval(layerName + ".style.pixelTop = newPosition;") : eval(layerName + ".style.pixelLeft = newPosition;");

                        break;

            case (2):

                        (Type < 3) ? eval("document." + layerName + ".top = newPosition;") : eval("document." + layerName + ".left = newPosition;");

                        break;

            case (3):

                        (Type < 3) ? eval("document.getElementById('" + layerName + "').style.top = newPosition + 'px';") : eval("document.getElementById('" + layerName + "').style.left = newPosition + 'px';");

                        break;

         }         

      }       



      //========== Animator ========== end =====

   } 



   //========== Main Trigger ========== end =====

}



function startFloatLayer(layerName, x, Margin, slideTime, Type) 

{

   //===== verify the Type ===== begin =====

   var browser;

   if (document.all)

      browser = 1;  //ie4



   if (document.layers)

      browser = 2;  //ns4



   if (!document.all && document.getElementById)

      browser = 3 ; //ns6

   

   setInterval("actFloatLayer(" + Margin + ", " + slideTime + ", '" + layerName + "', " + Type + ", " + browser + ")", 10);

}