var f_width = 200;
var f_height = 200;

function vt_prompt(iws_pop_msg, pop_width, pop_height, msg_type)
{
	f_width = pop_width;
	f_height = pop_height;

	if(document.getElementById('hope_FLOATS').style.display == "none")
		document.getElementById('hope_FLOATS').style.display = "block";

	vt_launch_prompt(iws_pop_msg, f_width, f_height, msg_type, "100", "60", "#FFFFFF", "#CCCCCC", "#999999", "#666");
}

function vt_get_user_win_dim() 
{
	i_width = 0; 
	i_height = 0;

	if(typeof(window.innerWidth) == 'number') 
	{
		// Standard 
		i_width = window.innerWidth;
		i_height = window.innerHeight;
	} 
	else 
	{
		if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
		{
			// IE > 6
			i_width = document.documentElement.clientWidth;
			i_height = document.documentElement.clientHeight;
		} 
		else 
		{
			if(document.body && (document.body.clientWidth || document.body.clientHeight)) 
			{
				// IE 4 - For Fun
				i_width = document.body.clientWidth;
				i_height = document.body.clientHeight;
			}
		}
	}
}

function vt_resize_prompt()
{
	if(document.getElementById('hope_FLOATS'))
	{
		if(document.getElementById('hope_FLOATS').style.display != "none")
			window.onresize = function() { vt_load_prompt(); };
	}		
}

