function IsNumeric(sText)
{
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	
	for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}

function changeCalcRFlexRate()
{
	var PLAN_base = 9.95;
	var DS_base = 0.10;
	var BW_base = 0.003;
	var DS_selected = document.rflexrate.diskspace.value;
	var BW_selected = document.rflexrate.bandwidth.value;

	var DS_amount = DS_selected * DS_base;
	var BW_amount = BW_selected * BW_base;

	if (!IsNumeric(DS_amount))
		DS_amount = 0;

	if (!IsNumeric(BW_amount))
		BW_amount = 0;

//	alert ("DS_amount" + DS_amount);


	document.getElementById('diskspace_amount').childNodes[0].nodeValue = "$" + DS_amount.toFixed(2); 
	document.getElementById('bandwidth_amount').childNodes[0].nodeValue = "$" + BW_amount.toFixed(2); 
	var Additional = 0;
	var Total = DS_amount + BW_amount;
	if (Total>PLAN_base)
	{
		Additional = (Total - PLAN_base);
		Total = PLAN_base + Additional;
	}
	else
		Total = PLAN_base;
	
	document.getElementById('additional').childNodes[0].nodeValue = "Additional: $" + Additional.toFixed(2); 
	document.getElementById('total_amount').childNodes[0].nodeValue = "Total: $" + Total.toFixed(2); 
	return true;
}

// email spam blocker
function nospam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}


// script from : http://www.sitepoint.com
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";
	}
}

/*
//	from adactio.com
function showPic (whichpic) { 
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 
			//alert (whichpic.href);
		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = '<a href="/build/portolio/' + whichpic.childNodes[0].nodeValue + '">' + whichpic.title +' Portfolio</a>'; 
			//alert (whichpic.title);
		} else { 
			document.getElementById('desc').childNodes[0].nodeValue = '<a href="/build/portolio/' + whichpic.childNodes[0].nodeValue + '">Client Portfolio</a>'; 
			//alert ( whichpic.childNodes[0].nodeValue);
		} 
		return false; 
	} else { 
		return true; 
	} 
}
*/

LASTPORT = '00';

function portOn (whichport) {
	LASTPORT = whichport;
	document.getElementById('01').className = 'portOn';
}

function showPic (whichport, id, cat, port) { 
/*
	alert (whichport.href);
	alert (cat);
	alert (port);
*/
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichport.href; 

		if (LASTPORT!=id)
		{
			if (LASTPORT!=0)
				document.getElementById(LASTPORT).className = 'portOff';
			LASTPORT = id;
			document.getElementById(id).className = 'portOn';
		}

//		alert (whichpic.title);
//		alert (whichpic.href);
		setPortfolioLinkDynamic (cat, port) 
	} 
	return false; 
}

function showCaseStudyPic (whichpic, whichport) { 
	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 


		if (LASTPORT!=whichport)
		{
			if (LASTPORT!=0)
				document.getElementById(LASTPORT).className = 'portOff';
			LASTPORT = whichport;
			document.getElementById(whichport).className = 'portOn';
		}
		return false; 
	} else { 
		return true; 
	} 
}

function setPortfolioLink (whichlink) {
//	theLink = parseInt(linkId);
//	linksRow = 0;
//	descripsRow = 0;
/*
	links = new Array();
	descrips =  new Array();
	links['Hen House'] = "http://www.henhouse.com";
	descrips['Hen House'] = "Hen House";
	links['Wakarusa'] = "http://www.entercomkc.com";
	descrips['Wakarusa'] = "Entercom";
	links['Interquest'] = "http://www.interqst.com";
	descrips['Interquest'] = "Interquest";
	links['Split Lip Rayfield'] = "http://www.splitliprayfield.com";
	descrips['Split Lip Rayfield'] = "Split Lip Rayfield";
	links['Kenny J Photography'] = "http://www.kennyj.com";
	descrips['Kenny J Photography'] = "Kenny J Photography";
	links['The Cycologist'] = "http://www.thecycologist.com";
	descrips['The Cycologist'] = "The Cycologist";
	links['Wally Emerson Photography'] = "http://www.wallyemersonphotography.com";
	descrips['Wally Emerson Photography'] = "Wally Emerson Photography";
	document.getElementById('port_link').href = links[whichlink];
	document.getElementById('port_desc').childNodes[0].nodeValue = descrips[whichlink]; 
*/
/*
	alert ("linkId: " + linkId);
	alert ("links 01: " + links[theLink]);
	alert ("descrips 01: " + descrips[theLink]);
*/
//	document.getElementById('port_link').childNodes[0].nodeValue = "http://www.yahoo.com";
//	alert (document.getElementById('port-desc').src);
//	alert ("1: " + linkId);
//	alert ("1: " + document.all.port_link);
//	this.document.links[93].href = "http://www.yahoo.com";
//	alert ("1: " + this.document.links[93]);
//	alert ("1: " + document.links['port_link']);
//	alert ("1: " + document.all.port_link);
//	alert ("1: " + document.all.port_desc.value);
	
/*	
	alert ( "1" );
	alert ( this.document.links.length );
	alert ( this.document.links[90].href );
	alert ( this.document.links[90].host );
	alert ( this.document.links[90].hostname );
	alert ( this.document.links[90].pathname );
	alert ( this.document.links[90].text );
	alert ( this.document.links[90].href );
*/
}


