/*************************************
 * Adam Spanier                      *
 * http://www.myscaryresume .com     *
 * adam@thecrazyspaniers.com         *
 *************************************/
function preloadImages() {
var d=document; if(d.images){ if(!d.p) d.p=new Array();
var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImage() {
var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function swapImgRestore() {
var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) {
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function validateForm() {
var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='--> '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='--> '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='--> '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '--> '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.returnValue = (errors == '');
}

function bookmarksite(title,url){
if (window.sidebar)
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)
	window.external.AddFavorite(url, title);
}

var win = null;
function popupContent(mypage,myname,w,h,scroll) {
leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
topPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+topPosition+',left='+leftPosition+',scrollbars='+scroll+''
win = window.open(mypage,myname,settings)
}

var clicked = new Array();
function doSection(divid) {
    if(clicked[0] == null) {
        Effect.Appear(divid, {duration: 0.3});
        clicked[0] = divid;
    } 
    else if(clicked[0] == divid) {
        clicked[0] = null;
        //ThisAnswer.style.display = 'none';
        Effect.Fade(divid, {duration: 0.1});
    } else {
        //var OldAnswer = document.getElementById(clicked[0]);
        //OldAnswer.style.display = 'none';
        Effect.Fade(clicked[0], {duration: 0.1});
        //ThisAnswer.style.display = 'block';
        Effect.Appear(divid, {duration: 0.3});
        clicked[0] = divid;
    }
}

var sec2 = new Array();
function doSection2(divid) {
    if(sec2[divid] == 1) {
        Effect.SlideUp(divid); // closing
        sec2[divid] = 2;
    } else {
        Effect.SlideDown(divid); // oppening
        sec2[divid] = 1;
    }
}
function closeSection() {
    if(clicked[0] == null) {
        return false;
    } else {
        var ThisAnswer = document.getElementById(clicked[0]);
        //ThisAnswer.style.display = 'none';
        Effect.Fade(clicked[0]);
    }
}

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";
 }
}
window.onload = externalLinks;

var ScrollWin = {
	w3c : document.getElementById,
	iex : document.all,
	scrollLoop : false, 
	scrollInterval : null, // setInterval id
	currentBlock : null,   // object reference
	getWindowHeight : function(){
		if(this.iex) return (document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight;
		else return window.innerHeight;
	},
	getScrollLeft : function(){
		if(this.iex) return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		else return window.pageXOffset;
	},
	getScrollTop : function(){
		if(this.iex) return (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		else return window.pageYOffset;
	},
	getElementYpos : function(el){
		var y = 0;
		while(el.offsetParent){
			y += el.offsetTop
			el = el.offsetParent;
		}
		return y;
	},
	scroll : function(name){
		if(!this.w3c){
			location.href = "#"+name;
			return;
		}
		if(this.scrollLoop){
			clearInterval(this.scrollInterval);
			this.scrollLoop = false;
			this.scrollInterval = null;
		}
		if(this.currentBlock != null) this.currentBlock.className = this.offClassName;
		this.currentBlock = document.getElementById(name);
		this.currentBlock.className = this.onClassName;
		var doc = document.getElementById(this.containerName);
		var documentHeight = this.getElementYpos(doc) + doc.offsetHeight;
		var windowHeight = this.getWindowHeight();
		var ypos = this.getElementYpos(this.currentBlock);
		if(ypos > documentHeight - windowHeight) ypos = documentHeight - windowHeight;
		this.scrollTo(0,ypos);
	},
	scrollTo : function(x,y){
		if(this.scrollLoop){
			var left = this.getScrollLeft();
			var top = this.getScrollTop();
			if(Math.abs(left-x) <= 1 && Math.abs(top-y) <= 1){
				window.scrollTo(x,y);
				clearInterval(this.scrollInterval);
				this.scrollLoop = false;
				this.scrollInterval = null;
			}else{
				window.scrollTo(left+(x-left)/2, top+(y-top)/2);
			}
		}else{
			this.scrollInterval = setInterval("ScrollWin.scrollTo("+x+","+y+")",50);
			this.scrollLoop = true;
		}
	}
};

ScrollWin.containerName = "container"; 
ScrollWin.anchorName    = "anchor";    
ScrollWin.blockName     = "home";     
ScrollWin.onClassName   = "active";   
ScrollWin.offClassName  = "visited";  
