// Browser
if(document.all)
{
var thisbrowser="IE"
}

if(!document.all && document.getElementById)
{
var thisbrowser="NN6";
}

var OSName="Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

// On Mouse events
function isDefined(property)
{
return (typeof property != 'undefined');
}

if (isDefined(window.addEventListener))
{
window.addEventListener("load", RunLoadFunctions, false);
}

else if (isDefined(window.attachEvent))
{
window.attachEvent("onload", RunLoadFunctions);
}

// Targets
function ExternalLinks()
{

if (!document.getElementsByTagName)
return;

var anchors = document.getElementsByTagName("a");

for (var i=0; i<anchors.length; i++)
{ 
var anchor = anchors[i];

if ((anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "external"))
{
anchor.target = "_blank"; 
}

}

}

// Targets
function LegalLinks()
{

if (!document.getElementsByTagName)
return;

var anchors = document.getElementsByTagName("a");

for (var i=0; i<anchors.length; i++)
{ 
var anchor = anchors[i];

if ((anchor.getAttribute("href")) && (anchor.getAttribute("rel") == "Legal"))
{
OldLink		= anchor.href;
anchor.href = "javascript:LegalPopUp('" + OldLink + "')";
}

}

}

function BlurLinks()
{
lnks	= document.getElementsByTagName("a");

for(i=0;i<lnks.length;i++)
{
	
if ((lnks[i].getAttribute("rel") == null) || (lnks[i].getAttribute("rel") == ""))
{
lnks[i].onfocus		= new Function("this.blur()");
}

}

// Input Buttons
inpts	= document.getElementsByName("input");

for(i=0;i<inpts.length;i++)
{
inpts[i].onfocus= new Function("this.blur()");
}

}

function RunLoadFunctions()
{
ExternalLinks();
BlurLinks();
LegalLinks();

if (document.getElementById("BoneRating"))
{
MakeBones();
}

if (document.getElementById("PressFloater"))
{
MakePressFloater();
}

if (document.getElementById("SameAsBillTo"))
{
document.getElementById("CheckOut").SameAsBillTo.onfocus		= new Function("SameAsBilling()");
}

if (window.attachEvent)
{

if (!isDefined(document.body.style.maxHeight))
{
correctPNG();
}

}

if (document.getElementById("ProductThumbs"))
{
var ProductThumbHolder	= document.getElementById("ProductThumbs").getElementsByTagName("ul");
var ProductThumbLi	= ProductThumbHolder[0].getElementsByTagName("li");
liwidth	= ProductThumbLi[0].offsetWidth

ProductThumbHolder[0].style.width	= ProductThumbLi.length * liwidth + "px";
}

if (document.getElementById("OtherProducts"))
{
var OtherProductss	= document.getElementById("OtherProducts").getElementsByTagName("li");

for (var i=0; i<OtherProductss.length; i++)
{
ThisClass	= OtherProductss[i].className;

if (ThisClass)
{
var ProductLinks	= OtherProductss[i].getElementsByTagName("a");
ProductLinks[0].onmouseover	= new Function("javascript:scrollStart('" + ThisClass + "')");
ProductLinks[0].onmouseout	= new Function("javascript:scrollEnd()");
ProductLinks[0].href	= "javascript:void('0')";
}

}

}

}

function MakePressFloater()
{
PanelSize	= document.getElementById("Panel").offsetHeight;
FloaterSize	= (parseInt(PanelSize) - 141) - 157;

document.getElementById("PressFloater").style.height	= FloaterSize + "px";
}

function correctPNG()
{
var arVersion = navigator.appVersion.split("MSIE")

var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (isDefined(document.body.filters)))
{
	
for(var i=0; i<document.images.length; i++)
{
var img 		= document.images[i]
var imgName 	= img.src.toUpperCase()
if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
{
var imgID = (img.id) ? "id='" + img.id + "' " : ""
var imgClass = (img.className) ? "class='" + img.className + "' " : ""
var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
var imgStyle = "display:inline-block;" + img.style.cssText 
if (img.align == "left") imgStyle = "float:left;" + imgStyle
if (img.align == "right") imgStyle = "float:right;" + imgStyle
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
var strNewHTML = "<span " + imgID + imgClass + imgTitle
+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
+ "(src=\'" + img.src + "\', sizingMethod='stretch');\"></span>" 
img.outerHTML = strNewHTML
i = i-1
}
}
}
}

function LogOut()
{
question = "Are you sure you wish to logout?";

if (confirm(question))
{
URL					= "/ajax/DoLogout.php";
ajax.requestFile	= URL;
ajax.onCompletion	= RunAJAX;
ajax.runAJAX();	
}

}

function copyDetails() {
	
document.getElementById("ShipToFirstName").value = document.getElementById("BillToFirstName").value;
document.getElementById("ShipToLastName").value = document.getElementById("BillToLastName").value;
document.getElementById("ShipToAddress1").value = document.getElementById("BillToAddress1").value;
document.getElementById("ShipToAddress2").value = document.getElementById("BillToAddress2").value;
document.getElementById("ShipToAddress3").value = document.getElementById("BillToAddress3").value;
document.getElementById("ShipToCity").value = document.getElementById("BillToCity").value;
document.getElementById("ShipToCounty").value = document.getElementById("BillToCounty").value;
document.getElementById("ShipToPostCode").value = document.getElementById("BillToPostCode").value;
document.getElementById("ShipToCountry").value = document.getElementById("BillToCountry").value;
}