LASTDESCRIPFAQ = 0;
LASTCOPYFAQ = 0;
JUMPFAQ = 0;
/* Original working faqOn before slimmed down
function faqOn (whichfaq) { 
	if (LASTFAQ!=whichfaq)
	{
		if (LASTFAQ!=0)
			document.getElementById(LASTFAQ).className = 'copyOff';
		LASTFAQ = whichfaq;
		document.getElementById(whichfaq).className = 'copyOn';
	}
	return false;
}
*/
function faqDescripOn (whichfaq) { 
	if (LASTDESCRIPFAQ!=whichfaq)
	{
		if (LASTDESCRIPFAQ!=0)
			document.getElementById("KB" + LASTDESCRIPFAQ).className = 'faqDescripOff';
		LASTDESCRIPFAQ = whichfaq;
		document.getElementById("KB" + whichfaq).className = 'faqDescripOn';
	}
	return false;
}

function faqOnReset () { 
	
	if (JUMPFAQ!=0)
		document.getElementById(JUMPFAQ).className = 'copyOn';
	return false;
}

function faqChangeState (whichfaq) {
/*
	if (LASTCOPYFAQ!=whichfaq)
	{
		if (LASTCOPYFAQ!=0)
			document.getElementById(LASTCOPYFAQ).className = 'copyOff';
	}
*/
	if (document.getElementById(whichfaq).className == 'copyOff')
	{
		document.getElementById(whichfaq).className = 'copyOn';
	}
	else
	{
		document.getElementById(whichfaq).className = 'copyOff';
	}
	return false;
}

function faqOpen (whichfaq) {
	if (LASTCOPYFAQ!=whichfaq)
	{
		if (LASTCOPYFAQ!=0)
			document.getElementById(LASTCOPYFAQ).className = 'copyOff';
	}

	if (LASTCOPYFAQ==whichfaq)
	{
		document.getElementById(whichfaq).className = 'copyOff';
		LASTCOPYFAQ = 0;
	}
	else
	{
		document.getElementById(whichfaq).className = 'copyOn';
		LASTCOPYFAQ = whichfaq;
	}
	return false;
}

function faqJump (whichfaq) {
	window.location.href='#KB' + whichfaq;
	JUMPFAQ = whichfaq;
	faqDescripOn (whichfaq);
	faqOpen (whichfaq);
	return false;
}

/* Original working faqOn before slimmed down
function faqJump (whichfaq) {
	JUMPFAQ = whichfaq;
	faqOn (whichfaq);
	window.location.href='#KB' + whichfaq;
	return false;
}
*/

function nospam(user,domain) {
	locationstring = "mailto:" + user + "@" + domain;
	window.location = locationstring;
}

function toggle(targetId) {
  if (document.getElementById) {
  		target = document.getElementById( targetId );
  			if (target.style.display == "none") {
  				target.style.display = "";
  			} else {
  				target.style.display = "none";
  			}
  	}
}

function togglehide(targetId) {
  if (document.getElementById) {
  		target = document.getElementById( targetId );
		target.style.display = "none";
  }
}



// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

// sets cookie so tab stays open
function setShowTab() {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	setCookie('tab', 'true', now, '/');
}

// sets cookie so tab stays closed
function setHideTab() {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	setCookie('tab', 'false', now, '/');
}



function openWin(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// onloads called for the page
function initscripts() {
	externalLinks();
}

//window.onload = initscripts;

