//--------------------------------------------------------------------
function GetCurrentDocumentName() {
   var href = window.location.href; //.replace("http://localhost",'');
   
   var endpos = href.indexOf("//localhost",0);
   if (endpos > 0 ){href = href.substr(endpos + 11);}
   
   endpos = href.indexOf(".com",0);
   if (endpos > 0 ){href = href.substr(endpos + 4);}
   
   endpos = href.indexOf("?",0);
   if (endpos > 0) {href = href.substr(0,endpos);}
   
   //alert ("href=" + href);
   if (href == "/") href = "default.html";
   
   return href;
}

function uuid() 
{ 
   var chars = '0123456789abcdef'.split(''); 
 
   var uuid = [], rnd = Math.random, r; 
   uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-'; 
   uuid[14] = '4'; // version 4 
 
   for (var i = 0; i < 36; i++) 
   { 
      if (!uuid[i]) 
      { 
         r = 0 | rnd()*16; 
 
         uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf]; 
      } 
   } 
 
   return uuid.join(''); 
} 

function rGetUrlParameter( name ){  
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
  var regexS = "[\\?&]" + name + "=([^&#]*)";  
  var regex = new RegExp( regexS );  
  var results = regex.exec( window.location.href );  
  if( results == null )   
     return "";  
  else    
     return results[1];
}


function rRedirectOnAspxErrorPath(aspxerrorpath) {

  //alert("aspxerrorpath:" + aspxerrorpath);
  var xurl;
  switch (aspxerrorpath) {
  
      case "/be/betroubleshoot.aspx": 
          xurl = "/be/betroubleshoot.html";
          break;
          
       case "/be/betips.aspx": 
          xurl = "/be/betips.html";
          break;
          
       case "/be/belegal_section.aspx": 
          xurl = "/be/belegalsection.html";
          break;
       case "/be/behelp.aspx": 
          xurl = "/be/behelp.html";
          break;
          
        case "/be/bedownload.aspx": 
          xurl = "/be/bedownload.html";
          break;  
          
        case "/be/benews.aspx": 
          xurl = "/be/benews.html";
          break;
        
        case "/be/beregistration.aspx":  
          xurl = "/be/beregistration.html";
          break;
          
        case "/be/befaq.aspx":  
          xurl = "/be/befaq.html";
          break;
          
        case "/be/bedescription.aspx":  
          xurl = "/be/bedescription.html";
          break;
          
        case "/blocklibrary.aspx":  
          xurl = "/be/blocklibrary.html";
          break;  
          
       case "/blockmanager.aspx":  
          xurl = "/be/blockmanager.html";
          break;  
          
       case "/contactus.aspx":  
          xurl = "/clickthrough/contactus.aspx";
          break;  
          
       case "/librarymanager.aspx":  
          xurl = "/be/librarymanager.html";
          break;           
          
       case "/librarymaker.aspx":  
          xurl = "/be/blockcollector.html";
          break;              
          
       case "/modifyblock.aspx":  
          xurl = "/be/modifyblocks.html";
          break;                 
          
       case "/replaceblocks.aspx":  
          xurl = "/be/replaceblocks.html";
          break;                    
       
       case "/standardsmanager.aspx":  
          xurl = "/be/standardsmanager.html";
          break;                         
          
        default:
          xurl = "/be/bedescription.html";
          break;                        
  }    
  
  //alert("xurl:" + xurl);
  window.location.href = xurl;
}

