﻿// JScript File

// some global variables

/*


var menucontentopen = false;
var menucontentname = 'menucontent';

var toptablewidth = null;
var toptableheight = null;

var maintablewidth = null;
var maintableheight = null;

var bottomtablewidth = null;
var bottomtableheight = null;



function determineSlideHeight() {

var height = parseInt(screen.height);
if(height <= 768) {
    return 470;
}
else if(height <= 1024) {
    return 650;
}
else {
    return height*0.745;
    }
}


function determineFullScreenSlideHeightCoefficient() {
var height = parseInt(screen.height);

if(height <= 768) {
    return 1.3;
}
else if(height <= 1024) {
    return 1.1;
}
else {
    return 1.13;
    }
}

var slidex = 0;
var slidey = 200; // determineSlideHeight();
var slidespeed = 500;
var closespeed = 500;

var pagewidth = 980;
 
     function centerX(objectWidth) {
        var screenx = screen.width;
        return (screenx - objectWidth)/2
     }

     function centerY(objectHeight) {
        var screeny = screen.height;
        return (screeny - objectHeight)/2
     }
     
     function getObjectWidth(controlString) {
        var control = dijit.byId(controlString);
        // dojo.console("Control width: " + control.width);
        return control.width;
     }
     
     function getObjectHeight(controlString) {
        var control = dijit.byId(controlString);
        // dojo.console("Control height: " + control.height);
        return control.height;
     }
 
      // opens a dojo-based dhtml object
      function openObject(someID) { 
            document.getElementById(someID).style.visibility = 'visible'; 
      } 
  
      // closes a dojo-based dhtml object
      function closeObject(someID) { 
        document.getElementById(someID).style.visibility = 'hidden'; 
      }     
      
      // loads a document remotely into a dojo-based widget
      function loadDocument(someID, someDocument) { 
            var pane = dijit.byId(someID);
            if(pane != null)
                pane.setHref(someDocument);
      }      
      
      function loadContent(controlString, contentHTML) {
        var pane = dijit.byId(controlString);
            if(pane != null)
                pane.setContent(contentHTML);
      }


      function fadeIn(whichControls, speed) {
           for(var i = 0; i < whichControls.length; i++) {
                var controlInArray = dojo.byId(whichControls[i]);
                controlInArray.style.opacity = 0.0;
                controlInArray.style.visibility = 'visible';
                dojo.fadeIn({node:controlInArray, duration:speed}).play();
           }
      }
            
      function expand(controlString, speed, startingWidth, startingHeight, finalWidth, finalHeight, additionalLayers) {
            var control1 = dojo.byId(controlString);
            var layers = additionalLayers;
            control1.style.width = startingWidth + "px";
            control1.style.height = startingHeight + "px";
            // control1.style.left = centerX(getObjectWidth(controlString)) + "px";
            // control1.style.top = centerY(getObjectHeight(controlString)) + "px";
            control1.style.visibility = 'visible';
            control1.style.opacity = 1.0;
             
            dojo.animateProperty(
                {node:control1, duration:speed, properties: 
                     {width: 
                         {start: startingWidth, end: finalWidth}, height: {start: startingHeight, end: finalHeight}
                     },
                onEnd: function() { control1.style.width = parseInt(finalWidth) + 7 + 'px';
                       control1.style.height = parseInt(finalHeight) + 7 + 'px';
                       toggleVisibility(layers,'visible', '1.0'); }
           }).play();
    }
           
    function wipeout(controlString, speed, easing) {
         var control = dojo.byId(controlString);
         dojo.fx.wipeOut({node:control,duration:speed,easing:easing}).play();
    }
           
    function returnSlideFunction(controlString, speed, slideByX, slideByY, easing) {
          var control = dojo.byId(controlString);
          var newX = parseInt(control.offsetLeft) + parseInt(slideByX);
          var newY = parseInt(control.offsetTop) + parseInt(slideByY);
          return dojo.fx.slideTo({node:control,top: newY + "", left: newX + "", duration:speed,easing:easing}).play();
   }
   
   function returnExpandFunction(controlString, speed, newWidth, newHeight, page) {
        
        var control = dojo.byId(controlString);
        control.style.visibility = "visible";
        control.style.opacity = 1.0;
        return dojo.animateProperty({
            node:control,
            duration:speed,
            properties: {
                         height: { start: '0', end: newHeight + "" },
                         width: { start: pagewidth + "", end: newWidth + "" }
                        },
            onEnd: function() { 
                              control.style.fontSize="8pt";
                              loadDocument(controlString, page);
                              menucontentopen = true;
                              }
        });        
   }
   
    function returnContractFunction(controlString, speed, currentWidth, currentHeight, page) {
        
        var control = dojo.byId(controlString);
        loadDocument(controlString, page);
        return dojo.animateProperty({
            node:control,
            duration:speed,
            properties: {
                         height: { start: currentHeight + "", end: '0' },
                         width: { start: currentWidth + "", end: pagewidth + "" }
                        },
            onEnd: function() { 
                              menucontentopen = false;
                              control.style.fontSize="0pt";
                              control.style.visibility = 'hidden';
                              control.style.opacity = 0.0;
                              }
        });        
   }
   
           
   function slideCombined(slides) {
        dojo.fx.combine(slides).play();
   }
           
   function toggleVisibility(layers, visibility, opacity) {
        for(var i = 0; i < layers.length; i++) {
              var layer = dojo.byId(layers[i]);
              layer.style.visibility = visibility;
              layer.style.opacity = opacity;
       }
  }
  
  function openMenuItem(controlString, page, slidey) {
   
       if(menucontentopen) {
           loadDocument(controlString, page);
       }
       else {
            var slideOpen = returnExpandFunction(controlString, slidespeed, pagewidth, slidey, page);
            slideCombined([slideOpen]);
       }       
   }
   
   function closeMenuItem(controlString, page) {
   
       if(menucontentopen) {
           returnContractFunction("menucontent", slidespeed, pagewidth, slidey, page).play();
       }
       else {
            return;
       }       
   }

function openMenuItemFullScreen(controlString, page) {
   
       if(menucontentopen) {
           loadDocument(controlString, page);
       }
       else {
            var slideOpen = returnExpandFunction(controlString, slidespeed, pagewidth, (screen.availHeight - 160), page);
            slideCombined([slideOpen]);
            setTimeout("returnSlideFunction('toptable',600,0,parseInt('-100')).play();", 100);
       }       
   }
 
 function openDatabase(page) {
 openMenuItemFullScreen(menucontentname, page);
 // toggleVisibility(['maintable','bottomtable'], 'hidden', 0.0);
 // toggleVisibility(['menucontentmenu'], 'visible', 1.0);
 // setTimeout("returnContractFunction('maintable', slidespeed, pagewidth, maintableheight).play()",1000);
 // setTimeout("returnContractFunction('bottomtable', slidespeed, pagewidth, bottomtableheight).play()",2000);
 setTimeout("returnExpandFunction('menucontentmenu', slidespeed, 980, 30).play()", 4000);
 }
 
 function closeDatabase(page) {
 openMenuItemFullScreen(menucontentname, page);
 // toggleVisibility(['maintable','bottomtable'], 'hidden', 0.0);
 // toggleVisibility(['menucontentmenu'], 'visible', 1.0);
 setTimeout("returnExpandFunction('menucontentmenu', 500, 980, 40).play()", 3000);
 }
 
 function setPosition(controlString, position, left, top) {
    var control = dojo.byId(controlString);
    control.style.position = position;
    control.style.left = left;
    control.style.top = top;
 }
 
 function setDatabasePosition() {
    var left = (dojo.byId('toptable')).offsetLeft;
    var top = (dojo.byId('toptable')).offsetTop;
    var top = 10;
    setPosition('freetrialcontainer', 'absolute', left, top);
    toggleVisibility(['bottomtable'], 'hidden', 0.0);
    
 }
 
 function openDatabaseTopBottomContent(controlStringContainer, controlStringTop, controlStringBottom) {
    var top = dijit.byId(controlStringTop);
    var bottom = dijit.byId(controlStringBottom);
    var content = "<div align=right style='padding-right: 20px; padding-top: 7px;'><a href='javascript:window.location.reload();'>close</a></div>";
    if(top != null)
        loadContent(controlStringTop, content);
    if(bottom != null)
        loadContent(controlStringBottom, content);
 }
 
 */
 
 function makePreloaderVisible() {
    document.getElementById('preloader').style.visibility='visible';
 }
 
 function makePreloaderHidden() {
    document.getElementById('preloader').style.visibility='hidden';
 }
 
 function makeParentPreloaderVisible() {
    parent.document.getElementById('preloader').style.visibility='visible';
 }
 
 function makeParentPreloaderHidden() {
    parent.document.getElementById('preloader').style.visibility='hidden';
 }
