// Used for pages with strict doctypes (i.e. no target="_blank")
// Automagically adds them back in to links with rel="external"

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { anchor.target = "_blank";  }
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popgall") {
      var subscribeURL = anchor.getAttribute('href');
      anchor.onkeypress = function(){window.open(this.href, 'GallWindow', 'toolbar=no,menubar=no,height=600,width=800,location=no,scrollbars=yes,resizable=yes,status=no,left=30,top=30'); return false; }
      anchor.onclick = function(){window.open(this.href, 'GallWindow', 'toolbar=no,menubar=no,height=600,width=800,location=no,scrollbars=yes,resizable=yes,status=no,left=30,top=30'); return false; }
      }
  }
}
window.onload = externalLinks;

var ie = document.all; // IE Test
// Gets around the problem of having multiple onload handlers ----------------------------------
// http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
// http://www.quirksmode.org/js/events_advanced.html

function addEvent(obj, evType, fn) {

    // W3C type of event registration model
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    // MS event registration model
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    // Bad browsers that cant do either
    } else {
        return false;
    }
}


// DISPLAY OR HIDE CERTAIN ELEMENTS BY ID
function showItem(id) {
	if (!document.getElementById) return;
	$obj = document.getElementById(id);
	if($obj) { $obj.className = (($obj.className == "shown") ? "hidden" : "shown"); }
}

function showImg(id,img,orientation,caption) {
	if(!document.getElementById) return;
	var image = document.getElementById(id);
	image.src = (image.src != img) ? img : image.src;
	image.className = (orientation == 1) ? 'portrait' : 'landscape' ;
	image.alt = caption;
}

function junkText(str,n) {
	var os=[];
	for (var i=0; i<n; i++) {
		os.push(str);
	}
	document.write(os.join(' '));
}

// EMAIL OBLITARATOR //
var blit={
	dc:function(i){var o="",c1,c2,c3,e1,e2,e3,e4,j=0,k="gNAkZGdEiV3jM7QXORxrfJKvzps";i=i.replace(/[^A-Za-z0-9+\/=]/g,"");k+="1ucwTyU092H4l658I+tDmPYBonbLqSaWehCF/=";while(j<i.length){e1=k.indexOf(i.charAt(j++));e2=k.indexOf(i.charAt(j++));e3=k.indexOf(i.charAt(j++));e4=k.indexOf(i.charAt(j++));c1=(e1<<2)|(e2>>4);c2=((e2&15)<<4)|(e3>>2);c3=((e3&3)<<6)|e4;o=o+String.fromCharCode(c1);if(e3!=64){o=o+String.fromCharCode(c2);}if(e4!=64){o=o+String.fromCharCode(c3);}}return o;
	}
};