function rRedirectOnTab() {
  
  
  var aspxerrorpath = rGetUrlParameter("aspxerrorpath");
  
  if (aspxerrorpath != '') {
    rRedirectOnAspxErrorPath(aspxerrorpath.toLowerCase());
    return;
  }
  
  var xtab = rGetUrlParameter("tab");
  
  var xurl;
  
  // get current page url  
  var href = window.location.href.replace("http://localhost",'');
  var endpos = href.indexOf(".com",0);
  if (endpos > 0 ){href = href.substr(endpos + 4);}
  endpos = href.indexOf("?",0);
  
  var args;
  if (endpos > -1) {
   args = href.substr(endpos + 1);
   href = href.substr(0,endpos);
  }
  
  if (xtab == ''){
    // not for root cases
    if (href.indexOf("default.html",2) < 0){
      //alert("case1: " + href);
      if (href == "/be/"){
        xurl = "/be/bedescription.html";
      }
      else
        return;
    }
    else {
     xurl = "/be/bedescription.html";
     //alert("case2");
    } 
  }
  
  //alert("pos=" + href.indexOf("default.html",2));
  
  
  switch (xtab) {
        case "benews": 
          xurl = "/be/benews.html";
          break;
          
        case "hlpsearch":  
          xurl = "/Products/ProductHelpIndex.htlm";
          break;
        
        case "personalize":
          xurl = "/UserProfile/UpdateInfo.htlm";
          break;
          
        case "behow2start":
          xurl = "/be/BeHowToStart.html";
          break;
        
        case "beregister":
          xurl = "/be/BeRegistration.html";
          break;
        
        case "belegal":
          xurl = "/be/BeLegalSection.html";
          break;
          
        case "befaq":
          xurl = "/be/BeFaq.html";
          break;
          
        case "exchange":
          xurl = "/belibraries/beexchange.html";
          break;
          
        case "betroubleshoot":
          xurl = "/be/BeTroubleshoot.html";
          break;            
        
        case "bedownload":
          xurl = "/be/BeDownload.html";
          break;            
          
        case "support":
          xurl = "/userprofile/ServiceRequest.aspx";
          break;            
          
        case "home":
          xurl = "/be/../default.html";
          break;            
        
        case "buyext":
          xurl = "/store/ViewCart.aspx";
          break;            
          
        case "registerlib":
          xurl = "/store/viewcart.aspx";
          break;            
          
        case "submitlib":
          xurl = "/belibraries/submitcustomlibrary.aspx";
          break;                        
          
        default:
          xurl = "/be/bedescription.html";
          break;                        
  }    
  
  
  if (xurl == null){return;}
   
   
  if (args != null){  
   if (xurl.toLowerCase() != href.toLowerCase()) {
    // append all arguments exept tab
     args = args.replace("tab=" + xtab,'');
     if (args != ''){args = "?" + args;}
        window.location.href = xurl + args;
   }
  } 
  else {
     window.location.href = xurl;
  } 
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function rGetCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
//	Please note that the above version fixes some fairly serious issues with the old version, here listed below for comparison. The original utterly fails to handle cases where cookie names are substrings of other cookies

function rSetCookie(name, value, expiresDays, path, domain, secure )
{
    //Set_Cookie( 'mycookie', 'visited 9 times', 30, '/', '', '' );. 
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );

    /*
        if the expires variable is set, make the correct
        expires time, the current script below will set
        it for x number of days, to make it for hours,
        delete * 24, for minutes, delete * 60 * 24
    */
    if ( expiresDays != null )
    {
        var expires = expiresDays * 1000 * 60 * 60 * 24; // days
    }
    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}
			

function rWriteToCookie (WhichCookie,WhichValue,WhichPath) {
   
   var ExpDate = new Date();
   // expires in 10 min
   ExpDate.setTime( ExpDate.getTime() + (1000 * 60 * 10 * 1 * 1) );
   document.cookie = WhichCookie + "=" + WhichValue + 
                    "; path=" + WhichPath + 
                    "; expires=" + ExpDate.toGMTString();
}
   
function rfIsAnyBoxChecked(formid){
    if (rfIsMSIE()){ 
      return rfIsAnyBoxCheckedIE(formid);
    }
    else  {
      return rfIsAnyBoxCheckedFireFox(formid);
    }  
}
function rfIsAnyBoxCheckedIE(formid){
    var e = document.getElementById(formid).elements;
    for (var i=0; i < e.length; i++) {
    //  alert(e[i].type);
      if(e[i].type == 'checkbox')
         if (e[i].checked) return true;
    }
    return null;
}
function rfIsAnyBoxCheckedFireFox(formid){
    var e = document.getElementById(formid).elements;
    for(i in e) {
      if (e[i].type == 'checkbox')
       if (e[i].checked) return true;
    }
    return null;
}

function rCheckAllBoxes(formid,fIsChecked){
    if (rfIsMSIE())
       rCheckAllBoxesIE(formid,fIsChecked);
    
    else  
       rCheckAllBoxesFireFox(formid,fIsChecked);
}

