﻿var zindex = 101;
var pageID;
var someArticleOpen = false;

$(document).ready(function() {

    pageID = $("#tabID").text();
      switch (pageID) {
          case '757':
             $(".clip").css("bottom","0px");
              break;
	  case '2055':
	  $(".questions").css("height","430px");
	      break;    
	      default:

      }

   

    $('.hp_lightbox SPAN, #overlay').click(function() {
        $('.hp_lightbox').fadeOut('slow', function() {
            // Animation complete.
        });
        $('#overlay').fadeOut('slow', function() {
            // Animation complete.
        });

    })
  
  
    /* main menu */
    $('.main-menu li.level-0')
        .mouseover(function() {

            //$('ul.level-1.hide-this').hide();
            zindex += 1;
            $(this).find('ul.level-1')
                .css({ 'z-index': zindex })
                .removeClass('hide-this').show(); //fadeIn(100);
        })
        .mouseout(function() {
            var o = $(this);
            o.find('ul.level-1').addClass('hide-this');
            //            setTimeout(function() {
            o.find('ul.level-1.hide-this').hide(); //fadeOut(70);
            //            }, 1);
        });
    $('.main-menu li.level-1')
        .mouseover(function() {
            $(this).find('ul.level-2').removeClass('hide-this').show(); //fadeIn(100);
        })
        .mouseout(function() {
            var o = $(this);
            o.find('ul.level-2').addClass('hide-this');
            setTimeout(function() {
                o.find('ul.level-2.hide-this').hide(); //fadeOut(70);
            }, 100);
        });

    });


   function openDemo() {
 
        var arrayPageSize = getPageSize();
        $('#overlay').css("display","block").css("opacity","0").animate({opacity: '0.7', height: arrayPageSize[1]},"slow");
		$('.hp_lightbox').fadeIn('slow')     
    }







    function getPageSize () {
        var xScroll, yScroll;

        if (window.innerHeight && window.scrollMaxY) {
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }

        var windowWidth, windowHeight;

        if (self.innerHeight) { // all except Explorer
            if (document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }

        // for small pages with total height less then height of the viewport
        if (yScroll < windowHeight) {
            pageHeight = windowHeight;
        } else {
            pageHeight = yScroll;
        }


        // for small pages with total width less then width of the viewport
        if (xScroll < windowWidth) {
            pageWidth = xScroll;
        } else {
            pageWidth = windowWidth;
        }

        var arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
        return arrayPageSize;
    };

   
