var gAutoPrint = true; 
/*************************************************************/
function ReturnKeyHit(btnID)
{
	
	if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))
	{
		document.getElementById(btnID).click();
		return false;
	}
	else
	{
		return true;
	}
}

/*****************************************************************/
function openWindowPopUpThenClose(url, center,nWidth,nHeight,nameOfWindow)
{
	var windowWidth=nWidth;
	var windowHeight=nHeight;
	var win="";
	if (center==true) 
	{
		var leftPosition = ((screen.width - windowWidth) / 2);
		var topPosition = ((screen.height - windowHeight) / 2);	
		win=window.open(url,nameOfWindow,'width='+windowWidth+',height='+windowHeight+',menubar=0,toolbar=no,scrollbars=yes,resizable=yes,top='+topPosition+',left='+leftPosition+'');
	}
	else
	{
		win=window.open(url,nameOfWindow,'width='+windowWidth+',height='+windowHeight+',menubar=0,toolbar=no,scrollbars=yes,resizable=yes');
	}
	win.focus();
}
/*****************************************************************/
function openWindowPopUp(url, center,nWidth,nHeight,nameOfWindow)
{
	//alert(url);
	//alert(location.href);
	var windowWidth=nWidth;
	var windowHeight=nHeight;
	var win="";
	if (center==true) 
	{
		var leftPosition = ((screen.width - windowWidth) / 2);
		var topPosition = ((screen.height - windowHeight) / 2);	
		win=window.open(url,nameOfWindow,'width='+windowWidth+',height='+windowHeight+',menubar=0,toolbar=no,scrollbars=yes,resizable=yes,top='+topPosition+',left='+leftPosition+'');
	}
	else
	{
		win=window.open(url,nameOfWindow,'width='+windowWidth+',height='+windowHeight+',menubar=0,toolbar=no,scrollbars=yes,resizable=yes');
	}
	win.focus();
}
/************************************************/
function openWindowForDocumentPopUp(url, center,bRefreshParent)
{
	//alert(url);
	//alert(location.href);
	var windowWidth=screen.width-100;
	var windowHeight=screen.height-200;
	var win="";
	if(bRefreshParent)
	{
		url=url+"&RefreshParent=true"
	}
	if (center==true) 
	{
		var leftPosition = ((screen.width - windowWidth) / 2);
		var topPosition = ((screen.height - windowHeight) / 2);	
		win=window.open(url,'documentPopUp','width='+windowWidth+',height='+windowHeight+',menubar=0,toolbar=no,scrollbars=yes,resizable=yes,top='+topPosition+',left='+leftPosition+'');
	}
	else
	{
		win=window.open(url,'documentPopUp','width='+windowWidth+',height='+windowHeight+',menubar=0,toolbar=no,scrollbars=yes,resizable=yes');
	}
	
	win.focus();
}
/***************************************************************/
function Trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
/***************************************************************/
function printSpecial() {
	if (document.getElementById != null) {
		var html = '<HTML>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		
		html += '\n</HEAD>\n<BODY>\n<center><img src=\'../images/logo.jpg\'></center><br><br>';
		
		var divs = window.document.getElementsByTagName("DIV");
	
		for (i = 0; i < divs.length; i++) {
			if (divs.item(i).id == "printReady") {
				html += divs[i].innerHTML;
			}
		}
			
		html += '\n</BODY>\n</HTML>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else {
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}



