// JavaScript Document
function doNewWindowLinks() {
  if (document.getElementsByTagName) {
    var links = document.getElementsByTagName("a");
    for (var i=0; i < links.length; i++) {
      if (links[i].className.match("newwin") || links[i].className.match("newWin")) {
        links[i].onclick = function() {
          window.open(this.getAttribute("href"));
          return false;
        };
      }
    }
	//Added check for paypal forms (buttons)
	var forms = document.getElementsByTagName("form");
	for (var j=0; j < forms.length; j++) {
		if (forms[j].className.match("newwin") || forms[j].className.match("newWin")) {
			forms[j].target = "_blank";
		}
	}
  }
}



//new_class - The new style to apply to links pointing to the current page location.
//target_id - The element to be checked for links to the current page location.
//exception_class - (OPTIONAL) Any link with this class wil be ignored by the function.
function doCurrentPageLinks(new_class, target_id, exception_class) {
	var i, ob, tA, h = document.location.href;
	if (document.getElementById) {
		ob = (target_id) ? document.getElementById(target_id) : document;
		if (ob) {
			tA = ob.getElementsByTagName('A');
			for (i=0; i<tA.length; i++) {
				if (tA[i].href == h) {
					if (tA[i].className.match(exception_class)) {
						return;
					} else {
						tA[i].className = new_class;
					}
				}
			}
		}
	}
}
function doCaptchaLinks() {
	//alert("doCaptchaLinks executed!");
	var i, ob, cLinks;
	if (document.getElementById) {
		//alert("so far so good!");
		ob = ("captcha") ? document.getElementById("captcha") : document;
		if (ob) {
			//alert(ob);
			cLinks = ob.getElementsByTagName("a");
			for (i=0; i < cLinks.length; i++) {
				if (cLinks[i].className.match("refreshCaptcha") || cLinks[i].className.match("refresh")) {
					//alert("matched " + (i+1));
					cLinks[i].onclick = function() {
						NewVerifyImage();
						return false;
					}
				}
			}
		}
	}
}

window.onload=function(){
	P7_ExpMenu();
	doNewWindowLinks();
	doCurrentPageLinks('current','subMenu','null');
	doCaptchaLinks();
}