// JavaScript Document

/*------------------------------ GENERAL SCRIPTS -----------------------------------------*/
function confTest(){
	var resp=getXML('act=3','_processAjax.cfm');
	var chk=resp.getElementsByTagName('success')[0].firstChild.data;
	if (chk!='true'){
		document.getElementById('response').innerHTML=resp;
		if (confirm("An error occurred while attempting to retrieve your test data. To try again, click 'OK'. If this problem persists, please click 'Cancel' and  contact Big Giant Media for assistance.")) obj.focus();
	}
	var numBlank=parseInt(resp.getElementsByTagName('unans')[0].firstChild.data);
	var msg='';
	if (numBlank>0) {
		msg='We see that you have left ' + numBlank + ' questions unanswered. ';
	}
	msg=msg+'You are only allowed to submit your test for grading one time. Before continuing, please confirm that you have answered all questions to the best of your ability. If you are certain you are ready to submit your test, click "OK" below. Click "Cancel" to return to your test to check your answers.'
	return confirm(msg);
}

function displayPR(objNum){
	var objStat=document.getElementById('pr'+objNum).style.display;
	var switchStat=document.getElementById('PRswitch'+objNum).innerHTML;
	document.getElementById('pr'+objNum).style.display=objStat=='block'?'none':'block';
	document.getElementById('PRswitch'+objNum).innerHTML=switchStat=='[ CLOSE ]'?'[ VIEW ]':'[ CLOSE ]';
}


function save(obj,lineNum,userID){
	var ans=document.getElementById('answers').value;
	var ansArray=ans.split('')
	ansArray.splice(lineNum-1,1,obj.value);
	var ans=ansArray.join('');
	document.getElementById('answers').value=ans;
	var resp=getXML('act=2&user='+userID+'&ans='+ans,'_processAjax.cfm');
	var chk=resp.getElementsByTagName('success')[0].firstChild.data;
	if (chk!='true'){
		if (confirm("An error occurred while attempting to save your answer. To try again, click 'OK'. If this problem persists, please click 'Cancel' and contact Accent on Parenting for assistance.")) obj.focus();
	}
}

function setupNav2(){
	var links=document.getElementById('nav').getElementsByTagName('a');
	for (i=0;i<links.length;i++){
		var thisPage=(document.URL==links[i].href || document.URL==links[i].href.replace(/index.cfm/g,''));
		if ((thisPage && links[i].parentNode.parentNode.id=='nav')) {
			//links[i].style.backgroundImage='url(images/btn-bckgrdOver.jpg)';
			links[i].style.color='#64137e';
		}
		if (document.URL.indexOf('parenting-books')!=-1 || document.URL.indexOf('parenting-order.cfm')!=-1){
			//document.getElementById('btnOrders').style.backgroundImage='url(images/btn-bckgrdOver.jpg)';
			document.getElementById('btnOrders').style.color='#64137e';
		}
	}
}

function setShipToName(){
	with (document.orderForm){
		shipToName.value=(firstName.value!=''?firstName.value+' ':'') + lastName.value;
	}
}

function updateDR(){
	if (document.getElementById('err')) document.getElementById('err').parentNode.style.display='none';
	var resp=getXML('act=1','_processAjax.cfm');
	var chk=resp.getElementsByTagName('success')[0].firstChild.data;
	if (chk!='true'){
		document.getElementById('response').innerHTML=resp;
		if (confirm("An error occurred while attempting to save your data. To try again, click 'OK'. If this problem persists, please click 'Cancel' and  contact Big Giant Media for assistance.")) obj.focus();
	}
	document.getElementById('numDR').innerHTML=parseInt(resp.getElementsByTagName('DR')[0].firstChild.data);
}

function useShip(){
	with (document.orderForm){
		if (useShipping.checked==true){
			address1.value=SHIPTOSTREET.value;
			address2.value=SHIPTOSTREET2.value;
			city.value=SHIPTOCITY.value;
			state.value=SHIPTOSTATE.value;
			zip.value=SHIPTOZIP.value;
		} else {
			address1.value='';
			address2.value='';
			city.value='';
			state.value='';
			zip.value='';
		}
	}
}

/*-------------------------------START IT ALL SCRIPT --------------------------------*/

var isLTIE7=false;

function setup(){
	ieVer=parseInt(navigator.appVersion.split("MSIE")[1]);
	isLTIE7=(ieVer<7);
	if (ieVer<7) replacePNG();
	//timer();
	//if (document.getElementById('content').offsetHeight<(document.body.clientHeight-280)){
	//	document.getElementById('content').style.height=(document.body.clientHeight-280)+'px';
	//}
	if (document.getElementById('nav')) {
		setupNav(document.getElementById('nav')); 
		setupNav2();
		setInterval('animate()',20);
	}
	//setInterval('timer()',992);
	makeCorners(document);
	makeDateFields(document);
	activateComboBox();
	//initAjax();
	headlines(document);
	//printNum();
}

window.onload=setup;

/*-------------------------CUSTOM HEADLINE SCRIPT ------------------------------------------*/

var charWidth5=new Array(12,10,10,14,11,16,16,7,10,10,10,12,9,9,9,10,17,10,13,15,15,15,13,15,16,14,9,9,10,12,10,15,18,15,15,16,16,14,13,17,16,10,13,16,12,18,16,17,15,17,16,13,14,17,16,20,15,15,15,9,11,9,12,15,6,14,14,13,13,12,11,14,13,7,9,12,8,18,13,13,13,14,11,11,10,13,13,17,12,14,11,11,8,11,11)

var charStart5=new Array(0,12,22,32,46,57,73,89,96,106,116,126,138,147,156,165,175,192,202,215,230,245,260,273,288,304,318,327,336,346,358,368,383,401,416,431,447,463,477,490,507,523,533,546,562,574,592,608,625,640,657,673,686,700,717,733,753,768,783,798,807,818,827,839,854,860,874,888,901,914,926,937,951,964,971,980,992,1000,1018,1031,1044,1057,1071,1082,1093,1103,1116,1129,1146,1158,1172,1183,1194,1202,1213,1224)

var charHt5=21;


function headlines(obj){
	for (k=5;k<6;k++){
		var hs=obj.getElementsByTagName('h'+k);
		for (i=0;i<hs.length;i++){
			var str=hs[i].innerHTML;
			var divWd=0;
			hs[i].innerHTML='';
			var frameAlpha=document.createElement('div');
			for (j=0;j<str.length;j++){
				var arrIndex=str.charCodeAt(j)-32;
				divWd+=eval('charWidth'+k+'['+arrIndex+']');
				var divAlpha=document.createElement('div');
				divAlpha.style.position='relative';
				divAlpha.style.height=eval('charHt'+k)+'px';
				divAlpha.style.width=eval('charWidth'+k+'['+arrIndex+']')+'px';
				divAlpha.style.marginLeft='-3px';
				divAlpha.style.cssFloat='left';
				divAlpha.style.styleFloat='left';
				divAlpha.style.backgroundImage='url(images/alpha' + k + '.gif)'
				divAlpha.style.backgroundRepeat='no-repeat';
				divAlpha.style.backgroundPosition=(-eval('charStart'+k+'['+arrIndex+']'))+'px top'; 
				frameAlpha.appendChild(divAlpha);
			}
			frameAlpha.style.height=eval('charHt'+k)+'px';
			frameAlpha.style.width=divWd+'px';
			hs[i].appendChild(frameAlpha);
			hs[i].style.visibility='visible';
		}
	}
}

		var cumsum=0; /*------------ NEEDED FOR ARRAY CREATION ONLY -------------------*/
		function printNum(){
			for (k=0;k<charWidth1.length;k++){
				cumsum=cumsum+charWidth1[k];
				document.getElementById('response').innerHTML=document.getElementById('response').innerHTML+','+cumsum;
			}
		}

/*------------------------------------AJAX FUNCTIONS---------------------------------------*/

if (window.ActiveXObject) {
	var srvrConnect=new ActiveXObject('Microsoft.XMLHTTP');
} else if (window.XMLHttpRequest) {
	var srvrConnect=new XMLHttpRequest();
}

function initAjax(){
	var inputs=document.getElementsByTagName('input');
	for (i=0;i<inputs.length;i++){
		if (inputs[i].getAttribute&&inputs[i].getAttribute('ajaxEnable')!=null){
			switch(inputs[i].getAttribute('ajaxEnable')){
				case "num": 
					inputs[i].onblur=function(){doAjax(this,1)}
				break
				case "date":
					inputs[i].onblur=function(){if(confDate(this,this.value)) doAjax(this,1)}
				break
				case "radio":
					inputs[i].onchange=function(){doAjax(this,1)}
				break
				default:
					inputs[i].onblur=function(){doAjax(this,1)}
			}
		}
	}
	var inputs=document.getElementsByTagName('textarea');
	for (i=0;i<inputs.length;i++){
		if (inputs[i].getAttribute&&inputs[i].getAttribute('ajaxEnable')!=null){
			inputs[i].onblur=function(){doAjax(this,1)};
		}
	}
	var inputs=document.getElementsByTagName('select');
	for (i=0;i<inputs.length;i++){
		if (inputs[i].getAttribute&&inputs[i].getAttribute('ajaxEnable')!=null){
			inputs[i].onblur=function(){doAjax(this,1)}
		}
	}
}

