var gAutoPrint = true; 
var rerel = new RegExp('<link(?:.|\\s)*?>','i');
var restyle = new RegExp('<style(?:.|\\s)*?</style>','i');

function SaveFunction()
{  
    var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
    disp_setting+="scrollbars=yes,width=700, height=600, left=100, top=25"; 
		  
    var html = "<HTML>\n<HEAD>\n";

   if(!printReadyElemId)
   {
	alert("Could not find the printReady section in the HTML");
	return;
   }

	
    if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';
				
		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
			{
				var h = headTags[0].innerHTML;

				while(h.match(rerel)) {
					var m = h.match(rerel);
					html += m;
					h = h.replace(m,'');
				}
				
				while(h.match(restyle)) {
					var m = h.match(restyle);
					html += m;
					h = h.replace(m,'');
				}

			}
		}

		html += "<style>.pagetools { display:none; }</style>";
	
    		html += '\n</HEAD>\n<BODY textsize=1>\n';
		html += '<div style=\"font-size:2pt;width:650px;word-wrap:break-word;\">';
			

		var printReadyElem = document.getElementById(printReadyElemId);
		if (printReadyElem != null) {
			var content = printReadyElem.innerHTML;
			content = content.replace(/width="100%"/gi,'');
			html += content;
		}
		else {
			alert("Could not find the printReady section in the HTML");
			return;
		} 
				
		html += '</div>';
		html += '\n</BODY>\n</HTML>';

		var win = window.open("","printhtml",disp_setting);
		var doc = win.document;
		doc.open("text/html", "replace");
		doc.write(html);
		doc.close();
		win.focus();
			
				
		if (gAutoPrint) {  
			win.print();
		} else	{
			alert("Sorry, the print ready feature is only available in modern browsers.");
		}
	}
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
function InitPage()
{
	if(document.getElementById('xbreadcrumb') && document.getElementById('xbreadcrumbbar'))
	{
		var text = document.getElementById('xbreadcrumb').innerHTML;
		if(trim(text).length <= 0)
	                 document.getElementById('xbreadcrumbbar').style.display='none';
	}


		var iframe1 = document.getElementById('MSOPageViewerWebPart_WebPartWPQ6');
		if(iframe1)
		{
			iframe1.scrolling='no';
			iframe1.style.height = '800px'
		}
}

function FixAnchorTags()
{
	 ExecuteOrDelayUntilScriptLoaded(JumpToAnchor, "sp.ribbon.js" );
}
function JumpToAnchor()
{
	window.location.hash = window.location.hash;
}

if (window.attachEvent) {

window.attachEvent("onload", InitPage);
window.attachEvent("onload", FixAnchorTags);

} else {

window.addEventListener("DOMContentLoaded", InitPage, false);
window.addEventListener("DOMContentLoaded", FixAnchorTags, false);

}



