// THIS CODE was mutated, modified, and re-done by the K10k» semi-bald posse
// THIS CODE was done in 1997-2001//
// ----------------------------------------------------------------------//
// NOTE1: IE4 fucks up if you try to "compress" js statements, like this:
// if (!document.getElementById) { browserNew = false; That's why all
// the lines have been written out in full.//
// ----------------------------------------------------------------------
// CHECK CLIENT BROWSER & PLATFORM
// original code from http://developer.apple.com/internet/_javascript///
// USAGE:	browserNaming();
// NOTES:	call it from within an external JS document
// RESULT:	browserNew = true/false
//			browserName = IE/NS/Opera
//			browserNameLong = IE5/etc
//			Macintosh = true/false
// WORKS:	everything	
var its;	
var browserName;	
var browserNameLong;	
var browserNew;	
var preloadFlag = false;	
var Macintosh = navigator.userAgent.indexOf('Mac')>0;	
function its() 
{		
	var n = navigator;		
	var ua = ' ' + n.userAgent.toLowerCase();		
	var pl = n.platform.toLowerCase();		
	var an = n.appName.toLowerCase();		
	// browser version		
	this.version = n.appVersion;		
	this.nn = ua.indexOf('mozilla') > 0;		
	// 'compatible' versions of mozilla aren't navigator		
	if(ua.indexOf('compatible') > 0) 
	{			
		this.nn = false;		
	}				
	this.opera = ua.indexOf('opera') > 0;		
	this.ie = ua.indexOf('msie') > 0;		
	this.major = parseInt( this.version );		
	this.minor = parseFloat( this.version );		
	// platform		
	this.mac = ua.indexOf('mac') > 0;		
	this.win = ua.indexOf('win') > 0;		
	// workaround for IE5 which reports itself as version 4.0		
	if(this.ie) 
	{			
		if(ua.indexOf("msie 5") > 1) 
		{			
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;			
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));			
		}		
	}		
	return this;	
}	
function browserNaming() 
{		
	its = new its();				
	// is it a DOM-enabled browser?		
	if (!document.getElementById) 
	{			
		browserNew = false;		
	}		
	else 
	{			
		browserNew = true;		
	}		
	// need the name, too		
	if (its.opera) 
	{			
		browserName = "Opera";		
	}		
	else if (its.ie) 
	{			
		browserName = "IE";		
	}		
	else 
	{			
		browserName = "NS";		
	}		
	// and the number		
	browserNameLong = browserName + its.major;		
}	
// CREATING THE MOUSEOVER IMAGES
// USAGE:	createObject('buttonoff','images/specfeature_celluar_off.gif');
// NOTES:	call it from within the preload function
// WORKS:	ie4+, ns4+, opera5	
function createObject(imgName,imgSrc) 
{		
	if (browserNew && (browserName == "NS")) 
	{		
		// a DOM-compatible browser		
		// which is probably NS6/mozilla (the other code works better in IE/Opera)			
		var tempImg = document.createElement("img");			
		tempImg.src = imgSrc;			
		tempImg.id = imgName;			
		tempImg.style.visibility = 'hidden';			
		tempImg.style.position = 'absolute';			
		tempImg.style.top = 0;			
		document.body.appendChild(tempImg);		
	}		
	else 
	{		
		// a non-DOM-compatible browser		
		// and IE/Opera			
		eval(imgName+' = new Image()');			
		eval(imgName+'.src = "'+imgSrc+'"');		
	}	
}