function rCheckAllBoxesIE(formid,fIsChecked){
    var e = document.getElementById(formid).elements;
    for (var i=0; i < e.length; i++) {
      if(e[i].type == 'checkbox')
         e[i].checked=fIsChecked;
    }
}

function rCheckAllBoxesFireFox(formid,fIsChecked){
    var e = document.getElementById(formid).elements;
    for(i in e) {
      if (e[i].type == 'checkbox')
       e[i].checked=fIsChecked;
    }
}

function fAllBoxesChecked(formid,sPattern){
    if (rfIsMSIE()){
      if (fAllBoxesCheckedIE(formid,sPattern)){
       return true;
      } 
    }
    else {  
      if (fAllBoxesCheckedFireFox(formid,sPattern)){
       return true;
      } 
    }
    return false;  
}

function fAllBoxesCheckedIE(formid,sPattern){
    var e = document.getElementById(formid).elements;

    for (var i=0; i < e.length; i++) {
      if(e[i].type == 'checkbox') {
        if (e[i].getAttribute('id').substring(0, sPattern.length) == sPattern){
          if (!e[i].checked) {
           return false;
          } 
        }
      }
    }
    return true;
}

function fAllBoxesCheckedFireFox(formid,sPattern){
   var e = document.getElementById(formid).elements;
    for(i in e) {
      if (e[i].type == 'checkbox'){
        if (e[i].getAttribute('id').substring(0, sPattern.length) == sPattern){
          if (!e[i].checked){
            return false;
          }
        }
      }
    }
    return true;
}

function rLookupEMail(DefaultValue){
    var  EMailAddr;
    var  aForm = rSubmitThisForm();

    EMailAddr = prompt("\nPlease enter your e-mail address.\n", DefaultValue );

    if ( EMailAddr == null || EMailAddr.length < 1 ) {
    
    }
    else if ( !fIsOKEMailAddress(EMailAddr) ) {
      rLookupEMail(EMailAddr);
    }
    else {

        aForm.LookupEMail.value = EMailAddr;
		rResubmitThisForm();
    }
}

// This will open a new window in a pop-up.

function rPopUpAWindow( WindowTitle, WindowName, TheURL, TheWidth ) {

    rPopUpAWindowWithHeight( WindowTitle, WindowName, TheURL, TheWidth, 450);
}


function rPopUpAWindowWithHeight(WindowTitle, WindowName, TheURL, TheWidth, TheHeight, iNoMessage ) {

    var TheWindow;
    var TheDocument;
    
    if (iNoMessage == null) iNoMessage=0
    
    if (iNoMessage == 1) {
      TheWindow = window.open( "", WindowName, "resizable=yes,menubar=no,toolbar=no,scrollbars=yes,status=no,directories=no,location=no,width=" + TheWidth + ",height=" + TheHeight );
      TheWindow.location = TheURL;
      return;
    }
    
    TheWindow = window.open( "", WindowName, "resizable=yes,menubar=no,toolbar=no,scrollbars=yes,status=no,directories=no,location=no,width=" + TheWidth + ",height=" + TheHeight );
    TheDocument = TheWindow.document;
    TheDocument.close();
    TheDocument.open("text/html", "replace");
    TheDocument.write("<HTML><HEAD><TITLE>Please wait:  Loading " + WindowTitle + 
    "</TITLE></HEAD><BODY BGCOLOR=#FFFFFF><TABLE BORDER=0 WIDTH=100% HEIGHT=100% ><TR><TD VALIGN=CENTER ALIGN=CENTER>" + 
    "<FONT FACE=Arial SIZE=2 COLOR=#000080><STRONG>Please wait:  Loading " + WindowTitle + ". . .</STRONG></FONT>" +
    "</TD></TR></TABLE></BODY></HTML>");
    
    
    
    //"<div id=\"PleaseWait\"><h2>Please wait: Loading <img src=\"/images/ajax-loader.gif\" title=\"Loading ...\"/></h2></div>" +
    
    //"<FONT FACE=Arial SIZE=2 COLOR=#000080><STRONG>Please wait:  Loading " + WindowTitle + ". . .</STRONG></FONT>" 
    //"</TITLE></HEAD><BODY BGCOLOR=#FFFFFF><TABLE BORDER=0 WIDTH=100% HEIGHT=100% ><TR><TD VALIGN=CENTER ALIGN=CENTER><FONT FACE=Arial SIZE=2 COLOR=#000080><STRONG>Please wait:  Loading " + WindowTitle + ". . .</STRONG></FONT></TD></TR></TABLE></BODY></HTML>");
    
    TheDocument.close();
    TheWindow.focus();
    TheWindow.location = TheURL;
}

