
function trim(string) {
return string.replace(/(\s+$)|(^\s+)/g, "");
}

function img_resize() {
    var td = document.getElementById('hTd');
    td.width=td.width+1;


}

function do_search(submit) {
    var searchText = document.getElementById('search_text');
    var searchForm = document.getElementById('search_form');
    if (searchText.value == "search.." || trim(searchText.value) == "") {
        searchText.focus();
        alert('Please enter search text');
        return false;
    } else {
        var searchValue = trim(searchText.value);
            searchValue = searchValue.replace(/[^A-Za-z0-9 +-]/g, "");
            searchValue = searchValue.replace(/(\s+)/g, "_");
        searchForm.action += searchValue;
        searchForm.submit();
    }
}

function do_resize(img) {
    if(document.img.width < document.img.height) document.img.height = "74";
    else document.img.width = "99";
}
                                                

function SetImageWidth() {
  screenshotImage = document.getElementById("ScreenshotImage");
  var width = screenshotImage.width;
  screenshotImage.width = 100;
  screenshotDiv = document.getElementById("screen_div");
  if (width > screenshotDiv.offsetWidth-50) {
    screenshotImage.width = screenshotDiv.offsetWidth-50;
  } else {
        screenshotImage.width = width;
  }   
}

function addBookmark(url, title) {
 if (!url) url = location.href;
 if (!title) title = document.title;

 //Gecko
 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
 //IE4+
 else if (typeof window.external == "object") window.external.AddFavorite(url, title);
 //Opera7+
 else if (window.opera && document.createElement)
 {
 var a = document.createElement('A');
 if (!a) return false; //IF Opera 6
 a.setAttribute('rel','sidebar');
 a.setAttribute('href',url);
 a.setAttribute('title',title);
 a.click();
 }
 else return false;

 return true;
}
