// Video Gallery Pro is the property of Sizzling Web Design, a subsidiary of -->
// Sizzling Video International and can only be used with permission.-->
//  Please visit www.SizzlingWebDesign.com for more information -->
//  Copyright 2006 All rights reserved -->
//
// initialize global variables
var detectableWithVB = false;
var pluginFound = false;
function stripslash (intext) {
//  alert("stripslash"+intext);
  var endstr = true;
  var outtext = "";
  do {
     var slashpos = intext.indexOf("\\");
     if (slashpos > 0) {
        outtext += intext.substr(0,slashpos);
        intext = intext.substr(slashpos + 1,intext.length - slashpos - 1);
     }
     else {
       outtext += intext;
       endstr = false;
     }
  } while (endstr);
  return outtext;
}
function checkdir (dirname) {
 // alert("check "+dirname);
 var isweb = false;
 if (dirname.length > 5) {
  //    alert(">5");
      var hdir = dirname.substr(0,5);
   //   alert(hdir);
      hdir = hdir.toLowerCase();
  //    alert('dirs.length '+dirs.length);
      for (nnn=0;nnn<dirs.length;nnn++) {
         if (hdir == dirs[nnn]) {
           isweb = true;
           nnn = dirs.length;
         }
      }
  }
//  if (isweb) alert("true");
//  else alert("false");
  return isweb;
}
function RealPlayerVersionNN(){
    var pname = "pname";
    var pfilename = "pfilename";
    var RealVer = " ";
    var pdesc = "pdesc";
    verflag = false;
    for (i=0; i < navigator.plugins.length; i++ ) {
       pname = navigator.plugins[i].name;
       pfilename = navigator.plugins[i].filename;
       pdesc = navigator.plugins[i].description;
       if ((pname.indexOf("Real") >= 0 ) && (verflag == false)) {
          if (pname.indexOf("Player") >= 0 ) {
             rver = pdesc.charAt(0);
             if (rver=='0') verflag = true;
             if (rver=='1') verflag = true;
             if (rver=='2') verflag = true;
             if (rver=='3') verflag = true;
             if (rver=='4') verflag = true;
             if (rver=='5') verflag = true;
             if (rver=='6') verflag = true;
             if (rver=='7') verflag = true;
             if (rver=='8') verflag = true;
             if (rver=='9') verflag = true;
             if (verflag == true) {
                 RealVer = pdesc;
                 i = navigator.plugins.length;
             }
          }
       }
    }
return RealVer;
}


function QuickTimeVersionNN(){
    var pname = "pname";
    var pfilename = "pfilename";
    var qtverlong = " ";
    var pdesc = "pdesc";
    var qtflag = false;
    verflag = false;
    for (i=0; i < navigator.plugins.length; i++ ) {
       pname = navigator.plugins[i].name;
       pfilename = navigator.plugins[i].filename;
       pdesc = navigator.plugins[i].description;
      if ((pname.indexOf("QuickTime") >= 0 ) && (qtflag == false)) {
         if (pname.indexOf("Plug-in") >= 0 ) {
            plugstrt = pname.indexOf("Plug-in");
            startchar = plugstrt + 8;
            qtver = pname.charAt(startchar);
            lastchar = pname.length - 1;
            qtverlong = pname.substr(startchar,lastchar);
            i = navigator.plugins.length;
            qtflag = true;
          }
      }
   }
return qtverlong;
}

function RealPlayerVersionIE(){
        var vers=RealOneActiveXObject.RealPlayerVersion
        if (vers > ' ') {
	   var unpacked=UnpackVersionNumber(vers)
	   return unpacked
        }
}

// Unpack the version number

function UnpackVersionNumber(n)
 {
   return "" + (n >> 28) + "." +
   ((n & 0xFF00000) >> 20) + "." +
   ((n & 0xFF000) >> 12) + "." +
   ( n & 0xFFF);
 }

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) ||
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }	
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectQuickTime() {
    if(detectableWithVB) {
	pluginFound = detectQuickTimeActiveXControl();
    }
    return pluginFound;
}

function detectReal(redirectURL, redirectIfFound) {
    RealVersion = RealPlayerVersionNN();
    // if not found, try to detect with VisualBasic
    if(RealVersion == " ") {
	RealVersion = RealPlayerVersionIE();
    }	
    return RealVersion;
}

function detectWindowsMedia() {
    pluginFound = detectPlugin('Windows Media Player');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return pluginFound;
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
	    // loop through all desired names and check each against the current plugin name
	    var numFound = 0;
	    for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
		// if desired plugin name is found in either plugin name or description
		if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
		}
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('<script language="VBscript">');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion >= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('</scr' + 'ipt>');
}
// -->



