var undefined;
function formatTag(tag) {
        tag = trim(tag.replace('/\s\s+/', ' '));
        tag = tag.replace(' ', '_');
        return tag.toLowerCase();
}

function zeropad(num)  // zero-pad single-digit numbers (00...09)
{
	if (num < 10)
		return ("0" + num);	
	else
		return num;
}

function delaySec(msg) {
	var len = msg.length;
	var show_sec = parseInt(len/5);
	return show_sec;
}

function popURL(url, name, width, height, scrollbar) {
       	var options = "scrollbars="+scrollbar+",resizable=0, location=no,toolbar=0,width=" + width + ", height=" + height;
	options += ",left="+((screen.width/2)-(width/2))+",top="+((screen.height/2)-(height/2));
        options += ",screenX="+((screen.width/2)-(width/2))+",screenY="+((screen.height/2)-(height/2));

        newwindow = window.open(url, name, options);
        if (window.focus) {
        	newwindow.focus();
        }       
        return newwindow;
}

function ridComma(numString) {
    var re = /,/g;
    return numString.replace(re,"");
}

function ReplaceAll(Source,stringToFind,stringToReplace){
var temp = Source;
var index = temp.indexOf(stringToFind);

while(index != -1){
	temp = temp.replace(stringToFind,stringToReplace);
        index = temp.indexOf(stringToFind);
}
return temp;
}

function containsComma(string) {
	var index = string.indexOf(",");
	if (index != -1) {
		return true;
	}
	return false;
}

function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
} 
function trim(s) {
	if (!s)
    return '';
  return s.replace(/^\s*|\s*$/g,"");
}
function get_element(id) {
	var ele = document.all ? document.all[id] : document.getElementById(id);
  	if (ele)
    		return ele;
  	else
		return null;
}
function get_value(id) {
	var ele = get_element(id);
	if (ele)
    		return ele.value;
  	else
		return null;
}
function set_html(id, intext) {
	if (document.getElementById(id)) {
		document.getElementById(id).innerHTML = intext;
	}
}
function clear(f) {
  if (get_element(f))
    get_element(f).value = '';
}
function setCookie(cookieName,cookieValue,expireDays)  {
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expireDays)
	document.cookie = cookieName +"="+ escape(cookieValue) +
		((expireDays==null) ? "" : ";expires=\""+ exdate.toGMTString()) +"\";path=/;";
}
function getCookie(name)  {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) &&
    ( name != document.cookie.substring( 0, name.length ) ) )
  {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function valid_url(url) {
        var re = /^http?:\/\/\S+|^https?:\/\/\S+/i
        if (re.test(url)) {
                return true
        } else {
                return false
        }
}

function chg_page_loc(url) {
	window.document.location.href = url;
}

function toggleDiv(id) {
	if (get_element(id).style.display == "none") {
		get_element(id).style.display = "";
	} else {
		get_element(id).style.display = "none";
	}
	return false;
}


function textEncode(intxt) {
	if (encodeURIComponent) {
		return encodeURIComponent(intxt);
	} else {
		return escape(intxt);
	}
}

function isEmpty(value) {
	if (value == '' || value == null || value == "") {
		return true;
	} else {
		return false;
	}
}

function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}

var AjaxObject = {

	/**
	* Wrapper for AJAX calls using YUI connector
	*
	* @param postAction {String} URL to post to
	* @param callBackSuccess {String} Success handler
	* @param postData {String} Data to post
	* @param obj {Object} Object that handler has scope in
	*
	*/
	startRequest:function(postAction, callBackSuccess, callBackFailure, postData, obj) {

		var callback = {
			success:callBackSuccess,
			failure:callBackFailure,
			scope:obj
		}
		YAHOO.util.Connect.asyncRequest('POST', postAction, callback, postData);
	}

};

Array.prototype.remove = function(from, to) {
        var rest = this.slice((to || from) + 1 || this.length);
        this.length = from < 0 ? this.length + from : from;
        return this.push.apply(this, rest);
};
Array.prototype.insertAt = function (vItem /*:variant*/, iIndex /*:int*/) /*:variant*/ {
    this.splice(iIndex, 0, vItem);
};

var hl_color = '#E9F5BA';// '#F2EFEB';
var polygon_colors = Array();
polygon_colors[0] = '#F4D3B1';
polygon_colors[1] = '#D4CAD8';
polygon_colors[2] = '#BFE4BF';