// MOUSEOVER SWITCHING
// USAGE:	<a href="#" onmouseover="changeImage(null,'buttonname','buttonnameon');" onmouseout="changeImage(null,'buttonname','buttonnameoff');">
// NOTES:	if the image is in a DIV, substitute 'null' with the DIV name.
// WORKS:	ie4+, ns4+, opera5	
function changeImage(layer,imgName,imgObj) 
{		
	if (preloadFlag) 
	{			
		if (browserNew && (browserName == "NS")) 
		{			
			// a DOM-compatible browser			
			// which is probably NS6/mozilla (the other code works better in IE/Opera)				
			thisImage = document.getElementById(imgName);				
			newImage = document.getElementById(imgObj);				
			newSrc = newImage.getAttribute("src");				
			thisImage.setAttribute("src",newSrc);			
		}			
		else 
		{			
			// a non-DOM-compatible browser			
			// and IE/Opera				
			if ((browserName == "NS") && layer!=null)
			{
				eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')				
			}
			else 
			{
				document.images[imgName].src = eval(imgObj+".src")
			}
		}		
	}	
}
// REMOVES THE LINK BORDER IN IE5/NS6// original code by evil@chelu.ro//
// USAGE:	getLinksToBlur();
// NOTES:	call it from within the preload function
// WORKS:	ie5+, ns6+, opera5+	
function unblur() 
{		
	this.blur();	
}	
function getLinksToBlur() 
{		
	if (!document.getElementById) 
	{
		return
	}
	links = document.getElementsByTagName("a");		
	for(i=0; i<links.length; i++) 
	{			
		links[i].onfocus = unblur		
	}
}
// POPUP WINDOW (FIXES THE IE4/MAC PROBLEM WHICH MAKES WINDOWS TOO SMALL)
// USAGE:	<a href="#" onclick="spawnWindow('newpage.php','windowname',400,384,'no');">
// NOTES:	substitute 400 with the width, 384 with the height, windowname with the name of the new window, scroll with either 'yes', 'no' or 'auto'
// WORKS:	ie4+, ns4+, opera5	
function spawnWindow(desktopURL,windowName,width,height,scroll) 
{ 		
	if (Macintosh) 
	{ 			
		if (browserNameLong == "IE4") 
		{				
			newheight = parseInt(height + 17);			
		}
		else if (browserNameLong == "IE4.5") 
		{
			newheight = parseInt(height + 17);			
		}		
		else 
		{				
			newheight = height;			
		} 
	} 		
	else 
	{ 
		newheight = height; 
	}	 	
	window.open(desktopURL, windowName, "toolbar=no,location=no,status=yes,menubar=no,scrollbars="+scroll+",width="+width+",height="+newheight+",resizable=no");
}	
function spawnWindowToo(desktopURL,windowName,width,height) 
{ 		
	window.open(desktopURL, windowName, "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width="+width+",height="+height+",resizable=no" );	
}
// HIDE AND SHOW LAYERS (ON THE SAME PAGE)
// USAGE:	show('layername'); hide('layername');
// WORKS:	ie4+, ns4+, opera	
function hide(id) 
{		
	if (browserNew) 
	{			
		setIdProperty(id,"visibility","hidden");		
	}		
	else
	{	
		if (browserName == "NS") 
		{ 
			document.layers[id].visibility = "hide"; 
		}
		else 
		{ 
			document.all[id].style.visibility = "hidden"; 
		}
	}
}	
function show(id) 
{
	if (browserNew) 
	{
		setIdProperty(id,"visibility","visible");		
	}
	else 
	{	
		if (browserName == "NS") 
		{
			document.layers[id].visibility = "show"; 
		}
		else 
		{
			document.all[id].style.visibility = "visible"; 
		}
	}
}
// DOM / GET PROPERTY
// original code from http://www.alistapart.com///
// NOTES:	given an id and a property (as strings), return the given property of that id.
// WORKS:	ie5+, ns6+, opera5+	
function getIdProperty(id,property) 
{		
	var styleObject = document.getElementById( id );		
	if (styleObject != null) 
	{			
		styleObject = styleObject.style;				
		if (styleObject[property]) 
		{
			return styleObject[ property ];				
		}
	}
	return (styleObject != null) ?		styleObject[property] :		null;	
}
// DOM / SET PROPERTY
// original code from http://www.alistapart.com///
// NOTES:	given an id and a property (as strings), set the given property of that id to the value provided.
// WORKS:	ie5+, ns6+, opera5+	
function setIdProperty(id,property,value) 
{		
	var styleObject = document.getElementById( id );		
	if (styleObject != null) 
	{			
		styleObject = styleObject.style;			
		styleObject[ property ] = value;		
	}	
}
// RANDOM NUMBER GENERATOR
// USAGE:	var ranNumber = 0+randNum(40);
// NOTES:	call it from within the main html page
// WORKS:	ie4+, ns4+, opera	
function randNum (num) 
{		
	var now = new Date();		
	var rand = Math.round(num * Math.cos(now.getTime()));		
	if (rand < 0)
	{
		rand = - rand; 		
	}
	if (rand == 0) 
	{
		rand++;
	}
	return rand;	
}