function vt_load_prompt()
{
	if(f_width == "auto" || f_width == "")
	{
		var docCenterWidth = document.documentElement.clientWidth / 2;
		var docOffsetWidth = docCenterWidth / 2;  
	}	
	else
	{
		var docBodyWidth = document.documentElement.clientWidth;
		var docCenterWidth = f_width;

		if(docCenterWidth >= docBodyWidth)
			var docOffsetWidth = 20; 
		else	
			var docOffsetWidth = (docBodyWidth - docCenterWidth) / 2;  
	}	

	if(f_height == "auto" || f_height == "")
	{
		var docCenterHeight = document.documentElement.clientHeight / 2;
		var docOffsetHeight = docCenterHeight / 2;  
	}	
	else	
	{
		var docBodyHeight = document.documentElement.clientHeight;
		var docCenterHeight = f_height;

		if(docCenterHeight >= docBodyHeight)
			var docOffsetHeight = 20; 
		else	
			var docOffsetHeight = (docBodyHeight - docCenterHeight) / 2;  
	}

	document.getElementById('hope_FLOATS_content').style.width = docCenterWidth + "px";
	document.getElementById('hope_FLOATS_content_2').style.padding = "15px";
	document.getElementById('hope_FLOATS_content_3').style.width = (docCenterWidth - 30) + "px"; 

	document.getElementById('hope_FLOATS_content_1').style.height = docCenterHeight + "px";
	document.getElementById('hope_FLOATS_content_3').style.height = (docCenterHeight - 30) + "px"; 

	document.getElementById('hope_FLOATS_content').style.top = docOffsetHeight + "px";
	document.getElementById('hope_FLOATS_content').style.left = docOffsetWidth + "px";

	if(navigator.appVersion.indexOf("Win") != -1)   
	{

		var ie6 = ((navigator.appVersion.indexOf('MSIE') >= 0) && (navigator.appVersion.indexOf('6.0') >= 0));
		show_obj = document.getElementById('hope_FLOATS_content');
		show_obj_c = document.getElementById('hope_FLOATS_content_2');
		show_obj_u = document.getElementById('hope_FLOATS_color');

		if(ie6)
		{
			var offsetY = document.documentElement.scrollTop;
			var screenY = document.documentElement.clientHeight; 

			show_obj_u.style.position = 'absolute';
			show_obj_u.style.display = 'block';
			show_obj_u.style.top = '0';
			show_obj_u.style.left = '0';
			show_obj_u.style.width = document.body.clientWidth;
			show_obj_u.style.height = document.body.clientHeight;

			var so_width = document.body.clientWidth / 2;
			so_width = so_width / 2;

			show_obj.style.position = 'absolute';
			show_obj.style.display = 'block';
			show_obj.style.top = (offsetY + 30) + 'px';
			show_obj.style.left = so_width + 'px';

			if(f_height == "auto" || f_height == "")
				show_obj.style.height = document.body.clientHeight / 3;
			else	
				show_obj.style.height = docCenterHeight + "px";
		}
	} 
}
function vt_launch_prompt(content, new_width, new_height, msg_type, foreground_alpha, background_alpha, foreground_color, background_color, border_color, text_color)
{
	f_width = new_width;
	f_height = new_height;

	vt_load_prompt(f_width, f_height);
	vt_resize_prompt(f_width, f_height);

	if(document.getElementById('hope_FLOATS').style.display == "none")
		document.getElementById('hope_FLOATS').style.display = "block";

	document.getElementById('hope_FLOATS_content_3').innerHTML = content; 

	var _ba = (background_alpha / 100);
	document.getElementById('hope_FLOATS_color').style.opacity = _ba; 
	document.getElementById('hope_FLOATS_color').style.backgroundColor = background_color;

	var _fa = (foreground_alpha / 100);
	document.getElementById('hope_FLOATS_content').style.opacity = _fa; 

	if(msg_type == "error")
		document.getElementById('hope_FLOATS_content').className = "i_o_c_e"; 
	else if(msg_type == "success")	
		document.getElementById('hope_FLOATS_content').className = "i_o_c_s"; 
	else
	{
		document.getElementById('hope_FLOATS_content').className = "i_o_c_d"; 
		document.getElementById('hope_FLOATS_content').style.borderColor = border_color; 
		document.getElementById('hope_FLOATS_content').style.backgroundColor = foreground_color; 
		document.getElementById('hope_FLOATS_content').style.color = text_color; 
	}	

}	
function vt_close_prompt()
{
	document.getElementById('hope_FLOATS').style.display = "none";

	if(typeof vt_count_down_clock_id != "undefined")
		clearTimeout(vt_count_down_clock_id);
}
function vt_handle_esc_press(e) 
{
	var kC  = (window.event) ? event.keyCode : e.keyCode;
	var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE
	if(kC == Esc)
		vt_close_prompt();
}
function vt_setup_prompt() 
{
	var str = "";
	str += '<div id="hope_FLOATS_color"></div>';
	str += '<div id="hope_FLOATS_content" class="i_o_c_d">';
		str += '<div id="hope_FLOATS_content_1">';
			str += '<div id="hope_FLOATS_content_2">';
				str += '<div id="hope_FLOATS_content_3">';
				str += '</div>'; // hope_FLOATS_content_3
			str += '</div>'; // hope_FLOATS_content_2
		str += '</div>'; // hope_FLOATS_content_1
		str += '<a href="javascript:vt_close_prompt();" id="hope_FLOATS_close"></a>';
	str += '</div>'; // hope_FLOATS_content 

	var div = document.createElement('div');

	div.id = 'hope_FLOATS';
	div.style.display = 'none';
	div.innerHTML = str;

	if(document.body.firstChild)
		document.body.insertBefore(div, document.body.firstChild);
	else 
		document.body.appendChild(div);
}

if(window.addEventListener)
	window.addEventListener("resize", vt_resize_prompt, false);
else if(window.attachEvent)                 
	window.attachEvent("onresize", vt_resize_prompt);

if(window.addEventListener)
	window.addEventListener("load", vt_setup_prompt, false);
else if(window.attachEvent)                 
	window.attachEvent("onload", vt_setup_prompt);

if(window.addEventListener)
	window.addEventListener("keypress", vt_handle_esc_press, false);
else if(window.attachEvent)                 
	window.attachEvent("onkeypress", vt_handle_esc_press);

function addslashes(str) 
{
	str = str.replace(/\'/g,'\\\'');
	str = str.replace(/\"/g,'\\"');
	str = str.replace(/\\/g,'\\\\');
	str = str.replace(/\0/g,'\\0');
	return str;
}

