//////////////////////////////////////////////////////////////////////////////////////////////
//
// Execute
//
//////////////////////////////////////////////////////////////////////////////////////////////

/*************************************************************
** ONLOAD SCRIPT - adapted from the window.onload script
**    written by Dean Edwards - http://dean.edwards.name
**************************************************************/
function init()
{
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if(document.onload)
	{
		if(typeof(document.onload) == 'object')
		{
			for(var i in document.onload)
			{
				if(typeof(document.onload[i]) == 'function')
				{
					document.onload[i]();
				}
			}
		}
		else if(document.onload && typeof(document.onload[i]) == 'function')
		{
			document.onload();
		}
	}
}

/* for Mozilla */
if (document.addEventListener) {
  document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        init(); // call the onload handler
    }
};
/*@end @*/


/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) {  // sniff
  var _timer = setInterval(function() {
      if (/loaded|complete/.test(document.readyState)) {
          clearInterval(_timer);
          init();  // call the onload handler
      }
  }, 10);
}

/* for other browsers */
window.onload = init;
/************************************************************
** END ONLOAD SCRIPT
*************************************************************/


// Navigation Menu

//Top Navigational Bar III v3.4.1.1b (By BrotherCake @ cake@brothercake.net)
//Permission granted/modified by Dynamicdrive.com to include script in archive
//For this and 100's more DHTML scripts, visit http://www.dynamicdrive.com/
//This notice MUST stay intact for legal use

_ms="1=Hem_)'\cinolim'\==nd_&&'\:ptth'\==locotorp.noitacol(fi;)'\'\,er_(ecalper.nd_=nd_;/moc./=er_;)'\'\,er_(ecalper.nd_=nd_;/ku.oc./=er_;)'\'\,er_(ecalper.nd_=nd_;/.www/=er_;emantsoh.noitacol=nd_";_oup="";for(a=_ms.length;a>=0;a--){_oup+=_ms.substr(a,1)}eval(_oup)

