//<script language="javascript">
// various helper scripts for knhproductions.ca -- written by Selva Nair
    var debug = 0; 
    var Mac, Win, Linux, Other;
    var bName, bVer, OS;
    detect = navigator.userAgent.toLowerCase();

    Win = navigator.userAgent.indexOf("Win") > - 1;
    Mac = navigator.userAgent.indexOf("Mac") > - 1;
    Linux = navigator.userAgent.indexOf("Linux") > - 1;
    Other = !(Win || Mac || Linux);
    OS = "Unknown OS"
    if(Win) OS = "Windows"
    else if(Mac) OS = "Macintosh"
    else if(Linux) OS = "Linux"

    if(detect.indexOf('safari') > -1) bName = "Safari";
    else if(detect.indexOf('opera') > -1) bName = "Opera";
    else if(detect.indexOf('msie') > -1) bName = "IE";
    else if(detect.indexOf('compatible') < 0) bName = "NS";
    else bName = "Other";
    if(document.layers) bName = "NN";
    //if(navigator.appName.substring(0,9) == "Microsoft") bName = "IE";
    //else if(navigator.appName.substring(0,8) == "Netscape") bName = "NS";

    if(parseInt(navigator.appVersion) >= 3) bVer="3+";
    if(parseInt(navigator.appVersion) >= 4) bVer="4+";
    if(parseInt(navigator.appVersion) >= 5) bVer="5+";
    
    //frame busting idea from www.quirksmod.com/js/framebust.html
    var intopframe = (top == self);
    var current_link_color = "#dd4444";

    // A simple album
    // Idea from http://www.mcfedries.com/JavaScript/ImageCycler.asp
    // using window.name as hack for persistence is from
    // 
    var imgNumber = 0
    function NextImage() {
        imgNumber++
        if (imgNumber == NumberOfImages)
        imgNumber = 0
        document.images["SlideShow"].src = img[imgNumber]
        window.name = String('SlideShow_' + imgNumber);
        if(change_quote) change_quote();
     }

    function PrevImage() {
        imgNumber--
        if (imgNumber < 0)
        imgNumber = NumberOfImages - 1
        document.images["SlideShow"].src = img[imgNumber]
        window.name = String('SlideShow_' + imgNumber);
        if(change_quote) change_quote();
    }

    var haveqt;