function ajaxSave(obj){
		str='act=1&field=' + obj.name + '&value=' + obj.value;
		srvrConnect.open('post','_processAjax.cfm',0);
		srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		srvrConnect.send(str);
		document.getElementById('response').innerHTML=srvrConnect.responseText;
}

function doAjax(obj,act){
	var sendStr='act='+act+'&field='+obj.name+'&value='+escape(obj.value);
	var resp=getXML(sendStr,'_processAjax.cfm');
	//crawlXML(resp);
	var chk=resp.getElementsByTagName('success')[0].firstChild.data;
	if (chk!='true'){
		document.getElementById('response').innerHTML=resp;
		if (confirm("An error occurred while attempting to save your data. To try again, click 'OK'. If this problem persists, please click 'Cancel' and  contact Big Giant Media for assistance.")) obj.focus();
	}
}

function getXML(sendStr,template){
	srvrConnect.open('post',template,0);
	srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	srvrConnect.send(sendStr);
	//alert(srvrConnect.responseText);
	//document.getElementById('response').innerHTML=srvrConnect.responseText;
	var resp=srvrConnect.responseXML;
	var notWhitespace = /\S/
	var xmlData=resp.getElementsByTagName('data')[0];
	//REMOVE white spaces in XML file. Intended mainly for NS6/Mozilla
	try {
		for (i=0;i<xmlData.childNodes.length;i++){
			if ((xmlData.childNodes[i].nodeType == 3)&&(!notWhitespace.test(xmlData.childNodes[i].nodeValue))) {
				// that is, if it's a whitespace text node
				xmlData.removeChild(xmlData.childNodes[i])
				i--
			}
		}
		return xmlData;
	} catch(err) {
		document.getElementById('response').innerHTML=srvrConnect.responseText;
		var xml=document.createDocumentFragment();
		var node=xml.createElement('success');
		xml.appendChild(node);
		var contents=xml.createTextNode('false');
		node.appendChild(contents);
	 	return xml;
	}
}

			var _xmlStr;	
			function crawlXML(doc) {   /* -----PARSES AND DISPLAYS XML DOCUMENT AS UNORDERED LIST  - FOR DEBUGGING -----*/
				if(doc.hasChildNodes()) {  
					_xmlStr+='<ul><li>'+doc.tagName+'> ';       
					for(var i=0; i<doc.childNodes.length; i++) {   
					crawlXML(doc.childNodes[i]);                
					}                                              
					_xmlStr+='</li></ul>';                         
				} else {                                          
					_xmlStr+=doc.nodeValue;                        
				}                                                 
			document.getElementById('response').innerHTML=_xmlStr;	
			} 


/*------------------------------GENERIC FORM VALIDATION SCRIPT----------------------------------------*/

function val(obj){
	var inputs=obj.getElementsByTagName('input');
	for (ind=0;ind<inputs.length;ind++){
	  if (inputs[ind].getAttribute&&inputs[ind].getAttribute('required')!=null&&(inputs[ind].value==''||inputs[ind].value=='Value Needed')){
		alert('You omitted a required value. We will take you to the empty field. Please supply a response and submit again');
		inputs[ind].value='Value Needed';
		inputs[ind].select();
		inputs[ind].focus();
		return false;
	  }
	  
	  // ------------ REQUIRES INPUT FIELD TYPE OF "EMAIL" ------------------//
	  
	  if (inputs[ind].getAttribute&&inputs[ind].getAttribute('type')=='email'&&inputs[ind].value!=''){
	  	if (inputs[ind].value.substr(0,1)=='@' || inputs[ind].value.indexOf('@.')!=-1 || inputs[ind].value.replace(/[^@]/g,'')!='@'){
			alert('Email address is incorrectly formatted.');
			inputs[ind].select();
			inputs[ind].focus();
			return false;
		} else {
			var emailStrip=inputs[ind].value.replace(/\w/g,'').split('@');
			if (emailStrip[0].replace(/\./g,'').length>0 || emailStrip[1]!='.'){
				alert('Email address is incorrectly formatted.');
				inputs[ind].select();
				inputs[ind].focus();
				return false;
			}
		}
	  }

	  // ------------ REQUIRES INPUT FIELD NAMES OF USER_PASSWORD AND CONFIRM_PASSWORD ------------------//
	  
	  if (inputs[ind].id=='loginPassword' && inputs[ind].value!=document.getElementById('confirmPassword').value){
	  	alert('Password entries do not match');
		inputs[ind].select();
		inputs[ind].focus();
		return false;
	  }
	  
	  // ------------------------END SPECIAL MOD--------------------//
	  
	}
	
	var inputs=obj.getElementsByTagName('select');
	for (ind=0;ind<inputs.length;ind++){
	  if (inputs[ind].getAttribute&&inputs[ind].getAttribute('required')!=null&&inputs[ind].value==''){
		alert('You omitted a required value. We will take you to the empty field. Please supply a response and submit again');
		inputs[ind].focus();
		return false;
	  }
	}
	var inputs=obj.getElementsByTagName('textarea');
	for (ind=0;ind<inputs.length;ind++){
	  if (inputs[ind].getAttribute&&inputs[ind].getAttribute('required')!=null&&(inputs[ind].value==''||inputs[ind].value=='Value Needed')){
		alert('You omitted a required value. We will take you to the empty field. Please supply a response and submit again');
		inputs[ind].value='Value Needed';
		inputs[ind].select();
		inputs[ind].focus();
		return false;
	  }
	}
	document.orderForm.processPayment.style.display='none';
	document.getElementById('processing').style.display='block';
}

/*------------------------------TRANSPARENT PNG REPLACEMENT FOR <IE7 ----------*/

function replacePNG(){
	var xPNG=document.images;
	for (i=0;i<xPNG.length;i++){
		if (xPNG[i].src.toLowerCase().indexOf('.png')!=-1) {
			var file=xPNG[i].src;
			xPNG[i].src='images/1x1.gif';
			xPNG[i].style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+file+'", sizingMethod="image")';
		}
	}
}

/*------------------------------ZOOM OVERLAY SCRIPT -------------------------*/

var pdfAdder=0; 

