<!-- Start of loading message //-->
// Global variables
var frameWidth, frameHeight;
var intTask_Still_Busy = 0;
var objTimer_Load_Page;

// ------------------------------ Prepare HTML code ------------------------------ 
// output http that contain our required div class
document.write("<div id=\"divLoading_Background\" class=\"transparent\" style=\"position:absolute; top:0px; left:0px; width:100%; height:100%; background-color:white; visibility:hidden;\"></div>");

//document.write("<div id=\"divLoading_Message\" style=\"background-color:white; padding:10px;border:2px solid; width:480px; height:50px; position:absolute; visibility:hidden;\"><font color=\"black\" size=\"20px\">Loading in progress..</font></div>");
document.write("<div id=\"divLoading_Message\" style=\"position:absolute; top:0px; left:0px; visibility:hidden;\"><img src=\"images/loading.gif\"></div>");

// Start of confirm box div html
document.write("<div id=\"divConfirm_Box\" style=\"position:absolute; top:0px; left:0px;z-index:3; visibility:hidden; \">");
document.write("<table width=\"487\" height=\"244\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"images/message_bg.gif\">");
document.write(" <tr>");
document.write("  <td width=\"10\" height=\"25\">&nbsp;</td>");
document.write("  <td width=\"467\" colspan=\"5\" valign=\"top\" id=\"itemConfirm_Box_Title\">&nbsp;</td>");
document.write("  <td width=\"10\">&nbsp;</td>");
document.write(" </tr>");
document.write(" <tr><td height=\"17\" colspan=\"7\">&nbsp;</td></tr>");
document.write(" <tr>");
document.write("  <td height=\"130\">&nbsp;</td>");
document.write("  <td colspan=\"5\" align=\"center\" valign=\"middle\" id=\"itemConfirm_Box_Message\">&nbsp;</td>");
document.write("  <td >&nbsp;</td>");
document.write(" </tr>");
document.write(" <tr><td height=\"17\" colspan=\"7\">&nbsp;</td></tr>");
document.write(" <tr>");
document.write("  <td height=\"30\">&nbsp;</td>");
document.write("  <td colspan=\"5\" align=\"right\">");
document.write("		<img src=\"images/en/button/button_15.gif\" name=\"Confirm_Box_button_1\" width=\"86\" height=\"30\" border=\"0\" class=\"link\" onClick=\"close_confirm_box('Y');\"  onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Confirm_Box_button_1','','images/en/button/button_15b.gif',1)\">");
document.write("		<img src=\"images/en/button/button_16.gif\" name=\"Confirm_Box_button_2\" width=\"86\" height=\"30\" border=\"0\" class=\"link\" onClick=\"close_confirm_box('N');\"  onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Confirm_Box_button_2','','images/en/button/button_16b.gif',1)\">");
document.write("		<img src=\"images/en/button/button_23.gif\" name=\"Confirm_Box_button_3\" width=\"86\" height=\"30\" border=\"0\" class=\"link\" onClick=\"close_confirm_box('');\"  onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Confirm_Box_button_3','','images/en/button/button_23b.gif',1)\" style=\"visibility:hidden\">");
document.write("  </td>");
document.write("  <td>&nbsp;</td>");
document.write(" </tr>");
document.write(" <tr><td height=\"5\" colspan=\"7\">&nbsp;</td></tr>");
document.write("</table>");
document.write("</div>");

