/* unobtrusive js for links */
var linkcount = 0;

onload = function() {
    // check to see if browser supports the getElementsByTagName method. if not exit the loop
    if (!document.getElementsByTagName) {
        return false;
    }
    // create an array of objects of each link in the document
    var links = document.getElementsByTagName("a");
    // loop trough each of these links
    for (var i=0;i < links.length;i++) {
        // loop each link named preventClicks and give them an generic number
        // see more for class function preventMoreClicks
        if(links[i].parentNode.id == "preventClicks") {
            links[i].parentNode.id = links[i].parentNode.id + linkcount;
            linkcount++;
        }
        // if the link has a class popup
        if (links[i].className.indexOf("popup") != -1) {
            // add an onclick event on the fly to pass the href attribute of the link to open a default Popup
            links[i].onclick = function() {
                openPopup(this.getAttribute("href"));
                return false;
            }
        }
        // if the link has a class external-popup
        if (links[i].className.indexOf("external-link") != -1) {
            // add an onclick event on the fly to pass the href attribute
            // open link in external window or tab
            links[i].onclick = function() {
                window.open(this.getAttribute("href"));
                return false;
            }
        }
        // if the link has a class preventMoreClicks
        if (links[i].className.indexOf("preventMoreClicks") != -1) {
            // add an onclick event on the fly to pass klick action
            // prevent user by clicking same link several times
            links[i].onclick = function() {
                // open function with 2 parameters
                preventClicks(this.parentNode.id,this.firstChild.data);
                // return true for linkaction but remove href for prevent clicking twice
                return true;
            }
        }
    }
    // end of link function
}

/*	new popup-function for unobtrusive js */
function openPopup (popupURL) {
	//window.open(popupURL,'popup');
	window.open(popupURL,'popup','width=550,height=500,scrollbars=no,menubar=no,resizable=yes,status=no,toolbar=no');
}
/* end */
