spacetype		= 'venu';

aImgTop 		= new Array(); 
aAdidTop		= new Array();
aTypeTop		= new Array();

aImgLeft 		= new Array();
aAdidLeft		= new Array();
aTypeLeft		= new Array();

aImgRite 		= new Array(); 
aAdidRite		= new Array();
aTypeRite		= new Array();

aImgTemp 		= new Array(); 
aAdidTemp		= new Array();
aTypeTemp		= new Array();

fListingID 		= new Array();
fPic1			= new Array();
fShortTitle		= new Array();
fAvailability	= new Array();
fLocation		= new Array();
fCostText		= new Array();
fCapacityText	= new Array();
fIconList		= new Array();

iconlabel 		= new Array();
icontt		= new Array();

reEmail=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/

//---------------------------------------------------------------------------------- writeAdverts
function writeAdverts(placement,nextAdIndex, numToShow)
{
	oHtml='';

	switch(placement)
		{
		case 'top': 
			inLine1 	= '<p><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%" target="_blank"><img src="i/ad/%IMG_NAME%" width="550" alt="advert" /></a></p>'; 
			inLine2 	= '<p><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%&allspace=1" target="_top"><img src="i/ad/%IMG_NAME%" width="550" alt="advert" /></a></p>';
			inLine3	= '<p><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%&allspace=1" target="costhelp" onclick="popuph(this.href,\'costhelp\',\'600\',\'450\',\'me,re,sc\');return false;"><img src="i/ad/%IMG_NAME%" width="550" alt="advert" /></a></p>';
			aImgTemp 	= aImgTop;
			aAdidTemp	= aAdidTop;
			aTypeTemp	= aTypeTop;
			break;

		case 'left': 
			inLine1 	= '<p class="adimage" align="center"><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%" target="_blank"><img src="i/ad/%IMG_NAME%" width="160" alt="advert" /></a></p>'; 
			inLine2 	= '<p class="adimage" align="center"><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%&allspace=1" target="_top"><img src="i/ad/%IMG_NAME%" width="160" alt="advert" /></a></p>';
			inLine3	= '<p class="adimage" align="center"><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%&allspace=1" target="costhelp" onclick="popuph(this.href,\'costhelp\',\'600\',\'450\',\'me,re,sc\');return false;"><img src="i/ad/%IMG_NAME%" width="160" alt="advert" /></a></p>';
			aImgTemp 	= aImgLeft;
			aAdidTemp	= aAdidLeft;
			aTypeTemp	= aTypeLeft;
			break;

		case 'right': 
			inLine1 	= '<p class="adimage"><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%" target="_blank"><img src="i/ad/%IMG_NAME%" width="160" alt="advert" /></a></p>'; 
			inLine2	= '<p class="adimage"><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%&allspace=1" target="_top"><img src="i/ad/%IMG_NAME%" width="160" alt="advert" /></a></p>';
			inLine3	= '<p class="adimage"><a href="../glob-php/commercial_advert_redirect.php?adid=%ADVERT_ID%&allspace=1" target="costhelp" onclick="popuph(this.href,\'costhelp\',\'600\',\'450\',\'me,re,sc\');return false;"><img src="i/ad/%IMG_NAME%" width="160" alt="advert" /></a></p>';
			aImgTemp 	= aImgRite;
			aAdidTemp	= aAdidRite;
			aTypeTemp	= aTypeRite;
			break;
		}

	j 		= nextAdIndex;
	lastEntry 	= aImgTemp.length - 1;

	if (j > lastEntry)
		j = 1 + Math.round((lastEntry - 1) * Math.random()) // generate a random number between 1 and the max entry 
//alert(aTypeTemp[j]);
	for (var x=0; x < numToShow; x++)
   		{
		if (aImgTemp[j])
      		{
			switch(aTypeTemp[j])
				{
				case 'local_page':
					outLine = inLine2; 			//local link
					break;
				case 'local_popup':
					outLine = inLine3;			//local popup link
					break;
				case 'offsite':
					outLine = inLine1;			//offsite link
					break;	
				default:						
					outLine = inLine1;			//offsite link
				 	break;
				}
			outLine= outLine.replace(/%ADVERT_ID%/g,aAdidTemp[j]);
			outLine= outLine.replace(/%IMG_NAME%/g,aImgTemp[j]);
			oHtml += outLine;
			j++; 
			if (j > lastEntry)
				j=1;
			}
		}
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- writeFeaturedListing
function writeFeaturedListing(nextFeaturedIndex,maxFeatured)
{
	oHtml = '<tr><td colspan="2" class="featuredlabel"><img border="0" src="i/featured.gif" width="548" height="21" alt="featured listing" /></td></tr>';

	inLine = '<tr><td colspan="2">';
	inLine+= '<table border="0" cellpadding="0" cellspacing="10" summary="layout" width="100%" class="featuredlisting">';
	inLine+= '<tr>';
	inLine+= '<td><a onclick="popuph(this.href,\'f1\',\'760\',\'500\',\'sc,me,to\');return false;" href="moredetails.php?lid=%LISTING_ID%" target="f1"><img border="0" src="i/list/%PIC1%" width="280" height="210" align="left" alt="" /></a></td>';
	inLine+= '<td><b>%SHORT_TITLE%</b><br /><span class="lsubh">AVAILABLE:</span> %AVAILABLE_TEXT%<br /><span class="lsubh">LOCATION:</span> %LOCATION_TEXT%<br /><span class="lsubh">COST:</span> %COST_TEXT%<br /><span class="lsubh">CAPACITY:</span> %CAPACITY_TEXT%</span><br /><br /><a onclick="popuph(this.href,\'f1\',\'760\',\'500\',\'sc,me,to\');return false;" href="moredetails.php?lid=%LISTING_ID%" target="f1">more details...</a><p>%ICON_LIST%</p></td>';
	inLine+= '</tr>';
	inLine+= '</table>';
	inLine+= '</td></tr>';
 
	j 		= nextFeaturedIndex;
	lastEntry 	= fListingID.length - 1;

	if (lastEntry < maxFeatured)
		maxFeatured = lastEntry;
	
//alert(j +  ' ' + maxFeatured);

	if (j > lastEntry)
		j=Math.floor(Math.random()*lastEntry) + 1; // random number between 1 and number of entries

	if (fListingID[j])
     		{
		outLine = inLine; 
		outLine= outLine.replace(/%LISTING_ID%/g,fListingID[j]);
		outLine= outLine.replace(/%PIC1%/g,fPic1[j]);
		outLine= outLine.replace(/%SHORT_TITLE%/g,fShortTitle[j]);
		outLine= outLine.replace(/%COST_TEXT%/g,fCostText[j]);
		outLine= outLine.replace(/%LOCATION_TEXT%/g,fLocation[j]);
		outLine= outLine.replace(/%CAPACITY_TEXT%/g,fCapacityText[j]);
		outLine= outLine.replace(/%AVAILABLE_TEXT%/g,fAvailability[j]);

		outLine= outLine.replace(/%ICON_LIST%/g,fIconList[j]);

		oHtml += outLine;
		j++; 
		if (j > lastEntry)
			j=1;
		}

	if (lastEntry > 0)
		document.write(oHtml);
}

//---------------------------------------------------------------------------------- writeIconsStyle2 
function writeIconsStyle2 (startIndex, endIndex, setfocus)
{
	if (setfocus == 1)
		tempOnClick="try{doOnClick(%ICON_ID%)}catch(e){};document.inpsearchform.subbutton.focus();";
	else
		tempOnClick="try{doOnClick(%ICON_ID%)}catch(e){}";

	oHtml='<table border="0" cellpadding="2" cellspacing="0" width="100%">';

	inLine =  '<tr>'; 
	inLine += '<td><input type="checkbox" name="chk_icon%ICON_ID%" onclick="' + tempOnClick +'"></td>'; 			
	inLine += '<td><img border="0" src="i/icon%ICON_ID%.gif" width="22" height="22" alt="" onMouseover="Tip(icontt[%ICON_ID%]);" ></td>'; 
	inLine += '<td width="80%">%ICON_LABEL%</td>'; 			
	inLine += '</tr>'; 	
	
	
	for (var j=startIndex; j < (endIndex +1); j++)
   		{
		if (iconlabel[j])
      		{
			outLine = inLine; 
			outLine= outLine.replace(/%ICON_ID%/g,j);
			outLine= outLine.replace(/%ICON_LABEL%/g,iconlabel[j]);
			oHtml += outLine;
			}
		}	

	oHtml += '<\/table>';
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- writeIconsStyle2 
function writeIconsStyle32 ()
{
	oHtml='<table border="0" cellpadding="2" cellspacing="0" width="100%">';

	inLine =  '<tr>'; 
	inLine += '<td><input type="checkbox" name="chk_icon%ICON_ID%"></td>'; 			
	inLine += '<td><img border="0" src="i/icon%ICON_ID%.gif" width="22" height="22" alt="" ></td>'; 
	inLine += '<td width="80%">%ICON_LABEL%&nbsp;<img src="i/moreinfo.gif" onMouseover="Tip(icontt[%ICON_ID%]);" alt="" /></td>'; 			
	inLine += '</tr>'; 	
	
	
	for (var j=0; j < (iconlabel.length -1); j++)
   		{
		if (iconlabel[j])
      		{
			outLine = inLine; 
			outLine= outLine.replace(/%ICON_ID%/g,j);
			outLine= outLine.replace(/%ICON_LABEL%/g,iconlabel[j]);
			oHtml += outLine;
			}
		}	

	oHtml += '<\/table>';
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- writeIconsStyle1 
function writeIconsStyle1 (startIndex, endIndex, setfocus)
{
	if (setfocus == 1)
		tempOnClick="try{doOnClick(%ICON_ID%)}catch(e){};document.inpsearchform.subbutton.focus();";
	else
		tempOnClick="try{doOnClick(%ICON_ID%)}catch(e){}";

	oHtml='<table border="0" cellpadding="2" cellspacing="0" width="100%">';

	inLine =  '<tr>'; 
	inLine += '<td><input type="checkbox" name="chk_icon%ICON_ID%" onclick="' + tempOnClick +'"></td>'; 			
	inLine += '<td><img border="0" src="i/icon%ICON_ID%.gif" width="22" height="22" alt="" ></td>'; 
	inLine += '<td width="80%">%ICON_LABEL%&nbsp;<img src="i/moreinfo.gif" onMouseover="Tip(icontt[%ICON_ID%]);" alt="" /></td>'; 			
	inLine += '</tr>'; 	
	
	
	for (var j=startIndex; j < (endIndex +1); j++)
   		{
		if (iconlabel[j])
      		{
			outLine = inLine; 
			outLine= outLine.replace(/%ICON_ID%/g,j);
			outLine= outLine.replace(/%ICON_LABEL%/g,iconlabel[j]);
			oHtml += outLine;
			}
		}	

	oHtml += '<\/table>';
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- writeIcons0 
function writeIcon0 ()
{
	oHtml='<table border="0" cellpadding="2" cellspacing="0" width="100%">';

	inLine =  '<tr>'; 
	inLine += '<td><input type="checkbox" name="chk_icon0" onclick="if (this.checked) resetAllTravelIcons()"></td>'; 			
	inLine += '<td><img border="0" src="i/icon0.gif" width="22" height="22" alt="" ></td>'; 
	inLine += '<td width="80%">any mode of travel&nbsp;<img src="i/moreinfo.gif" onMouseover="Tip(\'any form of travel method\');" alt="" /></td>'; 			
	inLine += '</tr>'; 	
	
	outLine = inLine; 
	oHtml += outLine;

	oHtml += '<\/table>';
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- writeIcons0-2 
function writeIcon0_2 ()
{
	oHtml='<table border="0" cellpadding="2" cellspacing="0" width="100%">';

	inLine =  '<tr>'; 
	inLine += '<td><input type="checkbox" name="chk_icon0" onclick="if (this.checked) resetAllTravelIcons_2()"></td>'; 			
	inLine += '<td><img border="0" src="i/icon0.gif" width="22" height="22" alt="" ></td>'; 
	inLine += '<td width="80%">any mode of travel&nbsp;<img src="i/moreinfo.gif" onMouseover="Tip(\'any form of travel method\');" alt="" /></td>'; 			
	inLine += '</tr>'; 	
	
	outLine = inLine; 
	oHtml += outLine;

	oHtml += '<\/table>';
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- resetAllTravelIcons
function resetAllTravelIcons()
{
	for (var j=1; j < 7; j++)
   		{
		eval('document.inpform.chk_icon' + j + '.checked=""');
		}
}

//---------------------------------------------------------------------------------- resetAllTravelIcons_2
function resetAllTravelIcons_2()
{
	for (var j=1; j < 7; j++)
   		{
		eval('document.inpform.chk_icon' + j + '.checked="checked"');
		}
}
//---------------------------------------------------------------------------------- writeIconsStyle3 
function writeIconsStyle3 (startIndex, endIndex, setfocus)
{
	if (setfocus == 1)
		tempOnClick="try{doOnClick(%ICON_ID%)}catch(e){};document.inpform.subbutton.focus();";
	else
		tempOnClick="try{doOnClick(%ICON_ID%)}catch(e){}";

	oHtml='<table border="0" cellpadding="2" cellspacing="0" width="100%">';

	inLine =  '<tr>'; 
	inLine += '<td><input type="radio" name="rad_private"></td>'; 			
	inLine += '<td><img border="0" src="i/icon%ICON_ID%.gif" width="22" height="22" alt="" ></td>'; 
	inLine += '<td width="80%">%ICON_LABEL%&nbsp;<img src="i/moreinfo.gif" onMouseover="Tip(icontt[%ICON_ID%]);" alt="" /></td>'; 			
	inLine += '</tr>'; 	
	
	
	for (var j=startIndex; j < (endIndex +1); j++)
   		{
		if (iconlabel[j])
      		{
			outLine = inLine; 
			outLine= outLine.replace(/%ICON_ID%/g,j);
			outLine= outLine.replace(/%ICON_LABEL%/g,iconlabel[j]);
			oHtml += outLine;
			}
		}	

	oHtml += '<\/table>';
	//alert(oHtml);
	document.write(oHtml);
}

//---------------------------------------------------------------------------------- getSelectedRadio
function getSelectedRadio(formID,fieldID)
{
	chosen 	= "";
	radioButt	= eval("formID."+fieldID);
	len 		= radioButt.length;

	for (i = 0; i < len; i++)
	{
	if (radioButt[i].checked)
		{
		chosen = radioButt[i].value
		}
	return chosen;
	}
}

//---------------------------------------------------------------------------------- setSelectedDropdown
function setSelectedDropdown(formID,fieldID,newVal)
{
	chosen 	= "";
	dropdownID	= eval("formID."+fieldID);
	len 		= dropdownID.length;

	for (i = 0; i < len; i++)
		{
		temp=dropdownID[i].value;
		if (temp == newVal)
			dropdownID.selectedIndex = i;
		}

}

//---------------------------------------------------------------------------------- getSelectedDropdownText
function getSelectedDropdownText(formID,fieldID)
{

	idx = document.forms[formID].elements[fieldID].selectedIndex;

	if (idx > -1)
		var foundText = document.forms[formID].elements[fieldID].options[idx].text;
	else
		var foundText = '';

	return foundText;
}

//---------------------------------------------------------------------------------- makePOSTRequest (AJAX)
function makePOSTRequest(url, parameters, checkRoutine)
{
	http_request = false;
	
	if (window.XMLHttpRequest) 
   		{ // Mozilla, Safari etc
		http_request = new XMLHttpRequest();
		
		if (http_request.overrideMimeType)
      		{
         		// set type accordingly to anticipated content type
			// http_request.overrideMimeType('text/xml');
          		http_request.overrideMimeType('text/html');
         		}
		}
	else if (window.ActiveXObject) 
			{ // IE
       		try {http_request = new ActiveXObject("Msxml2.XMLHTTP");} 
       		catch (e) {try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} 
       		catch (e) {}
			}
		}
   
	if (!http_request)
		{
       	alert('Cannot create XMLHTTP instance');
		return false;
		}
      
	eval("http_request.onreadystatechange = " + checkRoutine + ";");
	http_request.open('POST', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

//---------------------------------------------------------------------------------- createRequestString (AJAX)
function createRequestString(theForm)
{
	var reqStr = "";

	for(i=0; i < theForm.elements.length; i++)
		{
		isFormObject = false;

		switch (theForm.elements[i].tagName)
			{
			case "INPUT":

			switch (theForm.elements[i].type)
				{
				case "text":

				case "hidden":
					reqStr += theForm.elements[i].name + "=" + encodeURIComponent(theForm.elements[i].value);
					isFormObject = true;
					break;

				case "checkbox":
					if (theForm.elements[i].checked)
						{
						reqStr += theForm.elements[i].name + "=" + theForm.elements[i].value;
						}
					else
						{
						reqStr += theForm.elements[i].name + "=";
						}
					isFormObject = true;
					break;

				case "radio":
					if (theForm.elements[i].checked)
						{
						reqStr += theForm.elements[i].name + "=" + theForm.elements[i].value;
						isFormObject = true;
						}
				}
				break;

			case "TEXTAREA":
				reqStr += theForm.elements[i].name + "=" + encodeURIComponent(theForm.elements[i].value);
				isFormObject = true;
				break;

			case "SELECT":
				var sel = theForm.elements[i];
				reqStr += sel.name + "=" + sel.options[sel.selectedIndex].value;
				isFormObject = true;
				break;
			}

		if ((isFormObject) && ((i+1)!= theForm.elements.length))
			{
			reqStr += "&";
			}

		}

	return reqStr;
} 

//---------------------------------------------------------------------------------- getState
function getState(postcode)
{
	found_state='';
	
	if ((postcode >= 800) && (postcode < 1000))
		{found_state = "NT";}	

	if ((postcode >= 2000) && (postcode < 3000))
		{found_state = "NSW";}

	if (((postcode >= 2600) && (postcode < 2619)) || ((postcode >= 2900) && (postcode < 2915)))
		{found_state = "ACT";}

	if ((postcode >= 3000) && (postcode < 4000))
		{found_state = "VIC";}

	if ((postcode >= 4000) && (postcode < 5000))
		{found_state = "QLD";}

	if ((postcode >= 5000) && (postcode < 6000))
		{found_state = "SA";}
	
	if ((postcode >= 6000) && (postcode < 7000))
		{found_state = "WA";}
	
	if ((postcode >= 7000) && (postcode < 8000))
		{found_state = "TAS";}	
//alert(found_state);
	return found_state;

}

function filterLineBreaks (ta) 
{
  ta = ta.replace(/\r\n|\r|\n/g, '<br />');
  return ta;
}

function limitLineBreaks (ta,maxLimit) 
{
	break_count =0;
	out_ta = '';

	for (var x=0; x < 500; x++)
   		{
		if (ta.substring(x, x+6) == '<br />')
			{
			break_count = break_count + 1;
			if (break_count > maxLimit)
				{out_ta = out_ta + ' ';x=x+5;}
			else
				{out_ta = out_ta + ta.substring(x, x+1);}
			}
		else if (ta.substring(x, x+4) == '<br>')
			{
			break_count = break_count + 1;
			if (break_count > maxLimit)
				{out_ta = out_ta + ' ';x=x+3;}
			else
				{out_ta = out_ta + ta.substring(x, x+1);}
			}
		else
			{
			out_ta = out_ta + ta.substring(x, x+1);
			}
		}

	//alert(break_count);
	//alert(out_ta);
  	return out_ta;
}

function addLineBreaks (ta) 
{
  ta = ta.replace(/<br \/>|<br>/g, '\n');
  return ta;
}

function formatDisplayBreaks (ta) 
{
	if (IsUsingIE())	
		ta = ta.replace(/<br \/>/g, '<br \/><br \/>');
  	return ta;
}

function displayOn(objectID)
  {
	domStyle = findDOM(objectID,1);
	domStyle.display='block';
  }

function displayOff(objectID)
  {
  	domStyle = findDOM(objectID,1);
	domStyle.display='none';
  }

function visibleOn(objectID)
  {
	domStyle = findDOM(objectID,1);
	domStyle.visibility='visible';
  }

function visibleOff(objectID)
  {
  	domStyle = findDOM(objectID,1);
	domStyle.visibility='hidden';
  }

function gotoAddPage(spaceType, addType)
	{
	//newPage = "../" + spaceType + "&addtype=" + addType;
	if (addType == 'listing') 
		newPage = "../" + spaceType + "/add_new_listing.php?showacc=1";
	else
		newPage = "../" + spaceType + "/add_new_wanted.php?showacc=1";

	popuph(newPage,'p1','760','500','me,re,sc');
	}

function trimAll(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;
	}

//faster TRIM implementation May 2008
function trimString(str) {
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}
 
function isValidPostcode(sString)
	{
	rePost=/\d{4}?/

	if(rePost.test(sString) && (sString.length == 4))
		return true;
	else
		return false;
	}

extArray = new Array(".gif", ".jpg", ".png");

function isValidFileExt(form, file)
{

	allowSubmit = false;
	if (!file)
		return false;
	
	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
	
	ext = file.slice(file.indexOf(".")).toLowerCase();

	for (var i = 0; i < extArray.length; i++) 
		{
		if (extArray[i] == ext) 
			{allowSubmit = true;break;}
		}
	if (allowSubmit) 
		return true;
	else
		return false;
}

function isValidUrl(s)
{
	//reURL=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/

	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
	return regexp.test(s);
}

//FUNCs
function IsUsingIE() { var result = false; var strBrowser = navigator.appName.toLowerCase(); if (strBrowser.indexOf("microsoft") != -1) result = true; return result; }

function IsUsingNS() { var result = false; var strBrowser = navigator.appName.toLowerCase(); if (strBrowser.indexOf("netscape") != -1) result = true; return result;}

function IsUsingOP() { var result = false; var strBrowser = navigator.appName.toLowerCase(); if (strBrowser.indexOf("opera") != -1) result = true; return result;}

function IsUsingSAF() { var result = false; var strBrowser = navigator.userAgent.toLowerCase(); if (strBrowser.indexOf("safari") != -1) result = true; return result;}

function IsUsingPC() { var result = false; var strBrowser = navigator.userAgent.toLowerCase(); if (strBrowser.indexOf("win") != -1) result = true; else if (strBrowser.indexOf("inux") != -1) result = true; return result; }

function IsUsingMAC() { var result = false; var strBrowser = navigator.userAgent.toLowerCase(); if (strBrowser.indexOf("mac") != -1) result = true; else if (strBrowser.indexOf("68k") != -1) result = true; return result; }

function limitText(limitField, limitCount, limitNum) 
{
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

//FUNC---------------------------------------------------------------------------------------roundNumber
function roundNumber(Num, Places, ZeroPad) 
{
	if (!isNumeric(Num)) {Num=0;}

	var Num = parseFloat(Num);

	if (ZeroPad > 0)
		{
		switch (Places)
			{
			case 0:		addon = '';break;
			case 1:		addon = '.0';break;
			case 2:		addon = '.00';break;
			case 3:		addon = '.000';break;
			case 4:		addon = '.0000';break;
			default:	addon = '';
			}
		}
	else
		{
		addon='';
		}

   if (Places > 0) 
	{
       	var Rounder = Math.pow(10, Places);
	ret_val = (Math.round(Num * Rounder) / Rounder);
	if (ret_val.toString().lastIndexOf('.') > 0)
       		{return ret_val;}
	else
		{return ret_val+addon;}
					
   	}	
   else return Math.round(Num);
}

// end func

//FUNC---------------------------------------------------------------------------------------isNumeric
function isNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

