// Copyright Acro Media Inc. 1998-2006, www.acromediainc.com

function copyrightYear(){
	if(document.getElementById('insertYear')) document.getElementById('insertYear').innerHTML = new Date().getFullYear();
}


function externalLinks(){
	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";
	}
}

function siteOnLoad () {
	copyrightYear();
	externalLinks();
	//logout.check();
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({sSelector:"body h1", sFlashSrc:"/assets/images/bank.swf", sColor:"#FFFFFF", sLinkColor:"#FFFFFF", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"#colRightCredits h2", sFlashSrc:"/assets/images/bank.swf", sColor:"#FFFFFF", sLinkColor:"#FFFFFF", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sWmode:"transparent", sFlashVars:"textalign=center"}));
		sIFR.replaceElement(named({sSelector:"#colRight h2", sFlashSrc:"/assets/images/bank.swf", sColor:"#F3A60A", sLinkColor:"#FFFFFF", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sWmode:"transparent"}));
		sIFR.replaceElement(named({sSelector:"#colLeft h2", sFlashSrc:"/assets/images/bank.swf", sColor:"#F3A60A", sLinkColor:"#F3A60A", sBgColor:"#000000", sHoverColor:"#719FBE", nPaddingTop:0, nPaddingBottom:0, sWmode:"transparent"}));
	}
	liveChat.init();
	//SBDrawCart.init();
}

function addLoadEvent(func){
	var oldOnLoad = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	}
	else{
		window.onload = function(){
			oldOnLoad();
			func();
		}
	}
}


addLoadEvent(siteOnLoad);

var liveChat = {
	isSecure:function(){
		return location.href.match(/^https/i) == "https";
	},
	url:"",
	query:"",
	a:"bLiveChat",
	init:function(){
		if(document.getElementById(this.a)){
			a = document.getElementById(this.a);
			if(this.isSecure()){
				this.url = "https://chat.livechatnow.com/";
			}else{
				this.url = "http://chat.livechatnow.com/";
			}
			this.query = "&img=c&group=General&skin=&survey=&survey_ec=&survey_lm=&rule=&name=&email=&track=";
			this.open = this.url + "js/enter.php?cid=16188" + this.query + "&t=" + (new Date()).getTime();;
			a.href = this.open;
			a.onclick = liveChat.launch;
		}
	},
	launch:function(){
		window.open(liveChat.open, '_chat_16188', 'resizable=yes,menubar=no,scrollbars=yes, width=500, height=500');
		return false;
	}
}

var gMaps = {
	launch:function(obj){
		window.open(obj.href, 'tfxlocation', 'toolbar=yes, location=yes, resizable=yes,menubar=yes,scrollbars=yes, width=650, height=550');
	}
}

var logout = {
	linkId : "bSignIn",
	containerId: "siteContainer",
	check : function(){
		var nameEQ = "StoreBox_customerID=";
		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) {
				if(document.getElementById(this.containerId) && document.getElementById(this.linkId)){
					var cObj = document.getElementById(this.containerId);
					var newClass = "";
					if(cObj.className == ""){
						newClass = " ";
					}
					newClass += "loggedIn";
					cObj.className = newClass;
					document.getElementById(this.linkId).href = "/apps/StoreBox3.5/account.ami?action=logout";
				}
			}
		}
	}
}

//function videoPopUp(videopage) {
//	var popUpFeatures = "height=375,width=600,scrollTo,resizable=1,scrollbars=1,location=0"
//	newwindow=window.open(videopage, 'Popup', popUpFeatures);
//	return false;
//}

function videoPopUp(url) 
{
 var width  = 600;
 var height = 375;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}
