// Copyright Acro Media Inc. 1998-2006, www.acromediainc.com

var copyrightYear = {
	init: function(){
		if(document.getElementById('insertYear')) document.getElementById('insertYear').innerHTML = new Date().getFullYear();
	}
}

var externalLinks = {
	init: function(){
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") anchors[i].target = "_blank";
		}
	}
}


//Checks to see if safari is on, boolean
var detect = navigator.userAgent.toLowerCase();
var safStatus,thestring;
function checkSafari(){	
	if (checkIt('safari')) safStatus = true;
	else safStatus = false;
	function checkIt(string){
		place = detect.indexOf(string) + 1;
		return place;
	}
}

window.onload = function (){
	checkSafari();
	copyrightYear.init();
	externalLinks.init();
}

var photo = {
	lis : "", current : "", currentNum : 0, effectArray : [], initStat : false,
	init : function(){
		this.lis = $('photoNav').getElementsByTagName('li');
		for(var i = 0; i < this.lis.length; i++){
			this.effectArray[i] = new fx.Width(this.lis[i]);
			if(i >= 3) this.effectArray[i].hide();
		}
		this.initStat = true;
	},
	toggle : function(direction){
		if(!this.initStat) this.init();
		this.currentNum += direction;
		if(this.currentNum < 0) {this.currentNum = 0;return;}
		if(this.currentNum > this.lis.length - 3){this.currentNum = this.lis.length - 3;return;}
		if(direction < 0){this.effectArray[this.currentNum].toggle();this.effectArray[this.currentNum + 3].toggle();} 
		else {this.effectArray[this.currentNum - 1].toggle();this.effectArray[this.currentNum + 2].toggle();}
	},
	change : function(pNum){
		if(!this.initStat) this.init();
		if(this.current == "") this.current = document.getElementById('photo1');
		var obj = document.getElementById('photo'+pNum);
		obj.style.display = "block";
		if(this.current != obj) this.current.style.display = "none";
		this.current = obj;
	}
}

function contactForm(){
	($('contactForm').style.display = "block")? $('contactForm').style.display = "none":$('contactForm').style.display = "block";
}


var el = {
	currentV : "",
	change : function(targetObj){
		var obj = $(targetObj);
		if(obj == this.currentV){
			obj.style.display = "none";
			this.currentV = null;
		} else {
			obj.style.display = "block";
			this.currentV = obj;
		}
	}
}

var toggleExpand = {
	linkClass: ["tLink", "tLink_opened"],
	contClass:"tContainer", showClass:"showToggle",current : null, current_a : null,
	containers: new Array(),
	init: function (){
		var anchors  = document.getElementsByTagName('span');
		var divs = document.getElementsByTagName('div');
		for(var i = 0; i < divs.length; i++){if(Element.hasClassName(divs[i], this.contClass)) this.containers.push(divs[i]);if(Element.hasClassName(divs[i], this.showClass)) this.current = divs[i];}
		var aCounter = 0;
		for(var a = 0; a < anchors.length; a++){
			if(Element.hasClassName(anchors[a], this.linkClass[0]) || Element.hasClassName(anchors[a], this.linkClass[1])) {
				if(anchors[a].className == this.linkClass[1]) this.current_a = anchors[a];
				anchors[a].onclick = this.click;
				anchors[a].num = aCounter;aCounter++;
			}
		}
	},
	click: function(){
		var obj = toggleExpand.containers[this.num];
		//alert(toggleExpand.contClass);
		if (toggleExpand.current == obj) {return;}
		var sClass = toggleExpand.showClass;
		if (toggleExpand.current != null) {
			Element.removeClassName(toggleExpand.current, sClass);
			toggleExpand.current_a.className = toggleExpand.linkClass[0];
		}
		if (!Element.hasClassName(obj, sClass))
		{Element.addClassName(obj, sClass);this.className = toggleExpand.linkClass[1];}
		else {Element.removeClassName(obj, sClass);this.className = toggleExpand.linkClass[0];}
		toggleExpand.current = obj;
		toggleExpand.current_a = this;
	}
}

var newWin;

var popup = {
	open : function( pArgs ){return this.named( pArgs.url, pArgs.w, pArgs.h, pArgs.y, pArgs.x, pArgs.scroll, pArgs.resize, pArgs.name, pArgs.pos );},
	named : function(url, width, height, top, left, scroll, resize, name, position){
		if(!scroll) scroll = "no";
		if(!resize) resize = "no";
		if(!name) name = "popup";
		if(!width || !height){
			if(!scroll)	scroll = "yes";
			if(!resize) resize = "yes";
		}
		if(!width) width = screen.availWidth;
		if(!height) height = screen.availHeight;
		if(!top || top == "center") top = (screen.availHeight / 2 - height / 2);
		if(!left || left == "center") left = (screen.availWidth / 2 - width / 2);
		newWin = window.open(url,name,"toolbar=no,menubar=0,width="+width+",height="+height+",top="+top+",left="+left+",scrollbars="+scroll+",resizable="+resize);
		(position == "behind") ? setTimeout('newWin.blur();',100) : setTimeout('newWin.focus();',100);
	}
}

function pageLoader(){
	toggleExpand.init();
	setVisible('section1');
}


var field = {
	show : function(target_param){
		document.getElementById("field_"+target_param).style.display = "block";
	},
	hide : function(target_param){
		document.getElementById("field_"+target_param).style.display = "none";
	}
}


// ToggleCode Simpler Version

var currentVisible = "section1";

function setVisible(section) {
	if(currentVisible){
		document.getElementById(currentVisible).style.display="none";
	}
	document.getElementById(section).style.display="block";
	currentVisible = section;
}