/*
   <script language="VBscript">
    <!--
     On Error Resume Next
     Set theObject = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")
     On Error goto 0
     
     If IsObject(theObject) Then
        If theObject.IsQuickTimeAvailable(0) Then 'Just check for file
           haveqt=true
        Endif
     Endif
   //-->
   </script>
*/
    if(navigator.plugins) {
         for(i=0; i<navigator.plugins.length; i++) {
            if(navigator.plugins[i].name.indexOf("Quicktime") > -1)
               { haveqt = true; }
         }
    }
   
   var  media_type = "wmp"; // windows media by default
   function embed_movie(movie_url, type){
     // usage: document.write(embed_movie(filename, type) 
     //     with type = "qt" to embed quicktime player
     //                 "wmp" to embed media player
     var code = ""
     if(type == "qt") {
            code = ' <!-- active-X and netscape compatible EMBED as described at http://developer.apple.com/quicktime/compatibility.html --> \
              <object id="quicktime" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"  \
              width="320" height="256"  \
              standby="Loading the movie.."  \
              codebase="http://www.apple.com/qtactivex/qtplugin.cab"> \
              <param name="qtsrc" value="' + movie_url + '"> \
              <param name="qtsrcdontusebrowser" value="true"> \
              <param name="src" value="dummy.mov"> \
              <param name="controller" value="true">  \
              <param name="autoplay" value="true">  \
              <!--param name="target" value="myself"--> \
              <!--param name="href" value="' + movie_url +'"--> \
              <param name="bgcolor" value="black"> \
              <param name="standby" value="Loading the movie.."> \
              <param name="pluginspage" \
              value="http://www.apple.com/quicktime/download/"> \
              <embed type="video/quicktime" name="quicktime" \
                width="320" height="256" controller="true" \
                autoplay="true" src="dummy.mov" \
                qtsrcdontusebrowser="true" \
                qtsrc="' + movie_url +  '" bgcolor="black" border="0" \
                pluginspage="http://www.apple.com/quicktime/download/"> \
              </embed> \
              </object> ';
     }
     else {
              code = ' \
              <object id="medialplayer" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" \
              width="320" height="286"  \
              codebase="http://activex.microsoft.com/activex/controls/mplayer/ennsmp2inf.cab#Version=6,4,7,1112" standby="Loading the movie.."> \
              <param name="FileName" value="' +  movie_url + '"> \
              <param name="ShowControls" value="1"> \
              <param name="ShowDisplay" value="0"> \
              <param name="ShowStatusBar" value="0"> \
              <param name="Autostart" value="True"> \
              <param name="Autosize" value="0"> \
              <param name="AnimationAtStart" value="1"> \
              <param name="TransparentAtStart" value="true"> \
              <embed type="application/x-mplayer2"  \
                 name="mediaplayer" width="320" height="286" ShowControls="1" \
                 AutoStart="1" TransparentAtStart="1" ShowDisplay="0" \
                 ShowStatusBar="0" AnimationAtStart="1" \
                 src="' + movie_url + '" bgcolor="000000" border="0"> \
              </embed> \
              </object> ';
     }
     return code;
  }
  var extLinkWindow;
  function newwindow(url) {
    if(extLinkWindow && !extLinkWindow.closed && extLinkWindow.location) {
      extLinkWindow.location.href = url;
    }
    else {
       extLinkWindow=window.open(url, "window1", "width=740,height=640,location=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes");
    }
    if(extLinkWindow && window.focus) {
      extLinkWindow.focus();
    }
  }
  function newwindow1(e) {
    if(!e) e = event;
    // Dont do anything if a modifier key is pressed-allow opening in tabs etc 
    if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) 
    		return true;
    obj = e.target || e.srcElement;
    url = obj.getAttribute('href');
    if(extLinkWindow && !extLinkWindow.closed && extLinkWindow.location) {
      extLinkWindow.location.href = url;
    }
    else {
      extLinkWindow=window.open(url, "window1", "width=740,height=640,location=yes,menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes");
    }
    if(extLinkWindow) {
      if(window.focus) { extLinkWindow.focus();}
      return false;
    }
    return true; // Failure -- return true to allow the link to open in same window
  }

  function changeImage(imgname, imgsrc){
    if(document.images[imgname]) document.images[imgname].src = imgsrc ;
  }
  function init_trailer() {  // redefined when needed -- this empty def
                             // is to avoid undefined reference in onLoad
  }

  function toggle_display(id) { // toggle an element (eg. a div) from visible to invisible)
      if(!document.getElementById) return;
      var d = document.getElementById(id);
      if(d.style.display == "none") d.style.display = "block";
      else d.style.display = "none";
   }
   function maillink(me, mydomain) { // make a mail to link
      var url = "mailto:"+
                 me+
                 String.fromCharCode(64)+
                 mydomain ;
      location.href = url;
   }

   function PopWin(url,name,options){
    var ContextWindow = window.open(url,name,options);
    ContextWindow.opener = this;
    ContextWindow.focus();
   }
   function RefreshOriginalWindow(url) {
     if ((window.opener == null) || (window.opener.closed))
     {
       var OriginalWindow = window.open(url);
       OriginalWindow.opener = this;
     }
     else{
     window.opener.location=url;
     }
   }

function scroll(seed)

{

     var msg = "Sept 25, 7:30 pm - Watch N is for Nanotechnology on Tech TV.";
     var out   = " ";

     var i     = 1;

        

     if (seed > 100) {

          seed--;

          var cmd  = "scroll(" + seed + ")";

          timerTwo = window.setTimeout(cmd,100);

     }

     else if (seed <= 100 && seed > 0) {

          for (i = 0 ; i < seed ; i++) {

               out += " ";

          }

          out += msg;

          seed--;

          var cmd = "scroll(" + seed + ")";

          window.status=out;

          timerTwo=window.setTimeout(cmd,100);

     }

     else if (seed <= 0) {

          if (-seed < msg.length) {

               out += msg.substring(-seed,msg.length);

               seed--;

               var cmd="scroll(" + seed + ")";

               window.status=out;

               timerTwo=window.setTimeout(cmd,100);

          }

          else {

               window.status=" ";

               timerTwo=window.setTimeout("scroll(100)",75);

          }

     }

 }

// not used any more ..
function set_ccxe(){
  if(document.order.country.value=="") {
    alert("Select a country to set the shipping rate");
    return false;
  }
  var country = document.order.country.value;
  var shipby = document.order.shipby.value;
  var amt = "37.00";

  if(country == "CA" && shipby == "Air") amt = "33.00";
  else if(country == "CA" && shipby == "Express") amt = "42.00";
  else if(country == "US" && shipby == "Express") amt = "47.00";
  else if(country == "US" && shipby == "Air") amt = "36.00";
  else amt = "37.00";

  document.ccxe.Amount.value = amt;
  return true;
}

//</script>
