/**
* Copyright (c) 2006 Andriy Bidochko. All Rights Reserved.
* http://www.mapbuilder.net
*
* This code (including but not limited to the actual source code, documentation and database schemes) 
* is not freeware and is intended for the use of the original license purchaser according to the license agreement.
* The code all or in part may not be sold, redistributed, or included as part of another application.
* 
* THIS SOFTWARE PRODUCT IS PROVIDED "AS IS" AND LICENSOR MAKE NO WARRANTY AS TO ITS USE, PERFORMANCE, 
* OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
MAPBUILDER.namespace("MAPBUILDER.util");MAPBUILDER.util.trunkStr=function(value,length){return(value.length<=length)?value:(value.substr(0,length-3)+"...");}
MAPBUILDER.util.toInt=function(value){if(isNaN(value)){return 0;}
else{return parseInt(value);}}
MAPBUILDER.util.toFloat=function(value){if(isNaN(value)){return 0;}
else{return parseFloat(value);}}
MAPBUILDER.util.getRadioValue=function(radiobtn){for(var i=0;i<radiobtn.length;i++){if(radiobtn[i].checked){return radiobtn[i].value;}}
return 0;}
MAPBUILDER.util.formatNumber=function(number){var dotIdx=-1;if(number!=''){number=number.replace(/\$|\,/g,"");if(isNaN(number)){number='';}
else{if(number.length>9)
number=number.substring(0,9);dotIdx=number.indexOf('.');if(dotIdx!=-1)
number=number.substring(0,dotIdx);for(var i=0;i<Math.floor((number.length-(1+i))/3);i++)
number=number.substring(0,number.length-(4*i+3))+','+number.substring(number.length-(4*i+3));}}
return number;}
MAPBUILDER.util.changeClass=function(id,className){if(document.getElementById(id)!=null)
document.getElementById(id).className=className;}
MAPBUILDER.util.Cookie=function(){this.setCookie=function(name,value,expires,path,domain,secure){if(!expires){var now=new Date();now.setTime(now.getTime()+180*24*60*1000);expires=now;}
document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");}
this.getCookie=function(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}
else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end));}
this.deleteCookie=function(name,path,domain){if(getCookie(name)){document.cookie=name+"="+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}}