if (document.getElementById || document.all) {
	document.write('<div id="PopupBox">');
	document.write('</div>');
} // End of function

function gettrailobj(){
	if (document.getElementById)
		{ return document.getElementById("PopupBox").style }
	else if (document.all)
		{ return document.all.PopupBox.style }
} // End of function

function gettrailobjnostyle(){
	if (document.getElementById)
		{ return document.getElementById("PopupBox") }
	else if (document.all)
		{ return document.all.PopupBox }
} // End of function


function truebody() {
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
} // End of function


function showtrail(ImageFile, ProductNumber, ProductTitle, ProductDimensions, ProductCostPerWeek, ProductDescription, SiteLanguage) {
	document.onmousemove = followmouse;
	newHTML = '';
	newHTML = newHTML + '<div class="InnerContent">';
	newHTML = newHTML + '<img src="' + ImageFile + '">';
	newHTML = newHTML + '<div class="ProductTitle">' + ProductTitle + '</div>';
	newHTML = newHTML + '<div class="ProductNumber">' + ((SiteLanguage == 'en') ? 'Product #' : '# de produit') + ': ' + ((ProductNumber != '') ? ProductNumber : ((SiteLanguage == 'en') ? 'not available' : 'non disponible')) + '</div>';
	newHTML = newHTML + ((ProductDescription != '') ? '<div class="ProductDescription">' + ProductDescription + '</div>' : '');
//	newHTML = newHTML + '<div class="ProductCostPerWeek">' + ((SiteLanguage == 'en') ? 'Cost per week' : 'Coût par semaine') + ': ' + ((ProductCostPerWeek != '') ? ProductCostPerWeek : ((SiteLanguage == 'en') ? 'contact joe' : 'contactez joe')) + '</div>';
	newHTML = newHTML + '<div class="ProductCostPerWeek">' + ((SiteLanguage == 'en') ? 'Cost per week' : 'Coût par semaine') + ': ' + ((SiteLanguage == 'en') ? 'contact joe' : 'contactez joe') + '</div>';
	newHTML = newHTML + '<div class="ProductDimensions">' + ((SiteLanguage == 'en') ? 'Dimensions' : 'Dimensions') + ': ' + ((ProductDimensions != '') ? ProductDimensions : ((SiteLanguage == 'en') ? 'available upon request' : 'sur demande')) + '</div>';
	newHTML = newHTML + '</div>';
	gettrailobjnostyle().innerHTML = newHTML;
	gettrailobj().display = 'inline';
} // End of function


function hidetrail(){
	gettrailobj().innerHTML = "";
	gettrailobj().display = "none"
	document.onmousemove = ""
	gettrailobj().left = "-500px"
} // End of function

function followmouse(e) {
	// Offset for the div box
	var DivOffsetX = 15;
	var DivOffsetY = -275;

	// Gets the height/width of the div box
	var DivHeight = document.getElementById('PopupBox').offsetHeight;
	var DivWidth = document.getElementById('PopupBox').offsetWidth;

	// Gets the height/width of the main site div
	var SiteWidth = document.getElementById('SiteContainer').offsetWidth;
	var SiteHeight = document.getElementById('SiteContainer').offsetHeight;

	// Gets the height/width of the browser's viewport
	var DocumentWidth = document.all ? truebody().scrollLeft+truebody().clientWidth : pageXOffset + window.innerWidth;
	var DocumentHeight = document.all ? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight);

	// Calculates the current div x/y position
	if (typeof e != "undefined")
		{
		CurrentBoxPositionX = DivOffsetX + e.pageX;
		CurrentBoxPositionY = DivOffsetY + e.pageY;
		}
	else if (typeof window.event != "undefined")
		{
		CurrentBoxPositionX = DivOffsetX + truebody().scrollLeft + event.clientX;
		CurrentBoxPositionY = DivOffsetY + truebody().scrollTop + event.clientY;
		}

	// Calculates the max/min X coordinates of the site
	var MinPositionX = (DocumentWidth - SiteWidth) / 2;
	var MaxPositionX = DocumentWidth - MinPositionX;

	// Calculates the max/min Y coordinates of the site
	var MinPositionY = (DocumentHeight - SiteHeight) / 2;
	var MaxPositionY = DocumentHeight - MinPositionY;

	// Sets the div to the left of the cursor if the div surpasses the site div's width
	if ((CurrentBoxPositionX + DivWidth ) > DocumentWidth)
		{ CurrentBoxPositionX = CurrentBoxPositionX - DivWidth - ((DivOffsetX * 2) - 5); }

	// Sets the div to float along the top if the div goes above the site div's starting height
	if (CurrentBoxPositionY < 0)
		{ CurrentBoxPositionY = 0; }

// Sets the div to float along the bottom if the div surpasses the site div's height
	if ((CurrentBoxPositionY + DivHeight ) > DocumentHeight)
//		{ CurrentBoxPositionY = SiteHeight - DivHeight + MinPositionY; }
		{ CurrentBoxPositionY = DocumentHeight - DivHeight; }

//alert("SIZE: " + SiteWidth + ' x ' + SiteHeight);

	gettrailobj().left = CurrentBoxPositionX + "px";
	gettrailobj().top = CurrentBoxPositionY + "px";
} // End of function