function getZoom(url,action){
	pdfAdder=url.indexOf('.pdf')==-1?0:30;
	var size=openOverlay();
	document.getElementById('rolodex').setAttribute('corners','round,0,#CCCCFF,8,0.90');
	makeCorners(document.getElementById('rolodex'));
	var ifr=document.createElement('iframe');
	ifr.frameBorder='0';
	ifr.style.width=size[0]+'px';
	ifr.style.height=size[1]+'px';
	//if (url.indexOf('http://')==-1&&url.indexOf('_returnDetails.cfm?id=')==-1) url='http://'+url;
	ifr.src=url;
	ifr.id='newFrame';
	ifr.name='newFrame';
	document.getElementById('rolodex').insertBefore(ifr,document.getElementById('rolodex').firstChild);
	
	var closer=document.createElement('div');
	
	var button=document.createElement('input');
	button.type='button';
	button.className='noPrint';
	button.value='X';
	button.style.border='2px outset white';
	button.style.backgroundColor='#990000';
	button.style.color='white';
	button.style.fontWeight='bold';
	button.style.height='20px';
	button.style.fontSize='8pt';
	button.style.padding='0px 2px';
	button.id='histCloser';
	button.style.position='absolute';
	button.style.left=(size[0]-20)+'px';
	button.style.top='-23px';
	button.onclick=function(){showLess(this.parentNode.parentNode.parentNode,'updateSummary')};

	var button2=document.createElement('input');
	button2.type='button';
	button2.value='Print';
	button2.id='histPrinter';
	button2.style.styleFloat='left';
	button2.style.cssFloat='left';
	button2.style.display='none';
	button2.onclick=function(){printHist()};

	var button3=document.createElement('input');
	button3.type='button';
	button3.value='Create PDF';
	button3.id='makePDF';
	button3.style.styleFloat='left';
	button3.style.cssFloat='left';
	button3.style.display='none';
	button3.onclick=function(){createPDF()};

	var button5=document.createElement('input');
	button5.type='button';
	button5.value='Go to Lounge';
	button5.style.width='90px';
	button5.style.marginRight='10px';

	button5.id='last';
	button5.style.display='none';
	button5.onclick=function(){window.newFrame.document.location.href='module-lounge.cfm'};

	var button6=document.createElement('input');
	button6.type='image';
	button6.src='images/button-forward.gif';
	button6.value='Forward';
	button6.id='next';
	button6.style.display='none';
	button6.onclick=function(){window.newFrame.history.forward()};


	if (url.indexOf('.pdf')==-1){
		closer.style.position='relative';
	} else {
		closer.style.position='relative';
	}
	
	closer.style.top='0px';
	closer.id='closerHolder';
	closer.style.left='0px';
	closer.style.backgroundColor='transparent';
	closer.style.border='none';
	closer.style.padding='0px';
	closer.style.textAlign='left';
	closer.style.position='relative';
	
	closer.appendChild(button5);
	closer.appendChild(button6);
	closer.appendChild(button);
	closer.appendChild(button3);
	closer.appendChild(button2);

	//if (action!='register') {button5.style.display='inline';}
	//if (action=='makePDF'||action=='makeCalendar') button3.style.display='inline';
	//if (action=='makeCalendar') button4.style.display='inline';

	document.getElementById('rolodex').insertBefore(closer,document.getElementById('rolodex').firstChild);

}

			function openOverlay(){
					if (window.pageYOffset) prevScroll=window.pageYOffset;
			
					document.documentElement.style.overflow='hidden';
					window.scrollBy(0,1);
					if (document.documentElement.scrollTop==0){
						document.body.style.overflow='hidden';
					}
			
					var w=document.documentElement.clientWidth;
					var h=document.documentElement.clientHeight;
					if (h==0) h=document.body.clientHeight;
					if (w==0) w=document.body.clientWidth;
			
					var card=document.createElement('div');
					card.id='rolodex';
					with (card.style){
						overflow='visible';
						backgroundColor='white';
						border='1px #C9DA2A solid';
						borderWidth='25px 5px 5px 5px';
						position= 'absolute';
						zIndex=25;
						width = Math.max((w-250),750) + 'px';
						height=(h<600?h-50:h-150) + pdfAdder + 'px';
						top=(window.pageYOffset ? (window.pageYOffset) : (document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop))+(h/2-((parseInt(height)+30)/2))+'px';
						left=Math.max((w/2-(parseInt(width)+20)/2),0)+'px';
					}
					var size=new Array()
					size[0]=card.style.width.replace(/px/,'');
					size[1]=card.style.height.replace(/px/,'');
					
					var screener=document.createElement('div');
					screener.id='screen2';
					with (screener.style){
						position='absolute';
						top=(window.pageYOffset ? (window.pageYOffset) : (document.documentElement.scrollTop!=0?document.documentElement.scrollTop:document.body.scrollTop))+'px'
						left='0px';
						width=w+30+'px';
						height=h+10+'px';;
						filter='alpha(opacity=60)';
						opacity='0.60';
						backgroundColor='black';
						display='block';
						zIndex=20;
					}
					
					document.body.insertBefore(card,document.body.firstChild);
			
					document.body.insertBefore(screener,document.getElementById('rolodex'));
					setTimeout('setResize()',1000);
					return size;
			}
			
			function setResize(){
					window.onresize=function(){showLess(document.body.firstChild.nextSibling)};	
			}
			
			function showLess(obj,action){
					window.onresize=null;
					document.body.removeChild(obj);
					if (document.getElementById('screen2')) document.body.removeChild(document.getElementById('screen2'))
					document.documentElement.style.overflow='auto';
					window.scrollBy(0,1);
					if (document.documentElement.scrollTop==0){
						document.body.style.overflow='auto';
					}
					
					if (typeof prevScroll!='undefined' && prevScroll!=0) window.scrollTo(0,prevScroll);
					
					
			}

function printHist(){
	window.top.frames[0].focus();
	window.top.frames[0].print();
}
function createPDF(){
	window.top.frames[0].document.workOrder.submit();
}
function showButtons(){
	window.top.document.getElementById('showCalendar').style.display='inline';
}


/* -------------------------------SEARCHED WORD HIGHLIGHT FUNCTIONS -------------------------------*/

function highlightWord(node,word) {
  // Iterate into this nodes childNodes
  if (node.hasChildNodes) {
    var hi_cn;
    for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
      highlightWord(node.childNodes[hi_cn],word);
    }
  }

  // And do this node itself
  if (node.nodeType == 3) { // text node
    tempNodeVal = node.nodeValue.toLowerCase();
    tempWordVal = word.toLowerCase();
    if (tempNodeVal.indexOf(tempWordVal) != -1) {
      pn = node.parentNode;
      if (pn.className != "searchword") {
        // word has not already been highlighted!
        nv = node.nodeValue;
        ni = tempNodeVal.indexOf(tempWordVal);
        // Create a load of replacement nodes
        before = document.createTextNode(nv.substr(0,ni));
        docWordVal = nv.substr(ni,word.length);
        after = document.createTextNode(nv.substr(ni+word.length));
        hiwordtext = document.createTextNode(docWordVal);
        hiword = document.createElement("span");
        hiword.className = "searchword";
        hiword.appendChild(hiwordtext);
        pn.insertBefore(before,node);
        pn.insertBefore(hiword,node);
        pn.insertBefore(after,node);
        pn.removeChild(node);
      }
    }
  }
}


/*-----------------------NAV SCRIPT ------------------------*/

var shadows=true;
var primaryVertOffset=37;
var secondaryVertOffset=-2;
//var horizontalOffset=-274;      /* MUST BE GREATER THAN -(WIDTH OF BUTtON) FOR FIREFOX/OPERA*/
var secondaryHorizontalOffset=0;
var alpha=100;

var colors=new Array('#e1e1e1','#c2c2c2','#999999','#666666','#3e3e3e','#1f1f1f','#0b0b0b')

function setupNav(nav){
	var links=nav.getElementsByTagName('a');
	var lis=nav.getElementsByTagName('li');
	for (n=0;n<links.length;n++){
		links[n].innerHTML=links[n].innerHTML.replace(/ /g,'&nbsp;');
	}
	var uls=nav.getElementsByTagName('ul');
	nav.style.marginLeft=(990-nav.offsetWidth)/2+'px';
	nav.style.visibility='visible';
	//navWidth=links[0].offsetWidth;
	//navWidth=275;

	flyouts=new Object();
	closers=new Object();
	tmr=new Object();
	for (m=0;m<uls.length;m++){
	
		var theseLinks=uls[m].getElementsByTagName('a');
		var theseLis=uls[m].getElementsByTagName('li');
		uls[m].style.width=0;
		for (y=0;y<theseLinks.length;y++){
			uls[m].style.width=Math.max(parseInt(uls[m].style.width),parseInt(theseLinks[y].offsetWidth))+'px';
		}
		for (y=0;y<theseLinks.length;y++){
			theseLinks[y].style.width=parseInt(uls[m].style.width)-22+'px'; //change value depending on borders and padding set for ul li ul li a
			theseLis[y].style.width=parseInt(uls[m].style.width)+'px';
		}
		
		var navWidth=parseInt(uls[m].offsetWidth);
		if (uls[m].parentNode.parentNode.id=='nav') {
			uls[m].style.top=primaryVertOffset+'px';
			uls[m].style.marginLeft=-(parseInt(uls[m].style.width))+'px';
		} else {
			uls[m].style.top=secondaryVertOffset+'px';
			uls[m].style.marginLeft=secondaryHorizontalOffset+'px';
		}
		uls[m].id=m;
		// shadow stuff start
		if (shadows){
		
			if (document.all && !window.opera){
				a=document.createElement('div');
				a.style.width=(navWidth-3)+'px'
				a.style.height=(uls[m].offsetHeight-4)+'px'
				a.style.filter='progid:DXImageTransform.Microsoft.Blur(PixelRadius="4", MakeShadow="true", ShadowOpacity="0.30")';
				a.style.position='absolute';
				a.style.top='2px';
				a.style.left='2px';
				a.style.border='0px solid  black';
				a.style.backgroundColor='black';
				uls[m].insertBefore(a,uls[m].firstChild);
						
			}else{
					
				for (n=0;n<7;n++){
					a=document.createElement('div');
					a.style.width=navWidth+'px';
					a.style.top=n+'px';
					a.style.left=n+'px';
					a.style.height=uls[m].offsetHeight+'px';
					a.style.position='absolute';
					a.style.border='1px solid #777777';
					a.style.borderWidth='0px 1px 1px 0px';
					a.style.position='absolute';
					if (window.opera &&parseInt(window.opera.version())<9) 	a.style.borderColor=colors[6-n];
					a.style.filter='alpha(opacity='+((7-n)*10+n)+')';
					a.style['opacity']=((7-n)/10+n/100);
					a.style['-moz-opacity']=(7-n)/10+n/100;
					a.style['-khtml-opacity']=(7-n)/10+n/100;
					uls[m].insertBefore(a,uls[m].firstChild);
				}
			}
		}
		// shadow stuff end
	}
	for (o=0;o<lis.length;o++){
			lis[o].style.zIndex=lis.length-o;	
	}
	for (i=0;i<links.length;i++){
			if (links[i].parentNode.parentNode.id!='nav'){
				//links[i].style.filter='alpha(opacity='+alpha+')';
				links[i].style['opacity']=alpha/100;
				links[i].style['-moz-opacity']=alpha/100;
				links[i].style['-khtml-opacity']=alpha/100;
			}
			links[i].onmouseover=function(){showSub(this)};
			links[i].onmouseout=function(){hideSub(this)};
			links[i].onfocus=function(){this.blur()};
			if (links[i].href.indexOf('#')!=links[i].href.length-1){
				links[i].onclick=function(){hideSub(this)};
			} else {
				links[i].onclick=function(){return false};
			}	
	}
}