function detectreal(sendmsg) {
var abletodetect = canDetectPlugins();
var Realcur = false;
var Realins = false;
if (abletodetect) {
   var RealVerchk = detectReal();
//   alert("real ver"+RealVerchk);
   if (RealVerchk > " ") {
      Realins = true
      RealRel = RealVerchk.substr(4,2);
      if (sendmsg == false) msgout += "\n "+reallit+ verlit.toLowerCase() + RealRel + " "+installed+": ";
  //    alert(RealRel);
      if (RealVerchk.charAt(0) == "6") {
         if (RealRel.charAt(1) == ".") RealRel = RealRel.charAt(0);
   //      alert(RealRel+" "+realver);
         if  (RealRel >= realver) {
            Realcur = true;
            if (sendmsg == false) msgout += good;
         }
         else {
            if (sendmsg)
                alert(realvermsg);
            else  msgout += verlit+ realver +" "+isrequired+".";
         }
      }
      else {
         if (sendmsg == false)
             msgout += "\n "+unable+  reallit +installed+".  "+verlit +realver+ isrequired+".";
      }
   }
 //  if (Realcur == false) {
//	  pluginFound = detectActiveXControl('rmocx.RealPlayer G2 Control') 		
//	  if (pluginFound) {
//     	   Realins = true
//     }
//     else {
//        pluginFound = detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)')
//        if (pluginFound) {
//    	      Realins = true
//        }
//        else {
//		      pluginFound = detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)')
//             if (pluginFound) {
//        	      Realins = true
//             }
//         }
//      }
//   }
}
return Realins;
}
function detectqt(codec,sendmsg){
var abletodetect = canDetectPlugins();
var Quickcur = false;
var Quickins = false;
if (abletodetect) {
   var QuickTimeVer = QuickTimeVersionNN();
 //  alert(QuickTimeVer);
   if (QuickTimeVer > " ") {
      Quickins = true;
  //    alert(codec);
      if (codec == "QT") {
         var verchk = qtverchk;
         if (sendmsg == false) msgout += "\n "+quicklit+" "+ verlit.toLowerCase()+ QuickTimeVer.charAt(0)+ " "+installed+": ";
      }
      else {
          var verchk = mp4verchk;
          if (sendmsg == false) msgout += "\n "+forlit+" MPEG-4, "+quicklit+  verlit.toLowerCase()+" "+ QuickTimeVer.charAt(0)+ " "+installed+": ";
      }
      if (QuickTimeVer.charAt(0) >= verchk) {
          Quickcur = true;
          if (sendmsg == false) msgout += good;
      }
     else {
       if (sendmsg) {
         if (codec == "QT") alert(qtvermsg);
         else alert(mp4vermsg);
       }
       else msgout += verlit+ verchk + " "+needed;
     }
   }
   else {
      QuickTimeDet = detectQuickTime();
      if (QuickTimeDet) {
       // alert("qt fnd");
        Quickins = true;
        if (sendmsg == false) {
           msgout += "\n "+quicklit;
           if (codec == "MP4") msgout += forlit.toLowerCase()+"MPEG-4";
           msgout += noverfnd;
           if (codec == "QT") msgout += qtverchk;
           else msgout += mp4verchk;
           msgout += " "+isrequired+".";
        }
      }
      else {
         if (sendmsg == false) {
            msgout += "\n "+ unable + quicklit + installed+".  "+verlit+" ";
            if (codec == "QT") msgout += qtverchk;
            else msgout += mp4verchk;
            msgout += " "+isrequired+".";
         }
      }
   }
}
//alert("msgout "+msgout);
return Quickins;
}
function detectwm(codec,sendmsg){
//   alert("detect wm");
   var WinMediains = false;
   var abletodetect = canDetectPlugins();
  // alert(abletodetect);
 //  alert(navigator.plugins.length);
   if (abletodetect) {
     for (i=0; i < navigator.plugins.length; i++ ) {
        var plugname = navigator.plugins[i].name;
      //   alert(plugname);
        var fndwm = plugname.indexOf("Windows Media Player");
      //  alert("index "+fndwm);
        if (fndwm >= 0) {
      //    alert("fnd");
          WinMediains = true;
          i = navigator.plugins.length;
          if (sendmsg == false) {
              msgout += "\n "+winlit + noverfnd;
              if (codec == "WM9") msgout += "9";
              else msgout += "7";
               msgout += " "+isrequired+".";
          }
        }
     }
   }
  if (WinMediains == false) {
      var browser = GetBrowser();
   //   alert(browser);
      if (browser == "IE") {
      //  alert(WMPVer);
        if (WMPVer != "unknown") {
           WinMediains = true;
           var perpos = WMPVer.indexOf('.');
           var wmversins  = WMPVer.substr(0,perpos);
      //    alert(wmversins);
           var chkvers = codec.charAt(2);
        //    alert(chkvers+" "+wmversins);
           if (sendmsg == false) msgout += "\n "+ winlit +  verlit.toLowerCase()+ wmversins+ " "+installed+": ";
           if (parseFloat(chkvers) > parseFloat(wmversins)) {
              if ((parseFloat(chkvers) == 8) && (parseFloat(wmversins) == 7)) {
                if (sendmsg == false) msgout += good;
              }
              else {
                 if (sendmsg) alert(wmvermsg);
                 else  msgout += chkvers + " "+isrequired+".";
              }
           }
           else if (sendmsg == false) msgout += good;
        }
     }
  }
  if ((WinMediains == false) && (sendmsg == false))
     msgout += "\n "+unable+  winlit+" "+installed+".  "+verlit +codec.charAt(2)
       + " "+isrequired+".";
 // if (WinMediains)
 //   alert("wm fnd");
   return WinMediains;
}
function detectflash(codec,sendmsg){
 //  alert("detect flash");
   if (codec == "FL8") {
      var requiredMajorVersion = 8;
      var flashverchk = 8;
   }
   else {
      var requiredMajorVersion = 7;
       var flashverchk = 7;
   }
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
var flashverins = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
//  alert ( flashverins);
// var flashverins = 8;
           if (sendmsg == false) msgout += "\n "+ flashlit +  verlit.toLowerCase()+ flashverins+ " "+installed+": ";
           if (parseFloat(flashverchk) <= parseFloat(flashverins)) {
                if (sendmsg == false) msgout += good;
                return true;
           }
           else {
               if (sendmsg) alert(flashvermsg);
               else  msgout += flashverchk + " "+isrequired+".";
               return false;
           }
      return true;
}
function GetBrowser()
{
   var agt=navigator.userAgent.toLowerCase();
  // alert(agt);
   if( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) )
       return "IE";
   else if( ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
         && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
         && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)) )
       return "Netscape";
   else
       return "unknown";
}
function setfilesize () {
 // alert("start filesize");
  var sizefnd = document.getElementById('filesizedisp');
  if (sizefnd != null) {
    var codec = document.video.formatsel.value;
    var aud = document.video.connectsel.value;
    var videoid = document.video.videoid.value;
    var playlistid = document.video.playlistid.value;
    var filesz = "";
    if ((codec != "b1") && (aud != "b1")) {
       for (m=0;m<videoidarr.length;m++) {
      //    alert ("videoidarr[m] "+ videoidarr[m] + " playlistidarr[m] "+
      //    playlistidarr[m] + " videoid " + videoid + " playlistid "+playlistid );
          if ((videoidarr[m] == videoid) && (playlistidarr[m] == playlistid)) {
               for (n=0;n<codecarr[m].length;n++) {
          //          alert(codecarr[m][n]+" "+codec+" "+audarr[m][n]+" "+aud);
                  if ((codecarr[m][n] == codec) && (audarr[m][n] == aud)) {
                     filesz = filelit + sizearr[m][n];
                     n = codecarr[m].length;
                  }
               }
          }
       }
    }
    document.getElementById('filesizedisp').innerHTML =  filesz;
  }
}