function rPopUpAWindowWithHeightToolbar( WindowTitle, WindowName, TheURL, TheWidth, TheHeight ) {

    var TheWindow;
    var TheDocument;
    var Width;
    
    TheWindow = window.open( "", WindowName, "resizable=yes,menubar=no,toolbar=yes,scrollbars=yes,status=no,directories=no,location=no,width=" + TheWidth + ",height=" + TheHeight );
    TheDocument = TheWindow.document;
    TheDocument.close();
    TheDocument.open("text/html", "replace");
    TheDocument.write("<HTML><HEAD><TITLE>Please wait:  Loading " + WindowTitle + "</TITLE></HEAD><BODY BGCOLOR=#FFFFFF><TABLE BORDER=0 WIDTH=100% HEIGHT=100% ><TR><TD VALIGN=CENTER ALIGN=CENTER><FONT FACE=Arial SIZE=2 COLOR=#000080><STRONG>Please wait:  Loading " + WindowTitle + ". . .</STRONG></FONT></TD></TR></TABLE></BODY></HTML>");
    TheDocument.close();
    TheWindow.focus();
    TheWindow.location = TheURL;
}

//--------------------------------------------------------------------
//  Tests for browser types.

function rfIsNetscape ( ) {

    return navigator.appName == "Netscape";
}

function rfIsMSIE ( ) {

    //alert(navigator.appName);
    return navigator.appName == "Microsoft Internet Explorer"
}

function rfIsMSIEv55 ( ) {

    return rfIsMSIE() && navigator.appVersion.indexOf( "5.5" ) >= 0;
}
//-------------- rfIsNetscapeUnder5 ------

function rfIsNetscapeUnder5 () {
  var xver;
  if  (rfIsNetscape ()){
   xver = navigator.appVersion.charAt(0);
   //alert ("xver=" + xver);
   return xver < 5;
   }
}
//--------------------------------------------------------------------
//  Browser/window functions:

function rWindowHeight ( ) { return rfIsMSIE() ? document.body.clientHeight : window.innerHeight ; }
function rWindowWidth  ( ) { return rfIsMSIE() ? document.body.clientWidth  : window.innerWidth  ; }
function rVScroll      ( ) { return rfIsMSIE() ? document.body.scrollTop    : window.pageYOffset ; }
function rHScroll      ( ) { return rfIsMSIE() ? document.body.scrollLeft   : window.pageXOffset ; }

//====================================================================
//  The following are functions for manipulating a DIV/LAYER:

function rLocateOurGuy ( OurGuysName ) {
    
    if ( rfIsMSIE() ) {
    
        return document.all.tags("DIV")(OurGuysName);
    }
    else if ( rfIsNetscape() ) {
    
        return document.layers[OurGuysName];
    }
}

//------------------------------------------

function rCenterIt ( OurGuysName, OurGuysWidth, OurGuysHeight ) {

    var  OurGuy = rLocateOurGuy( OurGuysName );
    
    if ( OurGuy == null ) return;
    
    if ( rfIsNetscape() ) {
    
        OurGuysWidth  = OurGuy.clip.width;
        OurGuysHeight = OurGuy.clip.height;
    }

    var LastCHeight = rWindowHeight();
    var LastCWidth  = rWindowWidth();
    var LastLScroll = rHScroll();
    var LastTScroll = rVScroll();
    var YDelta       = (LastCHeight - OurGuysHeight)/2;
    var XDelta       = (LastCWidth  - OurGuysWidth) /2;
    if ( YDelta < 0 ) YDelta = 0;
    if ( XDelta < 0 ) XDelta = 0;
    
    if ( rfIsMSIE() ) {
        OurGuy.style.top  = LastTScroll + YDelta;
        OurGuy.style.left = LastLScroll + XDelta;
        OurGuy.style.zIndex = 10;
    }
    else {
        OurGuy.moveToAbsolute( LastLScroll+XDelta, LastTScroll+YDelta );
    }
}