// Start of alert box div html
document.write("<div id=\"divAlert_Box\" style=\"position:absolute; top:0px; left:0px;z-index:3; visibility:hidden\">");
document.write("<table width=\"487\" height=\"244\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" background=\"images/message_bg.gif\">");
document.write("	<tr>");
document.write("		<td width=\"10\" height=\"25\">&nbsp;</td>");
document.write("		<td width=\"467\" colspan=\"5\" valign=\"top\" id=\"itemAlert_Box_Title\">&nbsp;</td>");
document.write("		<td width=\"10\">&nbsp;</td>");
document.write("	</tr>");
document.write("	<tr><td height=\"17\" colspan=\"7\">&nbsp;</td></tr>");
document.write("	<tr>");
document.write("		<td height=\"130\">&nbsp;</td>");
document.write("		<td colspan=\"5\" align=\"center\" valign=\"middle\" id=\"itemAlert_Box_Message\">&nbsp;</td>");
document.write("		<td >&nbsp;</td>");
document.write("	</tr>");
document.write("	<tr><td height=\"17\" colspan=\"7\">&nbsp;</td></tr>");
document.write("	<tr>");
document.write("		<td height=\"30\">&nbsp;</td>");
document.write("		<td colspan=\"5\" align=\"right\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('alert_box_button_1','','images/en/button/button_15b.gif',1)\">");
document.write("			<img src=\"images/en/button/button_15.gif\" name=\"alert_box_button_1\" width=\"86\" height=\"30\" border=\"0\" class=\"link\" onClick=\"close_alert_box();\">");
document.write("		</td>");
document.write("		<td>&nbsp;</td>");
document.write("	</tr>");
document.write("	<tr><td height=\"5\" colspan=\"7\">&nbsp;</td></tr>");
document.write("</table>");
document.write("</div>");
// End of alert box div html

// ------------------------------ Calculate position ------------------------------ 
if (self.innerWidth)
{
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientWidth)
{
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
}
else if (document.body)
{
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
}

var objDiv_Loading_Background = $("divLoading_Background");
objDiv_Loading_Background.style.width= document.body.scrollWidth;
objDiv_Loading_Background.style.height = document.body.scrollHeight;

var objDiv_Loading_Message = $("divLoading_Message");
objDiv_Loading_Message.style.left = Math.round((frameWidth - 400)/2);
objDiv_Loading_Message.style.top = Math.round((frameHeight - 55)/2);

var objDivAlert_Box = $("divAlert_Box");
objDivAlert_Box.style.left = Math.round((frameWidth - 487)/2);
var intDivAlert_Box_OffsetHeight = Math.round((frameHeight - 244)/2);
objDivAlert_Box.style.top = intDivAlert_Box_OffsetHeight;

var objDivConfirm_Box = $("divConfirm_Box");
objDivConfirm_Box.style.left = Math.round((frameWidth - 487)/2);
var intDivConfirm_Box_OffsetHeight = Math.round((frameHeight - 244)/2);
objDivConfirm_Box.style.top = intDivConfirm_Box_OffsetHeight;


// ------------------------------ Function calls ------------------------------ 
function show_load_page()
{
	show_load_page(1000);
}

function show_load_page(intDelay)
{
	intTask_Still_Busy++;
	if(intDelay > 0)
	{
		objTimer_Load_Page = setTimeout("delayed_load_page()",intDelay);	// Only show load page if task exceed 1 second!
	}
	else
	{
		delayed_load_page();
	}
}

function delayed_load_page()
{
	if(objTimer_Load_Page)	clearTimeout(objTimer_Load_Page);
	
	if(intTask_Still_Busy > 0)
	{
		show_background();
//		$("divLoading_Message").style.visibility="visible";
	}
}

function hide_load_page()
{
	intTask_Still_Busy--;
	if(intTask_Still_Busy <= 0)
	{
		intTask_Still_Busy = 0;
		objDiv_Loading_Background.style.visibility="hidden";
//		$("divLoading_Message").style.visibility="hidden";
	}
}

var strAlert_Box_Function_Enter = "";
function alert_box(strAlert_Box_Message, strAlert_Box_Title, strAlert_Box_Function)
{
	if(strAlert_Box_Message)
	{
		strAlert_Box_Function_Enter = strAlert_Box_Function;
//		intDivAlert_Box_OffsetHeight = Math.round((frameHeight - 244)/2);
		try
		{
			strAlert_Box_Message = strAlert_Box_Message.replace("\n", "<BR>");
		}
		catch (e)
		{
			strAlert_Box_Message = "Function Error: alert_box";
		}

		intTask_Still_Busy++;
		show_background();
		if(strAlert_Box_Title) $("itemAlert_Box_Title").innerHTML = strAlert_Box_Title;
		$("itemAlert_Box_Message").innerHTML = strAlert_Box_Message;
		$("divAlert_Box").style.top =  document.body.scrollTop + intDivAlert_Box_OffsetHeight;
		$("divAlert_Box").style.visibility="visible";
	}
}

