// links that require leaving this domain will be opened in a new window

function outLinks() 
{
	var outLink;
	if (document.getElementsByTagName('a')) {
		for (var i = 0; (anchor = document.getElementsByTagName('a')[i]); i++) {
			if (
				( (anchor.href.indexOf("chuckprophet.") == -1) 
				&& (anchor.href.indexOf("localhost") == -1)
				&& (anchor.href.indexOf("theconnextion") == -1) )


				|| (anchor.href.indexOf(".pdf") != -1)
				|| (anchor.href.indexOf(".mp3") != -1)
				
				|| (anchor.getAttribute("rel") == "external") 
			   )
			{
				anchor.setAttribute('target', '_blank');
anchor.setAttribute('onclick', 'event.cancelBubble=true;');
			}
		}
	}
}
window.onload = function() { outLinks(); }

function errormsg(field, title)
{
	alert("Please enter "+title);
	cancelBubble = true;
	field.focus();
	return false;
}

function checkemail(str)
{
	var filter=/^([\w\-]+(?:\.[\w\-]+)*)@((?:[\w\-]+\.)*\w[\w\-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	return filter.test(str);
}

function checkZip(str) 
{
	var filter=/(^\d{5}$)|(^\d{5}-\d{4}$)/;
	return filter.test(str);
}

function validateBoardPost(myform)
{
	if ("" === myform.title.value) { return errormsg(myform.title,"a subject"); }
	if  ("" === myform.field_id_61.value) { return errormsg(myform.field_id_61,"your name"); }
/*	if  ("" === myform.field_id_62.value) { return errormsg(myform.field_id_62,"your email address"); }
	if (false === checkemail(myform.field_id_62.value)) { return errormsg(myform.field_id_62,"a valid email address"); } */
	if ("" === myform.field_id_60.value) { return errormsg(myform.field_id_60,"a message"); }
}

function validateReply(myform,group_id)
{
	if ("" === myform.comment.value) { return errormsg(myform.comment,"your reply"); }
	if ((group_id > 0) && (group_id != 7))
	{
		if ("" === myform.name.value) { return errormsg(myform.name,"your name"); }
/*
		if ("" === myform.email.value) { return errormsg(myform.email,"your email address"); } 
		if (false === checkemail(myform.email.value)) { return errormsg(myform.email,"a valid email address"); } 
*/
	}
}

function validateComment(myform,group_id)
{
	if ("" === myform.comment.value) { return errormsg(myform.comment,"your comment"); }
	if ((group_id > 0) && (group_id != 7))
	{
		if ("" === myform.name.value) { return errormsg(myform.name,"your name"); }
		if ("" === myform.email.value) { return errormsg(myform.email,"your email address"); }
		if (false === checkemail(myform.email.value)) { return errormsg(myform.email,"a valid email address"); }
	}
}

function validateSubscribe(myform)
{
	if ( ("EMAIL ADDRESS" == myform.username.value) || ("" === myform.username.value) ) { return errormsg(myform.username,"your email address"); }
	if (false === checkemail(myform.username.value)) { return errormsg(myform.username,"a valid email address"); }

	if (myform.country.selectedIndex == 0)
	{
		if ( ("ZIP CODE" == myform.zipcode.value) || ("" === myform.zipcode.value) ) { return errormsg(myform.zipcode,"your zip code"); }
		if (false === checkZip(myform.zipcode.value)) { return errormsg(myform.zipcode,"your correct zip code"); }
	}
}



var useBSNns;if(useBSNns){if(typeof (bsn)=="undefined"){bsn={}}var _bsn=bsn}else{var _bsn=this}_bsn.Crossfader=function(D,C,A){this.nAct=-1;this.aDivs=D;for(var B=0;B<D.length;B++){document.getElementById(D[B]).style.opacity=0;document.getElementById(D[B]).style.filter="alpha(opacity=0)";document.getElementById(D[B]).style.position="absolute";document.getElementById(D[B]).style.visibility="hidden";document.getElementById(D[B]).style.display="block"}this.nDur=C;this.nDelay=A;this._newfade()};_bsn.Crossfader.prototype._newfade=function(){if(this.nID1){clearInterval(this.nID1)}this.nOldAct=this.nAct;this.nAct++;if(!this.aDivs[this.nAct]){this.nAct=0}if(this.nAct==this.nOldAct){return false}document.getElementById(this.aDivs[this.nAct]).style.visibility="visible";this.nInt=50;this.nTime=0;var A=this;this.nID2=setInterval(function(){A._fade()},this.nInt)};_bsn.Crossfader.prototype._fade=function(){this.nTime+=this.nInt;var A=Math.round(this._easeInOut(this.nTime,0,1,this.nDur)*100);var C=A/100;document.getElementById(this.aDivs[this.nAct]).style.opacity=C;document.getElementById(this.aDivs[this.nAct]).style.filter="alpha(opacity="+A+")";if(this.nOldAct>-1){document.getElementById(this.aDivs[this.nOldAct]).style.opacity=1-C;document.getElementById(this.aDivs[this.nOldAct]).style.filter="alpha(opacity="+(100-A)+")"}if(this.nTime==this.nDur){clearInterval(this.nID2);if(this.nOldAct>-1){document.getElementById(this.aDivs[this.nOldAct]).style.visibility="hidden"}var B=this;this.nID1=setInterval(function(){B._newfade()},this.nDelay)}};_bsn.Crossfader.prototype._easeInOut=function(B,A,D,C){return D/2*(1-Math.cos(Math.PI*B/C))+A};

var ua = navigator.userAgent;
var ual = ua.toLowerCase();

var brokenHover = ((ual.indexOf("msie") != -1) && (ual.indexOf("konqueror") == -1));
var mozPosBug = false;

var bd = ua.match(/Gecko\/(\d+)/);
if (bd) {
	try {
		var d = new Date(bd[1].substr(0, 4), bd[1].substr(4,2), bd[1].substr(6,2));
		if (d <= new Date( 2003, 10, 18 )) {
			mozPosBug = true;
		}
	} catch (e) {}
}

function dSM( num ) {
	if (brokenHover) {
		var sm = document.getElementById('subMenu' + num);
//		sm.style.visibility = "visible";
//sm.style.display = "block";
sm.style.visibility = "visible";
	} else if (mozPosBug) {
		var sm = document.getElementById('subMenu' + num);
//		sm.style.marginTop = "20";
sm.style.marginTop = "0";
	}
}

function hSM( num ) {
	if (!brokenHover) return;
	var sm = document.getElementById('subMenu' + num);
//	sm.style.visibility = "hidden";
//sm.style.display = "none";
sm.style.visibility = "hidden";
}

function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';

return false; // cancel default behavior of calling object
}