function setformat() {
//alert("start set format");
//alert("formatsel "+formatsel);
if (formatselsw == "y") {
   var outcnt = -1;
   var outarr = new Array();
   var outdesc = new Array();
 //  alert("before videoid");
   var videoid = document.video.videoid.value;
 //  alert("before playlistid videoid "+videoid);
   var playlistid = document.video.playlistid.value;
 // alert ("videoid "+videoid+" playlistid "+playlistid+" nbr codec "+tblcodecarr.length);
 //   alert ("videoid "+videoid+" playlistid "+playlistid+" nbr codec ");
   var curselindex = document.video.formatsel.selectedIndex;
   if (curselindex == 0) var cursel = formatselval;
   else var cursel = document.video.formatsel.options[curselindex].value;
   for (n=0;n<tblcodecarr.length;n++) {
    //   alert ("videoidarr length "+videoidarr.length);
       for (m=0;m<videoidarr.length;m++) {
      //    alert ("videoidarr[m] "+ videoidarr[m] + " playlistidarr[m] "+
      //    playlistidarr[m] + " videoid " + videoid + " playlistid "+playlistid );
          if ((videoidarr[m] == videoid) && (playlistidarr[m] == playlistid)) {
       //      alert ("codecarr[m].length "+codecarr[m].length);
             for (p=0;p<codecarr[m].length;p++) {
        //       alert ("codecarr[m][p] "+codecarr[m][p]+ " tblcodecarr[n] " + tblcodecarr[n]);
               if (codecarr[m][p] == tblcodecarr[n]) {
                   outcnt++;
               //    alert("outcnt "+outcnt);
                   outarr[outcnt] = tblcodecarr[n];
                   outdesc[outcnt] = tblcodecdescarr[n];
                   p = codecarr[m].length;
             //      m = videoidarr.length;
              //     alert("end sets");
                }
              }
           }
       }
   }
 //  alert("outcnt "+outcnt);
   if (outcnt == 0) {
     document.video.formatsel.options.length = 1;
     document.video.formatsel.options[0].text = outdesc[0];
     document.video.formatsel.options[0].value = outarr[0];
     document.video.formatselh.value = outarr[0];
     document.video.formatsel.disabled = true;
   }
   else {
    //  alert("start set format");
      document.video.formatsel.options.length = outarr.length + 1;
      document.video.formatsel.options[0].text = selectformat;
      document.video.formatsel.options[0].value = "b1";
      document.video.formatsel.disabled = false;
      for (n=0;n<outarr.length;n++) {
        m = n + 1;
        document.video.formatsel.options[m].text = outdesc[n];
        document.video.formatsel.options[m].value = outarr[n];
        if (outarr[n] == cursel) document.video.formatsel.options[m].selected = true;
      }
   }
}
 //alert("end set format");
}
function setconnect() {
// alert("start set connect");
//alert("formatsel "+formatsel);
if (connectselsw == "y") {
   var outcnt = -1;
   var outarr = new Array();
   var outdesc = new Array();
//   alert("before videoid");
   var videoid = document.video.videoid.value;
//   alert("before playlistid "+videoid);
   var playlistid = document.video.playlistid.value;
//  alert ("videoid "+videoid+" playlistid "+playlistid+" nbr codec "+tblcodecarr.length);
 //   alert ("videoid "+videoid+" playlistid "+playlistid+" nbr codec ");
   var curselindex = document.video.connectsel.selectedIndex;
   var frmselindex = document.video.formatsel.selectedIndex;
// var  curfrmsel = document.video.formatsel.options[curselindex].value;
   var   curfrmsel = document.video.formatsel.value;
   if (curselindex == 0) var cursel = connectselval;
   else var cursel = document.video.connectsel.options[curselindex].value;
   for (n=0;n<tblaudarr.length;n++) {
    //   alert ("videoidarr length "+videoidarr.length);
       for (m=0;m<videoidarr.length;m++) {
      //   alert ("videoidarr[m] "+ videoidarr[m] + " playlistidarr[m] "+
      //    playlistidarr[m] + " videoid " + videoid + " playlistid "+playlistid );
          if ((videoidarr[m] == videoid) && (playlistidarr[m] == playlistid)) {
       //      alert ("codecarr[m].length "+codecarr[m].length);
             for (p=0;p<audarr[m].length;p++) {
     //          alert ("audarr[m][p] "+audarr[m][p]+ " tblaudarr[n] " + tblaudarr[n]);
               if (audarr[m][p] == tblaudarr[n]) {
                   if ((curfrmsel == "b1") || (curfrmsel  == codecarr[m][p])) {
                      outcnt++;
         //         alert("outcntco "+outcnt+tblaudarr[n]+tblaudiencearr[n]);
                      outarr[outcnt] = tblaudarr[n];
                      outdesc[outcnt] = tblaudiencearr[n];
                      p = audarr[m].length;
             //      m = videoidarr.length;
              //     alert("end sets");
                   }
                }
              }
           }
       }
   }
 //  alert("outcnt "+outcnt);
   if (outcnt == 0) {
     document.video.connectsel.options.length = 1;
     document.video.connectsel.options[0].text = outdesc[0];
     document.video.connectsel.options[0].value = outarr[0];
     document.video.connectselh.value = outarr[0];
     document.video.connectsel.disabled = true;
   }
   else {
   //   alert("start set aud "+outarr.length + 1);
      document.video.connectsel.options.length = outarr.length + 1;
 //     alert("after length");
      document.video.connectsel.options[0].text = selectspeed;
      document.video.connectsel.options[0].value = "b1";
      document.video.connectsel.disabled = false;
  //    alert("after please select co");
 //     alert("outarr.length "+outarr.length);
      for (n=0;n<outarr.length;n++) {
        m = n + 1;
  //      alert("m "+m+" outdesc[n] "+outdesc[n]);
        document.video.connectsel.options[m].text = outdesc[n];
        document.video.connectsel.options[m].value = outarr[n];
        if (outarr[n] == cursel) document.video.connectsel.options[m].selected = true;
      }
   }
}
 //alert("end set format");
}
function setplaydown() {
//alert("start set playdown");
//alert("downloadselsw "+downloadselsw);
if (downloadselsw == "y") {
   var outcnt = -1;
   var outarr = new Array();
   var outdesc = new Array();
//   alert("before videoid");
   var videoid = document.video.videoid.value;
 //  alert("before playlistid "+videoid);
   var playlistid = document.video.playlistid.value;
//  alert ("videoid "+videoid+" playlistid "+playlistid);
 //   alert ("videoid "+videoid+" playlistid "+playlistid+" nbr codec ");
   var curselindex = document.video.downloadsel.selectedIndex;
 //  alert("curselindex "+curselindex);
 //  var conselindex = document.video.connectsel.selectedIndex;
//   alert("conselindex "+conselindex);
  // curconsel = document.video.connectsel.options[conselindex].value;
   var curconsel = document.video.connectsel.value;
//   alert("curconsel "+curconsel);
  // var frmselindex = document.video.formatsel.selectedIndex;
//   alert("frmselindex "+frmselindex);
  // curfrmsel = document.video.formatsel.options[frmselindex].value;
    var curfrmsel = document.video.formatsel.value;
 //  alert("curfrmsel "+curfrmsel);
  // alert('downselval '+downloadselval);
   if ((curselindex == 0) || (curselindex == -1))  var cursel = downloadselval;
   else var cursel = document.video.downloadsel.options[curselindex].value;
//   alert("curconsel "+curconsel+" curfrmsel "+curfrmsel+" cursel "+cursel);
   var tblplayarr = new Array();
   tblplayarr[0] = "p";
   tblplayarr[1] = "d";
   var tblplaydescarr = new Array();
   tblplaydescarr[0] = dsplay;
   tblplaydescarr[1] = dsdown;
  // alert("tblplayarr length"+tblplayarr.length);
  for (n=0;n<tblplayarr.length;n++) {
   //   alert ("videoidarr length "+videoidarr.length);
       for (m=0;m<videoidarr.length;m++) {
  //        alert ("videoidarr[m] "+ videoidarr[m] + " playlistidarr[m] "+
   //       playlistidarr[m] + " videoid " + videoid + " playlistid "+playlistid );
          if ((videoidarr[m] == videoid) && (playlistidarr[m] == playlistid)) {
       //      alert ("codecarr[m].length "+codecarr[m].length);
             for (p=0;p<playarr[m].length;p++) {
               if ((playarr[m][p] == tblplayarr[n]) || (playarr[m][p] == "b")) {
                 //  alert ("playarr[m][p] "+playarr[m][p]+ " tblplayarr[n] " + tblplayarr[n]);
                   if ((curfrmsel == "b1") || (curconsel == "b1") ||
                      ((curfrmsel  == codecarr[m][p]) && (curconsel  == audarr[m][p])
                         && ((playarr[m][p] == tblplayarr[n]) || (playarr[m][p] == "b")) ) ) {
                     outcnt++;
            //       alert("outcntdl "+outcnt);
                      if (outcnt > 0) {
                         var prevcnt = outcnt - 1;
                         if (outarr[prevcnt] != tblplayarr[n]) {
                           outarr[outcnt] = tblplayarr[n];
                           outdesc[outcnt] = tblplaydescarr[n];
                         }
                         else outcnt = outcnt - 1;
                      }
                      else {
                        outarr[outcnt] = tblplayarr[n];
                        outdesc[outcnt] = tblplaydescarr[n];
                      }
                     p = playarr[m].length;
              //     alert("end sets");
                   }
                }
              }
           }
       //    m = videoidarr.length;
       }
   }
 // alert("outcnt "+outcnt);
   if (outcnt == 0) {
     document.video.downloadsel.options.length = 1;
     document.video.downloadsel.options[0].text = outdesc[0];
     document.video.downloadsel.options[0].value = outarr[0];
     document.video.downloadselh.value = outarr[0];
     document.video.downloadsel.disabled = true;
   }
   else {
   //   alert("start set playdown");
      document.video.downloadsel.options.length = outarr.length + 1;
      document.video.downloadsel.options[0].text = selectview;
      document.video.downloadsel.options[0].value = "b1";
      document.video.downloadsel.disabled = false;
     for (n=0;n<outarr.length;n++) {
        m = n + 1;
        document.video.downloadsel.options[m].text = outdesc[n];
        document.video.downloadsel.options[m].value = outarr[n];
    //    alert('outarr '+outarr[n]+' cursel '+cursel);
        if (outarr[n] == cursel) document.video.downloadsel.options[m].selected = true;
      }
   }
}
 //alert("end set format");
}

