/* Browser Detection Script begins here.*/
var theDOM1 = (document.getElementById) ? true : false;
/* theApp will contain the browser name */
var theApp = navigator.appName.toLowerCase();
/* UA (user agent) contains detailed browser info. For example,
UA for Internet Explorer on Mac would be 'mozilla/4.0 (compatible;
msie 5.0; mac_powerpc)' */
var UA = navigator.userAgent.toLowerCase();
/* variables for the two major browsers in existence today. */
var isIE = (UA.indexOf('msie') >= 0) ? true : false;
var isNS = (UA.indexOf('mozilla') >= 0) ? true : false;
/* 'compatible' text string is only in non-Netscape browsers */
if (UA.indexOf('compatible')>0){
isNS = false;
}
/* platform */
var thePlatform = navigator.platform.toLowerCase();
var isMAC = (UA.indexOf('mac') >= 0) ? true : false;
var isWIN = (UA.indexOf('win') >= 0) ? true : false;
/* Most UNIX users use X-Windows so this detects UNIX most of
the time.*/
var isUNIX = (UA.indexOf('x11') >= 0) ? true : false;
/* browser version */
var version = navigator.appVersion;
var isMajor = parseInt( version );
/* Internet Explorer version 5 on the Mac reports itself as version
4. This code corrects the problem. */
if(isIE && isMAC) {
if(UA.indexOf("msie 5")) {
isMajor = 5;
var stringLoc = UA.indexOf("msie 5");
version = UA.substring(stringLoc + 5, stringLoc + 8);
}
}
/* Internet Explorer version 6 on Windows reports itself as version
4. This code corrects the problem. */
if(isIE && isWIN) {
if(UA.indexOf("msie 6")) {
isMajor = 6;
var stringLoc = UA.indexOf("msie 6");
version = UA.substring(stringLoc + 5, stringLoc + 8);
}
if(UA.indexOf("msie 5.5")) {
isMajor = 5;
var stringLoc = UA.indexOf("msie 5.5");
version = UA.substring(stringLoc + 5, stringLoc + 8);
}
}
/* Netscape 6 reports itself as version 5 on all platforms.
This code corrects the problem. */
if(isNS && isMajor>4) {
if(UA.indexOf("netscape6")) {
isMajor = 6;
var stringLoc = UA.indexOf("netscape6");
version = UA.substring(stringLoc + 10, stringLoc + 14);
}
}
var isMinor = parseFloat( version );
/* a function to report browser info */
function getBrowserInfo(){
var temp="<p>";
temp += "User Agent: " + UA + "<br>";
temp += "Platform: " + thePlatform + "<br>";
temp += "Macintosh: " + isMAC + "<br>";
temp += "Windows: " + isWIN + "<br>";
temp += "Application: " + theApp + "<br>";
temp += "Version: " + version + "<br>";
temp += "Netscape: " + isNS + "<br>";
temp += "Internet Explorer: " + isIE + "<br>";
temp += "Major Version: " + isMajor + "<br>";
temp += "Full Version: " + isMinor + "<br>";
temp += "<br>";
if (theDOM1){
temp += "You appear to have a modern browser.<br>";
temp += "Netscape 6, IE 6, or IE5Mac are recommended.";
}else{
temp += "Alert! Your browser is obsolete.<br>";
temp += "You may enjoy the Web more if you upgrade.";
}
temp +="<\/p>";
return temp;
}
/* End of browser detection code */


/* Convert object name string or object reference
into a valid object reference */
function getObj(elementID){
if (typeof elementID == "string") {
return document.getElementById(elementID);
}else{
return elementID;
}
}

/*Set the visibility of an object*/
function setVisibility(thisobj, state){
getObj(thisobj).style.visibility = state;
}

/*Set the display of an object*/
function setDisplay(thisobj, state){
getObj(thisobj).style.display = state;
}

/*Set the background color of an object*/
function setBackgroundImage(thisobj, image){
getObj(thisobj).style.backgroundImage = "url(" + image + ")";
}
function setBackgroundImageFromIframe(thisobj, image){
parent.window.document.getElementById(thisobj).style.backgroundImage = "url(" + image + ")";
}

/*Set the link href of an object*/
function setLink(thisobj, theLink){
getObj(thisobj).href = theLink;
}
function setLinkFromIframe(thisobj, theLink){
parent.window.document.getElementById(thisobj).href = theLink;
}

/*Set the source of an object*/
function setSource(thisobj, theSource){
getObj(thisobj).src = theSource;
}

/*This function gets the available width of the screen.*/
function getScreenWidth(){
var screenWidth=null;
screenWidth = screen.width;

return screenWidth;
}
/*This function gets the available height of the screen.*/
function getScreenHeight(){
var screenHeight = null;
screenHeight = screen.height;

return screenHeight;
}


//--------------------------------------------------------------------------

function setRimContent(rimName) {
setBackgroundImage('outerFrame', 'images/patternRim_' + rimName + '.jpg');
setSource('rimSpecs', 'images/rimSizes_' + rimName + '.gif');
if(rimName.indexOf('tique') == -1 && rimName.indexOf('ss') == -1) {					
setLink('tcsLink', "javascript:popUpTCS('tcsWindow', '../TCS/index.php?skipIntro=true&qWhatRim=" + rimName + "');");
}
setLink('productSheet', '../PDF/productSheet_' + rimName + '.pdf');
setLink('productWallpaper', '../wallpapers/' + rimName + '.zip');
}

function setRimContentFromIframe(rimName) {
setBackgroundImageFromIframe('outerFrame', 'images/patternRim_' + rimName + '.jpg');
setLinkFromIframe('tcsLink', "javascript:popUpTCS('tcsWindow', '../TCS/index.php?skipIntro=true&qWhatRim=" + rimName + "');");
setLinkFromIframe('productSheet', '../PDF/productSheet_' + rimName + '.pdf');
setLinkFromIframe('productWallpaper', '../wallpapers/' + rimName + '.zip');
}

function popUpCenter(url,w,h) {
screenw = getScreenWidth();
screenh = getScreenHeight();

x = (screenw / 2) - (w / 2);
t = (screenh / 2) - (h / 2);

var theWindow = window.open(url, 'popup','top='+t+',left='+x+',height='+h+',width='+w+'' );
}

function popUpTCS(name,url) {
screenw = getScreenWidth();
screenh = getScreenHeight();

x = (screenw / 2) - (700 / 2);
t = (screenh / 2) - (500 / 2);

var theWindow = window.open(url, name,'top='+t+',left='+x+',height=500,width=700,resizable=no,scrollbars=no,toolbars=no,status=no' );
}

//--------------------------------------------------------------------------

//Image swapping scripts.
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		navRollover = newImage("images/rimThumbs_rev71_chrome.jpg");
		navRollover = newImage("images/rimThumbs_rev72_chrome.jpg");
		navRollover = newImage("images/rimThumbs_revLS_chrome.jpg");
		navRollover = newImage("images/rimThumbs_rev71_tique.jpg");
		navRollover = newImage("images/rimThumbs_rev72_tique.jpg");
		navRollover = newImage("images/rimThumbs_revLS_tique.jpg");
		navRollover = newImage("images/rimThumbs_sp1_chrome.jpg");
		navRollover = newImage("images/rimThumbs_sp2_chrome.jpg");
		navRollover = newImage("images/rimThumbs_sp3_chrome.jpg");
		navRollover = newImage("images/rimThumbs_ss1_chrome.jpg");
		navRollover = newImage("images/rimThumbs_ss3_chrome.jpg");

		preloadFlag = true;
	}
}