/*
function alert_box(strAlert_Box_Message, strAlert_Box_Title)
{
	alert_box(strAlert_Box_Message, strAlert_Box_Title, "");
}

function alert_box(strAlert_Box_Message)
{
	alert_box(strAlert_Box_Message, "", "");
}
*/


function close_alert_box()
{
	if($("divAlert_Box"))
	{
		intTask_Still_Busy--;
		$("divAlert_Box").style.visibility="hidden";
		if(intTask_Still_Busy == 0)
		{
			$("divLoading_Message").style.visibility="hidden";
			objDiv_Loading_Background.style.visibility="hidden";
		}
	}
	if(strAlert_Box_Function_Enter != "") eval(strAlert_Box_Function_Enter);
	strAlert_Box_Function_Enter = "";
}

var strConfirm_Box_Function_Yes, strConfirm_Box_Function_No;
function confirm_box(strConfirm_Box_Title, strConfirm_Box_Message, strConfirm_Box_Yes, strConfirm_Box_No, blnShow_Cancel)
{
	if(strConfirm_Box_Message)
	{
		strConfirm_Box_Function_Yes=(strConfirm_Box_Yes == "")?"":strConfirm_Box_Yes;
		strConfirm_Box_Function_No=(strConfirm_Box_No == "")?"":strConfirm_Box_No;

		strConfirm_Box_Message = strConfirm_Box_Message.replace("\n", "<BR>");
		intTask_Still_Busy++;
		show_background();
		$("itemConfirm_Box_Title").innerHTML = strConfirm_Box_Title;
		$("itemConfirm_Box_Message").innerHTML = strConfirm_Box_Message;
		if($("Confirm_Box_button_3")) $("Confirm_Box_button_3").style.visibility=(blnShow_Cancel == "true")?"visible":"hidden";
		$("divConfirm_Box").style.top =  document.body.scrollTop + intDivConfirm_Box_OffsetHeight;
		$("divConfirm_Box").style.visibility="visible";
	}
}

function close_confirm_box(strAnswer)
{
	if($("divConfirm_Box"))
	{
		intTask_Still_Busy--;
		$("divConfirm_Box").style.visibility="hidden";
		if(intTask_Still_Busy == 0)
		{
			$("divLoading_Message").style.visibility="hidden";
			objDiv_Loading_Background.style.visibility="hidden";
		}

		// Execute next step..
		switch (strAnswer)
		{
			case "Y":
				if(strConfirm_Box_Function_Yes != "") eval(strConfirm_Box_Function_Yes);
				break;
				
			case "N":
				if(strConfirm_Box_Function_No != "") eval(strConfirm_Box_Function_No);
				break;
		}
	}
}


// Show custom pop box
function showBox(strDiv_Name)
{
	var frameWidth, frameHeight;
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	
	var objDiv = $(strDiv_Name);
	if(objDiv)
	{
		show_load_page();
		divW = objDiv.style.width.replace("px", "");
		divH = objDiv.style.height.replace("px", "");
		objDiv.style.top = Math.round(document.body.scrollTop+((frameHeight - divH) / 2)-20);
		objDiv.style.left = Math.round((frameWidth - divW) / 2);
		objDiv.style.visibility = "visible";
	}
}

function show_loading(strDiv_Name)
{
	var objDiv = $(strDiv_Name);
	if(objDiv)
	{
		objDiv.innerHTML = "<img src='images/progress_loading.gif'>";
	}
}

function show_background()
{
	objDiv_Loading_Background.style.width= document.body.scrollWidth;
	objDiv_Loading_Background.style.height = document.body.scrollHeight;
	objDiv_Loading_Background.style.visibility = "visible";
}


// Show custom pop box
function hideBox(strDiv_Name)
{
	var objDiv = $(strDiv_Name);
	if(objDiv)
	{
		objDiv.style.visibility = "hidden";
		hide_load_page();
	}
}

function showBusy(strDiv_Name)
{
	var objDiv = $(strDiv_Name);
	if(objDiv)
	{
		objDiv.innerHTML = "<img src='images/progress_loading.gif'>";
	}
}
<!-- End of loading message //-->