﻿// JavaScript Document


// Script to enable CSS menus in IE6
// From http://www.alistapart.com/articles/horizdropdowns/
startMenu = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("navlist");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {	this.className+=" over"; }
				node.onmouseout=function() { this.className=this.className.replace(" over", "");	}
			}
 		}
 	}
}


// Script to enable CSS product gallery in IE & Opera
// Based on:
//  - http://www.alistapart.com/articles/horizdropdowns/, and
//  - http://alistapart.com/articles/cssmaps/
startGallery = function() {
	if (document.all&&document.getElementById) {
		DLs = document.getElementById("productgallery");
		stripWhitespace( DLs );
		for (i=0; i<DLs.childNodes.length; i++) {
			node1 = DLs.childNodes[i];
			if (node1.nodeName=="DT") {
				node1.onmouseover=function() { if(this.nextSibling){ this.nextSibling.className+=" over"; }	}
				node1.onmouseout=function() {	if(this.nextSibling){ this.nextSibling.className=this.nextSibling.className.replace("over", ""); } }
			}
 		}
 	}
}
stripWhitespace = function( el ){
	for(var i = 0; i < el.childNodes.length; i++){
		var node = el.childNodes[i];
		if( node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
			node.parentNode.removeChild(node);
		};
	};
}




// Script to open a javascript window with a link
// Based on http://www.webdevelopersnotes.com/tutorials/javascript/learning_javascript_functions.php3
function open_win(url_add){
   window.open(url_add,'welcome','scrollbars=no,toolbar=no,width=820,height=620,resizable=yes,left=10,top=10');
}
function open_feedback_win(){
   window.open('/feedback.php','welcome','scrollbars=no,toolbar=no,width=425,height=525,resizable=yes,left=10,top=10');
}
function open_blueprint_win(){
   window.open('/quotes/index.php','welcome','scrollbars=yes,toolbar=no,width=970,height=740,resizable=yes,left=10,top=10');
}
function open_email_win(){
   window.open('http://mail.goyoders.com/exchange/','welcome','scrollbars=yes,toolbar=no,width=425,height=525,resizable=yes,left=10,top=10');
}





init = function() {
	startMenu();
	startGallery();
}

window.onload=init;




function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}