/******************************************************************************
The following code will detect the browser as well as the version and OS and
place the values in the OS, browser and version global variables
*******************************************************************************/
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

// Get the browser
if (checkIt('konqueror')) {
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible')) {
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

// Get the browser version
if (!version) version = detect.charAt(place + thestring.length);

// Get the OS
if (!OS) {
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

/**
 * Re-Direct users to the alternate index page
 */
function macRedirect() {
	if (OS == "Mac" && browser == "Safari") {
		window.location = "index_alt.jsp";
	}
}

function flashRedirect(version) {
	var majorVersion = 8;
	
	if (version && version > 0) majorVersion = version;
	
	var cookie = getcookie("valspar-no-flash");
	var url = "index_alt.jsp";
	if (!detectMajorVersion(majorVersion)) {
		if (!cookie || cookie == "") {
			if (!confirm("This site is optimized for viewing with Macromedia Flash Viewer 8.\nClick \"OK\" to install.")) {				
				setcookie("valspar-no-flash", "true", 30);
				document.location.href = "index_alt.jsp";
			}
		}
		else {
			document.location.href = "index_alt.jsp";
		}
	}					  
}

function flashVerbiage() {
	var player = new MM_FlashInfo();

	if (browser != "Safari" && !player.installed || (player.version && player.version <= 5)) {
	}
}

function getexpirydate(nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}

function getcookie(cookiename) {
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function setcookie(name,value,duration){
	cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
	document.cookie=cookiestring;
	if(!getcookie(name)){
		return false;
	}
	else {
		return true;
	}
}

/**
 * Checks for the existence of a string passed
 */
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function findObject(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

/**
 * This function re-load  the page
 */
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

<!--

/*
Random Image Script- By JavaScript Kit (http://www.javascriptkit.com) 
Over 400+ free JavaScripts here!
Keep this notice intact please
*/

function random_bg(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="images/bgs/homebg_house.jpg"
myimages[2]="images/bgs/homebg_cans.jpg"
myimages[3]="images/bgs/homebg_wood.jpg"
myimages[4]="images/bgs/homebg_car.jpg"
myimages[5]="images/bgs/homebg_room.jpg"
myimages[6]="images/bgs/homebg_building.jpg"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<body background="'+myimages[ry]+'" border=0>')
}

var xmlHttpRequestHandler = new Object();
xmlHttpRequestHandler.createXmlHttpRequest = function(){

  var XmlHttpRequestObject;
  if (typeof XMLHttpRequest != "undefined"){
   XmlHttpRequestObject = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
   // look up the highest possible MSXML version
   var tryPossibleVersions=["MSXML2.XMLHttp.5.0",                          
                            "MSXML2.XMLHttp.4.0",
                            "MSXML2.XMLHttp.3.0",
                            "MSXML2.XMLHttp",                         
                            "Microsoft.XMLHttp"];

  for (i=0; i< tryPossibleVersions.length; i++){
   try{
      XmlHttpRequestObject = new ActiveXObject(tryPossibleVersions[i]);
      break;
   }
   catch (xmlHttpRequestObjectError){
      //ignore
   }
  }
 }
 return XmlHttpRequestObject;
}

//-->