function showSub(prime){ 
	var obj=prime;
	var sub=prime.parentNode.getElementsByTagName('ul');
	while (obj.id!='nav'){
		if (obj.tagName.toLowerCase()=='ul' && tmr[obj.id]) clearTimeout(tmr[obj.id]);
		obj=obj.parentNode;
	}
	if (sub.length>0){
		if (tmr[sub[0].id]) clearTimeout(tmr[sub[0].id]);
		flyouts[sub[0].id]=sub[0];
	}
}

function hideSub(prime){
	var sub=prime.parentNode.getElementsByTagName('ul');
	if (sub.length>0){
		  tmr[sub[0].id]=setTimeout('delete flyouts['+sub[0].id+'];closers['+sub[0].id+']='+sub[0].id,250);
	}
	var obj=prime;
	while (obj.id!='nav'){
			if (obj.tagName.toLowerCase()=='ul'){
		 	  tmr[obj.id]=setTimeout('delete flyouts['+obj.id+'];closers['+obj.id+']='+obj.id,250);
			}
			obj=obj.parentNode;
	}
}

function animate(){
	for (j in flyouts){
		delete closers[j];
		var curValue=(isNaN(curValue=parseInt(flyouts[j].style.left))?0:curValue);
		var navWidth=flyouts[j].offsetWidth;
		if(curValue<navWidth) {
				flyouts[j].style.left=(curValue+Math.ceil((navWidth-curValue)/2))+'px';
				flyouts[j].style.clip='rect(0px 2500px 2500px ' + (navWidth-curValue-2)+ 'px)';
		} else {
				delete flyouts[j];
		}
	}
	for (k in closers){
		var curUL=document.getElementById(closers[k]);
		var curValue2=parseInt(curUL.style.left);
		var navWidth=curUL.offsetWidth;
		if(curValue2>0) {
				curUL.style.left=(curValue2=curValue2-Math.ceil(curValue2/2))+'px';
				curUL.style.clip='rect(0px 2500px 2500px ' + (navWidth-curValue2)+ 'px)';
		} else {
			if (shadows) curUL.style.clip='rect(0px 2500px 2500px ' + (navWidth-curValue2+8)+ 'px)';
			delete closers[k];
		}
	}
}


/*-------------------------------CLOCK SCRIPT --------------------------------*/

var month=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var timeFlag=false;
	
function timer(){
	document.getElementById('timeHolder').innerHTML=calcTime();
}

function calcTime(){
	var now=new Date();
	var seconds=now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds();
	var minutes=now.getMinutes()<10?'0'+now.getMinutes():now.getMinutes();
	var timeStr=now.getHours()>11?((now.getHours()==12?12:now.getHours()-12))+':'+minutes+':'+seconds+' PM':(now.getHours()==0?12:now.getHours())+':'+minutes+':'+seconds+' AM';
	var dayStr=month[now.getMonth()]+' '+now.getDate()+', '+now.getFullYear();
	return dayStr  + ' - '+ timeStr;
}

/*------------------------------- ROUNDED CORNERS AND DROPSHADOW ROUTINE -------------*/

	function makeCorners(node){
	
		if (node.hasChildNodes) {
				var iteration;
				for (iteration=0;iteration<node.childNodes.length;iteration++) {
					makeCorners(node.childNodes[iteration]);
				}
		}
		  
  // format for ATTRIBUTE: corners="round,[radius (0 if none)],[color (0 if background or none)],[shadowOffset (0 if none)],[shadowOpacity (0-1)]"
  // ex: corners=round,10,#000FFF,10,0.50"
		  
		if (node.getAttribute&&(sty=node.getAttribute('corners'))){
		   
			var selectBoxes=node.getElementsByTagName('select');
			var tempStorage=new Array();
			for (xx=0;xx<selectBoxes.length;xx++){
				tempStorage[selectBoxes[xx].name]=selectBoxes[xx].selectedIndex
			}			

			var arrSty=sty.split(',');
			sty=arrSty[0];
			cornerRadius=parseInt(arrSty[1]);
			shadowOffset=parseInt(arrSty[3]);
			shadowOpacity=arrSty[4];
			
			var n=node;
			
			if (arrSty[2]!=0) {
				borderColor=arrSty[2];
			} else {
				borderColor=n.style.backgroundColor;
			}
						
			if (parseInt(n.offsetWidth)!=0){  

				elWidth=n.offsetWidth;
				elHeight=n.offsetHeight;
				
			} else {  //ROUTINE TO DETERMINE SIZE OF display:none ELEMENTS
			
				var elTemp=document.createElement('div');
				elTemp.style.position='absolute';
				elTemp.style.visibility='hidden';
				document.body.insertBefore(elTemp,document.body.firstChild);
				nodeTemp=n.cloneNode(true);
				elTemp.appendChild(nodeTemp);
				elWidth=nodeTemp.offsetWidth;
				elHeight=nodeTemp.offsetHeight;
				elTemp.parentNode.removeChild(elTemp);
			
			}
			
			var newDiv=document.createElement('div');
			newDiv.style.zIndex=n.style.zIndex;
			newDiv.style.width=elWidth+(!document.all?0:0)+'px';
			newDiv.style.styleFloat=n.style.styleFloat;
			newDiv.style.cssFloat=n.style.cssFloat;
			newDiv.style.marginLeft=n.style.marginLeft;
			newDiv.style.marginRight=n.style.marginRight;
			newDiv.style.marginTop=n.style.marginTop;
			newDiv.style.marginBottom=n.style.marginBottom;
			newDiv.style.position=n.style.position==''?'relative':n.style.position;
			newDiv.style.top=n.style.top;
			newDiv.style.left=n.style.left;

			if (sty=='round' && cornerRadius!=0){
			
				var topCorners=document.createElement('div');
				var bottomCorners=document.createElement('div');
				
				for (i=cornerRadius;i>0;i--){
					var newLine=document.createElement('div');
					newLine.style.height='1px';
					newLine.style.overflow='hidden';
					newLine.style.position='relative';
					newLine.style.zIndex='10';
					var mrgn=cornerRadius-Math.cos(Math.asin(i/cornerRadius))*cornerRadius;
					newLine.style.margin='0px ' + mrgn + 'px';
					newLine.style.backgroundColor=borderColor;
					topCorners.appendChild(newLine);	
				}
				newDiv.appendChild(topCorners);	
				
				var orig=n.cloneNode(true);
				orig.style.position='relative';
				orig.style.top='0px';
				orig.style.left='0px';
				orig.style.marginLeft='0px';
				orig.style.marginRight='0px';
				orig.style.marginTop='0px';
				orig.style.marginBottom='0px';
				orig.style.cssFloat='';
				orig.style.styleFloat='';
				newDiv.appendChild(orig);
				
				for (i=1;i<=cornerRadius;i++){
					var newLine=document.createElement('div');
					newLine.style.height='1px';
					newLine.style.overflow='hidden';
					newLine.style.position='relative';
					var mrgn=cornerRadius-Math.cos(Math.asin(i/cornerRadius))*cornerRadius;
					newLine.style.margin='0px ' + mrgn + 'px';
					newLine.style.backgroundColor=borderColor;
					bottomCorners.appendChild(newLine);	
				}
				newDiv.appendChild(bottomCorners);	
			
			} else {
			
				var orig=n.cloneNode(true);
				orig.style.position='relative';
				orig.style.top='0px';
				orig.style.left='0px';
				orig.style.marginLeft='0px';
				orig.style.marginRight='0px';
				orig.style.marginTop='0px';
				orig.style.marginBottom='0px';
				orig.style.cssFloat='';
				orig.style.styleFloat='';
				newDiv.appendChild(orig);
				
			}

			n.parentNode.replaceChild(newDiv,n);
				
			var selectBoxes=newDiv.getElementsByTagName('select');
			for (xx=0;xx<selectBoxes.length;xx++){
				selectBoxes[xx].selectedIndex=tempStorage[selectBoxes[xx].name]
			}	
					
			if (shadowOffset!=0){
			
				
				if (orig.style.backgroundColor!='' && orig.style.backgroundColor!='transparent'){
					var shad=document.createElement('div');
					shad.style.width=elWidth+'px';
					var contentBox=document.createElement('div');
					contentBox.style.height=elHeight+'px';
					contentBox.style.width=elWidth+'px';
					contentBox.style.backgroundColor='#000000';
					if (topCorners) shad.appendChild(topCorners.cloneNode(true));
					shad.appendChild(contentBox);
					if (bottomCorners) shad.appendChild(bottomCorners.cloneNode(true));
				} else {
					var shad=newDiv.cloneNode('true')
					var shadInputs=shad.getElementsByTagName('input')
					for (i=0;i<shadInputs.length;i++){
						shadInputs[i].id='';
					}
				}
			
				if (document.all && !window.opera){
					shad.style.position='absolute';
					shad.style.marginLeft='0px';
					shad.style.marginRight='0px';
					shad.style.marginTop='0px';
					shad.style.marginBottom='0px';
					shad.style.top=-shadowOffset/2+'px';
					shad.style.left=-shadowOffset/2+'px';
					shad.style.filter='progid:DXImageTransform.Microsoft.Blur(PixelRadius="'+shadowOffset+'", MakeShadow="true", ShadowOpacity="'+shadowOpacity+'")';
					newDiv.insertBefore(shad,newDiv.firstChild);
				} else {
					shad.style.marginLeft='0px';
					shad.style.marginRight='0px';
					shad.style.marginTop='0px';
					shad.style.marginBottom='0px';
					var allDivs=shad.getElementsByTagName('div');
					for (i=0;i<allDivs.length;i++){
						if (allDivs[i].style.backgroundColor!='' && allDivs[i].style.backgroundColor!='transparent'){
							allDivs[i].style.backgroundColor='#000000';
							allDivs[i].style.borderColor='#000000';
						}
					}
					shad.style.position='absolute';
					shadowOffset+=5;
					for (x=1;x<=shadowOffset;x++){
						var shad2=shad.cloneNode(true);
						shad2.style.top=x+'px';
						shad2.style.left=x+'px';
						shad2.style.zIndex=0;
						shad2.style.opacity=shadowOpacity/(1*x);
						newDiv.insertBefore(shad2,newDiv.firstChild);
					}
				}
			}
		}
	}

