var NS = (navigator.appName=="Netscape")?true:false;
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";

function isDefined(property)
{
return (typeof property != 'undefined');
}

function ExtraStyle()
{

if ((document.all) && (document.styleSheets) && (document.styleSheets[0]) && (document.styleSheets[0].addRule))
{
document.styleSheets[0].addRule(".Envelope", "behavior: url(css/iepngfix.htc)");
}

}

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='scale');\"></span>" 
img.outerHTML = strNewHTML
i = i-1
}
}
}
}

// 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"; 
}

}

}

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

for(i=0;i<lnks.length;i++)
{

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 RunFunctions()
{
externalLinks();
BlurLinks();
RunStars();

if (document.all)
{
ExtraStyle();
correctPNG();
}

LetterPicker();
}

if (isDefined(window.addEventListener))
{
window.addEventListener('load', RunFunctions, false);
}

else if (isDefined(window.attachEvent))
{
window.attachEvent('onload', RunFunctions);
}

function RunStars()
{
NumStars	= Math.round(Math.random()*(50-30));

for (var i=1; i<=NumStars; i++)
{
ContObj	= document.getElementsByTagName("body")[0].appendChild(document.createElement("div"));
ContObj.id	= "Star" + i;

Size	= Math.round(Math.random()*(100-25));
Size	= 25 + Size;

var so	= new SWFObject("flash/star.swf", "Star", Size, Size, 4, "#ffffff"); 
so.addParam("wmode", "transparent");
so.write(ContObj.id);

// Positioning
Left1	= (document.getElementById("Page").offsetLeft - Size);
Left2	= (document.getElementById("Page").offsetLeft + 800) - Size;
MarginRight	= (NS)?window.innerWidth:document.body.clientWidth;
MarginRight	= MarginRight - 100;
MarginBottom	= (document.getElementById("Page").offsetHeight - Size);
LeftArray	= new Array(Left1, Left2, Left2, Left1);
RandomLeft	= (Math.round(Math.random()*(LeftArray.length - 1)))
StyleLeft	= LeftArray[RandomLeft];

if (StyleLeft <= Left1)
{
LeftStyle	= Math.round(Math.random()*StyleLeft);
}

else
{
LeftStyle	= Math.round(Math.random()*(MarginRight-StyleLeft));
LeftStyle	= LeftStyle + StyleLeft;
}

TopStyle	= (Math.round(Math.random()*MarginBottom));

ContObj.style.position	= "absolute";
ContObj.style.padding	= "10px";
ContObj.style.left	= LeftStyle + "px";
ContObj.style.top	= TopStyle + "px";
ContObj.style.vackground	= "#0000ff";
}

}

function BackgroundImage()
{
	
if (typeof(window.innerWidth) == 'number')
{
WinWidth	= window.innerWidth;
}

else if ((document.documentElement) && ((document.documentElement.clientWidth) || (document.documentElement.clientHeight)))
{
WinWidth	= document.documentElement.clientWidth;
}

else if ((document.body) && ((document.body.clientWidth) || (document.body.clientHeight)))
{
WinWidth	= document.body.clientWidth;
} 

WinHeight	= document.getElementById("Page").offsetHeight + 10;

if (WinHeight >= WinWidth)
{
ImageScale	= WinHeight;
}

else if (WinWidth > WinHeight)
{
ImageScale	= WinWidth;
}

ImageName	= "images/general/background" + ImageScale + "_" + WinWidth + "_" + WinHeight + ".jpg";
}