
function parseDataCopyDiv(divName)
{
	var Div = document.getElementById(divName);
            // lets look for the <a> tags and modify the href and target
            var ATags = Div.getElementsByTagName('a');
            var oldHref = "";
            var server = window.location.host;
             
            for (var k = 0, l = ATags.length; k < l; k++) 
            {
                // for each <a> tag, lets get the href attribute and check if a 3rd party window should launch
                //oldHref = ATags[k].getAttribute("href")
		oldHref = ATags[k].href
                
                // First check for a PDF file link
               	var reg = new RegExp("[^\\s]+pdf$", "i");
				if (reg.test(oldHref))
				{
				    	// PDF link, so launch 3rd party frame
					var oldPDFText = ATags[k].innerHTML;
					ATags[k].href = 'http://www.pcma.org/x9905.xml?thirdparty=\"' + oldHref + '\"';  				
					ATags[k].onclick=new Function("launchWindow(this);return false;");
					ATags[k].innerHTML = oldPDFText;
	}
				else
				{
					// Check if it starts with http
					if(/^http/.test(oldHref))
					{
						// check if the http link is from the hosted server
						var regex = new RegExp("http[\\S\\s]*" + server);
						if(!(regex.test(oldHref))) 
						{
							// External server link, so launch 3rd party frame
						    var oldText = ATags[k].innerHTML;
						    ATags[k].href = 'http://www.pcma.org/x9905.xml?thirdparty=\"' + oldHref + '\"';
						    ATags[k].onclick = new Function("launchWindow(this);return false;");
						    ATags[k].innerHTML = oldText;
						}
					}
				}
            }            
  }

  function launchWindow(link) {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	var winFeatures = "location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,top=0,left=0,width=" + myWidth + ",height=" + myHeight;
	window.open(link, "_blank", winFeatures);
  }