/*--------------------------------CUSTOM DATE FIELD SCRIPT-----------------------*/

	function confDate(obj,str){
		if (str=='') return;
		str=str.replace(/-|\./g,'/');
		var dateArray=str.split('/')
		if (dateArray.length<3){
			alert('Improper date format!\n\nThe date must be formatted in the following way: xx/xx/xxxx.');
			obj.value='';
			setTimeout(function(){obj.select()},100);
			return false;;
		}
		if (dateArray[0]>12||dateArray[0]<1){
			alert('Month value seems unlikely!');
			obj.value='';
			setTimeout(function(){obj.select()},100);
			return false;
		}
		if (dateArray[1]>31||dateArray[1]<1){
			alert('Day value seems unlikely!');
			setTimeout(function(){obj.select()},100);
			return false; ;
		}
		for (i=0;i<2;i++){
			if (dateArray[i].length<2) dateArray[i]='0'+dateArray[i];
			if (dateArray[i].length>2){
				alert('Improper date format!\n\nThe date must be formatted in the following way: xx/xx/xxxx.');
			setTimeout(function(){obj.select()},100);
				return false; ;
			}
		}
		if (dateArray[2].length<4){
			alert('Please enter full year (4 digits).');
			setTimeout(function(){obj.select()},100);
			return false; ;
		}
		str=dateArray[0]+'/'+dateArray[1]+'/'+dateArray[2];
		obj.value=str;
	}

