// JavaScript library: by Patrick Heusser

// Tests if a real client browser is our http client. This is done by
// downloading a dummy resource from the server.
//
// Assuming that automated search engines do not process complex
// JavaScript, only a "real" browser will download a certain resource
// that we link here. This gives us a hit in the log, where we can
// figure out how many real browser visited the page.
//
// Additionally we add the requesting page as a dummy param (page) to our
// dummy resource.
function isRealBrowser() {

   // prepare resource
   var DUMMY_RESOURCE = "../resources/js/dummy.gif";
   var currentPage = window.location.pathname;
   // encode the query part of request
   var targetResource = DUMMY_RESOURCE + "?requested_browser_page=" + encodeURIComponent(currentPage);

   // insert the resource with DHTML into document
   // <img src="dummy.jpg" width="50" height="30" alt="dummy" >
   var elemBody = document.getElementsByTagName("body")[0];

   var elemImg = document.createElement("img");
   addAttribute(elemImg, "src", targetResource);
   addAttribute(elemImg, "width", "1");
   addAttribute(elemImg, "height", "1");
   addAttribute(elemImg, "alt", "d");

   elemBody.appendChild(elemImg);
   //alert('done. loaeded resource '+targetResource);

}

// helper: create a new attribute with a certain value and add it to the element
function addAttribute(element, attName, attValue) {
   var att = document.createAttribute(attName);
   att.nodeValue = attValue;
   element.setAttributeNode(att);
}


function openNewWindow(target) {
	window.open(target);
	return false; // stop link processing
}