function getplayer() {
   if (document.video.D1.value == "a1" ){
       x = window.open('http://www.microsoft.com/windows/windowsmedia/players.aspx');
   }
   if (document.video.D1.value == "a2" ){
       x = window.open('http://www.real.com/player/index.html');
   }
   if (document.video.D1.value == "a3" ){
       x = window.open('http://www.apple.com/quicktime/download');
   }
   if (document.video.D1.value == "a4" ){
       x = window.open('http://www.macromedia.com/go/getflashplayer');
   }
}
function nextvideosel(){
//  alert("next vid");
   var seqno = document.video.seqno.value;
   var nextsw = false;
//  alert(galseqnoarr.length);
   for (n=0;n<galseqnoarr.length;n++) {
  //    alert("seqno "+seqno+" galseqnoarr[n] "+galseqnoarr[n]);
      if (nextsw) {
   //      alert("next");
          document.video.videoid.value = videoidarr[n];
          document.video.playlistid.value = playlistidarr[n];
     //      alert("next2"+vgpdir+imagedirpatharr[n]  + imagefilearr[n]);
          if (checkdir(imagedirpatharr[n])) {
             var newimage = imagedirpatharr[n]  + imagefilearr[n];
          }
          else {
             var newimage = vgpdir + imagedirpatharr[n]  + imagefilearr[n];
             }
    //      alert("image "+newimage);
           document.videoimage.src= newimage;
         document.videoimage.alt = stripslash(videotextarr[n]);
          document.videoimage.title = stripslash(videotextarr[n]);
    //       alert("desc");
          document.getElementById('videodesc').innerHTML =  stripslash(videodescarr[n]);
          document.video.seqno.value = galseqnoarr[n];
          setnextprev(n);
          n = galseqnoarr.length;
      }
      else if (seqno == galseqnoarr[n]) {
        if (n < galseqnoarr.length - 1)  nextsw = true;
      }
   }
   setformat();
   setconnect();
   setplaydown();
   setfilesize();
   setplaydownbut();
}
function prevvideosel() {
 ///   alert("prev vid");
   var seqno = document.video.seqno.value;

//   alert(galseqnoarr.length);
   for (n=0;n<galseqnoarr.length;n++) {
    //  alert("seqno "+seqno+" galseqnoarr[n] "+galseqnoarr[n]);
       if (seqno == galseqnoarr[n]) {
          if (n > 0) {
            m = n - 1;
       //   alert("next");
            document.video.videoid.value = videoidarr[m];
            document.video.playlistid.value = playlistidarr[m];
      //    alert("image");
            if (checkdir(imagedirpatharr[m]))
               document.videoimage.src= imagedirpatharr[m] + imagefilearr[m];
            else
               document.videoimage.src= vgpdir + imagedirpatharr[m] + imagefilearr[m];
            document.videoimage.alt = stripslash(videotextarr[m]);
            document.videoimage.title = stripslash(videotextarr[m]);
     //      alert("desc");
            document.getElementById('videodesc').innerHTML =  stripslash(videodescarr[m]);
            document.video.seqno.value = galseqnoarr[m];
            setnextprev(m);
            n = galseqnoarr.length;
          }
      }
   }
   setformat();
   setconnect();
   setplaydown();
   setfilesize();
   setplaydownbut();
}

