function closeMe()
{
	if (window.opener) {
		window.opener.focus();
	}
	
	window.close();
}

function QueryString(page) {
	var args = new Object();
	var query = '';
	
	//page can be one of:
	//	a reference to a page object
	//	a complete URL (page.html?alice=bob) or
	//	a standalone querystring
	if (!page) {
		//no page passed in, get querystring for the current page
		query = location.search.substring(1);	//get the querystring (minus leading "?")
	} else {
		//get querystring for page
		if ('string' == typeof page) {
			//url or querystring for target page passed in
			//grab querystring from the end (sans "?") - 
			//	this will get everything if there is no "?",
			query = page.substring(page.indexOf('?') + 1)
		} else {
			//page reference
			if (page.location) {
				//make sure it has a location property
				query = page.location.search.substring(1);	//again, drop the leading "?"
			}
		}
	}
	var pairs = query.split('&');

	if (0 < query.length) {
		for (var i = 0; i < pairs.length; i++) {
			var pair = pairs[i].split('=');
			args[unescape(pair[0])] = unescape(pair[1]);
		}
		return args;
	} else {
		return false;
	}
}//QueryString()

function openWindow() {
	//arguments: url, name, features, replace
	var win, winUrl, winName, winFeat, winReplace;
	var winWidth, winHeight, winX, winY;
	var arrFeat, feat;
	/**
	features (arguments[2]):
		width, height (document area - IE)
		innerWidth, innerHeight (document area - NS4)
		outerWidth, outerHeight (window size - NS4)
		top, left (IE)
		screenX, screenY (NS4)
		location, menubar, resizable, scrollbars, status, toolbar (boolean)
	*/
	if (0 < arguments.length) {
		//window.open properties
		winUrl = arguments[0];
		winName = (arguments[1] ? arguments[1] : 'popwin');

		//default popup features
		if ('auth' == winName || 'search' == winName || 'svcs' == winName) {
			if (window.innerWidth) {
				winFeat = 'innerWidth=400,innerHeight=410,resizable,scrollbars,status';
			} else {
				winFeat = 'width=400,height=410,resizable,scrollbars,status';
			}
		} else {
			winFeat = 'resizable,scrollbars,status,toolbar';
			if (window.innerWidth) {
				winFeat += ',innerWidth=600,innerHeight=450';
			} else {
				winFeat += ',width=600,height=450';
			}
		}

		if (arguments[2]) {
			arrFeat = arguments[2].split(',');
			for (var i = 0; i < arrFeat.length; i++) {
				if (-1 < arrFeat[i].indexOf('=')) {
					//if there's an '=', then it's not just a boolean (i.e. 'scrollbars')
					feat = arrFeat[i].split('=');
					
					//sift through the features pulling out the items that are
					//cross-browser problematic
					switch (feat[0]) {
						case 'width':
						case 'innerWidth':
						case 'outerWidth':	//not the same as 'innerWidth', but we don't care
							winWidth = feat[1];	//grab the width
							if (arrFeat.splice()) {
								arrFeat.splice(i, 1);
								i--;
							}
							break;
						case 'height':
						case 'innerHeight':
						case 'outerHeight':	//not the same as 'innerHeight', but we don't care
							winHeight = feat[1];
							if (arrFeat.splice()) {
								arrFeat.splice(i, 1);
								i--;
							}
							break;
						case 'left':
						case 'screenX':
							winX = feat[1];
							if (arrFeat.splice()) {
								arrFeat.splice(i, 1);
								i--;
							}
							break;
						case 'top':
						case 'screenY':
							winY = feat[1];
							if (arrFeat.splice()) {
								arrFeat.splice(i, 1);
								i--;
							}
							break;
						default:
							break;
					}
				}
			}
			winFeat = arrFeat.join(',');
		}
		winReplace = (arguments[3] ? arguments[3] : false);

		//if (-1 == winFeat.indexOf('noreload')) {
			win = window.open(winUrl, winName, winFeat, winReplace);
		//} else {
		//	win = window[winName];
		//}
		
		//resize and move, if necessary
		if (winWidth && winHeight) {
			win.resizeTo(winWidth, winHeight);
		}
		if (winX && winY) {
			win.moveBy(winX, winY);
		}
		
		//make sure the window comes to the front
		win.focus();
	}
}

function PopVal()
{
	//mickey, 2003-06-23
	//Appends information to a form element based upon the current window's
	//querystring.
	//arguments[0] = text (either for text(area) or for the text portion of an
	//option.
	//arguments[1] (optional) = value for an option
	
	//get this page's querystring
	var qs = QueryString();
	
	//if this window has no parent, then we have nothing to do
	if (!window.opener) 
	{
		return;
	}
	
	//paranoia
	if (!arguments) 
	{
		arguments = this.arguments;
	}
	
	//get the text to be sent
	if (0 == arguments.length) 
	{
		return;
	} 
	else 
	{
		var txt = arguments[0];
	}
	
	//get the form name, item name
	var frm = qs['frm'];
	var itm = qs['itm'];

	//set textbox.value to text
	//get an object reference to the concerned form element
	if (!window.opener.document.forms[frm][itm]) 
	{
		alert('Error: cannot find "' + frm.toString() + '.' + itm.toString() + '"');
		return;
	} 
	else 
	{
		window.opener.document.forms[frm][itm].value = txt;
	}
	
	if (window.opener) 
	{
		window.opener.focus();
		
		if (!(frm.toString() == 'BriefcaseForm'))
		{
			window.opener.__doPostBack('btnSecret','click');
		}
		
		/*if (!((frm.toString() == 'BriefcaseForm') || (frm.toString() == 'PromoBoxForm')))
		{
			window.opener.__doPostBack('btnSecret','click');
		}*/
	}

	window.close();
	
}

