//
// based on IEPrompt from http://www.hunlock.com/blogs/Working_around_IE7s_prompt_bug,_er_feature
//

var _dialogPromptID=null;
var _blackoutPromptID=null;

function IEprompt(innertxt, def, type, onOk,onCancel) {
	that=this;
	def = def || "";
	type = type || "text";

	this.wrapupPrompt = function (cancled) {
		var val = document.getElementById('iepromptfield').value;
		
		_dialogPromptID.style.display='none';
		_blackoutPromptID.style.display='none';
		document.getElementById('iepromptfield').value = '';
		
		if (cancled) {
			if (onCancel) onCancel();
		}
		else if (onOk) {
			onOk(val);
		}
	}

	if (_dialogPromptID==null) {
		var tbody = document.getElementsByTagName("body")[0];
		tnode = document.createElement('div');
		tnode.id='IEPromptBox';
		tbody.appendChild(tnode);
		_dialogPromptID=document.getElementById('IEPromptBox');
		tnode = document.createElement('div');
		tnode.id='promptBlackout';
		tbody.appendChild(tnode);
		_blackoutPromptID=document.getElementById('promptBlackout');
		_blackoutPromptID.style.opacity='.9';
		_blackoutPromptID.style.position='absolute';
		_blackoutPromptID.style.top='0px';
		_blackoutPromptID.style.left='0px';
		_blackoutPromptID.style.backgroundColor='#555555';
		_blackoutPromptID.style.filter='alpha(opacity=90)';
		_blackoutPromptID.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
		_blackoutPromptID.style.display='block';
		_blackoutPromptID.style.zIndex='50';
		_dialogPromptID.style.border='2px solid #E0612B';
		_dialogPromptID.style.backgroundColor='#F8F8E4';
		_dialogPromptID.style.position='absolute';
		_dialogPromptID.style.width='330px';
		_dialogPromptID.style.zIndex='100';
	}

	var tmp = '<div class="inputrequired">'+innertxt +'</div>';
	tmp += '<div class="innertext">';
	tmp += '<form action="" onsubmit="return false;">';
	if (type == "text")
		tmp += '<input id="iepromptfield" name="iepromptdata" type="text" class="promptfield" value="'+def+'">';
	else
		tmp += '<textarea id="iepromptfield" name="iepromptdata" class="promptfield">' + def + '</textarea>';
	tmp += '<br /><br />';
	tmp += '<input type="submit" onclick="that.wrapupPrompt(false); return false;" value="&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;">';
	tmp += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	tmp += '<input type="button" onclick="that.wrapupPrompt(true)" value="&nbsp;Cancel&nbsp;">';
	tmp += '</form></div>';
	
	_blackoutPromptID.style.height=(document.body.offsetHeight<screen.height) ? screen.height+'px' : document.body.offsetHeight+20+'px'; 
	_blackoutPromptID.style.width='100%';
	_blackoutPromptID.style.display='block';
	
	_dialogPromptID.innerHTML=tmp;
	_dialogPromptID.style.top=parseInt(document.documentElement.scrollTop+(screen.height/3))+'px';
	_dialogPromptID.style.left=parseInt((document.body.offsetWidth-315)/2)+'px';
	_dialogPromptID.style.display='block';
	
	document.getElementById('iepromptfield').focus();
}




