//Animated Collapsible DIV- Author: Dynamic Drive (http://www.dynamicdrive.com)
//Last updated June 27th, 07'. Added ability for a DIV to be initially expanded.

var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "") //get current page path and name, used to uniquely identify this page for persistence feature

function cm_writeBann() {
	
	document.write('<img style="border-bottom:2px solid #d5904b;" src='+ RandomBanner() + ' alt="Nelson Design Group - House Plans Online, Home Design Plans" width="650" height="125" border="0" usemap="#mapMainMenu" />' );
}

function animatedcollapse(divId, animatetime, persistexpand, initstate){
	this.divId=divId
	this.divObj=document.getElementById(divId)
	this.divObj.style.overflow="hidden"
	this.timelength=animatetime
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract"
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
	this.contentheight=parseInt(this.divObj.style.height)
	var thisobj=this
	if (isNaN(this.contentheight)){ //if no CSS "height" attribute explicitly defined, get DIV's height on window.load
		animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
			this.divObj.style.visibility="hidden" //hide content (versus collapse) until we can get its height
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes") //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //just collapse content if CSS "height" attribute available
	if (persistexpand)
		animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
}

animatedcollapse.prototype._getheight=function(persistexpand){
	this.contentheight=this.divObj.offsetHeight
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){ //Hide DIV (unless div should be expanded by default, OR persistence is enabled and this DIV should be expanded)
		this.divObj.style.height=0 //collapse content
		this.divObj.style.visibility="visible"
	}
	else //else if persistence is enabled AND this content should be expanded, define its CSS height value so slideup() has something to work with
		this.divObj.style.height=this.contentheight+"px"
}


animatedcollapse.prototype._slideengine=function(direction){
	var elapsed=new Date().getTime()-this.startTime //get time animation has run
	var thisobj=this
	if (elapsed<this.timelength){ //if time run is less than specified length
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength)
	this.divObj.style.height=distancepercent * this.contentheight +"px"
	this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10)
	}
	else{ //if animation finished
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0
		this.isExpanded=(direction=="down")? "yes" : "no" //remember whether content is expanded or not
		this.runtimer=null
	}
}


animatedcollapse.prototype.slidedown=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==0){ //if content is collapsed
			this.startTime=new Date().getTime() //Set animation start time
			this._slideengine("down")
		}
	}
}

animatedcollapse.prototype.slideup=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){ //if animation isn't already running or has stopped running
		if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
			alert("Please wait until document has fully loaded then click again")
		else if (parseInt(this.divObj.style.height)==this.contentheight){ //if content is expanded
			this.startTime=new Date().getTime()
			this._slideengine("up")
		}
	}
}

animatedcollapse.prototype.slideit=function(){
	if (isNaN(this.contentheight)) //if content height not available yet (until window.onload)
		alert("Please wait until document has fully loaded then click again")
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown()
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup()
}

// -------------------------------------------------------------------
// A few utility functions below:
// -------------------------------------------------------------------

animatedcollapse.curveincrement=function(percent){
	return (1-Math.cos(percent*Math.PI)) / 2 //return cos curve based value from a percentage input
}


animatedcollapse.dotask=function(target, functionref, tasktype){ //assign a function to execute to an event handler (ie: onunload)
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false)
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref)
}

animatedcollapse.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
	if (document.cookie.match(re)) //if cookie found
		return document.cookie.match(re)[0].split("=")[1] //return its value
	return ""
}

animatedcollapse.setCookie=function(name, value, days){
	if (typeof days!="undefined"){ //if set persistent cookie
		var expireDate = new Date()
		var expstring=expireDate.setDate(expireDate.getDate()+days)
		document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()
	}
	else //else if this is a session only cookie
		document.cookie = name+"="+value
}






var mirror = 0;


//NEW FUNCTIONS TO DRAG STUFF, LETS SEE IF IT WORKS

// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}










//Functions added by Craig McCoy 3/1/06
//BEGIN FUNCTION

//randletterimage() returns nothing