/*--------------------------CALENDAR SCRIPT FOR DATE FIELD ---------------------------------*/

	var headerColor='#aaaaff';
	var daysColor='#aaaaaa';
	var bodyColor='#ffffdd';
	var todayColor='#000077';
	var hiliteColor='#ddddff';
	

	var month=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	
	var thisMonth, thisYear, origDate, cutoffDate


	function makeCalendar(obj,dir,objShadow,objInput){
	
		if (obj.firstChild) obj.removeChild(obj.firstChild);
		
		if (cutoffDate!=''&&cutoffDate!=null) {
			var dateParts=cutoffDate.split('/');
			var mo=dateParts[0]-1;
			var dy=dateParts[1];
			var yr=dateParts[2];
			var cutoffDate=new Date(yr,mo,dy)
		} else {
			cutoffDate=new Date(); //----USE IF DATES IN THE PAST ARE NOT ALLOWED, set date to arbitrary date in past to allow past dates
		}
				
		switch(dir){
			case 1:
				thisMonth=thisMonth<11?thisMonth+1:0;
				thisYear=thisMonth==0?thisYear+1:thisYear
				today=new Date(thisYear,thisMonth,1);
				break;
			case -1:
				thisMonth=thisMonth>0?thisMonth-1:11;
				thisYear=thisMonth==11?thisYear-1:thisYear;
				today=new Date(thisYear,thisMonth,1);
				break;
			default:
				today=new Date()
				origDate=today;
				if (cutoffDate>today){
					var today=cutoffDate
				}
				thisMonth=today.getMonth();
				thisYear=today.getFullYear();
		}
	
		var dateArray=new Array(), monthsLength=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		if (Math.floor(today.getFullYear()/4)==today.getFullYear()/4) monthsLength[1]=29;
		var dayNum=today.getDate(), weekDay=today.getDay(), firstDay;
		while (dayNum>7){
			dayNum-=7;
		}
		firstDay=weekDay-dayNum+1;
		firstDay+=(7*(firstDay<0));
		for (i=0;i<42;i++) {
			if (i<firstDay) {
				dateArray[i]=document.createTextNode(' ');
			} else {
				if ((i-firstDay)<monthsLength[thisMonth]) dateArray[i]=document.createTextNode((i+1-firstDay).toString());
			}
		}
	
		var tbl=document.createElement('table');
			tbl.style.border='none';
			tbl.cellPadding='0px';
			tbl.cellSpacing='0px';
			tbl.style.width='100%';
			tbl.style.fontFamily='arial';
			tbl.style.fontSize='8pt';
			tbl.style.position='relative';
			
		var tbdy=document.createElement('tbody');
		
		var row1=document.createElement('tr');
		var c11=document.createElement('td');
			c11.innerHTML='&laquo;';
			c11.style.paddingLeft='5px';
			c11.style.cursor='default';
			c11.style.paddingBottom='3px';
			c11.style.backgroundColor=headerColor;
			c11.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+headerColor+'")';
			c11.onclick=function(){makeCalendar(obj,-1,objShadow,objInput)}
		var c12=document.createElement('td');
			var ctr=document.createTextNode(month[thisMonth] + ' ' + thisYear);
			c12.style.textAlign='center';
			c12.style.fontSize='10pt';
			c12.style.color='#000000';
			c12.style.fontWeight='bold';
			c12.colSpan=5;
			c12.appendChild(ctr);
			c12.style.backgroundColor=headerColor;
			c12.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+headerColor+'")';
		var c13=document.createElement('td');
			c13.style.textAlign='right';
			c13.style.paddingRight='5px';
			c13.innerHTML='&raquo;';
			c13.style.paddingBottom='3px';
			c13.style.cursor='default';
			c13.style.backgroundColor=headerColor;
			c13.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+headerColor+'")';
			c13.onclick=function(){makeCalendar(obj,1,objShadow,objInput)}
		row1.appendChild(c11);
		row1.appendChild(c12);
		row1.appendChild(c13);
		
		var row2=document.createElement('tr');
		var c21=document.createElement('td');
			c21.innerHTML='S';
			c21.style.textAlign='center';
			c21.style.width='16%';
			c21.style.border='1px outset';
			c21.style.backgroundColor=daysColor;
			c21.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
		var c22=document.createElement('td');
			c22.innerHTML='M';
			c22.style.textAlign='center';
			c22.style.width='14%';
			c22.style.border='1px outset';
			c22.style.backgroundColor=daysColor;
			c22.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
		var c23=document.createElement('td');
			c23.innerHTML='T';
			c23.style.textAlign='center';
			c23.style.width='14%';
			c23.style.border='1px outset';
			c23.style.backgroundColor=daysColor;
			c23.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
		var c24=document.createElement('td');
			c24.innerHTML='W';
			c24.style.textAlign='center';
			c24.style.width='14%';
			c24.style.border='1px outset';
			c24.style.backgroundColor=daysColor;
			c24.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
		var c25=document.createElement('td');
			c25.innerHTML='T';
			c25.style.textAlign='center';
			c25.style.width='14%';
			c25.style.border='1px outset';
			c25.style.backgroundColor=daysColor;
			c25.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
		var c26=document.createElement('td');
			c26.innerHTML='F';
			c26.style.textAlign='center';
			c26.style.width='14%';
			c26.style.border='1px outset';
			c26.style.backgroundColor=daysColor;
			c26.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
		var c27=document.createElement('td');
			c27.innerHTML='S';
			c27.style.textAlign='center';
			c27.style.width='14%';
			c27.style.border='1px outset';
			c27.style.backgroundColor=daysColor;
			c27.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="'+daysColor+'")';
	
		row2.appendChild(c21);
		row2.appendChild(c22);
		row2.appendChild(c23);
		row2.appendChild(c24);
		row2.appendChild(c25);
		row2.appendChild(c26);
		row2.appendChild(c27);
			
	
		tbl.appendChild(tbdy);
		tbdy.appendChild(row1);
		tbdy.appendChild(row2);
		
		var dateRow=new Array(), cell=new Array(), dateValue=new Array();
		
		for (j=0;j<dateArray.length;j++){
			if (j/7==Math.floor(j/7)){
				dateRow[Math.floor(j/7)]=document.createElement('tr');
				tbdy.appendChild(dateRow[Math.floor(j/7)]);
			}	
			cell[j]=document.createElement('td')
			cell[j].style.textAlign='center';
			cell[j].style.cursor='default';
			cell[j].appendChild(dateArray[j]);
			if (cell[j].innerHTML==origDate.getDate()&&origDate.getMonth()==today.getMonth()&&origDate.getFullYear()==today.getFullYear()) {
				cell[j].style.backgroundColor=todayColor;
				cell[j].style.color='white';
			}
			var thisDate=new Date(today.getFullYear(),today.getMonth(),dateArray[j].data);
			if(thisDate>=cutoffDate){
				cell[j].onclick=function(){
					if (this.innerHTML!='') objInput.value=((thisMonth+1)<10?'0':'') + (thisMonth+1)+ '/' + ((parseInt(this.innerHTML))<10?'0':'') + this.innerHTML + '/' + thisYear;
					objInput.focus();
					if (document.all) EOT(objInput);  //SEND TO END OF INPUT DATA. ROUTINE EOT PART OF COMBOBOX CODE
	
				}
				cell[j].onmouseover=function(){
					this.style.backgroundColor=hiliteColor;
				}
				cell[j].onmouseout=function(){
					this.style.backgroundColor=bodyColor;
				}
			} else {
				cell[j].style.color='#d5d5d5';
			}
			dateRow[Math.floor(j/7)].appendChild(cell[j]);
		}	
	
	
		obj.appendChild(tbl);
		objShadow.style.height=parseInt(obj.offsetHeight)+'px';
		
	}

	var z=0, a, b, c;
	
	function makeDateFields(node){

		if (!window.opera){
		
		  if (node.hasChildNodes) {
				var iteration;
				for (iteration=0;iteration<node.childNodes.length;iteration++) {
					makeDateFields(node.childNodes[iteration]);
				}
		  }

		if (node.tagName=='INPUT'&&node.getAttribute&&(node.getAttribute('type')=='date')){
			z=z+1;
			var n=node;
			var n2=document.createElement('span');
			var newInput=n.cloneNode(true);
			var calBox=document.createElement('div');
			var calActivate=document.createElement('div');
			var calShadow=document.createElement('div');
			
			n2.style.marginRight='25px';
			n2.style.position='relative';
			n2.style.lineHeight='normal';
			n2.style.zIndex=500-z;
			
			n.style.position='relative';
			n.style.verticalAlign='top';
			n.style.margin='0px';
			n.style.width=(n.offsetWidth-25) + 'px';
			n.onchange=function(){confDate(this,this.value);}
			
			calBox.style.position='absolute';
			calBox.style.border='2px outset';
			calBox.style.backgroundColor=bodyColor;
			calBox.style.width=Math.max((parseInt(n.offsetWidth)+20),120)+'px';
			calBox.style.top=(n.offsetHeight+1)+'px';
			calBox.style.left='0px';
			calBox.style.display='none';
			
			calShadow.style.width=Math.max((parseInt(n.offsetWidth)+22),122)+'px';
			calShadow.style.position='absolute';
			if (document.all){
				calShadow.style.top=(parseInt(n.offsetHeight)+1)+'px';
				calShadow.style.left='0px';
			} else {
				calShadow.style.top=(parseInt(n.offsetHeight)+3)+'px';
				calShadow.style.left='5px';
			}
			calShadow.style.backgroundColor='#000000';
			calShadow.style.filter='progid:DXImageTransform.Microsoft.Blur(PixelRadius="3", MakeShadow="true", ShadowOpacity="0.50")';
			calShadow.style.opacity='0.25';
			calShadow.style.display='none';
			
			calActivate.innerHTML='&#8230;';
			calActivate.style.border='1px solid #999999';
			calActivate.style.width=(parseInt(n.offsetHeight))+'px';
			calActivate.style.textAlign='center';
			calActivate.style.height=(parseInt(n.offsetHeight)-(2))+'px';
			calActivate.style.overflow='hidden';
			calActivate.style.backgroundColor='#CCCCCC';
			calActivate.style.position='absolute';
			calActivate.style.top=document.all?'1px':'0px';
			calActivate.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="#AAAAAA")';
			calActivate.style.fontFamily='arial';
			calActivate.style.fontSize='10pt';
			calActivate.style.lineHeight='normal';
			calActivate.style.left=parseInt(n.offsetWidth)-1+'px';
			calActivate.style.cursor='default';
			
			calActivate.onclick=function(ev){
				if (a) a.display='none';
				if (b) b.display='none';
				if (c) c.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="#AAAAAA")';
				(a=calBox.style).display='block';
				(b=calShadow.style).display='block';
				(c=calActivate.style).filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#AAAAAA",endColorStr="#f3f3f3")';
				document.onclick=function(){
					calBox.style.display='none';
					calShadow.style.display='none';
					calActivate.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="#AAAAAA")';
				};
				if (document.all) {
					window.event.cancelBubble=true;
				} else {
					ev.stopPropagation();
				}
				makeCalendar(calBox,0,calShadow,n);
			}
			
			n.parentNode.replaceChild(n2,n)
			n2.appendChild(n)
			n2.appendChild(calActivate);
			n2.appendChild(calShadow);
			n2.appendChild(calBox)
		 }
	  }	
	}
	
//-----------------------------COMBO BOX SCRIPTS---------------------------------------//

var selectedItem, itemNum=0, itemCount;

function activateComboBox(){
	var inputs=document.getElementsByTagName('input');
	createComboStyle();
	for (i=0;i<inputs.length;i++){
		if (inputs[i].getAttribute('type')=='combo'){
		
			z=z+1;
			var n=inputs[i];
			var n2=document.createElement('span');
			n2.style.position='relative';
			n2.style.lineHeight='normal';
			n2.style.zIndex=500-z;
			n.parentNode.replaceChild(n2,n)
			n2.appendChild(n);

			inputs[i].onfocus=function(){initComboBox(this)};
			inputs[i].onclick=function(e){showItems(e,this); hilite(e,this)}
			inputs[i].onkeyup=function(e){hilite(e,this)}
			inputs[i].onkeydown=function(e){processKeystroke(e,this)}
			
			inputs[i].style.width=(inputs[i].offsetWidth-22)+'px';

			var comboActivate=document.createElement('span');
					comboActivate.innerHTML='&#8230;';
					comboActivate.style.border='1px solid #999999';
					comboActivate.style.lineHeight='normal';
					comboActivate.style.overflow='hidden';
					//comboActivate.style.width='20px';
					comboActivate.style.width=(n2.offsetHeight)+'px'
					comboActivate.style.textAlign='center';
					comboActivate.style.height=(parseInt(inputs[i].offsetHeight)-2)+'px';
					comboActivate.style.backgroundColor='#CCCCCC';
					comboActivate.style.position='absolute';
					comboActivate.style.top=document.all?'1px':'-1px';
					comboActivate.style.filter='progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr="#f3f3f3",endColorStr="#AAAAAA")';
					comboActivate.style.fontFamily='arial';
					comboActivate.style.left=parseInt(inputs[i].offsetWidth)+'px';
					comboActivate.style.cursor='default';
					comboActivate.onclick=function(ev){
						var event='';
						if (document.all) {
							window.event.cancelBubble=true;
						} else {
							ev.stopPropagation();
						}
						initComboBox(this.previousSibling);
						showItems(event, this.previousSibling); 
						hilite(event,this.previousSibling);
					}
			
			inputs[i].parentNode.insertBefore(comboActivate,inputs[i].nextSibling);
			
			var dropWindow=document.createElement('div');
					dropWindow.className='drop';
					dropWindow.style.height='90px';
					dropWindow.style.width=(n2.offsetWidth+20)+'px';//'100%';
					dropWindow.style.marginLeft='1px';
					dropWindow.style.position='absolute'; 
					//dropWindow.style.top='21px'; 
					dropWindow.style.top=(n2.offsetHeight)+'px'; 
					dropWindow.style.left='-1px'; 
					dropWindow.style.overflow='auto'; 
					dropWindow.style.border='1px solid #AAAAAA'; 
					dropWindow.style.display='none';
					dropWindow.style.fontSize='10pt';
					dropWindow.style.backgroundColor='#EEEEEE';
					dropWindow.style.color='#000000';
					dropWindow.style.zIndex='10';
			
			inputs[i].parentNode.insertBefore(dropWindow,comboActivate.nextSibling); 

			
			var comboOptions=inputs[i].getAttribute('options').split(',');
				dropWindow.style.height=Math.min(90,comboOptions.length*18)+'px';
			for (j=0;j<comboOptions.length;j++){
				var newOption=document.createElement('div');
				newOption.style.padding='0px 4px';
				newOption.style.height='18px';
				newOption.style.textTransform='capitalize';
				eval('newOption.onclick=function(){selItem(this,'+(j+1)+')}');
				//var optionText=document.createTextNode(comboOptions[j]);
				//newOption.appendChild(optionText);
				newOption.innerHTML=comboOptions[j];
				dropWindow.appendChild(newOption);
			}
		}
	}
				
	arr=document.getElementsByTagName('div');
	for (i=0;i<arr.length;i++){
		if (arr[i].parentNode.className=='drop'){
			arr[i].onmouseover=function(){this.className='over'; selectedItem=this.innerHTML};
			arr[i].onmouseout=function(){this.className='off';};

		}
	}
}