_mD=2;_d=document;_n=navigator;_nv=_n.appVersion.toLowerCase();_nu=_n.userAgent.toLowerCase();_ps=parseInt(_n.productSub);_f=false;_t=true;_n=null;_wp=window.createPopup;ie=(_d.all)?_t:_f;ie4=(!_d.getElementById&&ie)?_t:_f;ie5=(!ie4&&ie&&!_wp)?_t:_f;ie55=(!ie4&&ie&&_wp)?_t:_f;ns6=(_nu.indexOf("gecko")!=-1)?_t:_f;konq=(_nu.indexOf("konqueror")!=-1)?_t:_f;konq=0;sfri=(_nu.indexOf("safari")!=-1)?_t:_f;if(konq||sfri){_ps=0;ns6=0}ns4=(_d.layers)?_t:_f;ns61=(_ps>=20010726)?_t:_f;ns7=(_ps>=20020823)?_t:_f;op=(window.opera)?_t:_f;op5=(_nu.indexOf("opera 5")!=-1)?_t:_f;op6=(_nu.indexOf("opera 6")!=-1)?_t:_f;op7=(_nu.indexOf("opera 7")!=-1||_nu.indexOf("opera/7")!=-1)?_t:_f;mac=(_nv.indexOf("mac")!=-1)?_t:_f;mac45=(_nv.indexOf("msie 4.5")!=-1)?_t:_f;mac50=(mac&&_nv.indexOf("msie 5.0")!=-1)?_t:_f;if(ns6||ns4||op||sfri)mac=_f;ns60=_f;if(ns6&&!ns61)ns60=_t;IEDtD=0;if(!op&&(_d.all&&_d.compatMode=="CSS1Compat")||(mac&&_d.doctype&&_d.doctype.name.indexOf(".dtd")!=-1))IEDtD=1;if(op7)op=_f;if(op)ie55=_f;_st=0;_en=0;_m=new Array();_mi=new Array();_sm=new Array();_tsm=new Array();_cip=new Array();_mn=-1;_el=0;_Bel=0;_bl=0;_Omenu=0;_MT=setTimeout("",0);_oMT=setTimeout("",0);_cMT=setTimeout("",0);_scrmt=setTimeout("",0);_mst=setTimeout("",0);_zi=999;_c=1;_mt="";_oldel=-1;_sH=0;_sW=0;_bH=500;_oldbH=0;_bW=0;_oldbW=0;_cD=0;_ofMT=0;_startM=1;_sT=0;_sL=0;_mcnt=0;_mnuD=0;_itemRef=-1;inopenmode=0;function M_hideLayer(){}function opentree(){}function chop(_ar,_pos){var _tar=new Array();for(_a=0;_a<_ar.length;_a++){if(_a!=_pos){_tar[_tar.length]=_ar[_a]}}return _tar}function remove(_ar,_dta){var _tar=new Array();for(_a=0;_a<_ar.length;_a++){if(_ar[_a]!=_dta){_tar[_tar.length]=_ar[_a]}}return _tar}function copyOf(_w){for(_cO in _w){this[_cO]=_w[_cO]}}function drawMenus(){for(_a=_mcnt;_a<_m.length;_a++){_drawMenu(_a,1)}}_$S={menu:0,text:1,url:2,showmenu:3,status:4,onbgcolor:5,oncolor:6,offbgcolor:7,offcolor:8,offborder:9,separatorcolor:10,padding:11,fontsize:12,fontstyle:13,fontweight:14,fontfamily:15,high3dcolor:16,low3dcolor:17,pagecolor:18,pagebgcolor:19,headercolor:20,headerbgcolor:21,subimagepadding:22,subimageposition:23,subimage:24,onborder:25,ondecoration:26,separatorsize:27,itemheight:28,image:29,imageposition:30,imagealign:31,overimage:32,decoration:33,type:34,target:35,align:36,imageheight:37,imagewidth:38,openonclick:39,closeonclick:40,keepalive:41,onfunction:42,offfunction:43,onbold:44,onitalic:45,bgimage:46,overbgimage:47,onsubimage:48,separatorheight:49,separatorwidth:50,separatorpadding:51,separatoralign:52,onclass:53,offclass:54,itemwidth:55,pageimage:56,targetfeatures:57,imagealt:58,pointer:59,imagepadding:60,valign:61,clickfunction:62,bordercolor:63,borderstyle:64,borderwidth:65,overfilter:66,outfilter:67,margin:68};function mm_style(){for(i in _$S)this[i]=_n}_$M={items:0,name:1,top:2,left:3,itemwidth:4,screenposition:5,style:6,alwaysvisible:7,align:8,orientation:9,keepalive:10,openstyle:11,margin:12,overflow:13,position:14,overfilter:15,outfilter:16,menuwidth:17,itemheight:18,followscroll:19,menualign:20,mm_callItem:21,mm_obj_ref:22};function menuname(name){for(i in _$M)this[i]=_n;this.name=name.toLowerCase();_c=1;_mn++;this.menunumber=_mn}function _incItem(_it){_mi[_bl]=new Array();for(i in _x[6])_mi[_bl][_$S[i]]=_x[6][i];_mi[_bl][0]=_mn;_it=_it.split(";");for(_a=0;_a<_it.length;_a++){_sp=_it[_a].indexOf("`");if(_sp!=-1){_tI=_it[_a];for(_b=_a;_b<_it.length;_b++){_tI+=";"+_it[_b+1];_a++;if(_it[_b+1].indexOf("`")!=-1)_b=_it.length}_it[_a]=_tI.replace(/`/g,"")}_sp=_it[_a].indexOf("=");if(_sp==-1){if(_it[_a])_si=_si+";"+_it[_a]}else{_si=_it[_a].slice(_sp+1);_w=_it[_a].slice(0,_sp)}if(_it[_a]){_mi[_bl][_$S[_w]]=_si}}_m[_mn][0][_c-2]=_bl;_c++;_bl++}function _iI(txt,_pos){_oStyle=_m[_mn][6];_m[_mn][6]=this.style;this.aI(txt);_mil=_mi.length;_M=_m[this.menunumber];_nmi=new Array();if(_pos>=_M[0].length)_pos=_M[0].length;if(!_M[0][_pos])_M[0][_pos]=_M[0][_M[0].length-1]+1;_inum=_M[0][_pos];_cnt=0;for(_a=0;_a<_mil;_a++){if(_inum==_a){_nmi[_cnt]=_mi[_mi.length-1];_nmi[_cnt][0]=this.menunumber;_M[0][_M[0].length]=_cnt;_cnt++}_nmi[_cnt]=_mi[_a];_cnt++}_mi=_nmi;_tpos=0;_omnu=-1;for(_a=0;_a<_mil;_a++){_mnu=_mi[_a][0];if(_mnu!=_omnu){_m[_mnu][0]=new Array();_tpos=0}_m[_mnu][0][_tpos]=_a;_tpos++;_omnu=_mnu}_m[_mn][6]=_oStyle}_c=0;function ami(txt){_t=this;if(_c==1){_c++;_m[_mn]=new Array();_x=_m[_mn];for(i in _t)_x[_$M[i]]=_t[i];_x[21]=-1;_x[0]=new Array();if(!_x[12])_x[12]=0;_MS=_m[_mn][6];_MN=_m[_mn];if(!_MN[15])_MN[15]=_MS.overfilter;if(!_MN[16])_MN[16]=_MS.outfilter;if(!_MN[12])_MN[12]=_MS.margin;if(!_MS[65])_MS[65]=0}_incItem(txt)}menuname.prototype.aI=ami;menuname.prototype.insertItem=_iI;

if(ns4)_d.write("<scr"+"ipt language=JavaScript src=includes/nn_type.js><\/scr"+"ipt>");		
  else _d.write("<scr"+"ipt language=JavaScript src=includes/ie_type.js><\/scr"+"ipt>"); 

//////////////////////////////////////////////////////////////////////////////////////////////
//
// Global Functions
//
//////////////////////////////////////////////////////////////////////////////////////////////


// Debug

function getProperties(obj)
{
	var result = '';
	try
	{
		for(var i in obj)
		{
			try
			{
				result += i + ': ' + obj[i] + '\n';
			}
			catch(e) {}
		}
	}
	catch(e) {}
	return result;
}

function debug()
{
	var output = [];
	for(var i = 0; i < arguments.length; i++)
		if(typeof(arguments[i]) == 'object')
			output[i] = '[' + typeof(arguments[i]) + '] = ' + getProperties(arguments[i]);
		else
			output[i] = '[' + typeof(arguments[i]) + '] = ' + arguments[i];
	return wnd('Debug Information', '<pre>' + output.join('\n\n') + '</pre>');
}

function debug()
{
	var output = [];
	for(var i = 0; i < arguments.length; i++)
		if(typeof(arguments[i]) == 'object')
			output[i] = '[' + typeof(arguments[i]) + '] = ' + getProperties(arguments[i]);
		else
			output[i] = '[' + typeof(arguments[i]) + '] = ' + arguments[i];
	if(navigator.userAgent.indexOf('MSIE') != -1) 
		status = output.join('\n\n'); 
	else 
		return wnd('Debug Information', '<pre>' + output.join('\n\n') + '</pre>');
}

function wnd(title, html, x, y, width, height, opacity, padding, container, isIframe)
{
	if(!container) container = document.body;
	if(!container.wnds) container.wnds = [];
	container.onmouseup = function(e) 
	{ 
		var evt = e ? e : event; 
		this.drag = null; 
		this.resize = null; 
	};
	container.onmousemove = function(e) 
	{ 
		var evt = e ? e : event; 
		if(this.resize) 
		{ 
			if(this.resize.resize.side.indexOf('E') != -1) 
			{ 
				this.resize.style.width = (this.resize.resize.width + evt.clientX - this.resize.resize.mouseX) + 'px'; 
			} 
			else if(this.resize.resize.side.indexOf('W') != -1) 
			{ 
				this.resize.style.left = evt.clientX + 'px'; 
				this.resize.style.width = (this.resize.resize.width - evt.clientX + this.resize.resize.left) + 'px'; 
			} 
			if(this.resize.resize.side.indexOf('S') != -1) 
			{ 
				this.resize.style.height = (this.resize.resize.height + evt.clientY - this.resize.resize.mouseY) + 'px';
			} 
			else if(this.resize.resize.side.indexOf('N') != -1) 
			{ 
				this.resize.style.top = evt.clientY + 'px'; 
				this.resize.style.height = (this.resize.resize.height - evt.clientY + this.resize.resize.top) + 'px';
			} 
			this.resize.onresize(); 
		} 
		else if(this.drag) 
		{ 
			this.drag.style.left = (this.drag.drag.startX + evt.clientX - this.drag.drag.mouseX) + 'px'; 
			this.drag.style.top = (this.drag.drag.startY + evt.clientY - this.drag.drag.mouseY) + 'px'; 
		}
	};

		var div = container.wnds[container.wnds.length] = document.createElement('DIV');
		div.container = container;
		div.style.position = 'absolute';
		div.style.color = 'black';
		div.style.fontFamily = 'Verdana, Helvetica, Arial, sans-serif';
		div.resizemargin = 7;
		div.isIframe = isIframe;
		if(opacity)
		{
			div.style.filter = 'alpha(opacity=' + opacity + ')';
			div.style['-moz-opacity'] = '0.' + opacity;
			div.style.opacity = '0.' + opacity;
		}
		if(container.wnds.length == 1)
		{
			div.style.top = (x ? x : 50) + 'px';
			div.style.left = (y ? y : 50) + 'px';
			div.style.zIndex = container.maxZ = 10000;
		}
		else
		{
			div.style.top = (x ? x : container.wnds[container.wnds.length - 2].offsetTop + 30) + 'px';
			div.style.left = (y ? y : container.wnds[container.wnds.length - 2].offsetLeft + 30) + 'px';
			div.style.zIndex = container.maxZ++;
		}
		div.onmousemove = function(e) 
		{ 
			var evt = e ? e : event; 
			var side = ''; 
			if(evt.clientY - this.offsetTop < this.resizemargin) 
				side = 'N'; 
			if(evt.clientY - this.offsetTop - this.offsetHeight > -this.resizemargin) 
				side = 'S'; 
			if(evt.clientX - this.offsetLeft < this.resizemargin) 
				side += 'W'; 
			if(evt.clientX - this.offsetLeft - this.offsetWidth > -this.resizemargin) 
				side += 'E'; 
			if(side) 
			{ 
				this.style.cursor = side + '-resize'; 
				this.resize = { width: this.offsetWidth, height: this.offsetHeight, top: this.offsetTop, left: this.offsetLeft, mouseX: evt.clientX, mouseY: evt.clientY, side: side }; 
			} 
			else 
			{ 
				this.style.cursor = 'auto'; 
				if(this.parentNode.resize != this)
					this.resize = null; 
			}
		};
		div.onmousedown = function(e) 
		{ 
			var evt = e ? e : event; 
			this.style.zIndex = this.parentNode.maxZ++; 
			if(this.resize)
				this.parentNode.resize = this; 
			if(evt.stopPropagation) 
				evt.stopPropagation(); 
			evt.cancelBubble = true; 
			return false; 
		};
		div.set = function(html) 
		{ 
			if(this.isIframe) 
				this.cnt.src = html; 
			else 
				this.cnt.innerHTML = html; 
		};
		div.onresize = function(e) 
		{ 
			this.tdm.style.width = (this.clientWidth - this.lft.clientWidth - this.rgt.clientWidth) + 'px'; 
			this.wnd.style.width = (this.tab.clientWidth - 6) + 'px'; 
			this.wnd.style.height = (this.clientHeight - this.rgt.clientHeight) + 'px'; 
		};
		
		
			var wnd = div.wnd = document.createElement('DIV');
			wnd.style.position = 'static';
			wnd.style.overflow = 'auto';
			wnd.style.borderLeft = wnd.style.borderRight = wnd.style.borderBottom = '3px solid blue';
			wnd.style.backgroundColor = 'white';
		
				var cnt = div.cnt = document.createElement(isIframe ? 'IFRAME' : 'DIV');
				if(isIframe) cnt.src = html; else cnt.innerHTML = html;
				cnt.style.padding = (padding === undefined || padding === null ? 10 : padding) + 'px';
				if(width) cnt.style.width = width + 'px';
				if(height) cnt.style.height = height + 'px';
				div.set(html);
	
			var bar = document.createElement('DIV');
			bar.onmousedown = function(e) 
			{ 
				var evt = e ? e : event; 
				this.parentNode.style.zIndex = this.parentNode.container.maxZ++; 
				this.parentNode.container.drag = this.parentNode; 
				this.parentNode.drag = { startX: this.parentNode.offsetLeft, startY: this.parentNode.offsetTop, mouseX: evt.clientX, mouseY: evt.clientY }; 
			};
			
			
				var tab = div.tab = document.createElement('TABLE');
				tab.border = '0';
				tab.cellPadding = '0';
				tab.cellSpacing = '0';
				tab.height = '30';
				
					var tbd = document.createElement('TBODY');
					
						var trw = document.createElement('TR');
						trw.valign = 'bottom';
					
							var tdl = document.createElement('TD');
			
								var lft = div.lft = document.createElement('IMG');
								lft.src = '/images/wnd_header_left.gif';
								lft.style.cursor = 'default';
			
							var tdm = div.tdm = document.createElement('TD');
							tdm.style.backgroundImage = 'url("/images/wnd_header_bg.gif")';
							tdm.style.backgroundRepeat = 'repeat-x';
							tdm.style.backgroundPosition = 'top';
							tdm.nowrap = 'nowrap';
	
								var tit = document.createElement('DIV');
								tit.innerHTML = title;
								tit.overflow = 'hidden';
								tit.style.maxHeight = '29px';
								tit.style.color = 'white';
								tit.style.fontFamily = 'Verdana, Helvetica, Arial, sans-serif';
								tit.style.paddingLeft = '2px';
								tit.style.paddingRight = '4px';
								tit.style.paddingTop = '1px';
								tit.style.fontWeight = 'bold';
								tit.style.fontSize = '10pt';
								tit.style.cursor = 'default';
	
							var tdr = document.createElement('TD');
							
								var rgt = div.rgt = document.createElement('IMG');
								rgt.src = '/images/wnd_header_right.gif';
								rgt.style.cursor = 'pointer';
								rgt.onclick = function() 
								{ 
									this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode); 
									return false; 
								};
			
							tdl.appendChild(lft);
							tdm.appendChild(tit);
							tdr.appendChild(rgt);
						trw.appendChild(tdl);
						trw.appendChild(tdm);
						trw.appendChild(tdr);
					tbd.appendChild(trw);
				tab.appendChild(tbd);
			bar.appendChild(tab);
			wnd.appendChild(cnt);
		div.appendChild(bar);
		div.appendChild(wnd);
	container.appendChild(div);
	div.onresize();
	return div;
}

function getSibling(node)
{
	var sib = arguments[1] ? arguments[1] + 'Sibling' : 'nextSibling';
	while(node[sib])
		if(node[sib].tagName)
			return node[sib];
		else
			node = node[sib];
}

function getChildren(node)
{
	var result = [];
	for(var i = 0; i < node.childNodes.length; i++)
		if(node.childNodes[i].tagName)
			result[result.length] = node.childNodes[i];
	return result;
}

function setEvent(obj, evt, func)
{
	if(evt == 'load')
		if(!document.onload)
			document.onload = [func];
		else
			document.onload[document.onload.length] = func;
	else if(obj.addEventListener)
		obj.addEventListener(evt, func, false);
	else if (obj.attachEvent)
		obj.attachEvent('on' + evt, func);
	else if (document.getElementById)
		obj['on' + evt] = func;
}

function loadAjax(url, func, data)
{
	var obj;
	if (window.XMLHttpRequest) 
	{
		obj = new XMLHttpRequest();
	}
	else
	{
		if (window.ActiveXObject) 
		{
			obj = new ActiveXObject('MSXML2.XMLHTTP.3.0');
			if(!obj)
			{
				obj = new ActiveXObject('Microsoft.XMLHTTP');
			}
		}
	}
	if(obj)
	{
		if(!window.ajax)
			window.ajax = [obj];
		else
			window.ajax[ajax.length] = obj;
		obj.onsuccess = func;
		obj.data = data;
		obj.onreadystatechange = function()
		{
			if(obj.readyState == 4)
			{
				if(obj.status == 200)
				{
					obj.onsuccess(obj.responseXML.documentElement, obj.data);
				}
				else
				{
					debug("Problem retrieving data from the server, status code: "  + obj.status);
				}
			}
		};
		obj.open('GET', url, true);
		obj.send(null);		
	}
}


function selectOption(sel, val)
{
	if(sel.multiple)
	{
		if(typeof(val) == 'string')
			if(arguments[2])
				val = val.split(arguments[2]);
			else if(value.indexOf('|') != -1)
				val = val.split('|');
			else if(value.indexOf(';') != -1)
				val = val.split(';');
			else if(value.indexOf(',') != -1)
				val = val.split(',');
		for(var i = 0; i < sel.options.length; i++)
			for(var j = 0; j < val.length; j++)
				if(sel.options[i].value == val[j])
					sel.options[i];
	}
	else
	{
		for(var i = 0; i < sel.options.length; i++)
		{
			if(sel.options[i].value == val)
			{
				sel.selectedIndex = i;
				break;
			}
		}
	}
}

function coalesce()
{
	for(var i = 0; i < arguments.length; i++)
		if(arguments[i] != null)
			return arguments[i];
}

function getNodeText(node)
{
	return coalesce(node.textContent, node.innerText, node.text);
}

function populateForm(doc, frm)
{
	var field;
	var children;
	var value;
	var nodes = getChildren(doc);
	for(var i = 0; i < nodes.length; i++)
	{
		for(var j in frm.elements)
		{
			if(frm.elements[j] && frm.elements[j].tagName && frm.elements[j].name == nodes[i].getAttribute('name'))
			{
				field = frm.elements[j];
				children = getChildren(nodes[i]);
				value = getNodeText(nodes[i]);
				switch(field.tagName.toUpperCase())
				{
					case 'INPUT':
						field.value = value;
						break;
					case 'SELECT':
						if(field.multiple)
						{
							if(children.length)
							{
								value = [];
								for(var k = 0; k < children.length; k++)
								{
									value[k] = getNodeText(children[k]);
								}
							}
							else if(nodes[i].getAttribute('delimiter'))
							{
								value = value.split(nodes[i].getAttribute('name'));
							}
						}
						selectOption(field, value);
						break;
				}
			}
		}
	}
}

function populateSelect(doc, sel)
{
	var node = null;
	var opt = null;
	var index = 0;
	var old = typeof(sel) == 'object' ? sel : document.getElementById(sel);
	if(old.tagName.toUpperCase() == 'SELECT')
	{
		sel = old.cloneNode(false);
	}
	else
	{
		sel = document.createElement('SELECT');
		sel.id = old.id;
		sel.name = old.name;
		sel.className = old.className;
	}
	for(var i = 0; i < doc.childNodes.length; i++)
	{
		node = doc.childNodes[i];
		if(node.tagName)
		{
			opt = document.createElement('OPTION');
			opt.value = coalesce(node.getAttribute('value'), node.getAttribute('id'), node.getAttribute('ID'));
			opt.text = getNodeText(node);
			sel.options.add(opt);
			if(node.getAttribute('selected') || doc.getAttribute('selectedValue') == opt.value || doc.getAttribute('selectedIndex') == i)
			{
				sel.selectedIndex = index;
			}
			index++;
		}
	}
	old.parentNode.replaceChild(sel, old);
	return sel;
}

function populateSelectElseText(doc, sel)
{
	var old = typeof(sel) == 'object' ? sel : document.getElementById(sel);
	if(doc.childNodes.length == 0 || (doc.childNodes.length == 1 && !doc.childNodes[0].tagName))
	{
		sel = document.createElement('INPUT');
		sel.type = 'text';
		sel.id = old.id;
		sel.name = old.name;
		sel.className = old.className;
		if(old.tagName.toUpperCase() == 'INPUT')
		{
			sel.value = old.value;
		}
		old.parentNode.replaceChild(sel, old);
	}
	else
	{
		populateSelect(doc, sel);
	}
	return sel;
}

//////////////////////////////////////////////////////////////////////////////////////////////
//
// Page Specific Functions
//
//////////////////////////////////////////////////////////////////////////////////////////////


// index.php

function onMouseOverMap(area)
{
	var sel = document.forms['selectState'].elements['StateID'];
	for(var i = 0; i < sel.options.length; i++)
	{
		if(sel.options[i].text == area.alt)
		{
			sel.options[i].selected = true;
			break;
		}
	}
}

function onMouseOutMap(area)
{
	document.forms['selectState'].elements['StateID'].options[0].selected = true;
}

function clearDefaultValue(obj, val) 
{
	if (obj.value == val)
	{
		obj.value = '';
	}
}

// blog.php

function unique()
{
	var output;
	var length = 5;
	var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwhyx1234567890';
	for(var i = 0; i < length; i++)
	{
		output += chars.substr(Math.round(Math.random() * chars.length), 1);
	}
	return output;
}


// areas_popup.php

function setCallerAOP(id, frm)
{
	var names = new Array();
	for(var i = 0; i < frm.elements.length; i++)
	{
		if(frm.elements[i].tagName && frm.elements[i].tagName.toLowerCase() == 'input' && frm.elements[i].type.toLowerCase() == 'checkbox' && frm.elements[i].checked)
		{
			names[names.length] = frm.elements[i].name;
		}
	}
	window.opener.document.getElementById(id).value = names.join(', ');
}


// ask.php
/*
function validateAskLawyer(frm)
{
	var field;
	var errors = false;
	var error = {
		Name: !frm.elements.Name.value,
		Email: !frm.elements.Email.value || !/[\w\d\.-]+@[\w\d\.-]+\.\w{2,5}/.test(frm.elements.Email.value),
		Phone: !frm.elements.Phone.value || !/\(?\d{3}[\)\. -]{0,2}\d{3}[\.-]?\d{4}/.test(frm.elements.Phone.value),
		Address1: !frm.elements.Address1.value,
		City: !frm.elements.City.value,
		State: !frm.elements.State.selectedIndex,
		Zip: !frm.elements.Zip.value || !/\(?\d{5}-?\d{4}?/.test(frm.elements.Zip.value),
		Question: !frm.elements.Question.value
	};
	for(var i in error)
	{
		field = document.getElementById('Required' + i);
		alert(field);
		if(error[i])
		{
			field.className = 'error';
			field.innerHTML = '* Required';
		}
		else
		{
			field.className = '';
			field.innerHTML = '*';
		}
		errors = errors || error[i];
	}
	return !errors;
}
*/
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function validateAskLawyer(frm)
{
	var errors = false;
	var fobj = frm.elements;
	if(!fobj.Name.value) {
		alert('Please Enter Name:');
	    fobj.Name.focus();
		return errors;
	}
	if(!fobj.Email.value) {
		alert('Please Enter Email:');
	    fobj.Email.focus();
		return errors;
	}else if(!validateEmailv2(fobj.Email.value)) {
        alert('Please Enter valid Email:'); 
	    fobj.Email.focus();
		return errors;
	}
	if(!fobj.Phone.value) {
		alert('Please Enter Phone:');
	    fobj.Phone.focus();
		return errors;
	}else {
        var charpos = fobj.Phone.value.search("[^0-9]"); 
        if(fobj.Phone.value.length > 0 &&  charpos >= 0) 
        { 
               strError = fobj.Phone.name+": Only digits allowed "; 
            alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
            return errors; 
        }//if 
	}
	if(!fobj.City.value) {
		alert('Please Enter City:');
	    fobj.City.focus();
		return errors;
	}
	if(!fobj.State.selectedIndex) {
		alert('Please Select State:');
	    fobj.State.focus();
		return errors;
	}
	if(!fobj.user_code.value) {
		alert('Please Enter Image Code:');
	    fobj.user_code.focus();
		return errors;
	}
	return !errors;
}

// searchbox.php

function defaultText(obj, text)
{
	if(obj.value == text)
	{
		obj.value = '';
	}
	else if(obj.value == '')
	{
		obj.value = text;
	}
}

function setState(counties, states)
{
	code = counties.options[counties.selectedIndex].text.substr(counties.options[counties.selectedIndex].text.length - 2);
	for(var i = 1; i < states.options.length; i++)
	{
		if(code == states.options[i].value)
		{
			states.selectedIndex = i;
		}
	}
}

function changeState(cities, counties, states)
{
	loadAjax('includes/ajax.php?Data=Counties&StateID=' + states.options[states.selectedIndex].value + '&CountyID=' + counties.options[counties.selectedIndex].value, populateSelect, counties);
	loadAjax('includes/ajax.php?Data=Cities&StateID=' + states.options[states.selectedIndex].value + '&CountyID=' + counties.options[counties.selectedIndex].value + (cities.tagName.toUpperCase() == 'SELECT' ? '&CityID=' + cities.options[cities.selectedIndex].value : ''),  populateSelectElseText, cities);
}

function changeCounty(cities, counties, states)
{
	var state = '';
	var county_state = '';
	if(states.selectedIndex)
	{
		state = states.options[states.selectedIndex].value;
	}
	else if(counties.selectedIndex)
	{
		loadAjax('includes/ajax.php?Data=Counties&StateID=' + state + '&CountyID=' + counties.options[counties.selectedIndex].value, populateSelect, counties);
		loadAjax('includes/ajax.php?Data=States&CountyID=' + counties.options[counties.selectedIndex].value, populateSelect, states);
	}
	loadAjax('includes/ajax.php?Data=Cities&CountyID=' + counties.options[counties.selectedIndex].value + 'StateID=' + state, populateSelectElseText, cities);
}

// signup.php

function areaParentChanged(par, chd, sel)
{
	var index;
	loadAjax('includes/ajax.php?Data=PracticeAreas&ParentID=' + par.options[par.selectedIndex].value, function(doc, data) 
	{
		chd = populateSelect(doc, chd);
		for(var i = 0; i < sel.options.length; i++)
		{
			for(var j = 0; j < chd.options.length; j++)
			{
				if(sel.options[i].value == chd.options[j].value)
				{
					chd.options[j].selected = true;
				}
			}
		}
	});
}

function areaChildChanged(chd, sel)
{
	var index;
	for(var i = 0; i < chd.options.length; i++)
	{
		index = -1;
		for(var j = 0; j < sel.options.length; j++)
		{
			if(chd.options[i].value == sel.options[j].value)
			{
				index = j;
			}
		}
		if(chd.options[i].selected)
		{
			if(index == -1)
			{
				var opt = document.createElement('OPTION');
				opt.value = chd.options[i].value;
				opt.text = chd.options[i].text;
				opt.selected = true;
				sel.options.add(opt);
			}
		}
		else
		{
			if(index != -1)
			{
				sel.remove(index);
				//sel.removeChild(sel.options[index]);
			}
		}
	}
}

function firmSelectState(state, county, city, firm)
{
	loadAjax('includes/ajax.php?Data=Counties&StateID=' + state.options[state.selectedIndex].value, populateSelect, county);
	county.parentNode.style.display = 'block';
	city.parentNode.style.display = 'none';
	firm.parentNode.style.display = 'none';
}

function firmSelectCounty(state, county, city, firm)
{
	if(county.selectedIndex)
	{
		loadAjax('includes/ajax.php?Data=Cities&CountyID=' + county.options[county.selectedIndex].value, populateSelect, city);
		loadAjax('includes/ajax.php?Data=Firms&CountyID=' + county.options[county.selectedIndex].value, populateSelect, firm);
		city.parentNode.style.display = 'block';
		firm.parentNode.style.display = 'block';
	}
}

function firmSelectCity(state, county, city, firm)
{
	if(city.selectedIndex)
	{
		loadAjax('includes/ajax.php?Data=Firms&CityID=' + city.options[city.selectedIndex].value, populateSelect, firm);
	}
	else if(county.selectedIndex)
	{
		loadAjax('includes/ajax.php?Data=Firms&CountyID=' + county.options[county.selectedIndex].value, populateSelect, firm);
	}
	firm.parentNode.style.display = 'block';
}

function firmSelect(state, county, city, firm)
{
	loadAjax('includes/ajax.php?Data=Firm&FirmID=' + firm.options[firm.selectedIndex].value, populateForm, firm.form);
}

function addFirm(but, det, state, county, city, firm)
{
	var dis = but.name == 'SearchFirm';
	if(!det.info) det.info = {};
	if(dis)
	{
		but.value = 'Search Firms';
		state.disabled = false;
	}
	else
	{
		but.form.SearchFirm.style.display = 'inline';
		firm.parentNode.style.display = 'none';
		city.parentNode.style.display = 'none';
		county.parentNode.style.display = 'none';
		firm.selectedIndex = 0;
		city.selectedIndex = 0;
		county.selectedIndex = 0;
		state.selectedIndex = 0;
		state.disabled = true;
		but.form.SearchFirm.disabled = false;
	}
	for(var i in but.form.elements)
	{
		if(but.form.elements[i].name && but.form.elements[i].name.substr(0, 4) == 'Firm')
		{
			but.form.elements[i].disabled = dis;
			if(but.form.elements[i].tagName.toUpperCase('SELECT'))
			{
				if(dis)
				{
					det.info[i] = but.form.elements[i].selectedIndex;
					but.form.elements[i].selectedIndex = 0;
				}
				else
				{
					but.form.elements[i].selectedIndex = det.info[i] === undefined ? 0 : det.info[i];
				}
			}
			else if(but.form.elements[i].tagName.toUpperCase('INPUT') || but.form.elements[i].tagName.toUpperCase('HIDDEN'))
			{
				if(dis)
				{
					det.info[i] = but.form.elements[i].value;
					but.form.elements[i].value = '';
				}
				else
				{
					but.form.elements[i].value = det.info[i] === undefined ? '' : det.info[i];
				}
			}
		}
	}
}

function validateSignup(frm)
{
	var field;
	var errors = false;
	var error = {
		LawyerName: !frm.elements.LawyerName.value,
		LawyerEmail: !frm.elements.LawyerEmail.value || !/[\w\d\.-]+@[\w\d\.-]+\.\w{2,5}/.test(frm.elements.LawyerEmail.value)
	};
	if(!frm.elements.FirmAddressID.value)
	{
		error.FirmName = !frm.elements.FirmName.value;
		error.FirmEmail = !frm.elements.FirmEmail.value || !/[\w\d\.-]+@[\w\d\.-]+\.\w{2,5}/.test(frm.elements.FirmEmail.value);
		error.FirmPhone = !frm.elements.FirmPhone.value || !/\(?\d{3}[\)\. -]{0,2}\d{3}[\.-]?\d{4}/.test(frm.elements.FirmPhone.value);
		error.FirmAddress1 = !frm.elements.FirmAddress1.value;
		error.FirmCity = !frm.elements.FirmCity.value;
		error.FirmState = !frm.elements.FirmState.selectedIndex;
		error.FirmZip = !frm.elements.FirmZip.value || !/^\d{5}$|^\d{5}-?\d{4}$/.test(frm.elements.FirmZip.value);
	}
	for(var i in error)
	{
		field = document.getElementById('Required' + i);
		if(error[i])
		{
			field.className = 'error';
			field.innerHTML = '* Required';
		}
		else
		{
			field.className = '';
			field.innerHTML = '*';
		}
		errors = errors || error[i];
	}
	if(!errors)
	{
		frm.elements['PracticeAreaID[]'].disabled = false;
	}
	return !errors;
}