home *** CD-ROM | disk | FTP | other *** search
/ Il Mio Computer 2006 February / Mico02CD.bin / Internet / WebSite5 / RESFiles.001 / engine.js < prev    next >
Encoding:
Text File  |  2005-09-02  |  15.5 KB  |  528 lines

  1. // menu creation
  2. NS=(document.layers) ? true : false;
  3. IE=(document.all) ? true : false;
  4. IE50=(navigator.appVersion.indexOf("MSIE 5.0")!=-1?true:false);
  5. function popUp(){return};
  6. function popDown(){return};
  7. areCreated=false;
  8. mSecsVis = secondsVisible*1000;
  9. // layers settings
  10. semi = ";";
  11. styleStr = "<STYLE TYPE='text/css'>"
  12. styleStr += ".items {"
  13. styleStr += "width:" + menuWidth + semi
  14. styleStr += "color:"+ fntCol + semi
  15. styleStr += "font-size:"+ fntSiz + semi
  16. styleStr += "font-style:"+ fntSty + semi
  17. styleStr += "font-family:"+ fntFam + semi
  18. styleStr += "font-weight:"+ fntWeight + semi
  19. styleStr += "border-width:" + borWid + semi
  20. styleStr += "border-color:" + borCol + semi
  21. styleStr += "border-style: solid" + semi
  22. styleStr += "cursor: hand" + semi
  23. styleStr += "filter: progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")" + semi
  24. styleStr += "}"
  25. styleStr += "</STYLE>";
  26. document.write(styleStr);
  27. // image settings
  28. if (imgSrc !="") imgStr = "<IMG SRC=" + imgSrc + " BORDER=0 VSPACE=3 WIDHT=7 HEIGHT=7 ALIGN=RIGHT>" 
  29. else imgStr = ""
  30. topCount = 1;
  31. areCreated = false;
  32. isOverMenu = false;
  33. currentMenu = null;
  34. allTimer = null;
  35. function menuSetup(hasParent,lastItem,openCont,openItem) {
  36.     this.menuOver = menuOver;
  37.     this.menuOut = menuOut;
  38.     this.onmouseover = this.menuOver;
  39.     this.onmouseout = this.menuOut;
  40.     this.showIt = showIt;
  41.     this.keepInWindow = keepInWindow;
  42.     this.hideTree = hideTree
  43.     this.hideParents = hideParents;
  44.     this.hideChildren = hideChildren;
  45.     this.hideTop = hideTop;
  46.     this.hasChildVisible = false;
  47.     this.isOn = false;
  48.     this.hideTimer = null;
  49.     if (hasParent) {
  50.         this.hasParent = true;
  51.         this.parentMenu = openCont;
  52.         this.parentItem = openItem;
  53.         this.parentItem.child = this;
  54.     }
  55.     else {
  56.         this.hasParent = false;
  57.         this.hideSelf = hideSelf;
  58.     }
  59.  
  60.     if (NS) {
  61.         this.fullHeight = lastItem.top + lastItem.document.height;
  62.         this.clip.bottom = this.fullHeight;
  63.     }
  64.     else {
  65.         this.fullHeight = lastItem.style.pixelTop + lastItem.offsetHeight;
  66.         this.showIt(false);
  67.         this.onselectstart = cancelSelect;
  68.         this.moveTo = moveTo;
  69.         this.moveTo(0,0);
  70.     }
  71. }
  72. function itemSetup(arrayPointer,whichArray) {
  73.     this.itemOver = itemOver;
  74.     this.itemOut = itemOut;
  75.     this.onmouseover = this.itemOver;
  76.     this.onmouseout = this.itemOut;
  77.     this.dispText = whichArray[arrayPointer];
  78.     this.linkText = whichArray[arrayPointer + 1];
  79.     this.hasMore = whichArray[arrayPointer + 2];
  80.     if (this.linkText.length > 0) {
  81.         this.linkIt = linkIt;
  82.         if (NS) {
  83.             this.onfocus = this.linkIt;
  84.         }
  85.         else {
  86.             this.onclick = this.linkIt;
  87.         }
  88.     }
  89.          if (this.hasMore) {
  90.         htmStr = imgStr + this.dispText;
  91.     }
  92.     else {
  93.         htmStr = this.dispText;
  94.     }
  95.     if (NS) {
  96.         layStr = "<SPAN CLASS=items>" + htmStr+ "</SPAN>";
  97.         this.document.write(layStr);
  98.         this.document.close();
  99.         this.bgColor = backCol;
  100.         this.clip.right = menuWidth;
  101.         this.visibility = "inherit";
  102.         this.container = this.parentLayer;
  103.  
  104.         if (arrayPointer == 0) {
  105.             this.top = 0;
  106.         }
  107.         else {
  108.             this.top = this.prevItem.top + this.prevItem.document.height - borWid;
  109.         }
  110.         this.left = 0;
  111.     }
  112.     else {
  113.         this.className = "items";
  114.         this.style.padding = 3;
  115.         this.innerHTML = htmStr;
  116.  
  117.         this.style.backgroundColor = backCol; 
  118.         this.container = this.offsetParent;
  119.  
  120.         if (arrayPointer == 0) {
  121.             this.style.pixelTop = 0;
  122.         }
  123.         else {
  124.             this.style.pixelTop = this.prevItem.style.pixelTop + this.prevItem.offsetHeight - borWid;
  125.         }
  126.         this.style.pixelLeft = 0;
  127.     }
  128. }
  129. function makeElement(whichEl,whichContainer) {
  130.     if (arguments.length==1)
  131.         whichContainer = (NS) ? window : document.body;
  132.  
  133.     if (NS) {
  134.         eval(whichEl + "= new Layer(menuWidth,whichContainer)");
  135.     }
  136.     else {
  137.         elStr = "<DIV ID=" + whichEl + " STYLE='position:absolute'></DIV>";
  138.         whichContainer.insertAdjacentHTML("BeforeEnd",elStr);
  139.     }
  140.  
  141.     return eval(whichEl);
  142. }
  143. function makeTop() {
  144.     while(eval("window.arMenu" + topCount)) {
  145.         topArray = eval("arMenu" + topCount);
  146.         topName = "elmenu" + topCount;
  147.         topMenu = makeElement(topName);
  148.             topMenu.setup = menuSetup;
  149.         topItemCount = 0;
  150.         for (i=0; i<topArray.length; i+=3) {
  151.             topItemCount++;
  152.             topItemName = "item" + topCount + "_" + topItemCount;
  153.             topItem = makeElement(topItemName,topMenu);
  154.  
  155.             if (topItemCount >1)
  156.                 topItem.prevItem = eval("item" + topCount + "_" + (topItemCount-1));
  157.  
  158.             topItem.setup = itemSetup;
  159.             topItem.setup(i,topArray);
  160.  
  161.             if (topItem.hasMore) makeSecond();
  162.         }
  163.         topMenu.setup(false,topItem);
  164.         topCount++
  165.     }
  166.     areCreated = true;
  167. }
  168. function makeSecond() {
  169.     secondCount = topCount + "_" + topItemCount;
  170.     secondArray = eval("arMenu" + secondCount);
  171.     secondName = "elChild" + secondCount;
  172.     secondMenu = makeElement(secondName);
  173.     secondMenu.setup = menuSetup;
  174.     secondItemCount=0;
  175.     for (j=0; j<secondArray.length; j+=3) {
  176.         secondItemCount++;
  177.         secondItemName = "item" + secondCount +"_" + secondItemCount;
  178.  
  179.         secondItem = makeElement(secondItemName,secondMenu)        
  180.         
  181.         if (secondItemCount >1)
  182.             secondItem.prevItem = eval("item" + secondCount  + "_" + (secondItemCount-1));
  183.  
  184.         secondItem.setup = itemSetup;
  185.         secondItem.setup(j,secondArray);
  186.  
  187.         if (secondItem.hasMore) makeThird();
  188.     }
  189.     secondMenu.setup(true,secondItem,topMenu,topItem);
  190. }
  191. function makeThird() {
  192.     thirdCounter = secondCount + "_" + secondItemCount 
  193.     thirdArray = eval("arMenu" + thirdCounter);
  194.     thirdName = "elGrandChild" + thirdCounter;
  195.     thirdMenu = makeElement(thirdName)
  196.     thirdMenu.setup = menuSetup;
  197.     thirdItemCount=0;
  198.     for (k=0; k<thirdArray.length; k+=3) {
  199.         thirdItemCount++;
  200.         thirdItemName = "item" + thirdCounter + "_" + thirdItemCount;
  201.         thirdItem = makeElement(thirdItemName,thirdMenu);
  202.  
  203.         if (thirdItemCount >1)
  204.             thirdItem.prevItem = eval("item" + thirdCounter + "_" +(thirdItemCount-1));
  205.  
  206.         thirdItem.setup = itemSetup;
  207.         thirdItem.setup(k,thirdArray);
  208.     }
  209.     thirdMenu.setup(true,thirdItem,secondMenu,secondItem);
  210. }
  211. function linkIt() {
  212.     location.href = this.linkText;
  213. }
  214. function showIt(on) {
  215.     if (NS) {this.visibility = (on) ? "show" : "hide"}
  216.         else {this.style.visibility = (on) ? "visible" : "hidden"}
  217. }
  218. function keepInWindow() {
  219.     scrBars = 20;
  220.     if (NS) {
  221.         winRight = (window.pageXOffset + window.innerWidth) - scrBars;
  222.         rightPos = this.left + menuWidth;
  223.    
  224.         if (rightPos > winRight) {
  225.             if (this.hasParent) {
  226.                 parentLeft = this.parentMenu.left;
  227.                 newLeft = ((parentLeft-menuWidth) + childOverLeft);
  228.                 this.left = newLeft;
  229.             }
  230.             else {
  231.                 dif = rightPos - winRight;
  232.                 this.left -= dif;
  233.             }
  234.         }
  235.         winBot = (window.pageYOffset + window.innerHeight) - scrBars;
  236.         botPos = this.top + this.fullHeight;
  237.  
  238.         if (botPos > winBot) {
  239.             dif = botPos - winBot;
  240.             this.top -= dif;
  241.         }
  242.     }
  243.     else {
  244.         winRight = (document.body.scrollLeft + document.body.clientWidth) - scrBars;
  245.         rightPos = this.style.pixelLeft + menuWidth;
  246.     
  247.         if (rightPos > winRight) {
  248.             if (this.hasParent) {
  249.                 parentLeft = this.parentMenu.style.pixelLeft;
  250.                 newLeft = ((parentLeft - menuWidth) + childOverLeft);
  251.                 this.style.pixelLeft = newLeft;
  252.             }
  253.             else {
  254.                 dif = rightPos - winRight;
  255.                 this.style.pixelLeft -= dif;
  256.             }
  257.         }
  258.         winBot = (document.body.scrollTop + document.body.clientHeight) - scrBars;
  259.         botPos = this.style.pixelTop + this.fullHeight;
  260.  
  261.         if (botPos > winBot) {
  262.             dif = botPos - winBot;
  263.             this.style.pixelTop -= dif;
  264.         }
  265.     }
  266. }
  267. function popUp(menuName,e){
  268.     if (!areCreated) return;
  269.     hideAll();
  270.     currentMenu = eval(menuName);
  271.     if (NS) {
  272.         xPos = e.pageX;
  273.         yPos = e.pageY;
  274.     }
  275.     else  {
  276.         if (menuType == 1) {
  277.               xPos = document.all["ID_" + menuName].offsetLeft;
  278.              yPos = document.all["ID_" + menuName].offsetTop + document.all["ID_" + menuName].offsetHeight;
  279.         }
  280.         else  {
  281.               xPos = document.all["ID_" + menuName].offsetLeft + document.all["ID_" + menuName].offsetWidth - childOverLeft + 1;
  282.              yPos = document.all["ID_" + menuName].offsetTop + childOverTop;
  283.         }
  284.         if (document.all["ID_" + menuName].style.backgroundImage !="")
  285.         document.all["ID_" + menuName].style.backgroundImage = 'url(res/' + menuName + '1.gif)';
  286.         else{
  287.         document.all["ID_" + menuName].style.backgroundColor = mainOverCol;
  288.         document.all["ID_" + menuName].style.color = mainFntOverCol;
  289.         }
  290.     }
  291.     currentMenu.moveTo(xPos,yPos);
  292.     currentMenu.keepInWindow()
  293.     currentMenu.isOn = true;
  294.     currentMenu.showIt(true);
  295. }
  296. function popDown(menuName){ 
  297.     if (!areCreated) return;
  298.     whichEl = eval(menuName);
  299.     whichEl.isOn = false;
  300.     whichEl.hideTop();
  301.     if (!NS){
  302.         if (document.all["ID_" + menuName].style.backgroundImage !="")
  303.         document.all["ID_" + menuName].style.backgroundImage = 'url(res/' + menuName + '0.gif)';
  304.         else{
  305.         document.all["ID_" + menuName].style.backgroundColor = mainBackCol;
  306.         document.all["ID_" + menuName].style.color = mainFntCol;
  307.         }
  308.     }
  309. }
  310. function menuOver() {
  311.     this.isOn = true;
  312.     isOverMenu = true;
  313.     currentMenu = this;
  314.     if (this.hideTimer) clearTimeout(this.hideTimer);
  315. }
  316. function menuOut() {
  317.     if (IE && event.srcElement.contains(event.toElement)) return;
  318.     this.isOn = false;
  319.     isOverMenu = false;
  320.     if (IE) allTimer = setTimeout("currentMenu.hideTree()",10); 
  321. }
  322. function itemOver(){
  323.     if (IE && event.srcElement.tagName == "IMG") return;
  324.     if (NS) {
  325.         this.bgColor = overCol;
  326.     }
  327.     else {
  328.         this.style.backgroundColor = overCol;
  329.         this.style.color = fntOverCol;
  330.     }
  331.     
  332.     if (this.container.hasChildVisible) {
  333.         this.container.hideChildren(this);
  334.     }            
  335.     if(this.hasMore) {
  336.         if (NS) {
  337.             this.childX = this.container.left + (menuWidth - childOverLeft);
  338.             this.childY = this.pageY + childOverTop;
  339.         }
  340.         else {
  341.             this.childX = this.container.style.pixelLeft + (menuWidth - childOverLeft);
  342.             this.childY = this.style.pixelTop + this.container.style.pixelTop + childOverTop;
  343.         }
  344.  
  345.         this.child.moveTo(this.childX,this.childY);
  346.         this.child.keepInWindow();
  347.         this.container.hasChildVisible = true;
  348.         this.container.visibleChild = this.child;
  349.         this.child.showIt(true);
  350.     }
  351. }
  352. function itemOut() {
  353.     if (IE && (event.srcElement.contains(event.toElement)
  354.      || (event.fromElement.tagName=="IMG" && event.toElement.contains(event.fromElement))))
  355.         return;
  356.     if (NS) {
  357.         this.bgColor = backCol;
  358.         if (!isOverMenu) {
  359.             allTimer = setTimeout("currentMenu.hideTree()",10);
  360.         }
  361.     }
  362.     else {
  363.         this.style.backgroundColor = backCol;
  364.         this.style.color = fntCol;
  365.     }
  366. }
  367. function hideAll() {
  368.     for(i=1; i<topCount; i++) {
  369.         temp = eval("elmenu" + i);
  370.         temp.isOn = false;
  371.         if (temp.hasChildVisible) temp.hideChildren();
  372.         temp.showIt(false);
  373.     }    
  374. }
  375. function hideTree() { 
  376.     allTimer = null;
  377.     if (isOverMenu) return;
  378.     if (this.hasChildVisible) {
  379.         this.hideChildren();
  380.     }
  381.     this.hideParents();
  382. }
  383. function hideChildren(item) {
  384.     if (this.visibleChild.hasChildVisible) {
  385.         this.visibleChild.visibleChild.showIt(false);
  386.         this.visibleChild.hasChildVisible = false;
  387.     }
  388.  
  389.     if (!this.isOn || !item.hasMore || this.visibleChild != this.child) {
  390.         this.visibleChild.showIt(false);
  391.         this.hasChildVisible = false;
  392.     }
  393. }
  394. function hideParents() {     
  395.     if (this.hasParent) {
  396.         this.showIt(false);
  397.         if (this.parentMenu.hasParent) {
  398.             this.parentMenu.isOn = false;        
  399.             this.parentMenu.showIt(false);
  400.             this.parentMenu.parentMenu.isOn = false;
  401.             whichEl = this.parentMenu.parentMenu
  402.         }
  403.         else {
  404.             this.parentMenu.isOn = false;
  405.             whichEl = this.parentMenu;
  406.         }
  407.     }
  408.     else {
  409.         whichEl = this;
  410.     }
  411.     whichEl.hideTop();
  412. }
  413. function hideTop() {
  414.     whichEl = this;
  415.     this.hideTimer = setTimeout("whichEl.hideSelf()",mSecsVis);
  416. }
  417. function hideSelf() {
  418.     this.hideTimer = null;
  419.     if (!this.isOn && !isOverMenu) { 
  420.         this.showIt(false);
  421.     }
  422. }
  423. function cancelSelect(){return false}
  424. function moveTo(xPos,yPos) {
  425.     this.style.pixelLeft = xPos;
  426.     this.style.pixelTop = yPos;
  427. }
  428. window.onload = makeTop;
  429. // First Level Items MouseOver Style
  430. function chgPageStl(OverStyle,divID) {
  431.     if (!NS){
  432.         if (OverStyle==1){
  433.             hideAll();
  434.             if (document.all["ID_elpage" + divID].style.backgroundImage !="")
  435.             document.all["ID_elpage" + divID].style.backgroundImage = 'url(res/elpage' + divID + '1.gif)';
  436.             else{
  437.             document.all["ID_elpage" + divID].style.backgroundColor = mainOverCol;
  438.             document.all["ID_elpage" + divID].style.color = mainFntOverCol;
  439.             }
  440.         }
  441.         else {
  442.             if (document.all["ID_elpage" + divID].style.backgroundImage !="")
  443.             document.all["ID_elpage" + divID].style.backgroundImage = 'url(res/elpage' + divID + '0.gif)';    
  444.             else{
  445.             document.all["ID_elpage" + divID].style.backgroundColor = mainBackCol;
  446.             document.all["ID_elpage" + divID].style.color = mainFntCol;
  447.             }
  448.         }
  449.     }
  450. }
  451. // Code by Stefano Ranfagni. Incomedia.it. All rights reserved.
  452. // Link Description
  453. function ViewTip(Txt,backgColor,textColor,borderdColor,textSize,doFadeFlag) {
  454. HideTip();
  455. buf="<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=2 BGCOLOR=" + backgColor +" style=\"border: 1px solid " + borderdColor + "\"><TR><TD><FONT FACE=\"Tahoma, Arial\" SIZE=" + textSize + " COLOR=" + textColor + ">" + Txt + "</FONT></TD></TR></TABLE>";
  456. document.all.imToolTip.innerHTML = buf;
  457. document.all.imToolTip.style.left=event.x;
  458. document.all.imToolTip.style.top=event.y + 15;
  459. document.all.imToolTip.style.visibility="visible";
  460. fadeStep=0
  461. if (doFadeFlag) doFade();
  462. }
  463. function HideTip() {
  464. document.all.imToolTip.style.visibility="hidden";
  465. if (typeof oTime !== 'undefined') clearTimeout(oTime);
  466. document.all.imToolTip.style.filter="alpha(opacity=100)";
  467. }
  468. function doFade(){
  469. if (fadeStep<=100){
  470.     fadeStep+=15;
  471.     document.all.imToolTip.style.filter="alpha(opacity=" + fadeStep + ")";
  472.     oTime=setTimeout('doFade()', 50);
  473.     }
  474. }
  475. // PopUpWindows
  476. function popUpWin(page,w,h,sb){
  477. if ((w==-1) || (h==-1)){
  478. prop='fullscreen, scrollbars=No';
  479. }else{
  480.     l=(screen.width)?(screen.width-w)/2:100;
  481.     t=(screen.height)?(screen.height-h)/2:100;
  482. prop='width='+ w + ',height='+ h + ',top=' + t + ',left=' + l + ',scrollbars='+ sb +',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
  483. }
  484. popUpWinWindow=window.open(page,'',prop);
  485. popUpWinWindow.focus();
  486. }
  487. // SlideShow
  488. var iLastSlide
  489. var iCount=1;
  490. var iAutoDelay
  491. function doTrans(iStep, iLast, bPosition){
  492.     iCount=(bPosition == 1)? iStep : iCount=iCount+iStep;
  493.     if (iCount == iLast+1) iCount=1;
  494.     if (iCount == 0) iCount=iLast;
  495.     if (IE50 == false) div_Main.filters.item(0).Apply();
  496.     sContent="<img src=\"" + document.all["img_" + iCount].src + "\" border=\"0\" galleryimg=\"no\">";
  497.     if (document.all["img_" + iCount].title !="") sContent= document.all["img_" + iCount].title + sContent + "</a>";
  498.     if (document.all["img_" + iCount].alt !="") sContent= sContent + "<div style=\"padding: 3px; font: 8pt Arial\">" + document.all["img_" + iCount].alt + "</div>";
  499.     div_Main.innerHTML="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\"><tr><td width=\"100%\" align=\"center\">" + sContent + "</td></tr></table>";
  500.     if (IE50 == false) div_Main.filters.item(0).Play();
  501. }
  502. function doAuto(){
  503.     doTrans(1,iLastSlide,0);
  504.     oTime=setTimeout('doAuto()', iAutoDelay);
  505. }
  506. function PlayStop(iLast,iDelay,bAutoStart){
  507.     iLastSlide=iLast;
  508.     iAutoDelay=iDelay*1000;
  509.     if (bAutoStart == 1)
  510.         oTime=setTimeout('doAuto()', iAutoDelay);
  511.     else{
  512.         if (cmd_Auto.alt == 'Pause') {
  513.             cmd_Auto.alt='Play';
  514.             cmd_Auto.src='res/ss_play.gif';
  515.             clearTimeout(oTime);
  516.         }
  517.         else {
  518.             cmd_Auto.alt='Pause';
  519.             cmd_Auto.src='res/ss_pause.gif';
  520.             doTrans(1,iLastSlide,0);
  521.             oTime=setTimeout('doAuto()', iAutoDelay);
  522.         }
  523.     }
  524. }
  525. function ShowDate(){
  526. var now=new Date();
  527. document.write("DomLunMarMerGioVenSab".substr(now.getDay()*3,3)+' '+now.getDate()+' '+"GenFebMarAprMagGiuLugAgoSetOttNovDic".substr(now.getMonth()*3,3)+', '+now.getFullYear());
  528. }