Top_fix_margin=235;
hiden_menu_margin=200;
bottom_fix_margin=420;
floatX=0;
floatY=75;
layerwidth=335;
layerheight=310;
halign="left";
valign="Top";
delayspeed=2;

NS6=false;
IE4=(document.all);

if (!IE4) {
   NS6=(document.getElementById);
}

NS4=(document.layers);

function adjust() {
   if ((NS4) || (NS6)) {
      if (lastX==-1 || delayspeed==0) {
         //lastX=window.pageXOffset + floatX;
         lastX=0
         lastY=window.pageYOffset + floatY;
      }
      else {
         var dx=Math.abs(window.pageXOffset+floatX-lastX);
         var dy=Math.abs(window.pageYOffset+floatY-lastY);
         var d=Math.sqrt(dx*dx+dy*dy);
         var c=Math.round(d/10);
         	 if (window.innerHeight<=bottom_fix_margin) {
           if(window.innerHeight<hiden_menu_margin){
           lastY=window.pageYOffset-335;
           }else{
            lastY=window.pageYOffset-200;            
         }
         }
		if (Top_fix_margin>lastY) {
            lastY=Top_fix_margin; 
         }         

         if (window.pageXOffset+floatX>lastX) {
            //lastX=lastX+delayspeed+c;
            lastX=0;
         }

         if (window.pageXOffset+floatX<lastX) {
            //lastX=lastX-delayspeed-c;
            lastX=0;
         }

         if (window.pageYOffset+floatY>lastY) {
            lastY=lastY+delayspeed+c;
         }

         if (window.pageYOffset+floatY<lastY) {
            if (Top_fix_margin>=lastY){
            lastY=Top_fix_margin; 
            } else {
            lastY=lastY-delayspeed-c;
            }
         }
      }

      if (NS4) {
         document.layers['floatlayer'].pageX = lastX;
         document.layers['floatlayer'].pageY = lastY;
      }

      if (NS6) {
         document.getElementById('floatlayer').style.left=lastX;
         document.getElementById('floatlayer').style.top=lastY;
      }
   }
   else if (IE4) {
      if (lastX==-1 || delayspeed==0) {
         lastX=document.body.scrollLeft + floatX;
         lastY=document.body.scrollTop + floatY;
      }
      else {
         var dx=Math.abs(document.body.scrollLeft+floatX-lastX);
         var dy=Math.abs(document.body.scrollTop+floatY-lastY);
         var d=Math.sqrt(dx*dx+dy*dy);
         var c=Math.round(d/10);
          if (document.body.offsetHeight<=bottom_fix_margin) {
          if(window.innerHeight<hiden_menu_margin){
           lastY=document.body.scrollTop-335;
           }else{
           lastY=document.body.scrollTop-200;          
         }
         }
         
		if (Top_fix_margin>lastY) {
            lastY=Top_fix_margin;
         }
         if (document.body.scrollLeft+floatX>lastX) {
            //lastX=lastX+delayspeed+c;
            lastX=0;
         }

         if (document.body.scrollLeft+floatX<lastX) {
            //lastX=lastX-delayspeed-c;
            lastX=0;
         }

         if (document.body.scrollTop+floatY>lastY) {
            lastY=lastY+delayspeed+c;
         }

         if (document.body.scrollTop+floatY<lastY) {
            if (Top_fix_margin>=lastY){
            lastY=Top_fix_margin; 
            } else {
            lastY=lastY-delayspeed-c;
            }
         }
      }

      document.all['floatlayer'].style.posLeft = lastX;
       document.all['floatlayer'].style.posTop = lastY;
   }

   setTimeout('adjust()', 10);
   //alert(window.innerHeight)
}

function define() {
   if ((NS4) || (NS6)) {
      /*if (halign=="left") {
         floatX=ifloatX
             };

      if (halign=="right") {
         floatX=window.innerWidth-ifloatX-layerwidth-20
             };

      if (halign=="center") {
         floatX=Math.round((window.innerWidth-20)/2)-Math.round(layerwidth/2)
             };*/

      if (valign=="top") {
         floatY=ifloatY
             };

      if (valign=="bottom") {
         floatY=window.innerHeight-ifloatY-layerheight
             };

      if (valign=="center") {
         floatY=Math.round((window.innerHeight-20)/2)-Math.round(layerheight/2)
             };
   }

   if (IE4) {
      /*if (halign=="left") {
         floatX=ifloatX
             };

      if (halign=="right") {
         floatX=document.body.offsetWidth-ifloatX-layerwidth-20
             }

             if (halign=="center") {
                floatX=Math.round((document.body.offsetWidth-20)/2)-Math.round(layerwidth/2)
                    }*/

      if (valign=="top") {
          floatY=ifloatY
          };

      if (valign=="bottom") {
         floatY=document.body.offsetHeight-ifloatY-layerheight
          }

       if (valign=="center") {
         floatY=Math.round((document.body.offsetHeight-20)/2)-Math.round(layerheight/2)
          }
      
       }
 }
			  
function CreateLayer(){
if (NS4) {document.write('<LAYER NAME="floatlayer" z-index: 999 LEFT="'+floatX+'" TOP="'+floatY+'">');}
if ((IE4) || (NS6)) {document.write('<div id="floatlayer" style="position:absolute; z-index: 999 left:'+floatX+'; top:'+floatY+';">');}

document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="335" height="310" id="layer" align="middle">')
document.write('<param name="allowScriptAccess" value="sameDomain" />')
document.write('<param name="allowFullScreen" value="false" />')
document.write('<param name="movie" value="swf/html_submenu.swf" />')
document.write('<param name="quality" value="high" />')
document.write('<param name="wmode" value="transparent" />')
document.write('<param name="bgcolor" value="#00ffff" />')	
document.write('<embed src="swf/html_submenu.swf" quality="high" wmode="transparent" bgcolor="#00ffff" width="335" height="310" name="layer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
document.write('</object>')

if (NS4){document.write('</LAYER>');}
if ((IE4) || (NS6)){document.write('</DIV>');}

ifloatX=floatX;
ifloatY=floatY;
define();
window.onresize=define;
lastX=-1;
lastY=-1;
adjust();
}
			  


