var promptwin = {

	f_width:  200,
	f_height:  200,
	prompt_div_name: 's-j-X',

	launch_it:function(msg, width, height, type)
	{
		f_width = width;
		f_height = height;

		if(document.getElementById(this.prompt_div_name).style.display == "none")
			document.getElementById(this.prompt_div_name).style.display = "block";

		this.launch_prompt(msg, f_width, f_height, type, "100", "60", "#FFFFFF", "#000000", "#999999", "#666");
	},

	get_user_win_dim:function() 
	{
		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;
				}
			}
		}
	},

	resize_prompt:function()
	{
		if(document.getElementById(this.prompt_div_name))
		{
			if(document.getElementById(this.prompt_div_name).style.display != "none")
				window.onresize = function() { promptwin.load_prompt(); };
		}		
	},

	load_prompt:function()
	{
		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(this.prompt_div_name + '_content').style.width = docCenterWidth + "px";
		document.getElementById(this.prompt_div_name + '_content_2').style.padding = "15px";
		document.getElementById(this.prompt_div_name + '_content_3').style.width = (docCenterWidth - 30) + "px"; 

		document.getElementById(this.prompt_div_name + '_content_1').style.height = docCenterHeight + "px";
		document.getElementById(this.prompt_div_name + '_content_3').style.height = (docCenterHeight - 30) + "px"; 

		document.getElementById(this.prompt_div_name + '_content').style.top = docOffsetHeight + "px";
		document.getElementById(this.prompt_div_name + '_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(this.prompt_div_name + '_content');
			show_obj_c = document.getElementById(this.prompt_div_name + '_content_2');
			show_obj_u = document.getElementById(this.prompt_div_name + '_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 + 200) + '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";
			}
		} 
	},
	launch_prompt:function(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;

		this.load_prompt(f_width, f_height);
		this.resize_prompt(f_width, f_height);

		if(document.getElementById(this.prompt_div_name).style.display == "none")
			document.getElementById(this.prompt_div_name).style.display = "block";

		document.getElementById(this.prompt_div_name + '_content_3').innerHTML = content; 

		var _ba = (background_alpha / 100);
		document.getElementById(this.prompt_div_name + '_color').style.opacity = _ba; 
		document.getElementById(this.prompt_div_name + '_color').style.backgroundColor = background_color;

		var _fa = (foreground_alpha / 100);
		document.getElementById(this.prompt_div_name + '_content').style.opacity = _fa; 

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

	},	
	close_prompt:function()
	{
		document.getElementById(this.prompt_div_name).style.display = "none";

		if(typeof vt_count_down_clock_id != "undefined")
			clearTimeout(vt_count_down_clock_id);
	},
	handle_esc_press:function(e) 
	{
		var kC  = (window.event) ? event.keyCode : e.keyCode;
		var Esc = (window.event) ? 27 : e.DOM_VK_ESCAPE
		if(kC == Esc)
			promptwin.close_prompt();
	},
	setup_prompt:function() 
	{
		var str = "";
		str += '<div id="' + promptwin.prompt_div_name + '_color" style="position: fixed; margin: 0; padding: 0; width: 100%; height: 100%; opacity: 0.8; filter: alpha(opacity = 80); background-color: #000;"></div>';
		str += '<div id="' + promptwin.prompt_div_name + '_content" class="i_o_c_d" style="position: fixed; z-index: 1000000002; top: 50%; left: 50%; margin: 0; padding: 0; border: 1px solid #888; background-color: #888; -moz-border-radius: 9px; -webkit-border-radius: 9px;">';
			str += '<div id="' + promptwin.prompt_div_name + '_content_1" style="position: relative; margin: 0; padding: 3px; border: 1px solid #FFF; background-color: #FFF; -moz-border-radius: 9px; -webkit-border-radius: 9px;">';
				str += '<div id="' + promptwin.prompt_div_name + '_content_2" style="position: relative; margin: 0; padding: 0;">';
					str += '<div id="' + promptwin.prompt_div_name + '_content_3" style="position: relative; margin: 0; padding: 0; overflow: hidden;">';
					str += '</div>'; // _content_3
				str += '</div>'; // _content_2
			str += '</div>'; // _content_1
			str += '<a href="javascript:promptwin.close_prompt();" id="' + promptwin.prompt_div_name + '_close" style="position: absolute; z-index: 1000003; top: -10px; left: -10px; width: 30px; height: 30px; background: transparent url(/images/close.png) 0 0 no-repeat;"></a>';

			if(navigator.appVersion.indexOf('Win') != -1)
			{
				str += '<style type="text/css">';
					str += '* html #hello_color, * html #hello_content {';
						str += 'position: absolute;';
						str += 'top: expression(104+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+\'px\');';
						str += 'left: expression(15+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+\'px\');';
					str += '}';
				str += '</style>';
			}
		str += '</div>'; // _content 

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

		div.id = promptwin.prompt_div_name;
		div.style.display = 'none';
		div.style.position = 'absolute';
		if(navigator.appVersion.indexOf('Win') != -1)
			div.style.zIndex = '1000001';
		else	
			div.style.zIndex = '10000000001';
		div.style.top = '0';
		div.style.left = '0';
		div.style.margin = '0';
		div.style.padding = '0';
		div.style.width = '100%';
		div.style.height = '100%';

		div.innerHTML = str;

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

	},
	init_prompt:function(name)
	{
		promptwin.prompt_div_name = name;

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

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

		if(window.addEventListener)
			window.addEventListener("keypress", promptwin.handle_esc_press, false);
		else if(window.attachEvent)                 
			window.attachEvent("onkeypress", promptwin.handle_esc_press);
	}	
}	

