home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 March / Chip_2011.03_CD.iso / I386 / CONTROLS.JS_ / controls.js
Encoding:
Text File  |  2007-06-26  |  6.7 KB  |  249 lines

  1. var L_WARN800x600                 = "Your screen resolution is less than 800 x 600 pixels. Windows Media Player Tour cannot continue unless the screen resolution is set to 800 x 600 or greater.";
  2. var g_aTopicButtonsList;
  3. var g_sAudioPath                = "../audio/wav/";
  4. var g_sMediaPath                 = "video\\";
  5. var g_sImgWatermarks            = "img/wmarks/";
  6. var g_sLocalPath                = getLocalPath("wmptour.hta");
  7. var g_ClockInterval                    = 0;
  8. var g_CurTime                        = 0;
  9. var g_CurTick                        = 0;
  10. function getHTML(sID)
  11. {
  12.     return eval("idContents." + sID + ".innerHTML");
  13. }
  14. function getText(sID)
  15. {
  16.     return eval("idContents." + sID + ".innerText");
  17. }
  18. function PositionContainers()
  19. {
  20.     var nClientHeight = parseInt(screen.availHeight);
  21.     var nClientWidth = parseInt(screen.availWidth);
  22.     if ((screen.height < 600) || (screen.width < 800))
  23.     {
  24.         alert(L_WARN800x600);
  25.         window.close();
  26.     }
  27.     idTourContainer.style.top = nClientHeight/2 - 277;
  28.     idTourContainer.style.left = nClientWidth/2 - 400;
  29.     idVideoContainer.style.top = nClientHeight/2 - 278;
  30.     idVideoContainer.style.left = nClientWidth/2 - 400;
  31.     idTourContainer.style.visibility = "visible";
  32.     idVideoContainer.style.visibility = "hidden";
  33. }
  34. function getLocalPath(sProjRoot)
  35. {
  36.     var sLocation         = unescape(window.location.href.toLowerCase());
  37.     sProjRoot             = sProjRoot.toLowerCase();
  38.     var sRootLoc        = "file:///";
  39.     var nAt             = sLocation.indexOf(sRootLoc) + sRootLoc.length;
  40.     var nTo             = sLocation.indexOf(sProjRoot);
  41.     var sPath             = sLocation.substring(nAt, nTo);
  42.     var s = ""; var ch= "";
  43.     
  44.     for(i = 0; i< sPath.length; i++)
  45.     {
  46.         ch = sPath.charAt(i);
  47.         ch == "/" ? (s = s + "\\") : (s = s + ch);
  48.     }
  49.     return s;
  50. }
  51. function cleanString(sStr)
  52. {
  53.     sStr = escape(sStr);
  54.     sStr = sStr.replace(/%0D/g, "%20");
  55.     sStr = sStr.replace(/%20%20/g, "%20");
  56.     sStr = sStr.replace(/\%0A/g, "");
  57.     sStr = unescape(sStr);
  58.     return sStr;
  59. }
  60. function fixHyphen(sStr)
  61. {
  62.     sStr = escape(sStr);
  63.     sStr = sStr.replace(/%3CHYPHEN%3E/g, "-<BR>");
  64.     sStr = unescape(sStr);
  65.     return sStr;
  66. }
  67. function WriteTopicButtonsCaption()
  68. {
  69.     var sText = "";
  70.     g_aTopicButtonsList = idTourTopics.childNodes;
  71.     for(i=0; i < g_aTopicButtonsList.length; i++)
  72.     {
  73.         sText = fixHyphen(getHTML("txtTopic" + (i + 1) + "Title"));
  74.         g_aTopicButtonsList.item(i).firstChild.innerHTML = sText;
  75.         sText = cleanString(getText("txtTopic" + (i + 1) + "Title"));
  76.         g_aTopicButtonsList.item(i).firstChild.title = sText;
  77.         g_aTopicButtonsList.item(i).title = sText;
  78.     }
  79. }
  80. function ClickTopicButton(nIDX)
  81. {    
  82.     var nClicked = idTourTopics.CURCLICK;
  83.     idTourTopics.CURCLICK = nIDX;
  84.     
  85.     if(nClicked > 0) {
  86.         g_aTopicButtonsList.item(nClicked -1).firstChild.nextSibling.src = g_TopicButton_normal;
  87.         g_aTopicButtonsList.item(nClicked -1).firstChild.className = "clsTopicButtonCaption";
  88.     }
  89.     
  90.     idTourContents.style.background = getWMKImg(nIDX);
  91.     
  92.     g_aTopicButtonsList.item(nIDX -1).firstChild.nextSibling.src = g_TopicButton_down;
  93.     
  94.     g_aTopicButtonsList.item(nIDX-1).firstChild.className = "clsTopicButtonCaptionClicked";
  95.     
  96.     ShowTopic(nIDX);
  97.     if (MyTour.scenes[idTourTopics.CURCLICK -1].showMe) loadMedia(MyTour.scenes[idTourTopics.CURCLICK -1].showMe);
  98.     
  99.     if (idTourAudioImg.STAT == 0 && idTourPlayImg.STAT != 3) PlaySound();
  100.     
  101.     SndFadeOut();
  102.     
  103.     if (MyTour.curScene == (MyTour.length -1))
  104.     {
  105.         TourPlayEVENTonclick(2,0);
  106.     }
  107.     startClock();
  108. }
  109. function ShowTopic(nIDX)
  110. {
  111.     fadeIn(idContentsTitle, 1);
  112.     fadeIn(idContentsBody, 1);
  113.     idContentsTitle.innerHTML     = getText("txtTopic" + nIDX + "Title");
  114.     idContentsBody.innerHTML     = getHTML("txtTopic" + nIDX + "Text");
  115.                     
  116. }
  117. function ShowVideoInfo(nIDX)
  118. {
  119.     idVideoInfoTitle.innerText     = cleanString(getText("txtTopic" + nIDX + "Title"));
  120.     idVideoInfoBody.innerHTML     = getHTML("txtVideInfo" + nIDX);
  121. }
  122. function StartVideoSample()
  123. {
  124.     idAudioTrack.ClearTimedAction();
  125.     playVideo();
  126.     idVideoTitle.innerHTML = getText("txtNowPlaying") + ' " ' + getText("txtTopic" + idTourTopics.CURCLICK + "Title") + '"';
  127. }
  128. function PlaySound()
  129. {
  130.     if (idTourTopics.CURCLICK == 0) return;
  131.     
  132.     idAudioTrack.SndPlay(g_sAudioPath + MyTour.scenes[idTourTopics.CURCLICK - 1].sound);
  133.     
  134.     idAudioTrack.SndFadeIn(250);
  135.     SndFadeOut();
  136. }
  137. function SndFadeOut()
  138. {
  139.     idAudioTrack.TimedAction("SndFadeOut(125)", (MyTour.scenes[idTourTopics.CURCLICK - 1].tremaining - 4000));
  140. }
  141. function MuteSound()
  142. {
  143.     idAudioTrack.sound.src = "";
  144. }
  145. function playVideo()
  146. {
  147.     idVideo.controls.play();
  148. }
  149. function stopVideo()
  150. {
  151.     idVideo.controls.stop();
  152.     idVideo.URL = "";
  153. }
  154. function loadMedia(sMedia)
  155. {
  156.     var sFullPath = g_sLocalPath + g_sMediaPath + sMedia;
  157.     idVideo.URL = sFullPath;
  158. }
  159. function getWMKImg(nIDX)
  160. {
  161.     return "white url('" + g_sImgWatermarks + "/wm" + nIDX +".gif') no-repeat bottom right";
  162. }
  163. function fadeIn(oObj, tDur)
  164. {
  165.     if (tDur == 0)
  166.     {
  167.         oObj.style.visibility="visible";
  168.     }
  169.     else
  170.     {
  171.         oObj.style.filter="revealTrans(DURATION=" + tDur + ", TRANSITION=7)";
  172.         if (oObj.filters.revealTrans.status != 2)
  173.         {
  174.             oObj.style.visibility="hidden";
  175.             oObj.filters.revealTrans.apply();
  176.             oObj.style.visibility="visible";
  177.             oObj.filters.revealTrans.play();
  178.         }
  179. }
  180. }
  181. function startClock()
  182. {
  183.     pauseClock();
  184.     if(MyTour.scenes[MyTour.curScene])
  185.     {
  186.         g_CurTime = (MyTour.scenes[MyTour.curScene].tremaining /1000);
  187.         g_ClockInterval = setInterval("getElapsedTime()", 1000);
  188.         g_CurTick = 0;
  189.         getElapsedTime();
  190.     }
  191. }
  192. function stopClock()
  193. {
  194.     if (g_ClockInterval) clearInterval(g_ClockInterval);
  195.     g_ClockInterval = 0;
  196.     g_CurTick = 0;
  197.     
  198. }
  199. function pauseClock()
  200. {
  201.     clearInterval(g_ClockInterval);
  202.     g_ClockInterval = 0;
  203. }
  204. function resumeClock()
  205. {
  206.     pauseClock();
  207.     
  208.     g_ClockInterval = setInterval("getElapsedTime()", 1000);
  209. }
  210. function getElapsedTime()
  211. {
  212.     var time     = Math.ceil(g_CurTime - (++g_CurTick));
  213.     var s    = "";
  214.     if (time > 9)
  215.     {
  216.         s = "00:";    /* LOCALIZATION, if required to localize numerals displayed this variable should also be localized */
  217.     }
  218.     else
  219.     {
  220.         s = "00:0";    /* LOCALIZATION, if required to localize numerals displayed this variable should also be localized */        
  221.     }
  222.     if(time >= 0)
  223.     {
  224.         idTimeElapsed.innerText = s + time;
  225.     }
  226. }
  227. function clearClockDisplay()
  228. {
  229.     idTimeElapsed.innerText = "" ;
  230. }
  231. function setTitles()
  232. {
  233.     var sBackToTour        = getText("btnBackToTourCaption");
  234.     var sTourTitle        = getText("txtApplicationTitle");
  235.     var sCloseCaption     = getText("btnCloseCaption");
  236.     var sMPLogoCaption     = getText("titleWMPLogo");
  237.     
  238.     idCloseTourAppImg.title     = sCloseCaption;
  239.     idCloseTourAppImg.alt         = sCloseCaption;
  240.     idCloseVideoAppImg.title     = sCloseCaption;
  241.     idCloseVideoAppImg.alt         = sCloseCaption;
  242.     idBackToTourImg.title        = sBackToTour;
  243.     idBackToTourImg.alt            = sBackToTour;
  244.     idMPLogoImg.title             = sMPLogoCaption;
  245.     idMPLogoImg.alt             = sMPLogoCaption;
  246.     idTourTitle.innerText        = sTourTitle;
  247.         
  248. }
  249.