function getDomainName(){
  var h,p;
  h=location.host.split('.');
  p=h.length;
  return(h[p-2]);
}

function open_target_blank() {
	if (!document.getElementsByTagName){
		return; /*If the browser doesn't support DOM, do nothing*/
	}
	var anchors = document.getElementsByTagName("a");
	var forms = document.getElementsByTagName("FORM"); 
	/*Select all the 'a' tags, anchors*/
	for (var i=0; i<anchors.length; i++) {
		var links = anchors[i];
		if (links.getAttribute("href")&&(links.getAttribute("href").indexOf("http")!=-1&&links.getAttribute("href").indexOf(getDomainName())==-1)|links.getAttribute("href").indexOf("downloads")!=-1){ /*if it has an href and contains http but doesn't contain rockysoft or for downloads*/
			/*every anchor with 'href' attribute will get a new attribute, only those with 'href' attribute set because we don't want to mess with the section anchors, for example*/
			links.target = "_blank";
		}
	}
	/*Select all the 'form' tags*/
	for (var i=0; i<forms.length; i++) {
		var thisForm = forms[i];
		if (thisForm.getAttributeNode("action")){
			if(thisForm.getAttributeNode("action").value.indexOf("http")!=-1&&links.getAttribute("href").indexOf(getDomainName())==-1){ /*if it contains http but doesn't contain rockysoft*/
				/*every anchor with 'href' attribute will get a new attribute, only those with 'href' attribute set because we don't want to mess with the section forms, for example*/
				thisForm.target = "_blank";
			}
		}
	}
}
window.onload = open_target_blank;

// Replaces innerHTML
function setInnerHTML( id, str ){
	if(!document.getElementById) {return;} // Not Supported
	if(document.getElementById){
		document.getElementById(id).innerHTML = str;
	}
}
