// 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();
	if(SBDrawCart) {SBDrawCart.init();}
	SBDrawMenu();
}

// Used for the balance Checker - Resizes the window
var newWin;
var popup = {
	newWin : null,
	open : function( pArgs ){return this.named( pArgs.url, pArgs.w, pArgs.h, pArgs.y, pArgs.x, pArgs.scroll, pArgs.resize, pArgs.name, pArgs.pos, pArgs.tool, pArgs.menu, pArgs.addy, pArgs.stat );},
	named : function(url, width, height, top, left, scroll, resize, name, position, tool, menu, addy, stat){
		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);
		(tool) ? tool = "yes" : tool = "no";
		(addy) ? addy = 1 : addy = 0;
		(stat) ? stat = 1 : stat = 0;
		(menu) ? menu = 1 : menu = 0;
		newWin = window.open(url,name,"status="+stat+ ",location="+addy+ ",toolbar="+tool+",menubar="+menu+",width="+width+",height="+height+",top="+top+",left="+left+",scrollbars="+scroll+",resizable="+resize);
		(position == "behind") ? setTimeout('newWin.blur();',100) : setTimeout('newWin.focus();',100);
	}
}


//XML Parser for NewsBox Imp

var xmlDoc;
var articles;
function loadXML() {
	// code for IE
	if (window.ActiveXObject) {
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.load("testimonials.xml");
		getmessage();
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument) {
		xmlDoc=document.implementation.createDocument("","",null);
		xmlDoc.load("testimonials.xml");
		xmlDoc.onload=getmessage;
	}
	else {
		alert('Your browser cannot handle this script');
	}
}

function getmessage() {
	articles = xmlDoc.getElementsByTagName("body").length;
	var articleText = "";
	var i;
	for (i=0; i < articles; i++) {
		articleText += "<p><strong>" + xmlDoc.getElementsByTagName("name")[i].childNodes[0].nodeValue + "</strong><br/>";
		articleText += "<em>" + xmlDoc.getElementsByTagName("body")[i].childNodes[0].nodeValue + "</em></p>";
	}
	document.getElementById("testimonialContainer").innerHTML = articleText;
}