<!--//
	// Estimating JavaScript Functions for Atlas World Group, Inc. //
	
	//simplifiy object calls
	var df = document.forms;
	var di = document.images;
	
	
	// ------------------------------- //
	//         Display Functions       //
	// ------------------------------- //
	
	function setDisplay(divID,setType){
		if (document.layers){
			document.layers[divID].display = setType;
			}
		else if (document.all){
			document.all[divID].style.display = setType;
			}
		else if (document.getElementById){
			document.getElementById(divID).style.display = setType;
			}
	}
	
	function toggleDisplay(divID){
		if (document.layers){
			var thisDiv = document.layers[divID];
			var newValue = (thisDiv.display != 'block') ? 'block' : 'none';
			thisDiv.display = newValue;
			}
		else if (document.all){
			var thisDiv = document.all[divID];
			var newValue = (thisDiv.style.display != 'block') ? 'block' : 'none';
			thisDiv.style.display = newValue;
			}
		else if (document.getElementById){
			var thisDiv = document.getElementById(divID);
			var newValue = (thisDiv.style.display != 'block') ? 'block' : 'none';
			thisDiv.style.display = newValue;
			}
	}
	
	
	// ------------------------------- //
	//          Misc Functions         //
	// ------------------------------- //

	function jsnull() 
		{ /* prevents browser screen jumps that href="#" can cause */ }	
		
	function increment(fieldID, formIndex) {
		var incField = df[formIndex].elements[fieldID];
		if(isNaN(incField.value)){ incField.value = 0; }
		if(incField.value < 0){ incField.value = 0; }
		incField.value++;
	}
		
	function decrement(fieldID, formIndex) {
		var incField = df[formIndex].elements[fieldID];
		if(isNaN(incField.value)){incField.value = 1; }
		if(incField.value < 1){ incField.value = 1; }
		incField.value--;
	}
	
	function formFieldFocus(thisField, defaultText){
		if(thisField.value == defaultText){
			thisField.value='';
			thisField.className = 'formfocus';
		}
	}
	function formFieldBlur(thisField, defaultText){
		if(thisField.value == ''){
			thisField.value = defaultText;
			thisField.className = 'formblur';
		}
	}
	
	function charactercount(TextField, MaxChars, ReportItemName){
		var originaltext = TextField.value;
		var reporttext = document.getElementById(ReportItemName);
		
		//set report for web user to see, and stop entry of more words
		if (TextField.value.length < 1){
			//emptybox
			setDisplay(reporttext.id, 'none');
			reporttext.innerHTML = '';
		}else if (TextField.value.length >= MaxChars){
			setDisplay(reporttext.id, 'inline');
			
			//reached max
			reporttext.innerHTML = 'LIMIT REACHED';
			
			//stop entry of more characters
			var trimmedText = TextField.value.substr(0, MaxChars);
			TextField.value = trimmedText;
		}else{
			setDisplay(reporttext.id, 'inline');
			
			//have not yet reached max wordcount
			reporttext.innerHTML = (MaxChars - TextField.value.length) + ' left';
		}
	}
	
	function wordcount(TextField, MaxWords, ReportItemName){
		var originaltext = TextField.value;
		var wordsarray = originaltext.split(' ');
		var reporttext = document.getElementById(ReportItemName);
		var i;
		
		//set report for web user to see, and stop entry of more words
		if (TextField.value == '' || wordsarray.length < 1){
			//emptybox
			setDisplay(reporttext.id, 'none');
			reporttext.innerHTML = '';
		}else if (wordsarray.length >= MaxWords){
			setDisplay(reporttext.id, 'inline');
			
			//reached max
			reporttext.innerHTML = 'LIMIT REACHED';
			
			//stop entry of more words
			TextField.value = '';
			for (i = 0; i <= (MaxWords -1); i++){
				TextField.value += wordsarray[i] + ' ';
			}
		}else{
			setDisplay(reporttext.id, 'inline');
			
			//have not yet reached max wordcount
			reporttext.innerHTML = (MaxWords - wordsarray.length) + ' left';
		}
	}


	// ------------------------------- //
	//  Auto Image Rollover Functions  //
	// ------------------------------- //
	// XHTML Transitional Valid Image Rollovers //
	// This script runs on any images with the proper ending to their filename (foo_nm.jpg, foo_hv.jpg, foo_md.jpg, foo_ou.jpg, foo_mu.jpg) //

	// Non-Obtrusive Image Swap Script V1.1 by Hesido.com //
	// Attribution required on all accounts //
	
	// Updated to allow <input type="image" /> controls to use this too -- Brandon Luhring 2-25-08

	// If the browser is W3 DOM compliant, execute setImageSwaps function
	if (document.getElementsByTagName && document.getElementById) {
		if (window.addEventListener) window.addEventListener('load', setImageSwaps, false);
	else if (window.attachEvent) window.attachEvent('onload', setImageSwaps);
	}

	// When document loads, apply the prepareImageSwap function to various images with our desired settings
	function setImageSwaps() {
		// ---Mousedown, restore - for images in container with ID=example2
		// prepareImageSwap('example2',true,true,true,true);
		// ---Hover, mousedown, no restore - for images in container with ID=example3
		// prepareImageSwap('example3',true,false,true,false);
		// ---Hover with restore, most basic usage - for any image in document.body that are not yet processed (function accepts elements,too)
		prepareImageSwap(document.body);
		// ---Note that once an image is processed, it won't be processed again, so you should set more specific images first, e.g. document.body, as it is the grand
		// ---container, has to be processed last.
	}

	function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) { 
		if (typeof(elem) == 'string') elem = document.getElementById(elem); 
		if (elem == null) return; 
		
		var regg = /(.*)(_nm\.)([^\.]{3,4})$/ 
		var imgArray = [];
		var prel = new Array(), img, imgArray, imgsrc, mtchd; 
		
		//create NodeLists (special type of array)
		var imgList = elem.getElementsByTagName('img'); 
		var inptList = elem.getElementsByTagName('input');
		
		//append them to the imgArray
		for (var i=0; i < imgList.length; i++) {
			imgArray.push(imgList[i]);
		}
		for (var i=0; i < inptList.length; i++) {
			if (inptList[i].type == "image") {
				imgArray.push(inptList[i]);
			}
		}
		
		for (var i=0; img = imgArray[i]; i++) { 
			if (!img.rolloverSet && img.src.match(regg)) { 
				mtchd = img.src.match(regg); 
				img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3]; 
				img.outSRC = img.src; 
				if (typeof(mouseOver) != 'undefined') { 
					img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false; 
					img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false; 
					img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false; 
					img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false; 
					} 
				if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;} 
				if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;} 
				if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;} 
				if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;} 
				img.rolloverSet = true; 
			} 
		} 
		function preLoadImg(imgSrc) { 
			prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc; 
		} 
	} 
	function imgHoverSwap() {this.src = this.hoverSRC;} 
	function imgOutSwap() {this.src = this.outSRC;} 
	function imgMouseDownSwap() {this.src = this.mdownSRC;} 
	function imgMouseUpSwap() {this.src = this.mupSRC;}
		
//-->