function letterimg () {
	
		var randomn = Random(11);
		
		if (randomn < 6) {
			
			randomn = 8;
		}
		else if (randomn >= 6) {
			
			randomn = 9;
		}
	
	if (randomn == 0) {
		
		
		// Variable Definations
		var pics0 = new Array();
		pics0[0]= "/images/front/NDG111.gif";
		pics0[1]= "/images/front/NDG113-1.gif";
		pics0[2]= "/images/front/NDG115.gif";
		pics0[3]= "/images/front/NDG148.gif";
		pics0[4]= "/images/front/NDG178.gif";
		pics0[5]= "/images/front/NDG190.gif";
		
		
		document.write("<a href='/plan_details.php?planid=74'><img border='0' src='"+ pics0[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=77'><img border='0' src='"+ pics0[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=80'><img border='0' src='"+ pics0[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=118'><img border='0' src='"+ pics0[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=141'><img border='0' src='"+ pics0[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=146'><img border='0' src='"+ pics0[5] + "'</a><br />" )
		
	}
	
	else if (randomn == 1 ) {
		
		var pics1 = new Array();
		pics1[0]= "/images/front/NDG190.gif";
		pics1[1]= "/images/front/NDG178.gif";
		pics1[2]= "/images/front/NDG148.gif";
		pics1[3]= "/images/front/NDG115.gif";
		pics1[4]= "/images/front/NDG113-1.gif";
		pics1[5]= "/images/front/NDG111.gif";
		
		
		document.write("<a href='/plan_details.php?planid=146'><img border='0' src='"+ pics1[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=141'><img border='0' src='"+ pics1[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=118'><img border='0' src='"+ pics1[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=80'><img border='0' src='"+ pics1[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=77'><img border='0' src='"+ pics1[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=74'><img border='0' src='"+ pics1[5] + "'</a>" )
		
		
	}
	
	else if (randomn == 2 ) {
		
		var pics2 = new Array();
		pics2[0]= "/images/front/NDG209.gif";
		pics2[1]= "/images/front/NDG255.gif";
		pics2[2]= "/images/front/NDG256.gif";
		pics2[3]= "/images/front/NDG320.gif";
		pics2[4]= "/images/front/NDG327.gif";
		pics2[5]= "/images/front/NDG345.gif";
		
		document.write("<a href='/plan_details.php?planid=164'><img border='0' src='"+ pics2[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=189'><img border='0' src='"+ pics2[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=192'><img border='0' src='"+ pics2[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=258'><img border='0' src='"+ pics2[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=263'><img border='0' src='"+ pics2[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=277'><img border='0' src='"+ pics2[5] + "'</a><br />" )
		
		
	}
	
	else if (randomn == 3) {	
		
		var pics3 = new Array();
		pics3[0]= "/images/front/NDG345.gif";
		pics3[1]= "/images/front/NDG327.gif";
		pics3[2]= "/images/front/NDG320.gif";
		pics3[3]= "/images/front/NDG256.gif";
		pics3[4]= "/images/front/NDG255.gif";
		pics3[5]= "/images/front/NDG209.gif";
		
		document.write("<a href='/plan_details.php?planid=277'><img border='0' src='"+ pics3[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=263'><img border='0' src='"+ pics3[1] + "'</a><br />" )
		document.write("<a href='plan_details.php?planid=258'><img border='0' src='"+ pics3[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=192'><img border='0' src='"+ pics3[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=189'><img border='0' src='"+ pics3[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=164'><img border='0' src='"+ pics3[5] + "'</a><br />" )
		
	}
	
	else if (randomn == 4) {
		
		var pics4 = new Array();
		pics4[0]= "/images/front/NDG347.gif";
		pics4[1]= "/images/front/NDG371.gif";
		pics4[2]= "/images/front/NDG378.gif";
		pics4[3]= "/images/front/NDG379.gif";
		pics4[4]= "/images/front/NDG467.gif";
		pics4[5]= "/images/front/NDG483.gif";
		
		document.write("<a href='/plan_details.php?planid=279'><img border='0' src='"+ pics4[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=304'><img border='0' src='"+ pics4[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=312'><img border='0' src='"+ pics4[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=314'><img border='0' src='"+ pics4[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=404'><img border='0' src='"+ pics4[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=417'><img border='0' src='"+ pics4[5] + "'</a><br />" )
		
	}
	else if (randomn == 5) {
		
		var pics5 = new Array();
		pics5[0]= "/images/front/NDG483.gif";
		pics5[1]= "/images/front/NDG467.gif";
		pics5[2]= "/images/front/NDG379.gif";
		pics5[3]= "/images/front/NDG378.gif";
		pics5[4]= "/images/front/NDG371.gif";
		pics5[5]= "/images/front/NDG347.gif";
		
		document.write("<a href='/plan_details.php?planid=417'><img border='0' src='"+ pics5[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=404'><img border='0' src='"+ pics5[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=314'><img border='0' src='"+ pics5[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=312'><img border='0' src='"+ pics5[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=304'><img border='0' src='"+ pics5[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=279'><img border='0' src='"+ pics5[5] + "'</a><br />" )
		
	}
	else if (randomn == 6) {
			
		var pics6 = new Array();
		pics6[0]= "/images/front/NDG502.gif";
		pics6[1]= "/images/front/NDG526.gif";
		pics6[2]= "/images/front/NDG544.gif";
		pics6[3]= "/images/front/NDG563.gif";
		pics6[4]= "/images/front/NDG597.gif";
		pics6[5]= "/images/front/NDG646.gif";
		
		document.write("<a href='/plan_details.php?planid=434'><img border='0' src='"+ pics6[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=458'><img border='0' src='"+ pics6[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=475'><img border='0' src='"+ pics6[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=494'><img border='0' src='"+ pics6[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=520'><img border='0' src='"+ pics6[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=551'><img border='0' src='"+ pics6[5] + "'</a><br />" )
		
	}
	else if (randomn == 7) {
			
		var pics7 = new Array();
		pics7[0]= "/images/front/NDG646.gif";
		pics7[1]= "/images/front/NDG597.gif";
		pics7[2]= "/images/front/NDG563.gif";
		pics7[3]= "/images/front/NDG544.gif";
		pics7[4]= "/images/front/NDG256.gif";
		pics7[5]= "/images/front/NDG502.gif";
		
		document.write("<a href='/plan_details.php?planid=551'><img border='0' src='"+ pics7[0] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=520'><img border='0' src='"+ pics7[1] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=494'><img border='0' src='"+ pics7[2] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=475'><img border='0' src='"+ pics7[3] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=458'><img border='0' src='"+ pics7[4] + "'</a><br />" )
		document.write("<a href='/plan_details.php?planid=434'><img border='0' src='"+ pics7[5] + "'</a><br />" )
		
	}
	
	else if (randomn == 8) {
			
		var pics8 = new Array();
		pics8[0]= "/images/front/1132.gif";
		pics8[1]= "/images/front/1133.gif";
		pics8[2]= "/images/front/1135.gif";
		pics8[3]= "/images/front/1136.gif";
		pics8[4]= "/images/front/1134.gif";
		pics8[5]= "/images/front/1138.gif";
		
		document.write("<a href='/plan_details.php?planid=1087'><img border='0' src='"+ pics8[0] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1093'><img border='0' src='"+ pics8[1] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1096'><img border='0' src='"+ pics8[2] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1097'><img border='0' src='"+ pics8[3] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1098'><img border='0' src='"+ pics8[4] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1094'><img border='0' src='"+ pics8[5] + "' /></a><br />" )
		
	}
	
		else if (randomn == 9) {
			
		var pics9 = new Array();
		pics9[0]= "/images/front/1137.gif";
		pics9[1]= "/images/front/1139.gif";
		pics9[2]= "/images/front/1135.gif";
		pics9[3]= "/images/front/1136.gif";
		pics9[4]= "/images/front/1134.gif";
		pics9[5]= "/images/front/1138.gif";
		
		document.write("<a href='/plan_details.php?planid=1095'><img border='0' src='"+ pics9[0] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1100'><img border='0' src='"+ pics9[1] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1096'><img border='0' src='"+ pics9[2] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1097'><img border='0' src='"+ pics9[3] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1098'><img border='0' src='"+ pics9[4] + "' /></a><br />" )
		document.write("<a href='/plan_details.php?planid=1094'><img border='0' src='"+ pics9[5] + "' /></a><br />" )
		
	}
		
		

	
	
}



//Functions added by Craig McCoy 1/10/06
//BEGIN FUNCTION
//checkstring(field,error) takes 2 arguments, the current field usually passed as (this)
//and an error to output

function checkstring (field, error)
{

if (!field.value) return false;

   var iChars = "*|,\":<>[]/;{}`\';()=+&$#%";

   for (var i = 0; i < field.value.length; i++) {
      if (iChars.indexOf(field.value.charAt(i)) != -1){
         alert( error );
    	field.focus();
    	field.select();
    	return false;
    	}
   }
   return true;
}
function checknumber (field, error)
{
if (!field.value) return false;
var iChars = "*|,\":/<>[]{}`\';()=_+&$#%-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";

   for (var i = 0; i < field.value.length; i++) {
      if (iChars.indexOf(field.value.charAt(i)) != -1){
         alert( error );
    	field.focus();
    	field.select();
    	return false;
    	}
   }
   return true;
}
//END FUNCTION


//Functions added by Craig mcCoy 9/23/05

//BEGIN FUNCTION
//findScrollTop() takes 0 arguments, uses the DOM to find the distance scrolled and return it<!--



<!--




//BEGIN FUNCTION
//findScrollTop() takes 0 arguments, uses the DOM to find the distance scrolled and return it<!--

function findScrollTop() {
	
		if (window.pageYOffset) {

			var blah = window.pageYOffset;
			return (blah);
		}
		else if (document.documentElement.scrollTop) {
			return (document.documentElement.scrollTop);
		}
		else if (document.body.scrollTop) {
			return (document.body.scrollTop);
		}
		else {
		return(100);
	}
	
}


//Functions added by Craig McCoy 1/10/06
//BEGIN FUNCTION
//checkstring(field,error) takes 2 arguments, the current field usually passed as (this)
//and an error to output




function checkstring (field, error)
{

if (!field.value) return false;

   var iChars = "*|,\":<>[]_/;{}`\';()=+&$#%";

   for (var i = 0; i < field.value.length; i++) {
      if (iChars.indexOf(field.value.charAt(i)) != -1){
         alert( error );
    	field.focus();
    	field.select();
    	return false;
    	}
   }
   return true;
}
function checknumber (field, error)
{
if (!field.value) return false;
var iChars = "*|,\":/<>[]{}`\';()=_+&$#%-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";

   for (var i = 0; i < field.value.length; i++) {
      if (iChars.indexOf(field.value.charAt(i)) != -1){
         alert( error );
    	field.focus();
    	field.select();
    	return false;
    	}
   }
   return true;
}
//END FUNCTION






function validateEmail(objField) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (!objField.value.match(re)) {
		alert("Invalid email address");
		objField.focus();
		objField.select();
		return (false);
	} else {
		return true;
	}
}

// No rightclick script v.2.5
// (c) 1998 barts1000
// barts1000@aol.com
// Don't delete this header!
var message="Sorry. The images and code on this page are protected by copyright."; // Message for the alert box

// Don't edit below!

function click(e) {
	if (document.all) {
		if (event.button == 2) {
			alert(message);
			return false;
		}
	}
	
	if (document.layers) {
		if (e.which == 3) {
			alert(message);
			return false;
		}
	}
}

/*
	Right-click prevention currently disabled
	10/10/2003
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;
*/

// These Functions should be assigned
// to the onFocus() and onBlur() methods,
// respectively. GH_Highlight() creates
// a red border around the selected object,
// and GH_Obscure returns the object to
// its original state, as defined by the 
// style class .textbox (located in 
// "/include/sitestyle.css"

function addToFavorites(argVal) {
	var bookData = new Array();
	bookData = argVal.split("|");

	if (document.all) {
		window.external.AddFavorite(bookData[0], bookData[1]);
	} else {
		alert("Sorry. Netscape users must bookmark the pages manually by hitting <Ctrl-D>");
	}
}


function testAlert(strText) {
	alert(strText);
}

function GH_openFrames(strMenu, strContent) {
	parent.submenu.location.href=strMenu;
	parent.content.location.href=strContent;
}

function GH_Highlight(objName) {
	objName.style.borderColor = "#FF0000";
	objName.style.borderStyle = "solid";
	objName.style.borderWidth = "4px";
}

function GH_Obscure(objName) {
	objName.style.borderColor = "#000000";
	objName.style.borderStyle = "solid";
	objName.style.borderWidth = "1px";
}


// Looks to drop-down list, for planid to jump to
// creates URL and jumps
function quickJumpPlanEdit() {
	var strURL = "/admin/plan_edit.php?planid=";
	var intIndex = document.form1.selQuickjump.selectedIndex;
	var planID = document.form1.selQuickjump.options[intIndex].value;
	strURL = strURL + planID;
	location.href=strURL;
}

// Form Checking Functions

/*
	function: GH_checkLength
	parameters: form name, field name, descriptive name for field, required length
	action: checks to see if value of field length meets
	requirements. 
	returns: onSuccess() - blank string
			onError() - descriptive text.
*/
function GH_checkLength(frmName, objName, strFieldName, intMinLength) {
	oField = eval("document." + frmName + "." + objName);
	strFieldValue = new String(oField.value);
	if ((strFieldValue.length < intMinLength) || ((intMinLength == -1) && (strFieldValue.length == 0))) {
		if (intMinLength == -1) {
			strError = strFieldName + " cannot be left blank.\n";
		} else {
			strError = strFieldName + " must be at least " + intMinLength + " characters in length.\n";
		}
		
		return strError;
	} else {
		return "";
	}
}

function GH_addToFavorites(planid) {
	strURL = "/admin/addtofavorites.php?planid=" + planid;
	MM_openBrWindow(strURL, 'wndAddFav', 'width=150,height=95');
}

function GH_prevClicked() {
	document.form1.intStartAt.value = document.form1.tempPrevStartAt.value;
	document.form1.submit();
}

function GH_nextClicked() {
	document.form1.intStartAt.value = document.form1.tempNextStartAt.value;
	document.form1.submit();	
}

/*
// Popup Image Handler, form step through handler
function GH_prevClicked() {
	document.form1.intPos.value = document.form1.tempPrevStartAt.value;
	document.form1.submit();
}

function GH_nextClicked() {
	document.form1.intPos.value = document.form1.tempNextStartAt.value;
	document.form1.submit();	
}
*/

// function and code to enable popup image display
var imgDynamic = new Image();
imgDynamic.src = "/images/themes/vendor_root/clearbox.gif";

function GH_printImage() {
	

	var strImgSrc = document.imgDynamic.src;
	var intImgWidth = document.imgDynamic.width;
	var intImgHeight = document.imgDynamic.height;
	
	// retrieve info from image
		
	var strURL = "/printImage.php?imgurl=" + strImgSrc;
	
	MM_openBrWindow(strURL,'imgPrint','scrollbars=auto,width=' + intImgWidth + ',height=' + intImgHeight);
	MM_showHideLayers('popupImg','','hide');
	mirror=0;
}

function GH_loadImage(strImgURL) {
	// update image src
	document.imgDynamic.src = strImgURL;
	
	document.imgDynamic.style.filter='progid:DXImageTransform.Microsoft.BasicImage(mirror=0)';
	
	// reset position to default
	var oImg = MM_findObj('popupImg');
	oImg.style.left = '200px';
	oImg.style.top = findScrollTop() + "px";
	
	// show image layer
	MM_showHideLayers('popupImg','','show');
}

function GH_moveObject(objName, intLeft, intTop) {
	// get object
	oObj = MM_findObj(objName);
	
	// set left, right
	oObj.style.left = intLeft;
	oObj.style.top = intTop;
}

// A Function to give focus to the passed
// object

function GH_GiveFocus(frmName, objName) {
//	objForm = eval("document." + frmName);
	objElement = eval("document." + frmName + "." + objName);
	objElement.focus();
}

// GH modified to auto-center the popup window

function MM_openBrWindow(theURL,winName,features) { //v2.0
	var startpos, endpos, intWidth, intHeight, top, left, length;
	
	// Get Width
	startpos = features.indexOf("width=") + 6;
	endpos = startpos;
	
	while ((features.charCodeAt(endpos) >= 48) && (features.charCodeAt(endpos) <= 57)) {
		endpos++;
	}

	intWidth = features.substring(startpos, endpos);

	// Get Height
	startpos = features.indexOf("height=") + 7;
	endpos = startpos;
	
	while ((features.charCodeAt(endpos) >= 48) && (features.charCodeAt(endpos) <= 57)) {
		endpos++;
	}
	
	intHeight = features.substring(startpos, endpos);
	
	// Now determine top and left positions (centering) based on height and width
	top = (screen.height - intHeight) / 2;
	left = (screen.width - intWidth) / 2;
	
	features += ", top=" + top + ", left=" + left;
	
  	return window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

// Retrieves Parent URL,
// refreshes it and closes the current window
function GH_RefreshOpener(page) {

		// Refresh Opener
		var newURL = page;
		opener.location.href = newURL;
		
		// Close Current Window
		window.close();	
}

function GH_CheckPass(field1, field2, frmName) {
	// Get Values of Objects and compare
	objElement1 = eval("document." + frmName + "." + field1);
	objElement2 = eval("document." + frmName + "." + field2);
	
	objVal1 = objElement1.value;
	objVal2 = objElement2.value;
	
	if (objVal1 == objVal2) {
		objForm = eval("document." + frmName);
		objForm.submit();
	} else { 
		alert("Password Fields Don't Match");
		GH_GiveFocus(frmName, field1);
	} 
}

function GH_setText(frmName, frmField, strText) {
	objTarget = eval("document." + frmName + "." + frmField);
	
	objTarget.value = strText;
}

/* 	
	Function: Formats the following fields:
	social; dob; state; email; 
	
	If lnLglGuard == "yes", then requires that
	grdFname && grdLname != ""
	
	Action: If everything's fine, submits the form,
	otherwise, displays popup with details
*/
 
 function GH_ValidateAddUser(frmName) {
	var blnError, strError, strSocial, strDOB, strState, strEmail;
	var strBlnLglGuard, strGrdFname, strGrdLname;
	var intSelected, intValue;
	
	blnError = 0;
	strError = "";
	
	// get form object
	objForm = eval("document." + frmName);
	
	// Determine User Type and Proceed
	intSelected = objForm.userlevel.selectedIndex;
	intValue = objForm.userlevel[intSelected].value;
	
	switch (parseInt(intValue)) {
		case 5 :	// Client User
		
			
			
			// get needed values
				strSocial = new String(objForm.social.value);
				strDOB = new String(objForm.dob.value);
				strState = new String(objForm.state.value);
				strEmail = new String(objForm.email.value);
				strGrdFname = new String(objForm.grdFname.value);
				strGrdLname = new String(objForm.grdLname.value);
				
				
				// Format Social
					// 	first, remove all non-numeric characters
					var	strSocialTemp = new String();
					strSocialTemp = "";
					// alert("strSocial.length: " + strSocial.length);
					for (i = 0; i < strSocial.length; i++) {
						if ((strSocial.charCodeAt(i) <= 57) && (strSocial.charCodeAt(i) >= 48)) {
							// alert("strSocial.charCodeAt(" + i + "): " + strSocial.charCodeAt(i));
							strSocialTemp += strSocial.substr(i,1);
							// alert("strSocialTemp: " + strSocialTemp);
						}
					}
					
					// now Check length
					if (strSocialTemp.length != 9) {
						strError = strError + "Social Security Number not formatted properly: xxx-xx-xxxx\n";
						blnError = 1;
					} else {
						// length ok, now format it and assign it to the form field
						objForm.social.value = strSocialTemp.substr(0,3) + "-" + strSocialTemp.substr(3,2) + "-" + strSocialTemp.substr(5,4);
					}
					
					
				// Format DOB
					// 	first, remove all non-numeric characters
					var	strDOBTemp = new String();
					strDOBTemp = "";
					for (i = 0; i < strDOB.length; i++) {
						if ((strDOB.charCodeAt(i) <= 57) && (strDOB.charCodeAt(i) >= 48)) {
							strDOBTemp += strDOB.substr(i,1);
						}
					}
					
					// now Check length
					if (strDOBTemp.length != 8) {
						strError = strError + "DOB not formatted properly: xx/xx/xxxx\n";
						blnError = 1;
					} else {
						// length ok, now format it and assign it to the form field
						objForm.dob.value = strDOBTemp.substr(0,2) + "/" + strDOBTemp.substr(2,2) + "/" + strDOBTemp.substr(4,4);
					}
					
				// Format State
					if (strState.length != 2) {
						strError = strError + "You must enter a two-character state code.\n";
						blnError = 1;
					} else {
						objForm.state.value = strState.toUpperCase();
					}
				
				// Check Legal Guardian Status
			
					if (objForm.blnLglGuard[0].checked) {
						// First name and last name can't be null
						if ((strGrdFname.length == 0) || (strGrdLname.length == 0)) {
							strError = strError + "Legal Guardian first name and last name must be completed.\n";
							blnError = 1;
						}
					}		
					
			 	
				// Check length on all of these fields to make sure they're not blank
				var arrFields = new Array("Fname", "Lname", "address", "city", "state", "zip");
										  // "phone1", "phone2", "phone3");
										  
				for (i = 0; i < arrFields.length; i++) {
					objField = eval("document." + frmName + "." + arrFields[i]);
					strField = new String(objField.value);
					if (strField.length == 0) {
						strError = strError + arrFields[i] + " cannot be left blank.\n";
						blnError = 1;
					}
				}
			
				// Make sure one of two radio buttons is checked in the following fields
				var arrFields = new Array("gender", "blnSMI", "blnActive");
				for (i = 0; i < arrFields.length; i++) {
					objField = eval("document." + frmName + "." + arrFields[i]);
					if (!objField[0].checked && !objField[1].checked) {
						strError = strError + arrFields[i] + ": must select either 'yes' or 'no'.\n";
						blnError = 1;
					}
				}
				
			break;		
				
		
		case 4 :	// FMH User, email required
		
			// Check length on all of these fields to make sure they're not blank
			var arrFields = new Array("Fname", "Lname", "username", "password", "email");
									  
			for (i = 0; i < arrFields.length; i++) {
				objField = eval("document." + frmName + "." + arrFields[i]);
				strField = new String(objField.value);
				if (strField.length == 0) {
					strError = strError + arrFields[i] + " cannot be left blank.\n";
					blnError = 1;
				}
			}		
		
			break;
			
		default :	// All Other Users

			// Check length on all of these fields to make sure they're not blank
			var arrFields = new Array("Fname", "Lname", "username", "password");
									  
			for (i = 0; i < arrFields.length; i++) {
				objField = eval("document." + frmName + "." + arrFields[i]);
				strField = new String(objField.value);
				if (strField.length == 0) {
					strError = strError + arrFields[i] + " cannot be left blank.\n";
					blnError = 1;
				}
			}		

			break;
	}
	
	
		
	// Check to see if error flag has been set and prompt or submit accordingly
	
		if (blnError == 1) {
			alert(strError);
		} else {
			objForm.submit();
		}
			
}

/* 
	Used on Form 1
*/

function GH_updateLayout() {

	// look at current usertype, then display or hide 
	// appropriate sections
	
	// retrieve selected index of iv_reviewtype
	var intSelected, intValue;
	blnShowVIII = '0';
	intSelected = document.form1.userlevel.selectedIndex;
	intValue = document.form1.userlevel[intSelected].value;
	
	switch (parseInt(intValue)) {
		// alert(blnSMI);
		case 5 :
			// Client Level User
			MM_showHideLayers('layerLogin', '', 'hide');
			MM_showHideLayers('layerAddInfo', '', 'show');
			break;

		default :
			// All other users
			MM_showHideLayers('layerLogin', '', 'show');
			MM_showHideLayers('layerAddInfo', '', 'hide');
			break;
			
	}	
}


function ActiveBG(srcElement, Type) {
	if (Type == 0)
	{
	   if(srcElement.bgColor == "#CCCCCC")
	  {
   	   srcElement.bgColor = "#999999";
	  }else{
   	   srcElement.bgColor = "#CCCCCC";
	  }
	}else{
	   if(srcElement.bgColor == "#CCCCCC")
	  {
   	   srcElement.bgColor = "#999999";
	  }else{
   	   srcElement.bgColor = "#CCCCCC";
	  }	
	}
}

// *************************************
// MENU FUNCTIONS
// *************************************
	function layer_enter (id, parentid)
	{
		if (parentid == -1) { // Not a Sub-Menu
			on_layer_id = id;
		} else {	// Sub-Menu
			on_layer_id = parentid;
			on_sublayer_id = id;
		}
	}
	
	function layer_exit (id, parentid)
	{
		if (parentid == -1) { // Not a Sub-Menu
			on_layer_id = - 1;
			setTimeout("hide(\"" + id + "\")", delay/5);	
		} else {
			on_sublayer_id = - 1;
			setTimeout("hidesub(\"" + id + "\")", delay/5);
			buff_id = parentid;
			on_layer_id = -1;
			setTimeout("hide(\"" + parentid + "\")", delay);
		}
	}
	function menu_enter (id, parentid)
	{
		// Immediately Hides another menu and submenu if they're visible
		if (buff_id != -1)
			hide (buff_id);
		if (buff_sub_id >= 0)
			hidesub (buff_sub_id);
	
		// Displays Menu That We've just entered
		if (parentid == -1) {
			show (id);
			active_layer_id = id;
		} else {
			// Show Sub-menu
			show (id);
			active_sublayer_id = id;
			
			// Show Main Menu
			show (parentid);
			active_layer_id = parentid;
		}
	}
	function menu_exit (id, parentid)
	{
		
		
		if (parentid == -1) { // Not a Sub-Menu
			// setTimeout ('hide('+ id +')', delay);
			// setTimeout (hide("'" + id + "'"), delay);
			setTimeout("hide(\"" + id + "\")", delay);
			buff_id = active_layer_id;
			active_layer_id = -1;	
		} else { // Sub-Menu
			setTimeout ("hide(\"" + id + "\")", delay);
			buff_sub_id = active_sublayer_id;
			active_sublayer_id = -1;
			
			// Handle Parent Menu
			setTimeout ("hide(\"" + parentid + "\")", delay);
			buff_id = active_layer_id;
			active_layer_id = -1;
			
		}
		
		
	
	}
	function show (id)
	{
		MM_showHideLayers(id,'','show');
	} 
	function hide (id)
	{
		if (active_layer_id != id && on_layer_id != id)
		{
			// alert("id: " + id);
			MM_showHideLayers(id,'','hide');
		}
	}
	
	
	function hidesub (id)
	{
		if (active_sublayer_id != id && on_sublayer_id != id)
		{
			MM_showHideLayers(id,'','hide');
		}
	}
	
// *************************************
// NEW MENU FUNCTIONS
// *************************************	
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function tdBGEnter(target) {
	target.style.backgroundColor='#D5904B'
}

function tdBGExit(target) {
	target.style.backgroundColor='#F2EED3';
}

function tdEnter(target) {
	target.style.backgroundColor = "#E3DFC3";
	target.style.border = "1px solid #50441F";
	target.style.color = "#000000";
}

function tdExit(target) {
	target.style.backgroundColor = "";
	target.style.border = "1px solid #666632";
	target.style.color = "#F2EED3";
}

// Define menu object
function menuObj(layerName) {
	this.name = layerName;
	this.parent = -1;
	this.arrChildren = new Array();
	this.blnDisplayed = false;
	this.blnOnChild = false;
	this.blnOnLayer = false;
	this.delay = 500;
	this.headerCell = null;
}

// Add child to menu object
menuObj.prototype.addChild = function(childObj) {
	this.arrChildren.push(childObj);
	childObj.parent = this;
}

// Show this item
menuObj.prototype.show = function(targetCell) {
	MM_showHideLayers(this.name,'','show');
	this.blnDisplayed = true;
	
	if (targetCell != null) {
		this.headerCell = targetCell;
		tdEnter(this.headerCell);
	}
	
	// Hide Siblings
	if (this.parent != -1) {
		for (var i = 0; i < this.parent.arrChildren.length; i++) {
			if (this.parent.arrChildren[i] != this) {
				this.parent.arrChildren[i].hide();
			}
		}
	}
}

// Hide this item
menuObj.prototype.hide = function() {
	// Hide Self and children if not on layer
	if (!this.blnOnLayer && !this.blnOnChild) {
		MM_showHideLayers(this.name,'','hide');
		this.blnDisplayed = false;	
		
		if (this.headerCell != null) {
			tdExit(this.headerCell);
		}
		
		// hide all children
		// alert("arrChildren.length: " + this.arrChildren.length);
		
		for (var i = 0; i < this.arrChildren.length; i++) {
			// alert("hide[" + i + "]: " + this.arrChildren[i].name);
			this.arrChildren[i].hide();
		}		
	}	
}

// Mark layer as entered
menuObj.prototype.enter = function() {
	this.blnOnLayer = true;
	this.parent.blnOnChild = true;
}

function hideMenuObj(targetName) {
	// alert("hideMenuObj(" + targetName + ")");
	for (var i = 0; i < mnuObjTop.arrChildren.length; i++) {
		if (mnuObjTop.arrChildren[i].name == targetName) {
			mnuObjTop.arrChildren[i].hide();
		}
	}
}

// Note layer as exited
menuObj.prototype.exit = function() {
	this.blnOnLayer = false;
	this.parent.blnOnChild = false;
	// alert("this.delay: " + this.delay);
	// alert("this.name: " + this.name);
		
	setTimeout("hideMenuObj('" + this.name + "')", this.delay);
	setTimeout("hideMenuObj('" + this.parent.name + "')", this.delay);
}

// Trace menu object

menuObj.prototype.trace = function(intLevel) {
	if (intLevel == null)
		intLevel = 0;
	
	var strOutput = "";
	
	for (var i = 0; i < intLevel; i++) {
		strOutput += '    ';
	}
	strOutput += '>' + this.name + '\n';
	for (var i = 0; i < this.arrChildren.length; i++) {
		strOutput += this.arrChildren[i].trace(intLevel +1);	
	}
	
	if (this.parent == -1) {
		alert(strOutput);
	} else {
		return strOutput;
	}
}
// *************************************
// END NEW MENU FUNCTIONS
// *************************************	


	
// -->
// Functions Added By Craig McCoy 9/2/05

var newwindow;
function poptastic(url)
{
	//newwindow=window.open(url,'name','height=600,width=300');
	newwindow=window.open(url,'name', 'resizable=1,status=1,menubar=1,toolbar=1,scrollbars=1,location=1,directories=1,width=750,height=1500,top=60,left=60');
	if (window.focus) {newwindow.focus()}
}


	// BEGIN FUNCTION
	// Random(int x) will return a random number between 0 and X
	
	function Random(anInt) {
		var randomnumber=Math.floor(Math.random()*anInt);
		return(randomnumber);
	}
	// END FUNCTION
	
	// BEGIN FUNCTION
	// Random Image Will Be Generated, arg is X where random image will be between 0 and X
	// Returns the image path from the internal array of the random image
	
	function RandomBanner() {
		
	// Variable Definations
		var picture = new Array();
		picture[0]= "/images/RotateBanner/Banner-Image1.gif";
		picture[1]= "/images/RotateBanner/Banner-Image2.gif";
		picture[2]= "/images/RotateBanner/Banner-Image3.gif";
		picture[3]= "/images/RotateBanner/Banner-Image4.gif";
		picture[4]= "/images/RotateBanner/Banner-Image5.gif";
		
		
		var random = Random(5);
		
		return (picture[random]);
		
	}
	
	// END FUNCTION
	
	
	// BEGIN FUNCTION
	// Random Image Will Be Generated, arg is X where random image will be between 0 and X
	// Returns the image path from the internal array of the random image
	
	function RandomHouse() {
		
	// Variable Definations
		var picture = new Array();
		picture[0]= "images/random-house/1.jpg";
		picture[1]= "images/random-house/2.jpg";
		picture[2]= "images/random-house/3.jpg";
		picture[3]= "images/random-house/4.jpg";
		picture[4]= "images/random-house/5.jpg";
		picture[5]= "images/random-house/6.jpg";
		picture[6]= "images/random-house/7.jpg";
		picture[7]= "images/random-house/8.jpg";
		picture[8]= "images/random-house/9.jpg";
		
		var random = Random(9);
		
		return (picture[random]);
		
	}
	
	// END FUNCTION
	
// END OF CRAIG's FUNCTIONS
