/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;

function NewWindow(mypage,myname,w,h,scroll,pos){

if(pos=="topleft"){LeftPosition='20';TopPosition='40'}

settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';

win=window.open(mypage,myname,settings);}


//
// ie selection fix //
//
  
function doIESelectionFix() {
  
  if (navigator.appName == "Microsoft Internet Explorer") {
    // defaults the onClick and onDrag events for anchors to blur in IE //
    for (theCounter = 0; theCounter < document.links.length; theCounter++) {
      document.links[theCounter].onclick = function() { if (navigator.appName == "Microsoft Internet Explorer") { this.blur(); } };
      document.links[theCounter].ondrag = function() { if (navigator.appName == "Microsoft Internet Explorer") { this.blur(); } };
      }
    }
  }

//
// netscape resize fix //
//

function WM_netscapeCssFix() {
  /*
    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Taylor
    Author Email: taylor@wired.com
    Author URL: http://www.taylor.org/
    */

  // This part was inspired by Matthew_Baird@wayfarer.com
  // It gets around another unfortunate bug whereby Netscape 
  // fires a resize event when the scrollbars pop up. This 
  // checks to make sure that the window's available size 
  // has actually changed.
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function doNetscapeCssFix() {
  // This function checks to make sure the version of Netscape 
  // in use contains the bug; if so, it records the window's 
  // width and height and sets all resize events to be handled 
  // by the WM_netscapeCssFix() function.
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

function WM_preloadImages() {
 
/*
WM_preloadImages()
Loads images into the browser's cache for later use.
 
Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)
 
Author: Nadav Savio
Author Email: nadav@wired.com
 
Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/
 
  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}
 

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
    Changes the source of an image.
 
    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)
 
    Author: Shvatz
    Author Email: shvatz@wired.com
 
    Usage: WM_imageSwap(originalImage, 'newSourceUrl');
 
    Requires: WM_preloadImages() (optional, but recommended)
    Thanks to Ken Sundermeyer (ksundermeyer@macromedia.com) for his help
    with variables in ie3 for the mac. 
    */
 
  // Check to make sure that images are supported in the DOM.
  if(document.images){
    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
      objStr = 'document.' + daImage;
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') && daImage && daImage.src) {
      daImage.src = daSrc;
    }
  }
}
 
// simple browser detect
 

 var browser = navigator.appName;
 var version = versionNumber();
 var the_string = browser + " " + version;
 

function versionNumber() {
  // return version number (e.g., 4.03)
  return parseFloat(navigator.appVersion)
}

//comprehensive browser detect

/* 
Browser sniffer. Written by PerlScriptsJavaScripts.com
Copyright http://www.perlscriptsjavascripts.com 
Free and commercial Perl and JavaScripts     
*/

v3 = 0; op = 0; ie4  = 0; ie5 = 0; nn4 = 0; nn6 = 0; isMac = 0; aol = 0;

if(document.images){
    if(navigator.userAgent.indexOf("Opera") != -1){
        op = 1;
    } else {
        if(navigator.userAgent.indexOf("AOL") != -1){
            aol = 1;
        } else {
            ie4 = (document.all && !document.getElementById);
            nn4 = (document.layers);
            ie5 = (document.all && document.getElementById);
            nn6 = (document.addEventListener);
        }
    }
} else {
    v3 = 1;	
}

if(navigator.userAgent.indexOf("Mac") != -1){
    isMac = 1;
}

//end browser sniffer

//put this in body to perform actions based on browser type

/*
<script>
<!--

if(op){ // do this
    alert("You are using Opera");
} 
if(ie4){ // do this
    alert("You are using Internet Explorer 4");
} 
if(ie5){ // do this
    alert("You are using Internet Explorer 5 or higher");
} 
if(nn4){ // do this
    alert("You are using Netscape 4");
} 
if(nn6){ // do this
    alert("You are using Netscape 6");
} 
if(aol){ // do this
    alert("You are using an AOL browser");
}
if(v3){ // do this
    alert("You are using a pre version 4 browser");
}

// -->
</script>
*/




function addbookmark(){
if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >=4) {
window.external.AddFavorite(location.href,document.title);
}
else {
alert("Netscape user: please hit Ctrl-D (PC) or Cmd-D (Mac) to add this site to your bookmarks");
   }
}

 

//CSS using simple browser detect
/*
 if ((browser == "Netscape") && (version < 5)) {
  document.writeln('<link rel=stylesheet href="css/mdp_N4.css" type="text/css">');
 }
 
else  if ((browser == "Explorer") && (version < 4)) {
  document.writeln('<link rel=stylesheet href="css/mdp_N4.css" type="text/css">');
 }
 
 else  {
   document.writeln ('<link rel=stylesheet href="css/mdp.css" type="text/css">');
 }
*/

// CSS using comprehensive browser detect

 if(nn4) {
  document.writeln('<link rel=stylesheet href="http://www.modukpai.com/css/mdp_N4.css" type="text/css">');
 }
 
else  if(ie4) {
  document.writeln('<link rel=stylesheet href="http://www.modukpai.com/css/mdp_N4.css" type="text/css">');
 }
 
 else  {
   document.writeln ('<link rel=stylesheet href="http://www.modukpai.com/css/mdp.css" type="text/css">');
 }
 
/*
     function emsTweak()
     Author: Matt Round
     Url: http://www.thenoodleincident.com/tutorials/box_lesson/font/matt_round.html

*/

 function emsTweak()
{
	if ((document.createElement) && (document.createTextNode))
	{
		document.writeln('<div id="emsTest" style="position:absolute; visibility:hidden; font-family:Verdana,helvetica,sans-serif">&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br /></div>');
		var scaling=100;
		if ((navigator.platform=="Win32") && (navigator.appName=="Microsoft Internet Explorer")) scaling=105;
		var h=999;
		if (document.getElementById('emsTest').clientHeight) h=parseInt(document.getElementById('emsTest').clientHeight);
		else if (document.getElementById('emsTest').offsetHeight) h=parseInt(document.getElementById('emsTest').offsetHeight);
		if (h<85) document.body.style.fontSize=Math.round(scaling*90/h)+"%";
	}
}
