<!--//
	// General JavaScript Functions for Atlas World Group, Inc. //
	
	//simplifiy object calls
	var df = document.forms;
	var di = document.images;
	
	// ------------------------------- //	//       Window Popup Function     //	// ------------------------------- //
	
	var w;
	function popup(target, width, height, scrollbars, hidemenus)
	{
 		var menus;
 		if (hidemenus) { menus = ",status=yes,toolbar=no,menubar=no,location=no"; }
 		
 		if (scrollbars){
 			w = window.open(target,'atlaspop','width='+width+',height='+height+',resizable,scrollbars'+menus);
 		}else{
 			w = window.open(target,'atlaspop','width='+width+',height='+height+',resizable'+menus);
 		}
 		w.focus();
	}
	

	// ------------------------------- //	//  Visibility & Display Functions //	// ------------------------------- //
	
	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;
			}
	}
	
	function toggleVisible(divID){
		if (document.layers){
			var thisDiv = document.layers[divID];
			var newValue = (thisDiv.visibility != 'show') ? 'show' : 'hide'
			thisDiv.visibility = newValue;
			}
		else if (document.all){
			var thisDiv = document.all[divID];
			var newValue = (thisDiv.style.visibility != 'visible') ? 'visible'	: 'hidden';
			thisDiv.style.visibility = newValue;
			}
		else if (document.getElementById){
			var thisDiv = document.getElementById(divID);
			var newValue = (thisDiv.style.visibility != 'visible') ? 'visible' : 'hidden';
			thisDiv.style.visibility = newValue;
			}
	}
	
	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 hideDisplay(divID){
		if (document.layers){
			var thisDiv = document.layers[divID];
			thisDiv.display = 'none';
			}
		else if (document.all){
			var thisDiv = document.all[divID];
			thisDiv.style.display = 'none';
			}
		else if (document.getElementById){
			var thisDiv = document.getElementById(divID);
			thisDiv.style.display = 'none';
			}
	}
	
	function hideVisible(divID){
		if (document.layers){
			var thisDiv = document.layers[divID];
			thisDiv.visibility = 'hide';
			}
		else if (document.all){
			var thisDiv = document.all[divID];
			thisDiv.style.visibility = 'hidden';
			}
		else if (document.getElementById){
			var thisDiv = document.getElementById(divID);
			thisDiv.style.visibility = 'hidden';
			}
	}

	// ------------------------------- //	//          Date Functions         //	// ------------------------------- //

	function getMonthName(zeroMonthNum, abbreviated){
		var longMonths = "January,February,March,April,May,June,July,August,September,October,November,December"; longMonths=longMonths.split(",");
		var shortMonths = "Jan.,Feb.,Mar.,Apr.,May,Jun.,Jul.,Aug.,Sep.,Oct.,Nov.,Dec."; shortMonths=shortMonths.split(",");
		var Months;
		
		if(abbreviated){ Months = shortMonths; }else{ Months = longMonths;}
		
		return Months[zeroMonthNum]	
	}

	// ------------------------------- //	//  Number and Currency Functions  //	// ------------------------------- //

	function formatCurrency(amount){
		var i = parseFloat(amount);
		if(isNaN(i)) { i = 0.00; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		i = parseInt((i + .005) * 100);
		i = i / 100;
		s = new String(i);
		if(s.indexOf('.') < 0) { s += '.00'; }
		if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
		s = minus + s;
		return "$" + formatCommaSep(s);
	}
	function formatCommaSep(amount){
		var delimiter = ","; // replace comma if desired
		var a = amount.split('.',2)
		var d = a[1];
		var i = parseInt(a[0]);
		if(isNaN(i)) { return ''; }
		var minus = '';
		if(i < 0) { minus = '-'; }
		i = Math.abs(i);
		var n = new String(i);
		var a = [];
		while(n.length > 3){
			var nn = n.substr(n.length-3);
			a.unshift(nn);
			n = n.substr(0,n.length-3);
		}
		if(n.length > 0) { a.unshift(n); }
		n = a.join(delimiter);
		if(d.length < 1) { amount = n; }
		else { amount = n + '.' + d; }
		amount = minus + amount;
		return amount;
	}

	// ------------------------------- //	//       Select Box Functions      //	// ------------------------------- //
	// IE6 does not properly handle <select> boxes when dealing with z-index
	// when layers overlap select boxes, we have to temporarily hide them
	
	function hideAllSelectBoxes(){
		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "hidden";}
	}

	function showAllSelectBoxes(){
		// reveal select boxes that were hidden from IE	
		selects = document.getElementsByTagName("select");
		for (i = 0; i != selects.length; i++) {selects[i].style.visibility = "visible";}	
	}

	// ------------------------------- //	//         String Functions        //	// ------------------------------- //
	
	function trim(sString){
		while (sString.substring(0,1) == ' '){sString = sString.substring(1, sString.length);}
		while (sString.substring(sString.length-1, sString.length) == ' '){sString = sString.substring(0,sString.length-1);}
		return sString;
	}
	function strip(string, symbol) {
		var newstring = "";

		for (var i = 0; i < string.length; i++) {
			if (string.charAt(i) != symbol) newstring += string.charAt(i);
		}
		return newstring;
	}

	// ------------------------------- //	//          Misc Functions         //	// ------------------------------- //

	function jsnull() 
		{ /* prevents browser screen jumps that href="#" can cause */ }	

	// ------------------------------- //	//         Image Functions         //	// ------------------------------- //
	
	function changeImage(imgID,imgURL){
		if (document.images){
			document.images[imgID].src = imgURL;
		}else{
			document.getElementById( imgID).src = imgURL;
		}
	}

	// ------------------------------- //	//  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 //	// 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 prel = new Array(), img, imgList, imgsrc, mtchd; 		imgList = elem.getElementsByTagName('img'); 		for (var i=0; img = imgList[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;}


	// ------------------------------- //
	//          AJAX Functions         //
	// ------------------------------- //

	var http = false;
	var shttp = false;
	if(navigator.appName == "Microsoft Internet Explorer"){
		http = new ActiveXObject("Microsoft.XMLHTTP");
		shttp = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		http = new XMLHttpRequest();
		shttp = new XMLHttpRequest();
	}

	function ajaxRequest(htmlID, inputID, pageURL, htmlCurrency, inputCurrency){
		// This function will retrieve an AJAX page request, then set either or both a supplied HTML ID's innerHTML or a Value of a form field
		// As a work-around, this will also allow either or both the HTML or Form field to be formatted for currency
			
		if(htmlID != ""){ document.getElementById(htmlID).innerHTML = '...Loading'; }
		if(inputID != ""){ document.getElementById(inputID).value = '...Loading'; }
			
		http.open("GET",pageURL, true);
		http.onreadystatechange=function(){
			if(http.readyState == 4 && http.status == 200){
				var htmlResult;
				if(htmlCurrency){ htmlResult = formatCurrency(http.responseText); }else{ htmlResult = http.responseText; }
				if(htmlID != ""){ document.getElementById(htmlID).innerHTML = htmlResult; }
				
				var inputResult;
				if(inputCurrency){ inputResult = formatCurrency(http.responseText); }else{ inputResult = http.responseText; }
				if(inputID != ""){ document.getElementById(inputID).value = http.responseText; }
			}else if(http.readyState == 4 && http.status != 200){
				if(htmlID != ""){ document.getElementById(htmlID).innerHTML = "ERROR"; }
				if(inputID != ""){ document.getElementById(inputID).value = "ERROR"; }
			}
  		}
		http.send(null);
	}
	function sjaxRequest(htmlID, inputID, pageURL, htmlCurrency, inputCurrency){
		// This function will retrieve an AJAX page request, then set either or both a supplied HTML ID's innerHTML or a Value of a form field
		// As a work-around, this will also allow either or both the HTML or Form field to be formatted for currency
		// This function differs from ajaxRequest, in that it is synchronous, and will	
		if(htmlID != ""){ document.getElementById(htmlID).innerHTML = '...Loading'; }
		if(inputID != ""){ document.getElementById(inputID).value = '...Loading'; }
		
		shttp.open("GET",pageURL, false);
		shttp.send(null);

		if(shttp.status == 200){
			var htmlResult;
			if(htmlCurrency){ htmlResult = formatCurrency(shttp.responseText); }else{ htmlResult = shttp.responseText; }
			if(htmlID != ""){ document.getElementById(htmlID).innerHTML = htmlResult; }
			
			var inputResult;
			if(inputCurrency){ inputResult = formatCurrency(shttp.responseText); }else{ inputResult = shttp.responseText; }
			if(inputID != ""){ document.getElementById(inputID).value = shttp.responseText; }
		}else{
			if(htmlID != ""){ document.getElementById(htmlID).innerHTML = "ERROR"; }
			if(inputID != ""){ document.getElementById(inputID).value = "ERROR"; }
		}
	}

//-->
