﻿   var hovered = "foox2";
     $(document).ready(function () {
     resizePanel();
       $('#mainmenu').fadeOut(500);
       $('#mainmenu').fadeIn(500);
  
	        var style = 'easeOutExpo';
	        var default_left = -50;
	        var default_top = 0;
            $('#boxcontainer').fadeOut(800);
	        //Set the default position and text for the tooltips
	        $('#boxcontainer').css({ left: default_left, top: default_top });
	        $('#boxcontainer .head').html($('#mainmenu li.selected').find('a').text());

	        //if mouseover the menu item
	        $('#mainmenu a').hover(function () {

                
                offset = $(this).offset();
                leftoffset = Math.round(offset.left+25);
                topoffset = Math.round(offset.top+25);
                $('#boxcontainer .head').html($(this).text());
                $('#boxcontainer').stop(false, true).animate({ left: leftoffset, top: topoffset }, { duration: 500, easing: style });

                href = $(this).attr('href');
                menuId = $(this).attr('rel');
                if (menuId == 'submenu' || menuId == 'contacterror' )
                {
                }
                else
                {
                    var newHovered = $(this).attr('id');
                    if(hovered != newHovered && hovered != "")
                    {
                        $(".submenu").fadeOut(800);
                        if(menuId == 'True')
                        {
                            $('#li'+$(this).attr('id')).find('ul').fadeIn(800);
                            hovered = newHovered;
                        }
                        else
                        {
                            hovered = "";
                        }
                    }
                    else
                    {
                        hovered = newHovered;
                    }
                }
	        })
            
            $('#menuspan').mouseenter(function () {
            
                $('#boxcontainer').fadeIn(800);
            });

            $('#menuspan').mouseleave(function () {
            
                $('#boxcontainer').fadeOut(800);
            });


    $(".iframelink").fancybox({
          'type': 'iframe',
          'transitionIn': 'fade',
          'transitionOut': 'none'

      });
    $('a.panel').click(function () {

        

        current = $(this);
        href = $(this).attr('href');
        menuId = $(this).attr('rel');
        if (menuId == 'submenu' || menuId == 'contacterror' ) {
        
        $('a.panel').removeClass('selected');
            $(this).addClass('selected');
            $("#wrapper").scrollTo(href, 800, { queue: true, axis: 'yx' });
            
        } else {
            $("#wrapper").scrollTo(href, 800, { queue: true, axis: 'xy' });
            

            $('a.panel').removeClass('selected');
            $(this).addClass('selected');
            $('#wrapper').scrollTo($('a.selected').attr('href'), 0);
        }
                    

        return false;
    });
        });
                    function resizePanel() {

                    width = $(window).width();
                    height = $(window).height();

                    mask_height = height * $('.item').length;
                    mask_width = width * $('.item').length;

                    body_height = height * $('.hitem').length;
                    body_width = width * $('.hitem').length;

                    $('#wrapper, .item').css({ width: width, height: height });
                    $('#wrapper, .hitem').css({ width: width * $('.hitem').length, height: height });
                    $('#mask').css({ width: mask_width, height: mask_height });
                    $('body').css({ width: body_width, height: body_height });
                }
            $(window).resize(function() {
              resizePanel();
               $('#wrapper').scrollTo($('a.selected').attr('href'), 0);
            });
