


function rewriteLinks() {
     //create an array to store all the anchor elements in the page

     var anchors = document.getElementsByTagName("a");

     //loop through the array

     for (var x=0; x<anchors.length; x++) {

     //does this anchor element contain #openinnewwindow?

          if (anchors[x].outerHTML.indexOf('#openinnewwindow')>0) 
		{
			
			               
			//store the HTML for this anchor element
			
			                
			oldText = anchors[x].outerHTML;
			
			               
			//rewrite the URL to remove our test text and add a target instead
			
			               
			newText = oldText.replace(/#openinnewwindow/,'" target="_blank');
			
			               
			//write the HTML back to the browser
			
			               
			anchors[x].outerHTML = newText;

          }

     }
 }
