//******************************************************************
// function browserCheck()                                         *
// function lTrim(string)                                          *
// function chkNumber(string)                                      *
// function chkRange(string, from, to)                             *
// function chkDigit(string)                                       *
// function chkPhone(string)                                       *
//******************************************************************
//
function browserCheck() {
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.toUpperCase().indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.toUpperCase().indexOf('MSIE 5')>0)
	this.ie6 = (navigator.userAgent.toUpperCase().indexOf('MSIE 6')>0)
    this.mac = (navigator.userAgent.toUpperCase().indexOf("MAC")!=-1);
	this.min = (this.ns||this.ie)
}
// is object contained version
is = new browserCheck()

function lTrim(s) {
  var i=0;
  var white = " ,;:.";
  while (i<s.length && white.indexOf(s.charAt(i))>=0) i++;
  return s.substr(i);
}
function isInt(s) {
  var i, len;
  var digits = "0123456789"
  len = s.length;
  for (i=0; i<=len; i++) {
    if (digits.indexOf(s.charAt(i))<0) return false;
  }
  return true;
}
function isNameWithQuotes(s) {
  var i=0;
  var special = "!@#$%^*()+={}[]:;?";
  while (i<s.length) {
	if (special.indexOf(s.charAt(i))>=0)
		return false;
	i++;
  }
  return true;
}
function chkNumber(s) {
  // both integer or real
  if (isNaN(parseFloat(s)))
	return false;
  return true;
}
function chkRange(s,from,to) {
  if (s!="") {
    var n = parseFloat(s);
	if (n<from || n>to)
	    return false;
  }
  return true;
}
function chkDigit(c) {
  if (c>="0" && c<="9")
    return true;
  else
    return false;
}

function chkReason(s) {
  var sr = lTrim(s);
  if (sr.length>1) 
    return true;
  else
    return false;
}
function chkPhone(ps) {
  var s = lTrim(ps);
  var i = 0;
  while (i<3 && chkDigit(s.charAt(i))) i++;
  if (i!=3)
    return false;
  if (s.charAt(i)!="-" && s.charAt(i)!=".")
    return false;
  else
    i++;
  while (i<7 && chkDigit(s.charAt(i))) i++;
  if (i!=7)
    return false;
  if (s.charAt(i)!="-" && s.charAt(i)!=".")
    return false;
  else
    i++;
  while (i<12 && chkDigit(s.charAt(i))) i++;
  if (i<12) 
    return false;
  else
    return true;    
}

// disable right click
function hp_ne() {return true}
onerror=hp_ne;
function hp_cm() {return false}
function hp_md(e) {if(e.which==2||e.which==3) {return false} }
function disableRC() {
	if (navigator.appName.indexOf('Internet Explorer')==-1 || navigator.userAgent.indexOf('MSIE')!=-1) {
		if (document.all) { document.oncontextmenu=hp_cm }
		if (document.layers) {
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown=hp_md
		}
		if (document.getElementById && !document.all) { document.oncontextmenu=hp_cm }
	}
}
// customized bad image
function galBadImage( iobj )
{
    iobj.src = "http://www.bunk1.com/bad.jpeg";
}