/*
Script Name: Simple Javascript Browser/OS detection
Authors: Harald Hope, Tapio Markula, Websites: http://techpatterns.com/
http://www.nic.fi/~tapio1/Teaching/index1.php3
Script Source URI: http://techpatterns.com/downloads/javascript_browser_detection.php
Version 2.0.1
Copyright (C) 08 August 2004
*/

var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;

d = document;
n = navigator;
na = n.appVersion;
nua = n.userAgent;
win = ( na.indexOf( 'Win' ) != -1 );
mac = ( na.indexOf( 'Mac' ) != -1 );
lin = ( nua.indexOf( 'Linux' ) != -1 );

if ( !d.layers ){
	dom = ( d.getElementById );
	op = ( nua.indexOf( 'Opera' ) != -1 );
	konq = ( nua.indexOf( 'Konqueror' ) != -1 );
	saf = ( nua.indexOf( 'Safari' ) != -1 );
	moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
	ie = ( d.all && !op );
	ie4 = ( ie && !dom );

	/*
	ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
	Opera will register true in this test if set to identify as IE 5
	*/

	ie5x = ( d.all && dom );
	ie5mac = ( mac && ie5x );
	ie5xwin = ( win && ie5x );
}

function browser_css( ) { 
	d = document;// shorthand so we don't have to write out document each time..
	
	/*
	if ( ie5mac ) {
		d.write('<link rel = "stylesheet" type = "text\/css" href = "css/ie5mac.css" />');
	}
	else if ( d.layers ){
		d.write('<link rel = "stylesheet" type = "text\/css" href = "css/ns4x.css" />');
	}
	else if ( ie4 ){
		d.write('<link rel = "stylesheet" type = "text\/css" href = "css/ie4.css" />');
	}
	else if ( moz ){
		d.write('<link rel = "stylesheet" type = "text\/css" href = "css/moz.css" />');
	}
	else {
		d.write('< link rel = "stylesheet" type = "text\/css" href = "css/moz5.css" />');
	}
	*/
	
	if (ie) {  
	  d.write('<link rel="stylesheet" type="text\/css" href="/css/ie.css" />');
	}
}

if (ie5xwin) {
  var ie55up = true;
}

function fixPNG(myImage) { // correctly handle PNG transparency in Win IE 5.5 or higher.
  if (window.ie55up) {
 	  var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	  var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	  var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
	  var imgStyle = "display:inline-block;" + myImage.style.cssText 
	  var strNewHTML = "<span " + imgID + imgClass + imgTitle
	  strNewHTML += " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";"
	  strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	  strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>" 
	  myImage.outerHTML = strNewHTML
	}
}
function fixPNGswap(myImage) {  // correctly handle PNG transparency in Win IE 5.5 or higher. WITH swap implementation
  if (window.ie55up) {
	  var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	  var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	  var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
	  var imgStyle = "display:inline-block;" + myImage.style.cssText 
	  var strNewHTML = "<span " + imgID + imgClass + imgTitle
	  strNewHTML += " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";"
	  strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	  strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"" 
	  strNewHTML += " onmouseover=\"PNGswap('" + myImage.id + "');\" onmouseout=\"PNGswap('" + myImage.id +"');\""
    strNewHTML += "></span>" 
	  myImage.outerHTML = strNewHTML
	}
}
function PNGswap(myID) {
  var strOver  = "_on"
  var strOff = "_off"
  var oSpan = document.getElementById(myID)
  var currentAlphaImg = oSpan.filters(0).src
  if (currentAlphaImg.indexOf(strOver) != -1)
    oSpan.filters(0).src = currentAlphaImg.replace(strOver,strOff)
  else
    oSpan.filters(0).src = currentAlphaImg.replace(strOff,strOver)
}

	 
		

		

		
						
						
						