function createComboStyle(){
	var pa= document.getElementsByTagName('head')[0] ;
	var el= document.createElement('style');
	var str='.drop .off{background-color: #EEEEEE;color: #000000;}.drop .over{	background-color: #000000;	color: #FFFFFF;}';

	el.type= 'text/css';
	el.media= 'screen';
	if(el.styleSheet) el.styleSheet.cssText= str;// IE method
	else el.appendChild(document.createTextNode(str));// others
	pa.appendChild(el);
	return el;
}

function initComboBox(obj){

	itemBox=obj.parentNode.getElementsByTagName('div')[0];
	items=itemBox.getElementsByTagName('div');
	itemCount=items.length;
	comboBox=obj;
	hilite(0,obj);
				
}

function showItems(e,obj){
		if (window.event){
			var e=window.event;
			var obj=e.srcElement;
		} else {
			obj=e.target;
		}
	if (e.keyCode!=13) {
		if (e.type=='click' && itemBox.style.display=='block') {
			itemBox.style.display='none';
		} else {
			itemBox.style.display='block';
		}
	}
	document.onclick=function(){itemBox.style.display='none';}
}

function scrollItems(x){
	y=itemBox.scrollTop;
	pos=-y+x*20;
	if (pos>80){
		itemBox.scrollTop=(x-4)*18;//itemBox.scrollTop+18;
	} else if (pos<0) {
		itemBox.scrollTop=(x)*18;//itemBox.scrollTop-18;
	}
}

function hilite(e,obj){
		if (window.event){
			var e=window.event;
		}
	if (e.keyCode!=38 && e.keyCode!=40){
	clearAllSelected(obj,itemCount);
		for (var j=0;j<=itemCount-1; j++){
			if (obj.value.length>0 && obj.value.toLowerCase()==items[j].innerHTML.substring(0,obj.value.length).toLowerCase()){
				items[j].className='over';
				scrollItems(j);
				selectedItem=items[j].innerHTML;
				itemNum=j;
				break;
			}
		}
	}
}

function clearAllSelected(obj, itemCount){
			for (var j=0;j<=itemCount-1; j++) items[j].className='off'
			selectedItem='';
}

function processKeystroke(e, obj){
		if (window.event){
			var e=window.event;
			var obj=e.srcElement;
		} else {
			obj=e.target;
		}
	if (e.keyCode==38 && itemNum>0){
			if (itemBox.style.display=='block') itemNum-=1;
			showItems(e, obj);
			clearAllSelected(obj,itemCount);
			items[itemNum].className='over';
			scrollItems(itemNum);
			selectedItem=items[itemNum].innerHTML;
	}
	if (e.keyCode==40 && itemNum<itemCount-1){
			if (itemBox.style.display=='block') itemNum+=1;
			showItems(e, obj);
			clearAllSelected(obj,itemCount);
			items[itemNum].className='over';
			scrollItems(itemNum);
			selectedItem=items[itemNum].innerHTML;
	}
	showItems(e, obj);
	if (e.keyCode==13 && itemBox.style.display=='block'){
		e.returnValue=false;
		obj.value=selectedItem!=''?selectedItem:obj.value;
		clearAllSelected(obj,itemCount);
		itemBox.style.display='none';
	}
	if (e.keyCode==9 || e.keyCode==27){
		obj.value=selectedItem!=''?selectedItem:obj.value;
		clearAllSelected(obj,itemCount);
		itemBox.style.display='none';
		itemNum=0;
	}
}
function selItem(obj,num){
		comboBox.value=selectedItem;
		itemNum=num;
		comboBox.focus();
		itemBox.style.display='none';
		if (document.all) EOT(comboBox);
}

function EOT(txt) {
  var range = txt.createTextRange();
  range.move("textedit");
  range.select();
}

//---------------------------- CONTACT MANAGER -----------------------//

	if (window.ActiveXObject) {
		var srvrConnect=new ActiveXObject('Microsoft.XMLHTTP');
	} else if (window.XMLHttpRequest) {
		var srvrConnect=new XMLHttpRequest();
	}

function delContact(id){
	if (confirm('You have chosen to delete this contact. Are you sure you wish to continue?')){
		srvrConnect.open('post','admin/_delContact.cfm',0);
		srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		srvrConnect.send('id='+id);
		document.getElementById('contList').innerHTML=srvrConnect.responseText;
	} else {
		return;
	}
}

function selContact(id){
		srvrConnect.open('post','admin/_selContact.cfm',0);
		srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		srvrConnect.send('id='+id);
}

function selAll(){
		srvrConnect.open('post','admin/_selAllContacts.cfm',0);
		srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		srvrConnect.send();
		document.getElementById('contList').innerHTML=srvrConnect.responseText;
}
function deselAll(){
		srvrConnect.open('post','admin/_deselAllContacts.cfm',0);
		srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		srvrConnect.send();
		document.getElementById('contList').innerHTML=srvrConnect.responseText;
}

function sendEmail(){
		msg=document.getElementById('content1').innerHTML;
		srvrConnect.open('post','admin/_sendEmail.cfm',0);
		srvrConnect.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		msg=msg.replace(/&nbsp;/g,' ');
		srvrConnect.send('msg='+msg);
		if (srvrConnect.responseText.indexOf('Send OK') != -1){
			alert('Your email was sent successfully!');
			document.getElementById('content1').innerHTML='';
		} else {
			alert('There was a problem and your email was not sent.')
		}
		
}

//------------------------------ADMIN - CONTENT EDITOR SCRIPTS ------------------//

var viewMode=1;  // View mode default setting--------------------------------//

function setMode(viewNewMode) {
 if (viewNewMode!=viewMode) {
  if (viewNewMode) {
  	if (document.all&&!window.opera){
		 var sContents=document.getElementById('content'+activeBox).innerText
		 document.getElementById('content'+activeBox).innerHTML=sContents;
	 } else {
		 var html=document.createRange();
		 html.selectNodeContents(document.getElementById('content' + activeBox));
		 document.getElementById('content' + activeBox).innerHTML=html;
	 }
  }
  else {
	 var html=document.createTextNode(document.getElementById('content'+activeBox).innerHTML);
	 document.getElementById('content'+activeBox).innerHTML='';
	 document.getElementById('content'+activeBox).appendChild(html);
  }
  viewMode=viewNewMode
 }
}

var viewMode=true,strErr="Formatting toolbar is not accessible in Edit Source mode"

function format(what,opt,ui) {
	if (!viewMode) {
		alert(strErr);
		document.getElementById('content'+activeBox).focus();
		return;
	} 
   if (ieVer>=5) document.getElementById('content'+activeBox).focus();
   if (what=='backcolor' && isNaN(ieVer)) what='hilitecolor';
 	ui = (ui==true)
	if (what=='createlink') opt=prompt('Enter URL');
	if ((what=='createlink' && opt!='') || what!='createlink') document.execCommand(what,ui,opt)
}

