/* External Links */
// match all instances of 'external'
function externalLinks(){
if (!document.getElementsByTagName) return;
var externalRegExp = /(^|\s)external($|\s)/i;
var anchors = document.getElementsByTagName("a");
for (var i=0;i<anchors.length;i++){
var anchor = anchors[i];
if (anchor.getAttribute("href") 
&& (!anchor.getAttribute("target") || anchor.getAttribute("target") == "")
&& (externalRegExp.test(anchor.getAttribute("rev")))
)
anchor.target = "_blank";
}
return;
}
window.onload = function() {
externalLinks();
}
/* Bookmarking Links */
function bookmarkdelicious(){document.write("<a href='http://del.icio.us/post?url="+encodeURIComponent(document.location.href)+"&title="+encodeURIComponent(document.title)+"'>Del.icio.us</a>")}
function bookmarkdigg(){document.write("<a href='http://digg.com/submit?phase=2&url="+encodeURIComponent
(document.location.href)+"'>DiggThis</a>")}
function bookmarkreddit(){document.write("<a href='http://reddit.com/submit?url="+encodeURIComponent(document.location.href)+"&title="+encodeURIComponent(document.title)+"'>Reddit</a>")}
function bookmarkfacebook(){document.write("<a href='http://www.facebook.com/sharer.php?u="+encodeURIComponent
(document.location.href)+"'>Facebook</a>")}
function bookmarkstumbleupon(){document.write("<a href='http://www.stumbleupon.com/submit?url="+encodeURIComponent(document.location.href)+"&title="+encodeURIComponent(document.title)+"'>StumbleUpon</a>")}
/* Clear Default Form Text */
addEvent(window,'load',init,false)
function init(){
var formInputs=document.getElementsByTagName('input')
for(var i=0;i<formInputs.length;i++){
var theInput=formInputs[i]
if(theInput.type=='text'&&theInput.className.match(/\bcleardefault\b/)){
addEvent(theInput,'focus',clearDefaultText,false)
addEvent(theInput,'blur',replaceDefaultText,false)
if(theInput.value !=''){
theInput.defaultText=theInput.value}}}}
function clearDefaultText(e){
var target=window.event ? window.event.srcElement : e ? e.target : null
if(!target)return
if(target.value==target.defaultText){
target.value=''}}
function replaceDefaultText(e){
var target=window.event ? window.event.srcElement : e ? e.target : null
if(!target)return
if(target.value==''&&target.defaultText){
target.value=target.defaultText}}
/* Website Preview */
var webSnapr={
x:0,
y:0,
obj:{},
img:null,
lnk:null,
timer:null,
opacityTimer:null,
errorTimer:null,
hidden:true,
linkPool:{},
baseURI: "./",
imageCache: [],
init: function(){
var lnks=document.getElementsByTagName('a')
var i=lnks.length || 0
var cnt=0
while(i--){
if(lnks[i].className&&lnks[i].className.search(/websnapr/)!=-1){
webSnapr.addEvent(lnks[i],["focus","mouseover"],webSnapr.initThumb)
webSnapr.addEvent(lnks[i],["blur","mouseout"],webSnapr.hideThumb)
webSnapr.linkPool[lnks[i].href]=cnt++}}
if(cnt){
webSnapr.preloadImages()
webSnapr.obj=document.createElement('div')
webSnapr.ind=document.createElement('div')
webSnapr.ind.className="imageLoaded"
webSnapr.img=document.createElement('img')
webSnapr.img.alt="preview"
webSnapr.img.id="fdImage"
webSnapr.addEvent(webSnapr.img,["load"],webSnapr.imageLoaded)
webSnapr.addEvent(webSnapr.img,["error"],webSnapr.imageError)
webSnapr.obj.id="fdImageThumb"
webSnapr.obj.style.visibility="hidden"
webSnapr.obj.style.top="0"
webSnapr.obj.style.left="0"
webSnapr.addEvent(webSnapr.img,["mouseout"],webSnapr.hideThumb)
webSnapr.obj.appendChild(webSnapr.ind)
webSnapr.obj.appendChild(webSnapr.img)
webSnapr.addEvent(webSnapr.obj,["mouseout"],webSnapr.hideThumb)
document.getElementsByTagName('body')[0].appendChild(webSnapr.obj)}
},
preloadImages: function(){
var imgList=["lt.png","lb.png","rt.png","rb.png","error.gif","loading.gif"]
var imgObj=document.createElement('img')
for(var i=0,img;img=imgList[i];i++){
webSnapr.imageCache[i]=imgObj.cloneNode(false)
webSnapr.imageCache[i].src=webSnapr.baseURI+img}
},
imageLoaded: function(){
if(webSnapr.errorTimer)clearTimeout(webSnapr.errorTimer)
if(!webSnapr.hidden)webSnapr.img.style.visibility="visible"
webSnapr.ind.className="imageLoaded"
webSnapr.ind.style.visibility="hidden"
},
imageError: function(e){
if(webSnapr.errorTimer)clearTimeout(webSnapr.errorTimer)
webSnapr.ind.className="imageError"
webSnapr.errorTimer=window.setTimeout("webSnapr.hideThumb()",2000)
},
initThumb: function(e){
e=e || event
webSnapr.lnk=this
var positionClass="left"
var heightIndent
var indentX=0
var indentY=0
var trueBody=(document.compatMode&&document.compatMode!="BackCompat")? document.documentElement : document.body
if(String(e.type).toLowerCase().search(/mouseover/)!=-1){
if(document.captureEvents){
webSnapr.x=e.pageX
webSnapr.y=e.pageY
}else if(window.event.clientX){
webSnapr.x=window.event.clientX+trueBody.scrollLeft
webSnapr.y=window.event.clientY+trueBody.scrollTop}
indentX=10
heightIndent=parseInt(webSnapr.y-(webSnapr.obj.offsetHeight))+'px'
}else{
var obj=this
var curleft=curtop=0
if(obj.offsetParent){
curleft=obj.offsetLeft
curtop=obj.offsetTop
while(obj=obj.offsetParent){
curleft+=obj.offsetLeft
curtop+=obj.offsetTop}}
curtop+=this.offsetHeight
webSnapr.x=curleft
webSnapr.y=curtop
heightIndent=parseInt(webSnapr.y-(webSnapr.obj.offsetHeight)-this.offsetHeight)+'px'}
if(parseInt(trueBody.clientWidth+trueBody.scrollLeft)<parseInt(webSnapr.obj.offsetWidth+webSnapr.x)+indentX){
webSnapr.obj.style.left=parseInt(webSnapr.x-(webSnapr.obj.offsetWidth+indentX))+'px'
positionClass="right"
}else{
webSnapr.obj.style.left=(webSnapr.x+indentX)+'px'}
if(parseInt(trueBody.clientHeight+trueBody.scrollTop)<parseInt(webSnapr.obj.offsetHeight+webSnapr.y)+indentY){
webSnapr.obj.style.top=heightIndent
positionClass+="Top"
}else{
webSnapr.obj.style.top=(webSnapr.y+indentY)+'px'
positionClass+="Bottom"}
webSnapr.obj.className=positionClass
webSnapr.timer=window.setTimeout("webSnapr.showThumb()",500)
},
showThumb: function(e){
webSnapr.hidden=false
webSnapr.obj.style.visibility=webSnapr.ind.style.visibility='visible'
webSnapr.obj.style.opacity=webSnapr.ind.style.opacity='0'
webSnapr.img.style.visibility="hidden"
var addy=String(webSnapr.lnk.href)
webSnapr.errorTimer=window.setTimeout("webSnapr.imageError()",15000)
webSnapr.img.src='http://images.websnapr.com/?url='+encodeURIComponent(addy)+'&rndm='+parseInt(webSnapr.linkPool[webSnapr.lnk.href])
webSnapr.fade(10)
},
hideThumb: function(e){
e=e || window.event
if(e.type=="mouseout"){
var elem=e.relatedTarget || e.toElement
if(elem.id&&elem.id.search("fdImage")!=-1)return false}
webSnapr.hidden=true
if(webSnapr.timer)clearTimeout(webSnapr.timer)
if(webSnapr.errorTimer)clearTimeout(webSnapr.errorTimer)
if(webSnapr.opacityTimer)clearTimeout(webSnapr.opacityTimer)
webSnapr.obj.style.visibility='hidden'
webSnapr.ind.style.visibility='hidden'
webSnapr.img.style.visibility='hidden'
webSnapr.ind.className="imageLoaded"
},
fade: function(opac){
var passed=parseInt(opac)
var newOpac=parseInt(passed+10)
if(newOpac<90){
webSnapr.obj.style.opacity=webSnapr.ind.style.opacity='.'+newOpac
webSnapr.opacityTimer=window.setTimeout("webSnapr.fade('"+newOpac+"')",20)
}else{
webSnapr.obj.style.opacity=webSnapr.ind.style.opacity='1'}
},
addEvent: function(obj,types,fn){
var type
for(var i=0;i<types.length;i++){
type=types[i]
if(obj.attachEvent){
obj['e'+type+fn]=fn
obj[type+fn]=function(){obj['e'+type+fn](window.event);}
obj.attachEvent('on'+type,obj[type+fn])
}else obj.addEventListener(type,fn,false)}}}
webSnapr.addEvent(window,['load'],webSnapr.init)
/* Yetti Tabs */
function Yetii() {

	this.defaults = {
		
		id: null,
		active: 1,
		interval: null,
		wait: null,
		persist: true,
		tabclass: 'tabcontent',
		activeclass: 'selected',
		callback: null
	
	};
	
	for (var n in arguments[0]) { this.defaults[n]=arguments[0][n]; };	
	
	this.getTabs = function() {
        	
        var retnode = [];
        var elem = document.getElementById(this.defaults.id).getElementsByTagName('*');
		
		var regexp = new RegExp("(^|\\s)" + this.defaults.tabclass.replace(/\-/g, "\\-") + "(\\s|$)");
	
        for (var i = 0; i < elem.length; i++) {
        if (regexp.test(elem[i].className)) retnode.push(elem[i]);
        }
    
        return retnode;
    
    };
	
	this.links = document.getElementById(this.defaults.id + '-nav').getElementsByTagName('a');
	
	this.show = function(number){
        
        for (var i = 0; i < this.tabs.length; i++) {
        this.tabs[i].style.display = ((i+1)==number) ? 'block' : 'none';
        this.links[i].className = ((i+1)==number) ? this.defaults.activeclass : '';
		}
		
		this.defaults.active = number;
		if (this.defaults.callback) this.defaults.callback(number);
    
    };
	
	this.rotate = function(interval){
    
        this.show(this.defaults.active);
        this.defaults.active++;
    
        if(this.defaults.active > this.tabs.length) this.defaults.active = 1;
    
	
        var self = this;
		
		if (this.defaults.wait) clearTimeout(this.timer2);
		 
        this.timer1 = setTimeout(function(){self.rotate(interval);}, interval*1000);
    
    };
	
	this.next = function() {
		
		this.defaults.active++;
    	if(this.defaults.active > this.tabs.length) this.defaults.active = 1;
		this.show(this.defaults.active);
	
	};
	
	this.previous = function() {
		
		this.defaults.active--;
    	if(!this.defaults.active) this.defaults.active = this.tabs.length;
		this.show(this.defaults.active);
	
	};
	
	this.parseurl = function(tabinterfaceid){
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")); 
		return (result==null)? null : parseInt(RegExp.$1);
	};

	this.createCookie = function(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	};
	
	this.readCookie = function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	};


	
	this.tabs = this.getTabs();
	
	this.defaults.active = (this.parseurl(this.defaults.id)) ? this.parseurl(this.defaults.id) : this.defaults.active;
	if (this.defaults.persist && this.readCookie(this.defaults.id)) this.defaults.active = this.readCookie(this.defaults.id);  
	this.show(this.defaults.active);
	
	var self = this;
	for (var i = 0; i < this.links.length; i++) {
	this.links[i].customindex = i+1;
	this.links[i].onclick = function(){ 
		
		if (self.timer1) clearTimeout(self.timer1);
		if (self.timer2) clearTimeout(self.timer2); 
		
		self.show(this.customindex);
		if (self.defaults.persist) self.createCookie(self.defaults.id, this.customindex, 0);
		
		if (self.defaults.wait) self.timer2 = setTimeout(function(){self.rotate(self.defaults.interval);}, self.defaults.wait*1000);
		
		return false;
	};
    }
	
	if (this.defaults.interval) this.rotate(this.defaults.interval);
	
};
/* Random Content Display */
if(document.getElementById)
document.documentElement.className='jsclass'
var randomcontentdisplay={
divholders:new Object(),
masterclass: "randomcontent",
init:function(){
if(!document.getElementById)
return
var alldivs=document.getElementsByTagName("div")
var randomcontentsearch=new RegExp(this.masterclass+"\\s+(group\\d+)","i")
for(var i=0;i<alldivs.length;i++){
if(randomcontentsearch.test(alldivs[i].className)){
if(typeof this.divholders[RegExp.$1]=="undefined")
this.divholders[RegExp.$1]=new Array()
this.divholders[RegExp.$1].push(alldivs[i])}}
this.showone()
},
showone:function(){
for(group in this.divholders){
var chosenOne=Math.floor(Math.random()*this.divholders[group].length)
this.divholders[group][chosenOne].style.display="block"}}}