function checkplayer() {
    var   curfrmsel = document.video.formatsel.value;
  //  alert(curfrmsel);
    if (curfrmsel == "RM") {
      var realchkret = detectreal(true);
      if (realchkret == false) alert(noreal);
    }
    else if (curfrmsel == "QT") {
      var qtchkret = detectqt(curfrmsel,true);
      if (qtchkret == false) alert(noqt);
    }
    else if (curfrmsel == "MP4") {
      var mp4chkret = detectqt(curfrmsel,true);
      if (mp4chkret == false) alert(nomp4);
    }
    else if ((curfrmsel == "WM9") || (curfrmsel == "WM8")) {
      var wmchkret = detectwm(curfrmsel,true);
      if (wmchkret == false) alert(nowm);
    }
    else if ((curfrmsel == "FL8") || (curfrmsel == "FL7")) {
      var wmchkret = detectflash(curfrmsel,true);
      if (wmchkret == false) alert(noflash);
    }
}
function checkplayerinst () {
 msgout = playermsg;
 msgout += "\n____________________";
 if (formatselsw == "y") {
    for(n=0;n < document.video.formatsel.options.length;n++) {
          var curcodec = document.video.formatsel.options[n].value;
      //    alert(curcodec);
          if  (curcodec == "RM") detectreal(false);
          if  ((curcodec == "QT") || (curcodec == "MP4")) detectqt(curcodec,false);
          if  ((curcodec == "WM9") || (curcodec == "WM8")) detectwm(curcodec,false);
          if  ((curcodec == "FL8") || (curcodec == "FL7")) detectflash(curcodec,false);
    }
 }
 else {
   var curcodec = document.video.formatsel.value;
   if  (curcodec == "RM") detectreal(false);
   if  ((curcodec == "QT") || (curcodec == "MP4")) detectqt(curcodec,false);
   if  ((curcodec == "WM9") || (curcodec == "WM8")) detectwm(curcodec,false);
   if  ((curcodec == "FL8") || (curcodec == "FL7")) detectflash(curcodec,false);
 }
 alert(msgout);
}
function setpage () {
 // alert("setpage");
     setformat();
   //   alert("afterformat");
     setconnect();
  //   alert("afterconnect");
     setplaydown();
  //   alert("afterplaydown");
     if (document.video.embedhere.value != "y")
        setfilesize();
     else {
       if (playnowsw == "y")
         setfilesize();
     }
     setplaydownbut();
     var seqno = document.video.seqno.value;
     for (gg=0;gg<galseqnoarr.length;gg++) {
       // alert("seq "+seqno+" galseq "+galseqnoarr[gg]);
        if (seqno == galseqnoarr[gg]) {
            setnextprev(gg);
            gg = galseqnoarr.length;
        }
     }
     setstartseq();
}
function setplaydownbut () {
 if (document.video.downloadsel.value != "b1") {
      document.downerr.src = vgpdir+"images/noerror.gif";
      if ((document.video.connectsel.value != "b1")
      && (document.video.formatsel.value != "b1"))
        document.getElementById("msg").innerHTML = "";
   }
 if (playbuttonsw == "y") {
    var dsel = document.video.downloadsel.value;
    if (dsel == "b1") var butval = playdownbutton;
    else if (dsel == "p") var butval = playbutton;
    else if (dsel == "d") var butval = downloadbutton;
    document.video.play.value = butval;
  }
}
function doconnect () {
   if (document.video.formatsel.value != "b1") {
      document.formaterr.src = vgpdir+"images/noerror.gif";
      if ((document.video.connectsel.value != "b1")
      && (document.video.downloadsel.value != "b1"))
         document.getElementById("msg").innerHTML = "";
   }
   setconnect();
   setplaydown();
   setfilesize();
   setplaydownbut();
   checkplayer();
}
function doplaysize () {
    if (document.video.connectsel.value != "b1") {
       document.connecterr.src = vgpdir+"images/noerror.gif";
      if ((document.video.formatsel.value != "b1")
      && (document.video.downloadsel.value != "b1"))
        document.getElementById("msg").innerHTML = "";
   }
   setplaydown();
   setfilesize();
   setplaydownbut();
}
function setnextprev(curpos) {
//   alert("startnextprev"+curpos+" "+galseqnoarr.length);
  if (curpos == 0){
     document.prevbut.src = noarrow;
     document.prevbut.title = "";
     document.prevbut.alt = "";
  }
  else {
    document.prevbut.src = prevarrow;
    document.prevbut.title = back;
    document.prevbut.alt = back;
  }
  if (thumbssw == "y") var lastpos = curpos + thumbcnt - 1;
  else var lastpos = curpos;
  if (lastpos >= galseqnoarr.length - 1) {
     document.nextbut.src = noarrow;
     document.nextbut.title = "";
     document.nextbut.alt = "";
  }
  else {
    document.nextbut.src = nextarrow;
    document.nextbut.title = next;
    document.nextbut.alt = next;
  }
}
function setvideolist () {
   var selseq = document.video.videosel.value;
    for (n=0;n<galseqnoarr.length;n++) {
    //  alert("seqno "+seqno+" galseqnoarr[n] "+galseqnoarr[n]);
       if (selseq == galseqnoarr[n]) {
            document.video.videoid.value = videoidarr[n];
            document.video.playlistid.value = playlistidarr[n];
            n = galseqnoarr.length;
        }
     }
   setformat();
   setconnect();
   setplaydown();
   setfilesize();
   setplaydownbut();
}
function prevthumb () {
  var prevon = true;
  var nexton = false;
  var seqfnd = false;
  var seqcnt = -1;
  var setthumbsw = false;
  var startseqno = document.video.startseqno.value;
  for (n=0;n<galseqnoarr.length;n++) {
   //  alert("startseq "+startseqno+" galseq "+galseqnoarr[n]);
     if (startseqno == galseqnoarr[n]) {
    //    alert("fnd start"+n+" "+galseqnoarr[n]+" "+startseqno);
        seqfnd = true;
        if (n == 0 ) {
           seqfnd = false;
           prevon = false;
           if (thumbcnt < galseqnoarr.length) nexton = true;
        }
        if (n == 1) {
          prevon = false;
      //    alert("prevon false");
        }
     }
     if (seqfnd) {
      //  alert("seqcnt "+seqcnt+" thumbcnt "+thumbcnt);
        seqcnt++;
        if ((seqcnt > -1) && (seqcnt < thumbcnt)) {
           m = n - 1;
           nexton = true;
           document.video.videoid.value = videoidarr[m];
           document.video.playlistid.value = playlistidarr[m];
       //   alert("image");
            var imageid = "thumbimage" + seqcnt;
     //     alert("imageid "+imageid+" "+vgpdir + thimagedirpatharr[n] + thimagefilearr[n]);
            if (checkdir(thimagedirpatharr[m]))
               document.getElementById(imageid).src= thimagedirpatharr[m] + thimagefilearr[m];
            else
              document.getElementById(imageid).src= vgpdir + thimagedirpatharr[m] + thimagefilearr[m];
      //   alert("after src");
           document.getElementById(imageid).alt = stripslash(videotextarr[m]);
          //   document.getElementById(imageid).alt = "text";
         //    alert("after src")
          document.getElementById(imageid).title = stripslash(videotextarr[m]);
       //     document.getElementById(imageid).title = "text";
     //      alert("desc");
           if (seqcnt == 0) {
               document.video.startseqno.value = galseqnoarr[m];
           }
           if (seqcnt == thumbcnt - 1) {
               if (document.video.seqno.value > galseqnoarr[m]) {
                  var setthumbsw = true;
               }
           }
        }
     }
  }
//  alert("before set");
  if (setthumbsw) setthumb(0,"n");
//  alert("after set");
  if (prevon) {
//      alert("prev");
      document.prevbut.src = prevarrow;
     document.prevbut.title = back;
     document.prevbut.alt = back;
  }
  else {
  //  alert("no prev");
    document.prevbut.src = noarrow;
     document.prevbut.title = "";
     document.prevbut.alt = "";
  }
// alert(nexton+ " "+ galseqnoarr.length + noarrow + nextarrow);

  if (nexton) {
  //    alert("next "+next);
     document.nextbut.src = nextarrow;
      document.nextbut.alt = next;
       document.nextbut.title = next;
  }
  else {
   document.nextbut.src = noarrow;
    document.nextbut.title = "";
     document.nextbut.alt = "";
  }
}
function nextthumb () {
//alert("start next");
  var prevon = false;
  var nexton = -1;
  var seqfnd = false;
  var seqcnt = -2;
  var setthumbsw = false;
  var startseqno = document.video.startseqno.value;
  for (n=0;n<galseqnoarr.length;n++) {
  //    alert("startseq "+startseqno+" galseq "+galseqnoarr[n]);
     if (startseqno == galseqnoarr[n]) {
    //  alert("fnd start");
        seqfnd = true;
        if (thumbcnt >= galseqnoarr.length - n ) {
           seqfnd = false;
           nexton = 99999;
           if (n > 0) prevon = true;
        }
     }
     if (seqfnd) {
     //   alert("seqcnt "+seqcnt+" thumbcnt "+thumbcnt);
        seqcnt++;
        if ((seqcnt > -1) && (seqcnt < thumbcnt)) {
           prevon = true;
           nexton = n;
           document.video.videoid.value = videoidarr[n];
           document.video.playlistid.value = playlistidarr[n];
      //    alert("image");
            var imageid = "thumbimage" + seqcnt;
     //     alert("imageid "+imageid+" "+vgpdir + thimagedirpatharr[n] + thimagefilearr[n]);
           if (checkdir(thimagedirpatharr[n]))
               document.getElementById(imageid).src=  thimagedirpatharr[n] + thimagefilearr[n];
           else
              document.getElementById(imageid).src= vgpdir + thimagedirpatharr[n] + thimagefilearr[n];
      //   alert("after src");
           document.getElementById(imageid).alt = stripslash(videotextarr[n]);
          //   document.getElementById(imageid).alt = "text";
       //      alert("after src")
          document.getElementById(imageid).title = stripslash(videotextarr[n]);
       //     document.getElementById(imageid).title = "text";
       //    alert("desc");
           if (seqcnt == 0) {
               document.video.startseqno.value = galseqnoarr[n];
          //     alert("startseq"+document.video.startseqno.value);
               if (document.video.seqno.value < galseqnoarr[n]) {
                  var setthumbsw = true;
               }
           }
        }
     }
  }
  // alert(nexton);
  if (setthumbsw) setthumb(0,"n");
  // alert(nexton);
  if (prevon) {
     document.prevbut.src = prevarrow;
     document.prevbut.title = back;
     document.prevbut.alt = back;
  }
  else {
    document.prevbut.src = noarrow;
    document.prevbut.title = "";
     document.prevbut.alt = "";
  }
 // alert(nexton+ " "+ galseqnoarr.length + noarrow + nextarrow);
  if (nexton < galseqnoarr.length - 1 ) {
     document.nextbut.src = nextarrow;
      document.nextbut.alt = next;
       document.nextbut.title = next;
  }
  else {
    document.nextbut.src = noarrow;
    document.nextbut.title = "";
     document.nextbut.alt = "";
  }
}
function setstartseq() {
//  alert("setstart");
   var startseqno = document.video.startseqno.value;
 //  alert("startseq"+startseqno);
   for (n=0;n<galseqnoarr.length;n++) {
      if (startseqno == galseqnoarr[n]) {
 //        alert("n "+n+" galseqnoarr[n] " + galseqnoarr[n]);
         if (n > 0) {
            var m = n - 1;
            document.video.startseqno.value = galseqnoarr[m];
            nextthumb();
         }
      }
   }
}