//------------------------------------------

function rKeepAtTop ( OurGuysName ) {

    var  OurGuy = rLocateOurGuy( OurGuysName );
    
    if ( OurGuy == null ) return;

    var LastCHeight = rWindowHeight();
    var LastCWidth  = rWindowWidth();
    var LastLScroll = rHScroll();
    var LastTScroll = rVScroll();
    
    if ( rfIsMSIE() ) {
        OurGuy.style.top  = LastTScroll + 5;
        OurGuy.style.left = LastLScroll + 5;
    }
    else {

        var Offset = (LastCWidth - OurGuy.clip.width) / 2;
        OurGuy.moveToAbsolute( LastLScroll+Offset, LastTScroll+5);
    }
}

//------------------------------------------

function rShowIt ( OurGuysName, fOn ) {

    var  OurGuy = rLocateOurGuy( OurGuysName );
    
    if ( OurGuy != null ) { 
    
        if ( rfIsMSIE() ) {

            OurGuy.style.display = fOn ? "" : "none";
        }
        else {

            OurGuy.visibility = fOn ? "show" : "hide";
        }
    }
}

//====================================================================
//  The following set of functions are used to control the 
//  'please wait' display, in conjunction with please-wait-box.htm.

var gCCOnBox     = 0; 
var gCCDirection = 1;

function rChangeColor ( ) { 
   var i;	
   for ( i=0; i < 12; i++ ) { 
   
       if ( rfIsNetscape() ) {
       
           var TheLayer   = document.layers["T" + i];
           if ( i == gCCOnBox ) { 
               TheLayer.bgColor  = "#000080";
           } 
           else if ( i == gCCOnBox-1 || i == gCCOnBox+1) { 
               TheLayer.bgColor  = "#C0C0FF"; 
           } 
           else {
               TheLayer.bgColor  = "#FFD700";
           }
       }
       else {
       
           var OurGuy     = "T" + i; 
           var el         = document.all[OurGuy]; 
           var TheColor   = "#FFD700"; 
           var TheBGColor = "#FFFFC0";
           if ( i == gCCOnBox ) { 
               TheColor   = "#FFFFFF";	
               TheBGColor = "#000080"; 
           } 
           else if ( i == gCCOnBox-1 || i == gCCOnBox+1) { 
               TheColor   = "#000080";	
               TheBGColor = "#C0C0FF"; 
           } 
           el.style.color           = TheColor; 
           el.style.backgroundColor = TheBGColor;
       }
   } 
   if ( gCCOnBox == 11 ) gCCDirection = -1;
   if ( gCCOnBox == 0  ) gCCDirection = 1;	
   gCCOnBox += gCCDirection; 
   setTimeout('rChangeColor()', 100);
}

//--------------------------------------------------------------------------- 

function rAlignPleaseWaits ( ) {

    if ( !rfIsNetscape() ) return;
    
    var i, TheLayer;
    
    var ScreenWidth  = rWindowWidth();
    var ScreenHeight = rWindowHeight();
    var HScroll      = rHScroll();
    var VScroll      = rVScroll();
    var YDelta       = (ScreenHeight - 200) / 2 + 125 + VScroll;
    var XDelta       = (ScreenWidth - (24*12)) / 2 + HScroll;
    
    if ( YDelta < 0 ) YDelta = 0;
    if ( XDelta < 0 ) XDelta = 0;
    
    for ( i=0; i < 12; i++ ) {
    
        TheLayer = document.layers["T"+i];
        TheLayer.moveToAbsolute( XDelta + i * 24, YDelta );
        TheLayer.visibility = "show";
    }
}
  
//--------------------------------------------------------------------------- 

