/*
 * Filename: main.js
 * This file contains javascript functionality that are used throughtout the KMDphoto.com site.
 * This functionality includes:
 *    - Checking the platform and browser combination and linking to the appropriate css file.
 *	  - Workaround for Netscape 4 window resize bug.
 * 
 */ 


// *** Start: Code for checking which CSS file to use ***
// get platform and browser versions
var platform = navigator.platform.substr(0,3);
var browserName = navigator.appName;
var browserVer;

//for IE 5, the first number in "navigator.appVersion" is 4.0, so need to parse the string further 
if (navigator.appVersion.indexOf('MSIE 5') != -1) {
	browserVer=5;
}
else {
	browserVer = parseInt(navigator.appVersion);
}

// Platform is Windows
if (platform=="Win") {

	//Netscape 4 on Windows
	if ((browserName=="Netscape") && (browserVer <=4)) {	
		document.write('<link rel="stylesheet" type="text/css" href="ns.css" >');
	}
	//IE, NS6, (or any other browsers) on Windows 
	else {
		document.write('<link rel="stylesheet" type="text/css" href="ie.css" >');
	}
} 
	
// Platform is Macintosh
else if (platform=="Mac") {

	//IE5 or NS6 on Mac
	if (browserVer >=5) {
		document.write('<link rel="stylesheet" type="text/css" href="ie.css" >');
	}
		
	//Netscape 4, IE4, and all other browsers on Mac
	else {
		document.write('<link rel="stylesheet" type="text/css" href="mac.css" >');
	}
} 

// All other platforms
else {
	document.write('<link rel="stylesheet" type="text/css" href="ie.css" >');
}

// *** End: Code for checking which CSS file to use ***


 


// *** Start: Code for Netscape 4 Resize bug ***

// This is a workaround for a Netscape 4 bug that causes 
// stylesheets to be corrupted when the window is resized.
if (document.layers) {
	var widthCheck = window.innerWidth;
	var heightCheck = window.innerHeight;
	window.onResize = resizeFix;
}

function resizeFix() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href;
}

// *** End: Code for Netscape 4 Resize bug ***






