/* 
   Float Submit Button To Right Edge Of Window
   Version 1.0
   April 11, 2010
 
   Will Bontrager
   http://www.willmaster.com/
   Copyright 2010 Bontrager Connection, LLC
 
   Generated with customizations on April 11, 2010 at
   http://www.willmaster.com/library/manage-forms/floating-submit-button.php
 
   Bontrager Connection, LLC grants you 
   a royalty free license to use or modify 
   this software provided this notice appears 
   on all copies. This software is provided 
   "AS IS," without a warranty of any kind.
*/
 
//*****************************//
var ButtonId = "floatingbutton";
var ButtonId1 = "floatingbutton1";
var ButtonId2 = "floatingbutton2";

var ButtonLocation = "right";

var SpaceBetweenButtonAndEdge = 10;

var SpaceBetweenButtonAndTop = 295;
var SpaceBetweenButtonAndTop1 = 173;
var SpaceBetweenButtonAndTop2 = 416;

TotalWidth = 35;
ButtonLocation = ButtonLocation.toLowerCase();
ButtonLocation = ButtonLocation.substr(0,1);
var ButtonOnLeftEdge = (ButtonLocation=='l') ? true : false;
 
function AddButtonPlacementEvents(f)
{
   var cache = window.onload;
   if(typeof window.onload != 'function') { window.onload = f; }
   else { window.onload = function() { if(cache) { cache(); } f(); }; }
   cache = window.onresize;
   if(typeof window.onresize != 'function') { window.onresize = f; }
   else { window.onresize = function() { if(cache) { cache(); } f(); }; }
}
function WindowHasScrollbar() {
var ht = 0;
if(document.all) {
   if(document.documentElement) { ht = document.documentElement.clientHeight; }
   else { ht = document.body.clientHeight; }
   } 
else { ht = window.innerHeight; }
if (document.body.offsetHeight > ht) { return true; }
else { return false; }
}
 
function GlueButton(ledge) {
var did = document.getElementById(ButtonId);
var did1 = document.getElementById(ButtonId1);
var did2 = document.getElementById(ButtonId2);

did.style.top = SpaceBetweenButtonAndTop + "px";
did1.style.top = SpaceBetweenButtonAndTop1 + "px";
did2.style.top = SpaceBetweenButtonAndTop2 + "px";

//did.style.width = ButtonWidth + "px";
did2.style.left = did1.style.left = did.style.left = ledge + "px";
did2.style.display = did1.style.display = did.style.display = "block";
did2.style.zIndex = did1.style.zIndex = did.style.zIndex = "9999";
did2.style.position = did1.style.position = did.style.position = "fixed";
}
 
function PlaceTheButton() 
{
	if(ButtonOnLeftEdge) {
   		GlueButton(SpaceBetweenButtonAndEdge);
   		return;
   	}
	if(document.documentElement && document.documentElement.clientWidth) 
	{
		GlueButton(document.documentElement.clientWidth-TotalWidth); 
	} else {
   		if(navigator.userAgent.indexOf('MSIE') > 0) 
		{
			GlueButton(document.body.clientWidth-TotalWidth+19); 
		} else {
      		var scroll = WindowHasScrollbar() ? 0 : 15;
      		if(typeof window.innerWidth == 'number') { GlueButton(window.innerWidth-TotalWidth-15+scroll); }
      		else { GlueButton(document.body.clientWidth-TotalWidth+15); }
      	}
   	}
   	if(apply_scroll=="Yes")
   		window.scrollTo(0,680);
}
AddButtonPlacementEvents(PlaceTheButton);

