
var popUpHandlerNew = {
	
	popUpWin:		null,
	x_pos:			null,
	y_pos:			null,
	direction: 		null,
	titleBackgroundColor: '#F4EAC4',
	
	create:	function () {
		var popUp = document.createElement("DIV");
		popUp.className = "popUp";
		document.body.appendChild(popUp);
		this.popUpWin = popUp; 
	},
	

	
	createHelpTip:	function (title, formWidth, formHeight) {

		if (this.popUpWin == null) {
			this.create();
		}
		var popUp = this.popUpWin;
		content = '';
		content += '<div class="popUp" style="position:absolute; z-index:1000; top:200px; border-top: 1px solid #D4D0C8; border-left: 1px solid #D4D0C8; border-right: 1px solid #333333; border-bottom: 1px solid #333333;" id="popUp_w">';
		content += '<table border="0" cellspacing="3" cellpadding="0" width="*" style="border-top: 1px solid #FFFFFF; border-left: 1px solid #FFFFFF; border-right: 1px solid #999999; border-bottom: 1px solid #999999; background-color: #DED09B;">';
		content += 		'<tr>';
		content += 			'<th style=" width: 100%; border: 1px solid #999999; background-color: ' + this.titleBackgroundColor + '">';
		content += 				'<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		content += 					'<tr>';
		content += 						'<td style="background-color: ' + this.titleBackgroundColor + '; padding: 3Px; vertical-align: middle; color: #000000; font-size: 18px; font-family : Comic Sans MS;"><nobr><b>' + title + '</b></nobr></td>';
		content += 						'<td style="width: 80%; background-color: ' + this.titleBackgroundColor + '; text-align: right;" valign="middle;"><a title="Закрыть окно" href="javascript:void(0)" onClick="popUpHandlerNew.popHide()" style="color: #000000; font-size: 18px; font-family : Comic Sans MS; text-decoration : none;" > [ x ] </a>&nbsp;</td>';
		content += 					'</tr>';
		content += 				'</table>';
		content +=			'</th>';
		content +=		'</tr>';
		content +=		'<tr>';
		content +=			'<td style="border: 1px solid #999999;">';
		content += 				'<div style="overflow:auto; margin:0px; padding: 0px; height: ' + formHeight + 'px; width: ' + formWidth + 'px; background-image: url(/images/bgrnd.gif);" id="inpopUp">';
		content += 				'</div>';
		content += 			'</td>';
		content += 		'</tr>';
		content += '</table>';
		content += '</div>';
		

		popUp.innerHTML = content;
		//popUp._boundAnchor = elem;
		//elem._popUpWin = popUp;  
//		alert(document.getElementById("whiteboxroundbox").innerHTML);
//		this.x_pos = 300;
//		this.y_pos = 300;
		//popUp.style.visibility = "hidden";
		return popUp;
	},
	
	
	removeHelpTip:	function (popUp) {
		popUp._boundAnchor = null;
		popUp.style.filter = "none";
		popUp.innerHTML = "";
		popUp.onmousedown = null;
		popUp.onmouseup = null;
		popUp.parentNode.removeChild(popUp);  
		//d.style.display = "none";
	},
		
	hideHelpTip:	function (elem) {
		var popUp = elem._popUpWin;
		/*	Mozilla (1.2+) starts a selection session when moved
			and this destroys the mouse events until reloaded
		d.style.top = -el.offsetHeight - 100 + "px";
		*/		
		
		popUp.style.visibility = "hidden";
		//d._boundAnchor = null;

		elem.onblur = null;
		elem._onblur = null;
		elem._helpTip = null;
		elem.onkeydown = null;
	
	},
	popHide: function () {
		// покажем селекты (вообще надо и ифреймы , но их тут нет)
		if (navigator.appName!="Netscape") {
			for (i = 0; i < document.all.tags("SELECT").length; ++i){
				document.all.tags("SELECT")[i].style.visibility = 'visible';
				}
			}
		var popUp = this.popUpWin;
		if (document.getElementById("inpopUp")) 
			document.getElementById("inpopUp").innerHTML="";
		if (popUp)	
			popUp.style.visibility = 'hidden';
		popUp = null;	
	},
	
	hideHelpTip:	function (elem) {
		var popUp = elem._popUpWin;
		popUp.style.visibility = "hidden";
		elem.onblur = null;
		elem._onblur = null;
		elem._helpTip = null;
		elem.onkeydown = null;
	
	},
	
	view: function (main_contex) { 
		// скроем селекты (вообще надо и ифреймы , но их тут нет)
		if (navigator.appName!="Netscape") {
			for (i = 0; i < document.all.tags("SELECT").length; ++i){
				document.all.tags("SELECT")[i].style.visibility = 'hidden';
				}
			}
		var popUp = this.popUpWin;
		
		document.getElementById("inpopUp").innerHTML=main_contex;  
			var direction = 0;
			if (document.getElementById("LeftBox")) direction = document.getElementById("LeftBox").offsetWidth;
			document.getElementById("popUp_w").style.top = document.body.clientHeight/2 - ( document.getElementById("popUp_w").offsetHeight )/2 + document.body.scrollTop;
			document.getElementById("popUp_w").style.left = (document.body.clientWidth -  document.getElementById("popUp_w").offsetWidth)/2 + direction/2;	
			
		popUp.style.visibility = 'visible'; 
		}
};