function setthumb (thumbpos,action) {
 //alert("start setthumb");
  var startseqno = document.video.startseqno.value;
  // alert("start seq"+startseqno+" length "+galseqnoarr.length);
  var seqfnd = false;
  var thumbpnt = -1;
  for (n=0;n<galseqnoarr.length;n++) {
  //   alert("seqno "+startseqno+" galseqnoarr[n] "+galseqnoarr[n]);
  //  alert("seqno ");
     if (startseqno == galseqnoarr[n]) seqfnd = true;
     if (seqfnd) thumbpnt++;
     if (thumbpnt == thumbpos) {
         document.video.videoid.value = videoidarr[n];
         document.video.playlistid.value = playlistidarr[n];
      //    alert("image");
         document.video.seqno.value = galseqnoarr[n];
         if (playembed == "y") {
            if  (action == "y") {
     //       alert("a"+vgpdir);
               document.video.playnow.value = "y";
               document.video.submit();
            }
         }
         else {
      //      alert("b"+vgpdir+" "+imagedirpatharr[n]+imagefilearr[n]);
            if (checkdir(imagedirpatharr[n])) {
      //         alert("no vgp");
               document.videoimage.src=  imagedirpatharr[n] + imagefilearr[n];
            }
            else  {
       //       alert("vgp");
               document.videoimage.src= vgpdir + imagedirpatharr[n] + imagefilearr[n];
            }
       //   alert("desc src"+document.videoimage.src);
           document.videoimage.alt = stripslash(videotextarr[n]);
           document.videoimage.title = stripslash(videotextarr[n]);
        //  alert("desc");
           document.getElementById('videodesc').innerHTML =  stripslash(videodescarr[n]);
           setformat();
       //    alert("format");
           setconnect();
        //    alert("connect");
           setplaydown();
       //     alert("playdown");
           setfilesize();
      //      alert("filesize");
         }
         n = galseqnoarr.length;
     }
  }
}
function playthumb (thumbpos) {
// alert("start playthumb");
//  var startseqno = document.video.startseqno.value;
 // alert(" length ");
 //  alert(" length "+galseqnoarr.length);
  for (n=0;n<galseqnoarr.length;n++) {
     if (n == thumbpos) {
         document.video.videoid.value = videoidarr[n];
         document.video.playlistid.value = playlistidarr[n];
         document.video.seqno.value = galseqnoarr[n];
         document.video.playnow.value = "y";
         document.video.submit();
     }
  }
}
function vgppreload () {
  var preimg = new Array();
   var thpreimg = new Array();
  for (pr=0;pr<imagefilearr.length;pr++) {
      if ((imagefilearr[pr] > " ") && (imagefilearr[pr] != "No File")) {
         preimg[pr] = new Image();
         if (checkdir(imagedirpatharr[pr])) {
             preimg[pr].src = imagedirpatharr[pr]+ imagefilearr[pr];
         }
         else {
             preimg[pr].src = vgpdir + imagedirpatharr[pr]+ imagefilearr[pr];
         }
      }
      if ((thimagefilearr[pr] > " ") && (thimagefilearr[pr] != "No File")) {
         thpreimg[pr] = new Image();
         if (checkdir(thimagedirpatharr[pr])) {
             thpreimg[pr].src = thimagedirpatharr[pr]+ thimagefilearr[pr];
         }
         else {
             thpreimg[pr].src = vgpdir + thimagedirpatharr[pr]+ thimagefilearr[pr];
         }
      }
  }
}
function gotopage (pagenum) {
  // alert("goto" +pagenum);
   document.video.pagestart.value = pagenum;
  //   alert("before submit " +pagenum);
   document.video.submit();
   //  alert("after submit " +pagenum);
}
// Video Gallery Pro is the property of Sizzling Web Design, a subsidiary of -->
// Sizzling Video International and can only be used with permission.-->
//  Please visit www.SizzlingWebDesign.com for more information -->
//  Copyright 2006 All rights reserved -->