function getToolbar() {

	var buttons=new Array(24,23,23,4,23,23,23,23,4,23,23,23,23,4,230,23,40,(23*imgSupport),230,4,23); //Values greater than 25 are ignored (MUST APPEND ZERO to delete and maintain proper button placement)
	
	var action=new Array("bold","italic","underline","","justifyleft","justifycenter","justifyright","justifyfull","","insertorderedlist","insertunorderedlist","outdent","indent","","createlink","createlink","","insertImage","addButton","","setMode");
	
	var tooltip=new Array("Bold Text","Italic Text","Underline Text","","Left Justify","Center Justify","Right Justify","Full Justify","","Ordered List","Unordered List","Remove Indent","Indent","","Link to Document","Link to Website","","Insert Image","Add Button Link to Other Pages","","Edit Source")
	
	var left=0,width=0, inc=0
	
	var s=""
	for (var i=0;i<buttons.length;i++) {
	 if (buttons[i]<25) {
		 s+="<DIV STYLE='position:relative;float:left;height:26px;overflow:hidden;width: " + buttons[i] + "px'>";
		 s+="<IMG BORDER=0 SRC='admin/images/htmleditortoolbar.gif' STYLE='position:absolute;top:0px;left:-" + (left) + "px'"
		 if (buttons[i]!=4) {
		   switch (action[i]) {
			 case "insertImage":
			   s+=" onmouseover='this.style.top=\"-25px\"' onmouseout='this.style.top=\"0px\"' ONCLICK=\""
			   s+="initImageEdit('insert');this.style.top=\'0px\'\" "
			   s+="TITLE=\"" + tooltip[i] + "\""
			   break;
			 case "setMode":
			   s+=" id='modeSwitch' onmouseover='if (viewMode) this.style.top=\"-25px\"; else this.style.top=\"-49px\";' onmouseout='if (viewMode) this.style.top=\"0px\"; else this.style.top=\"-73px\";' ONCLICK=\""
			   s+="if (viewMode) this.style.top=\'-49px\'; else this.style.top=\'0px\'; setMode(!viewMode)\" "
			   s+="TITLE=\"" + tooltip[i] + "\""
			   break;
			default:
			  s+=" onmouseover='this.style.top=\"-25px\"' onmouseout='this.style.top=\"0px\"' ONCLICK=\""
			  s+="format('" + action[i] + "');this.style.top=\'0px\'\" "
			  s+="TITLE=\"" + tooltip[i] + "\""
		   }
		   
		 }
		 s+="></DIV>"
	 }
	 inc=buttons[i]<25?buttons[i]:buttons[i]/10;
	 left+=inc
	}
//	return "<span ID=tb2 class=htmlEditToolbar STYLE=\"height:27px; width: " + (width+3) + "\" ONSELECTSTART=\"return false\" ONDRAGSTART=\"return false\">" + s + "</span>"
	return s;
}

function stripHTML(){
	if (confirm('Continuing will remove all HTML tags from the selected\ncontent box, including images. Paragraph structure will\nremain unchanged.\n\nAre you sure you want to continue?')){
		var html=eval('document.all.content'+activeBox).innerHTML
		html=html.replace(/<P[^>]+>/g,'{prg}');
		html=html.replace(/<BR>/g,'{brk}');
		eval('document.all.content'+activeBox).innerHTML=html;
		var html=eval('document.all.content'+activeBox).innerText;
		html=html.replace(/{prg}/g,'<P>');
		html=html.replace(/{brk}/g,'<BR>');
		eval('document.all.content'+activeBox).innerHTML=html;
	}	
}

// ------------------------- Functions for custom image insert/editing panel ----------------------------------

var imgRange;

function initImageEdit(action){
	if (!viewMode) {
	  alert(strErr);
	  document.getElementById('content'+activeBox).focus();
	  return
	}

	if (ieVer>=5) document.getElementById('content'+activeBox).focus();
	var selObj = document.selection&&!window.opera?document.selection:window.getSelection(); 
	imgRange = selObj.createRange?selObj.createRange():selObj.getRangeAt(0);

	if (typeof(imgRange.cloneContents)!='undefined' 
		 && imgRange.cloneContents().childNodes.length==1 
		 && imgRange.cloneContents().childNodes[0].tagName=='IMG'){
		
		var imgToEdit=imgRange.cloneContents().childNodes[0];
		switch (imgToEdit.style.cssFloat){
			case 'left':
				document.recSubmit.imgEditAlign[0].checked=true;
				break;
			case 'right':
				document.recSubmit.imgEditAlign[2].checked=true;
				break;
			default:
				document.recSubmit.imgEditAlign[1].checked=true;
				break;
		}
		document.getElementById('imageEditPanel').style.display='block';
		
	} else if (action=='insert' && selObj.type=='Control' && imgRange(0).tagName=='IMG') {
 
		switch (imgRange(0).style.styleFloat){
			case 'left':
				document.recSubmit.imgEditAlign[0].checked=true;
				break;
			case 'right':
				document.recSubmit.imgEditAlign[2].checked=true;
				break;
			default:
				document.recSubmit.imgEditAlign[1].checked=true;
				break;
		}
		document.getElementById('imageEditPanel').style.display='block';
	
	} else {
 
		document.getElementById('imagePanel').style.display='block';
	 
	}
}

function insertImage(doc){

	if (typeof(doc.fileName)=='undefined') return;
	
	if (ajaxRenameFile(doc.filePath)){
	
		var newImg=document.createElement('img');
		newImg.src=doc.fileName;
		if (document.recSubmit.imgAlign[0].checked){
			newImg.style.cssFloat='left';
			newImg.style.styleFloat='left';
			newImg.style.margin='10px 10px 10px 0px';
		} else if (document.recSubmit.imgAlign[1].checked) {
			newImg.style.margin='10px';
		} else if (document.recSubmit.imgAlign[2].checked) {
			newImg.style.cssFloat='right';
			newImg.style.styleFloat='right';
			newImg.style.margin='10px 0px 10px 10px';
		}

		if (typeof(imgRange.insertNode)=='function'){
			imgRange.deleteContents();
			imgRange.insertNode(newImg);
		} else {
			imgRange.pasteHTML(newImg.outerHTML);
		}
		
		//if (imgRange.select) imgRange.select();     ----moved to _inc_photoInput.cfm-----
		document.getElementById('imagePanel').style.display='none';
	
	} 
	
}

function imageEdit(){
		try {
			var imgToEdit=imgRange(0);
		} catch(err) {
			var imgSelect=imgRange.cloneContents()
			var imgToEdit=imgSelect.childNodes[0];
		}
		if (document.recSubmit.imgEditAlign[0].checked){
			imgToEdit.style.styleFloat='left';
			imgToEdit.style.cssFloat='left';
			imgToEdit.style.margin='10px 10px 10px 0px';
		} else if (document.recSubmit.imgEditAlign[1].checked) {
			imgToEdit.style.margin='10px';
			imgToEdit.style.styleFloat='none';
			imgToEdit.style.cssFloat='none';
		} else if (document.recSubmit.imgEditAlign[2].checked) {
			imgToEdit.style.cssFloat='right';
			imgToEdit.style.styleFloat='right';
			imgToEdit.style.margin='10px 0px 10px 10px';
		}
		if (typeof(imgRange.deleteContents)=='function'){
			imgRange.deleteContents();
			imgRange.insertNode(imgSelect);
		}
		document.getElementById('imageEditPanel').style.display='none';
}

function ajaxRenameFile(filePath){
	var sendStr='act=1&filePath='+filePath;
	var resp=getXML(sendStr,'_processAjax.cfm');
	//crawlXML(resp);
	var chk=resp.getElementsByTagName('success')[0].firstChild.data;
	if (chk!='true'){
		document.getElementById('response').innerHTML=resp.getElementsByTagName('message')[0].firstChild.data;
		if (confirm("An error occurred while attempting to save your data. To try again, click 'OK'. If this problem persists, please click 'Cancel' and  contact Big Giant Media for assistance."));
		return false;
	} else {
		return true;
	}
}

/* ----------------- EMAIL Obfuscator -----------------------------------*/

function stumpIt(theName,theExtras,theLink,theDomain) {
	if (theDomain==''){
		var theDomain ="michellebrogan.com";
	}
	var theEmail = theName+"@"+theDomain;
	if (theName == ""){
		theName = "ERROR";
		theLink = "ERROR";
		myEmail = theName;
		myLink = theLink;
	}else{
		if ((theExtras == "") && (theLink =="")){
			myEmail = theEmail;
			myLink = theEmail;
		}
		if ((theLink == "") && (theExtras != "")){
			myLink = theEmail;
			myEmail = theEmail+theExtras;
		}
		if 	((theLink != "") && (theExtras != "")){
			myLink = theLink;
			myEmail = theEmail+theExtras;
		}
		if 	((theLink != "") && (theExtras == "")){
			myLink = theLink;
			myEmail = theEmail;
		}
	}
	document.write('<a href=mailto:' + myEmail + '>' + myLink + '</a>');
}