﻿var _IsOpen_LeftDoorPanel = false;
var _IsOpen_RightDoorPanel = false;
        
$(function() {
	Locate_DoorPanel();
	$(window).resize(function() {
		Locate_DoorPanel();
	});
	
	// $("#Panel_Left_DoorPanel_Button").click(function() {
		// Click_DoorPanelButton("#Panel_Left_DoorPanel_MessageBox", "left");
	// });
	
	// Click_DoorPanelButton("#Panel_Right_DoorPanel_Button", "#Panel_Right_DoorPanel_MessageBox", "right");
	
	$("#Panel_Left_DoorPanel_Button").click(function() {
		var Control_Left_DoorPanel_MessageBox = $("#Panel_Left_DoorPanel_MessageBox");
		if (_IsOpen_LeftDoorPanel ==  true) {
			Control_Left_DoorPanel_MessageBox.animate({ left: (0 - Control_Left_DoorPanel_MessageBox.width() - 100) }, 500);
			_IsOpen_LeftDoorPanel = false;
		} else {
			Control_Left_DoorPanel_MessageBox.animate({ left: 0 }, 500);
			_IsOpen_LeftDoorPanel = true;
		}
	});
	
	$("#Panel_Left_DoorPanel_Close").click(function() {
		var Control_Left_DoorPanel_MessageBox = $("#Panel_Left_DoorPanel_MessageBox");
		if (_IsOpen_LeftDoorPanel ==  true) {
			Control_Left_DoorPanel_MessageBox.animate({ left: (0 - Control_Left_DoorPanel_MessageBox.width() - 100) }, 500);
			_IsOpen_LeftDoorPanel = false;
		} else {
			Control_Left_DoorPanel_MessageBox.animate({ left: 0 }, 500);
			_IsOpen_LeftDoorPanel = true;
		}
	});

	$("#Panel_Right_DoorPanel_Button").click(function() {
		var Control_Right_DoorPanel_MessageBox = $("#Panel_Right_DoorPanel_MessageBox");
		if (_IsOpen_RightDoorPanel ==  true) {
			Control_Right_DoorPanel_MessageBox.animate({ right: (0 - Control_Right_DoorPanel_MessageBox.width() - 100) }, 350);
			_IsOpen_RightDoorPanel = false;
		} else {
			Control_Right_DoorPanel_MessageBox.animate({ right: 0 }, 350);
			_IsOpen_RightDoorPanel = true;
		}
	});
	
	$("#Panel_Right_DoorPanel_Close").click(function() {
		var Control_Right_DoorPanel_MessageBox = $("#Panel_Right_DoorPanel_MessageBox");
		if (_IsOpen_RightDoorPanel ==  true) {
			Control_Right_DoorPanel_MessageBox.animate({ right: (0 - Control_Right_DoorPanel_MessageBox.width() - 100) }, 350);
			_IsOpen_RightDoorPanel = false;
		} else {
			Control_Right_DoorPanel_MessageBox.animate({ right: 0 }, 350);
			_IsOpen_RightDoorPanel = true;
		}
	});
});


function Locate_DoorPanel() {
	$("#Panel_Left_DoorPanel_Button").locate("grid", 4);
	$("#Panel_Left_DoorPanel_MessageBox").locate("grid", 4).css("left", (0 - $(this).width() - 10));
	
	$("#Panel_Right_DoorPanel_Button").locate("grid", 6);
	$("#Panel_Right_DoorPanel_MessageBox").locate("grid", 6).css("right", (0 - $(this).width() - 10));	
}

function Click_DoorPanelButton(thisMessageBoxId, thisDirection) {
		var Control_MessageBox = $(thisMessageBoxId);
		
		if (Control_MessageBox.attr("isopen") ==  "true") {
			$(thisMessageBoxId).animate({ thisDirection: (0 - Control_MessageBox.width() - 10) }, 350);
			Control_MessageBox.attr("isopen", "false");
		} else {
			$(thisMessageBoxId).animate({"left":  0}, 350);
			Control_MessageBox.attr("isopen", "true");
		}
}
