/** 
 * get dynamic base url
 * 
 */
function autoHide(obj, liveTime) {
  jQuery(obj).show('slow');
  setTimeout("jQuery('" + obj + "').hide('slow');", liveTime);
}
function getFileExtension($file) {
  return ($file.substring($file.lastIndexOf('.') + 1)).toLowerCase();
}
function open_popup(url, popup_name, width, height) {
  var left = Math.floor((screen.width - width) / 2);
  var top = Math.floor((screen.height - height) / 2);
  window.open(url, popup_name, 'height=' + height + ', width=' + width + ', left=' + left + ',top=' + top + ',toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');
}

/**
 * check window is opened as popup
*/
function is_popup() {
  return (window.opener && !window.opener.closed) ? true: false;
}

function open_popup_ajax(url, popup_name, width, height) {
  var left = Math.floor((screen.width - width) / 2);
  var top = Math.floor((screen.height - height) / 2);
  var params = "width=" + width + "px,height=" + height + "px,left=" + left + "px,resize=1,scrolling=1";
  if (popup_name == '') {
    popup_name = 'Web Excellent';
  }
  ajaxwin = dhtmlwindow.open("ajaxbox", "ajax", url, popup_name, params); //ajaxwin.onclose=function(){return window.confirm("Close window?")} //Run custom code when window is about to be closed
}

function redir(url) {
  eval("location.href = '" + url + "'");
}

function redirParent(url) {
  eval("opener.location.href = '" + url + "'");
  self.close();
}

function checkAll(objControl, obj) {
  if (obj && objControl) {
    var value = objControl.checked;
    if (obj.length) {
      for (i = 0; i < obj.length; i++) obj[i].checked = value;
    } else {
      obj.checked = value;
    }
  }
}

function ClearSelectBox(obj) {
  var NumState = obj.options.length;
  while (NumState > 0) {
    NumState--;
    obj.options[NumState] = null;
  }
}

function onEnterpress(e) { //define any varible
  var KeyPress; //if which property of event object is supported 
  if (e && e.which) {
    e = e; //character code is contained in NN4's which property
    KeyPress = e.which;
  } else {
    e = event; 
	KeyPress = e.keyCode;
  } 
  //13 is the key code of enter key
  return (KeyPress == 13) ? true : false;
}