function textCounter (field, countfield, maxlimit) {
  	if (field.value.length > maxlimit)
  	field.value = field.value.substring(0, maxlimit);
  	else
    countfield.value = maxlimit - field.value.length;
}

function newWindow (mypage,myname,w,h,features) {
  	if(screen.width) {
  		var winl = (screen.width-w)/2;
  		var wint = (screen.height-h)/2;
  	} else {
  	    winl=0; wint=0;
  	}

  	if (winl<0) winl=0;
  	if (wint<0) wint=0;

  	var settings = 'height=' + h + ',';
  	settings += 'width=' + w + ',';
  	settings += 'top=' + wint + ',';
  	settings += 'left=' + winl + ',';
  	settings += features;
  	settings += ' scrollbars=yes ';

  	win = window.open(mypage,myname,settings);

  	win.window.focus();
}
function addOption(selectId, val, txt) {
    var objOption = new Option(txt, val);
    document.getElementById(selectId).options.add(objOption);
}

function search_delay(element, type) {
    // Create a function to get the search results
    var func = function() { xajax_getSearchRecords(element.value,type); };

    // Check to see if there is already a timeout and if so...
    // ...cancel it and create a new one
    if ( element.zid ) {
        clearTimeout(element.zid);
    }
    element.zid = setTimeout(func,500);

}

function addBookmark(title, url) { 
    if (window.sidebar) {
        // mozilla/firefox     
        window.sidebar.addPanel(title, url,"");    
    } else if( window.external ) {
        // IE        
        window.external.AddFavorite( url, title); 
    } else if(window.opera && window.print) {
        // Opera        
        var bookmark = document.createElement('a');
        bookmark.setAttribute('href',url);
        bookmark.setAttribute('title',title);
        bookmark.setAttribute('rel','sidebar');
        bookmark.click(); 
    } 
}