﻿$(document).ready(function(){
	
    //Get the div
    var productWindow = '#MoreInfoContent';
    var Mask = '#Mask';
    var dxInEditMode = false;
    
   if(dxInEditMode){
	    $(productWindow).show(); 
        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();
              
        //Set the popup window to center
        $(productWindow).css('top',  500);
        $(productWindow).css('left', winW/2-$(productWindow).width()/2);	    
 
         //Initiate scrollbar
        $(function()
        {
            $('#Scrollbar1').jScrollPane({showArrows:true, scrollbarWidth: 11, arrowSize: 17});
        });
    }

/*
    $("#ProductMoreInfo").click(function(e) {	
     
	    e.preventDefault();
	    popupShow(productWindow);
    });
*/  	
  
      $("#ProductMoreInfo").click(
        function(e){
	        e.preventDefault();
	        popupShow(productWindow, Mask);

            //Initiate scrollbar
            $(function()
            {
	            $('#Scrollbar1').jScrollPane({showArrows:true, scrollbarWidth: 11, arrowSize: 17});
            });

            return false;
        }
    );

	
  	
    //if close button is clicked
    $('.CloseWindow').click(function (e) {
	    //Cancel the link behavior
	    e.preventDefault();
		
	    $(Mask).hide();
	    $(productWindow).hide();
    });		
	
    //if mask is clicked
	$(Mask).click(function () {
	    $(this).hide();
	    $(productWindow).hide();
    });			

	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27){
		    $(Mask).hide();
		    $(productWindow).hide();
		}
	});

    $(window).resize(function() { 

        if(!dxInEditMode){
            //Get the screen height and width
            var maskHeight = $(document).height();
            var maskWidth = $(window).width();

            //Set heigth and width to mask to fill up the whole screen
            $(Mask).css({'width':maskWidth,'height':maskHeight});

            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();
                  
            //Set the popup window to center
            $(productWindow).css('top',  120);
            $(productWindow).css('left', winW/2-$(productWindow).width()/2);
        }else
        {
            //Get the window height and width
            var winH = $(window).height();
            var winW = $(window).width();
                  
            //Set the popup window to center
            $(productWindow).css('top',  600);
            $(productWindow).css('left', winW/2-$(productWindow).width()/2);
        }
    }); 

});


function popupShow(id, Mask)
{

	    //Get the screen height and width
	    var maskHeight = $(document).height();
	    var maskWidth = $(window).width();

	    //Set heigth and width to mask to fill up the whole screen
	    $(Mask).css({'width':maskWidth,'height':maskHeight});
 
	    //transition effect		
	    $(Mask).fadeIn(10);	
	    $(Mask).fadeTo("fast",0.3);	




	    //Get the window height and width
	    var winH = $(window).height();
	    var winW = $(window).width();
              
	    //Set the popup window position
    //	$(idw).css('top',  winH/2-$(id).height()/2);
	    $(id).css('top',  120);
	    $(id).css('left', winW/2-$(id).width()/2);

	    //transition effect
	    $(id).fadeIn(10);
}
