function submitForm(formID, url)
{
  url = url || '';
  objForm = document.getElementById(formID);
  if (objForm)
  {
    if (url != '')
      objForm.action = url;
    objForm.submit();
  }
}

function changePage(url)
{
  window.location.href = url;
}

// all parmas should be strings
function imageSwap(imgID, newImg, newAlt, newWidth, imgHeight)
{
  var objImg = document.getElementById(imgID);

  if (objImg)
  {
  	objImg.src = newImg;
  	objImg.width = newWidth;
  	objImg.height = imgHeight;
  	objImg.alt = newAlt;
  }
}

function imageSwapShort(imgID, newImg)
{
  var objImg = document.getElementById(imgID);
  if (objImg)
  {
  	objImg.src = newImg;
  }
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// paging
function paging(from)
{
  var thisURL = window.location.href;
  var re = /&from=[0-9]+/;
  thisURL = thisURL.replace(re, '');
  thisURL += '&from=' + from;
  changePage(thisURL);
}

// user friendly paging
function ufpaging(from)
{
  var thisURL = window.location.href;
  var re = /\/?([0-9]+)?\/?$/;
  thisURL = thisURL.replace(re, '');
  thisURL += '/' + from + '/';
  changePage(thisURL);
}

// append "http://" if absents
function appendHTTPPrefix(URL)
{
  var checkURL = allTrim(URL);
  var re = /^http(s)*:\/\//;
  if (checkURL != "" && !checkURL.match(re))
  {
  	checkURL = "http://" + checkURL;
  }
  return checkURL;
}

// hide
function hideContent(objID)
{
  var obj = document.getElementById(objID);

  if (obj)
  {
		obj.style.visibility = "hidden";
		obj.style.overflow = "hidden";
		obj.style.height = "1px";
  }
}

// show
function showContent(objID)
{
  var obj = document.getElementById(objID);

  if (obj)
  {
		obj.style.visibility = "visible";
		obj.style.overflow = "visible";
		obj.style.height = "";
  }
}

function switchContent(objID)
{
  var obj = document.getElementById(objID);

  if (obj)
  {
  	if (obj.style.visibility == "hidden")
  	{
  		showContent(objID);
  	}
  	else
  	{
  		hideContent(objID);
  	}
  }
}

function inputClear(objID)
{
  var obj = document.getElementById(objID);
  if (obj)
  {
  	obj.value = '';
  }
}

function selectClear(objID, isAddEmptyRow)
{
  isAddEmptyRow = isAddEmptyRow || true;
  var obj = document.getElementById(objID);
  if (obj)
  {
  	obj.length = 0;
    if (isAddEmptyRow)
      obj.options[0] = new Option('...', '');
  }
}

function fSearch(obj)
{

}

function checkAll(objAll, prefix)
{
  var isCheck = objAll.checked;
  var obj;
  var i = 0;

  while (obj = document.getElementById(prefix + i))
  {
  	obj.checked = isCheck;
  	i++;
  }
}

// retutrns cursor position
function getPosition(e) {
  e = e || window.event;
  var cursor = {x:0, y:0};
  if (e.pageX || e.pageY) {
    cursor.x = e.pageX;
    cursor.y = e.pageY;
  }
  else {
    var de = document.documentElement;
    var b = document.body;
    cursor.x = e.clientX +
      (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
    cursor.y = e.clientY +
      (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
  }
  return cursor;
}