function rWritePleaseWaitLayers() {

    var  i;
    var  LeftOffset = (window.innerWidth  - 13*20) / 2;
    var  TopOffset  = (window.innerHeight - 40)    / 3;
    var  TheText    = "MBG SOLUTIONS";

    if ( LeftOffset < 0 ) LeftOffset = 0;
    if ( TopOffset  < 0 ) TopOffset  = 0;
    var  LoginOffset = TopOffset;
    TopOffset += 30;

    for ( i=0; i < 12; i++ ) {
        document.write( "<LAYER CLASS=PleaseWaitLayer ID=T" + i 
                      + " TOP=" + TopOffset + " LEFT=" + (LeftOffset + i*20) 
                      + " WIDTH=20 HEIGHT=20 VISIBILITY=hide BGCOLOR=#FFD700> &nbsp;" 
                      + TheText.charAt(i) + "&nbsp; </LAYER>");
    }
    return true;
}

//--------------------------------------------------------------------------- 

function rWritePleaseWaitDivs ( ) {

    var  TheText    = "MBG SOLUTIONS";
    var  i;
    
    document.write("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=4><TR>");
    
    for ( i=0; i < 12; i++ ) {
       document.write( "<TD><FONT FACE=Arial SIZE=3><B><DIV ID=T" + i + "> &nbsp;" + TheText.charAt(i) + "&nbsp;  </DIV></B></FONT></TD>" );
    }
    document.write("</TR></TABLE>" );
}

//--------------------------------------------------------------------

function rWritePleaseWait ( WindowTitle ) {

    if ( !rfIsNetscape() && !rfIsMSIEv55() ) {
        document.open();
        document.write("<HTML><HEAD><TITLE>Please Wait</TITLE></HEAD>");
        document.write("<BODY>");
        document.write("<TABLE BORDER=0 WIDTH=100% HEIGHT=100% ><TR><TD VALIGN=CENTER ALIGN=CENTER><FONT FACE=Arial SIZE=2 COLOR=#000080><STRONG>Please wait: " + WindowTitle + ". . .</STRONG></FONT></TD></TR></TABLE>");
        document.write("</BODY></HTML>");
        document.close();
    }
}

//--------------------------------------------------------------------

function rPleaseWait ( WindowTitle ) {

    if ( rLocateOurGuy("PleaseWait") != null ) {
    
        rShowIt( "BaseForm",   false );
        rCenterIt( "PleaseWait", 400, 200 );
        rShowIt( "PleaseWait", true  );
        rAlignPleaseWaits();
        rChangeColor();
    }
    else {
    
        rWritePleaseWait( WindowTitle );
    }
}
    
//====================================================================
function JSFX_FloatTopDiv(xDiv, verticalpos, offset)
{
	var startX = 3;
	startY = 150;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startX;
		
		if (verticalpos=="tl"){
		 el.y = startY;
		}
		
		if (verticalpos=="bl"){
		 el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		 el.y -= startY;
		}
		
		return el;
	}
	function mr(id)
	{
		var er=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=er;
		er.sP=function(x,y){this.style.right=x;this.style.top=y;};
		er.x = startX;
		
		if (verticalpos=="tr"){
		 er.y = startY;
		}
		
		if (verticalpos=="br"){
		 er.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		 er.y -= startY;
		}
		
		return er;
	}

	// tl bl tr br
	window.stayTopLeft=function()
	{
		if (verticalpos=="tl"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		
		 if (offset == 770){
		   ftlObj.y += (pY + startY - ftlObj.y)/8;
		  }
		  else {
		   ftlObj.y = pY + offset;
		  }    
		}
		
				
		if (verticalpos=="bl"){
		  var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		  if (offset == 770){
		   ftlObj.y += (pY + startY - ftlObj.y)/8;
		  }
		  else {
		   ftlObj.y = pY + offset;
		  }  
		}
		
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	
	window.stayTopRight=function()
	{
		if (verticalpos=="tr"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		
				
		if (verticalpos=="br"){
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		
		ftlObj.sP(ftlObj.x-100, ftlObj.y);
		setTimeout("stayTopRight()", 10);
	}
	
		
	if (verticalpos=="tl" || verticalpos=="bl"){
	  ftlObj = ml(xDiv);
	  stayTopLeft();
	}
	else {
	  ftlObj = mr(xDiv);
	  stayTopRight();
	} 
}