function CloseWindow()
{
	closeMe()
}

function articlePopImg(fn,te,cm,wd,ht,siteName,contentID){
	var newTitle = convertTitle(te);

	var screenWidth=screen.availWidth;	
	var screenHeight=screen.availHeight;
	var requiredWidth=parseInt(wd)+53;	
	var requiredHeight=parseInt(ht)+140;
	var actualWidth=requiredWidth;
	var actualHeight=requiredHeight;
	var scrollbars="no";
  
	if (requiredHeight > screenHeight) {
	actualHeight = screenHeight;
	scrollbars="yes";
	}

	if (requiredWidth > screenWidth) {
	actualWidth = screenWidth;
	scrollbars="yes";
	}
	
	popwin=window.open("","popwin","toolbar=no,location=no,status=no,menubar=no,scrollbars="+scrollbars+",resizable=yes,width=1,height=1");
	popwin.document.open("text/html");

	popwin.document.write("<html>");
	popwin.document.write("<head>");
	popwin.document.write("<title>" + newTitle + "</title>");
	popwin.document.write("<style type='text/css'>");
	popwin.document.write("<!--");
	popwin.document.write(".buttonTextCancel{color:#0099cc;font:12px Arial,Helvetica;font-weight:bold;text-decoration:none}");
	popwin.document.write(".popup-header{font-size:12px;font-weight:bold;font-family:arial,helvetica}");
	popwin.document.write(".popup-caption{color:#666666;font-size:10px;font-family:arial,helvetica;}");
	popwin.document.write("-->");
	popwin.document.write("</style>");
	popwin.document.write("</head>");
	popwin.document.write("<body onLoad='javascript:moveTo(0,0);resizeTo("+actualWidth+","+actualHeight+");window.focus();' bgcolor='ffffff'>");
	popwin.document.write("<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'>");
	popwin.document.write("	<tr>");
	popwin.document.write("		<td valign='top'>");
	popwin.document.write("			<table cellpadding='0' cellspacing='0' border='0' width='100%'>");
	popwin.document.write("			<tr>");
	popwin.document.write("				<td><span class='popup-header'>"+newTitle+"</span></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			<tr>");
	popwin.document.write("				<td width='100' colspan='2' bgcolor='#0099cc'><img src='/"+siteName+"/sitewide/images/pix.gif' width='1' height='1' border='0'></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			</table>");

	popwin.document.write("			<img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='12' border='0'><br>");
	popwin.document.write("			<img src="+fn+" border='0' width="+wd+" height="+ht+" vspace='3' name='main'><br>");
	popwin.document.write("			<span class='popup-caption'>"+cm+"</span>");
	popwin.document.write("			<table width='100%' cellspacing='0' cellpadding='0' border='0'>");
	popwin.document.write("			<tr>");
	popwin.document.write("			<td><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='10' alt='' border='0'></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			<tr>");
	popwin.document.write("				<td valign='top' rowspan='2'><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='4' alt='' border='0'></td>");
	popwin.document.write("				<td width='9' rowspan='5'><img src='"+siteName+"/sitewide/images/but_convex_left_white.gif' width='9' height='21' alt='' border='0'></td>");
	popwin.document.write("				<td bgcolor='#0099cc'><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='1' alt='' border='0'></td>");
	popwin.document.write("				<td width='9' rowspan='5'><img src='"+siteName+"/sitewide/images/but_convex_right_white.gif' width='9' height='21' alt='' border='0'></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			<tr>");
	popwin.document.write("			<td><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='3' alt='' border='0'></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			<tr>");
	popwin.document.write("			<td width='100%' bgcolor='#0099cc'><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='1' alt='' border='0'></td>");
	popwin.document.write("				<td align='center' nowrap rowspan='2'><a href='javascript:void' onClick='window.close();'  class='buttonTextCancel' >&nbsp; &nbsp; Close Window &nbsp; &nbsp;</a></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			<tr>");
	popwin.document.write("				<td><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='15' alt='' border='0'></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			<tr>");
	popwin.document.write("				<td><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='1' alt='' border='0'></td>");
	popwin.document.write("				<td bgcolor='#0099cc'><img src='"+siteName+"/sitewide/images/pix.gif' width='1' height='1' alt='' border='0'></td>");
	popwin.document.write("			</tr>");
	popwin.document.write("			</table></td>");
	popwin.document.write("	</tr>");
	popwin.document.write("</table>");
	popwin.document.write("</body>");
	popwin.document.write("</html>"); 

	popwin.document.close();
	popwin.opener.name="hivewin";
}

function convertTitle(entry) {
	if (entry.indexOf("~") != -1) {
	while (entry.indexOf("~") != -1) {
	var tempTitle = ((entry.substring(0, entry.indexOf("~")))+"'"+(entry.substring(entry.indexOf("~") + 1, entry.length)));
	entry = tempTitle;
	}
	}
	else var tempTitle = entry;
	return tempTitle;
}	
