//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer


var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);

if (ie && win) {        pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {
                nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
                pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}

function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }

pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

plugJava = plugFlash = plugQT = false;

if (pluginlist.indexOf("Java")!=-1) {
    plugJava = true;
}
if (pluginlist.indexOf("QuickTime")!=-1) {
    plugQT = true;
}
if (pluginlist.indexOf("Flash")!=-1) {
    plugFlash = true;
}


/*
 * Attach this to the onload event handler
 * to make sure all of the items we’re
 * activating are available via the DOM.
 */
function activateActiveX()
{
  var activeXObjTypes = new Array( "applet", "embed", "object" );
  for ( var i = 0; i < activeXObjTypes.length; i++ )
  {
    var xObj = document.getElementsByTagName( activeXObjTypes[i] );
    for( var j = 0; j < xObj.length; j++ )
    {
      xObj[j].outerHTML = xObj[j].outerHTML;
    }
  }
}

function detectSize(step,full) {

         var winWidth = -1, winHeight = -1;
           
         var d=document;
         var winWidth, WinHeight;
                                             
         if (typeof window.innerWidth!='undefined')
           { winWidth = window.innerWidth; var winHeight = window.innerHeight; }
         else
           if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0)
             { winWidth = d.documentElement.clientWidth; winHeight = d.documentElement.clientHeight; }
           else
             if (d.body && typeof d.body.clientWidth!='undefined')
               { winWidth = d.body.clientWidth; winHeight = d.body.clientHeight; }

         if (winWidth+winHeight==-2) {
            if (step==undefined) { step = 0; }                   
            if (step<4) { detectSize(step+1,full); }
            winWidth = 800;
            winHeight = 600;
         }
              
         var winPW = 0;
         var winPH = 0;

         if (full==1) {
            winPW = winWidth-16;         
		    winPH = winHeight-27;
         } else {  
            winPW = winWidth-(step==0 ? (ie ? 16 : 16) : (ie ? 16 : 16));         
            winPH = Math.round(Math.min(winHeight-130,winPW/100*70)); 
         }

         return Array(winPW,winPH);
}


function checkJava(me) {

         oth = "(nemáte žádný alternativní prohlížeč)";
         oth2 = "(no alternative player)";
         othl = "no";

         if (plugFlash) {
             oth = oth2 = "Flash";
             othl = "flash";
         }
         if (plugQT) {
             oth = oth2 = "QuickTime";
             othl = "qt";
         }

         href = me.getAttribute('href');
         href = href.replace(/java/g, othl);

         if (!plugJava) {
             text = "Vás prohlížeč nemá instalován prohlížeč JAVA.\nKliknutím na OK, budete přesměrování na stránku s možností instalace JAVA.\nPokud nechcete instalovat JAVA, klikněte na STORNO\na bude Vám nabídnuta varianta prohlížeče "+oth+", který máte instalován.\n\nYour browser doesn't support JAVA.\nClick OK to redirect for JAVA instraller page.\nClick CANCEL to redirect for alternative "+oth2+" player you have installed.";

             if (!confirm(text)) {
                 if (othl!="no") {
                     window.location.href=href;
                 }
             } else {
                     window.open("http://www.java.com/en/download/index.jsp");
             }
             return false;
         }
         return true;
}

function checkQT(me) {

         oth = "(nemáte žádný alternativní prohlížeč)";
         oth2 = "(no alternative player)";
         othl = "no";

         if (plugFlash) {
             oth = oth2 = "Flash";
             othl = "flash";
         }
         if (plugQT) {
             oth = oth2 = "QuickTime";
             othl = "qt";
         }

         href = me.getAttribute('href');
         href = href.replace(/qt/g, othl);

         if (!plugQT) {
             text = "Vás prohlížeč nemá instalován prohlížeč QuickTime.\nKliknutím na OK, budete přesměrování na stránku s možností instalace JAVA.\nPokud nechcete instalovat QuickTime, klikněte na STORNO\na bude Vám nabídnuta varianta prohlížeče "+oth+", který máte instalován.\n\nYour browser doesn't support QuickTime.\nClick OK to redirect for QuickTime instraller page.\nClick CANCEL to redirect for alternative "+oth2+" player you have installed.";

             if (!confirm(text)) {
                 if (othl!="no") {
                     window.location.href=href;
                 }
             } else {
                     window.open("http://www.devalvr.com/paginas/instalacion/instalaplugiexp.html");
             }
             return false;
         }
         return true;
}

function checkFlash(me) {

         oth = "(nemáte žádný alternativní prohlížeč)";
         oth2 = "(no alternative player)";
         othl = "no";

         if (plugQT) {
             oth = oth2 = "QuickTime";
             othl = "qt";
         }
         if (plugJava) {
             oth = oth2 = "Java";
             othl = "java";
         }

         href = me.getAttribute('href');
         href = href.replace(/flash/g, othl);

         if (!plugFlash) {
             text = "Vás prohlížeč nemá instalován prohlížeč Flash.\nKliknutím na OK, budete přesměrování na stránku s možností instalace JAVA.\nPokud nechcete instalovat Flash, klikněte na STORNO\na bude Vám nabídnuta varianta prohlížeče "+oth+", který máte instalován.\n\nYour browser doesn't support Flash.\nClick OK to redirect for Flash instraller page.\nClick CANCEL to redirect for alternative "+oth2+" player you have installed.";

             if (!confirm(text)) {
                 if (othl!="no") {
                     window.location.href=href;
                 }
             } else {
                     window.open("http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash");
             }
             return false;
         }
         return true;
}

function checkAll(typ,href) {

         oth = "Nemáte žádný vhodný prohlížeč na panoramatické fotografie.\nKlikněte na OK pro instalaci prohlížeče.\n\nNo panorama-photo player found. Click OK to install player.";
         othl = "no";

         if (plugFlash) {
             oth = oth2 = "Flash";
             othl = "flash";
         }
         if (plugQT) {
             oth = oth2 = "QuickTime";
             othl = "qt";
         }
         if (plugJava) {
             oth = oth2 = "Java";
             othl = "java";
         }

         switch (typ) {
         case "flash":
               if (!plugFlash) {
                   if (othl!="no") {
                          href = href.replace(/flash/g, othl);
                          window.location.href=href;
                   } else {
                      if (confirm(oth)) {
                          window.open("http://www.devalvr.com/paginas/instalacion/instalaplugiexp.html");
                      }
                   }
               }
               break;
         case "qt":
               if (!plugQT) {
                   if (othl!="no") {
                          href = href.replace(/qt/g, othl);
                          window.location.href=href;
                   } else {
                      if (confirm(oth)) {
                          window.open("http://www.devalvr.com/paginas/instalacion/instalaplugiexp.html");
                      }
                   }
               }
               break;
         default:               
               if (!plugJava) {
                   if (othl!="no") {
                          href = href.replace(/java/g, othl);                       
                          window.location.href=href;
                   } else {
                      if (confirm(oth)) {
                          window.open("http://www.devalvr.com/paginas/instalacion/instalaplugiexp.html");
                      }
                   }
               }
               break;
         }
         return true;
}

