	// FIXED PUZZLE SCRIPT
	// ===============================================================

	function PUZ_COMMON(){};
	
	
	// initialize
	// .................................................
	PUZ_COMMON.PUZZLE_BASE_IMAGE = '<!--[#SITE_URL;]-->/p/status/res/puzzle_base_pattern.png';
	PUZ_COMMON.PUZZLE_SUCCESS_IMAGE = '<!--[#SITE_URL;]-->/p/status/res/success.png';
	
	// SE
	PUZ_COMMON.SE_SELECT = null; 
	PUZ_COMMON.SE_SET = null; 
	PUZ_COMMON.SE_FREE = null; 
	
	// BGM
	PUZ_COMMON.BGM_ONGAME = null;
	PUZ_COMMON.BGM_COMPLETE = null;
	PUZ_COMMON.BGM_LAST_STATUS = null;
	
	// Common Variables
	PUZ_COMMON.ROW_MAX = 0;
	PUZ_COMMON.COL_MAX = 0;
	PUZ_COMMON.ROW_INDEX = 0;
	PUZ_COMMON.COL_INDEX = 0;
	
	PUZ_COMMON.HTML_ELEMENT = null;
	PUZ_COMMON.LINK_ELEMENT = null;
	PUZ_COMMON.PIECE_ELEMENT = null;
	PUZ_COMMON.ELEMENT_INDEX = 0;
	
	PUZ_COMMON.PUZZLE_PIECES = [];
	PUZ_COMMON.PUZZLE_PIECE_RES = [];
	PUZ_COMMON.PUZZLE_PIECE_ATTEMPT = 0;
	
	PUZ_COMMON.PUZZLE_PIECE_SELECTED_INDEX = null;
	PUZ_COMMON.PUZZLE_LOCK_EDIT = null;
	PUZ_COMMON.PUZZLE_COMPLETED = null;
	
	
	// Call this on re-loading puzzle
	PUZ_COMMON.CLEAR = function()
	{
		// Stop all audio
		if(JSVC_VAR.VAR_ISSET(PUZ_COMMON.SE_SELECT))
		{
			PUZ_COMMON.SE_SELECT.pause();
			PUZ_COMMON.SE_SET.pause(); 
			PUZ_COMMON.SE_FREE.pause();
		
			PUZ_COMMON.BGM_ONGAME.pause();
			PUZ_COMMON.BGM_COMPLETE.pause();			
		}
		
		// Unloads audio
		PUZ_COMMON.SE_SELECT = null;
		PUZ_COMMON.SE_SET = null;
		PUZ_COMMON.SE_FREE = null;
	
		PUZ_COMMON.BGM_ONGAME = null;
		PUZ_COMMON.BGM_COMPLETE = null;		
		
		// Reset Settings
		PUZ_COMMON.PUZZLE_PIECE_ATTEMPT = 0;
		
		// Clear Internal Elements
		JSOC_ELEMENT.VAR_CLEAR('main_div');
		
		// Add BGM Buttons
		// .................................................	
		PUZ_COMMON.HTML_ELEMENT = document.createElement("button");
		document.getElementById('main_div').appendChild(PUZ_COMMON.HTML_ELEMENT);	
		PUZ_COMMON.HTML_ELEMENT.innerHTML = "PLAY BGM";
		PUZ_COMMON.HTML_ELEMENT.className = "PUZZLE_BUTTON";
		PUZ_COMMON.HTML_ELEMENT.onclick = function(){ PUZ_COMMON.PLAY_BGM(PUZ_COMMON.BGM_LAST_STATUS); };
		PUZ_COMMON.HTML_ELEMENT.style.top = 10;
		PUZ_COMMON.HTML_ELEMENT.style.left = 550;
					
		PUZ_COMMON.HTML_ELEMENT = document.createElement("button");
		document.getElementById('main_div').appendChild(PUZ_COMMON.HTML_ELEMENT);	
		PUZ_COMMON.HTML_ELEMENT.innerHTML = "PAUSE BGM";
		PUZ_COMMON.HTML_ELEMENT.className = "PUZZLE_BUTTON";
		PUZ_COMMON.HTML_ELEMENT.onclick = function(){ PUZ_COMMON.PAUSE_BGM(PUZ_COMMON.BGM_LAST_STATUS); };							
		PUZ_COMMON.HTML_ELEMENT.style.top = 10;
		PUZ_COMMON.HTML_ELEMENT.style.left = 650;
		
		// Puzzle Base
		// .................................................
		PUZ_COMMON.HTML_ELEMENT = document.createElement("img");
		document.getElementById('main_div').appendChild(PUZ_COMMON.HTML_ELEMENT);		
		PUZ_COMMON.HTML_ELEMENT.setAttribute('src', PUZ_COMMON.PUZZLE_BASE_IMAGE);
		PUZ_COMMON.HTML_ELEMENT.className = "PUZZLE_BASE";
		PUZ_COMMON.HTML_ELEMENT.style.top = 0;
		PUZ_COMMON.HTML_ELEMENT.style.left = 0;
		
		// Puzzle success
		// .................................................				
		PUZ_COMMON.PIECE_ELEMENT = document.createElement("img");
		PUZ_COMMON.PIECE_ELEMENT.id = "IMG_PUZZLE_SUCCESS";
		document.getElementById('main_div').appendChild(PUZ_COMMON.PIECE_ELEMENT);		
		PUZ_COMMON.PIECE_ELEMENT.className = "IMG_SUCCESS";
		
		PUZ_COMMON.PIECE_ELEMENT.setAttribute('src', PUZ_COMMON.PUZZLE_SUCCESS_IMAGE);
		PUZ_COMMON.PIECE_ELEMENT.style.top = 125;
		PUZ_COMMON.PIECE_ELEMENT.style.left = 10;
		document.getElementById("IMG_PUZZLE_SUCCESS").style.display = "none";
	}
	
	PUZ_COMMON.PLAY_BGM = function()
	{
		if(PUZ_COMMON.PUZZLE_COMPLETED === true)
		{
			PUZ_COMMON.BGM_ONGAME.pause();
			JSRC_AUDIO.REF_PLAY(PUZ_COMMON.BGM_COMPLETE, null, true);
			PUZ_COMMON.BGM_LAST_STATUS = true;
		}
		else
		{
			PUZ_COMMON.BGM_COMPLETE.pause();
			JSRC_AUDIO.REF_PLAY(PUZ_COMMON.BGM_ONGAME, null, true);
			PUZ_COMMON.BGM_LAST_STATUS = false;
		}
	}
	
	PUZ_COMMON.PAUSE_BGM = function()
	{
		PUZ_COMMON.BGM_ONGAME.pause();
		PUZ_COMMON.BGM_COMPLETE.pause();
	}
