function clean(obj,action,str)
{
 if(obj.value==str && action=="focus"){obj.value="";obj.style.color="#0000AA";}
 if(!obj.value && action=="blur"){obj.value=str;obj.style.color="#AAAAAA";}
 myTrim(obj);
}

function myTrim(obj)
{
	var str = "";
	str = "" + obj.value;
	//trim the end
	while('' + str.charAt(str.length-1) == ' ')
	{
		str = str.substring(0,str.length-1);
	}
	//trim the front
	while('' + str.charAt(0) == ' ')
	{
		str = str.substring(1,str.length);
	}
	obj.value = str;
}

function importclean(obj)
{
  if(obj.newgroup){
   myTrim(obj.newgroup);
   if(obj.newgroup=="Type Here")obj.newgroup="";
  }
  if(obj.importnamesurl){
  if(obj.importnamesurl=="Type Here")obj.importnamesurl="";
  }
  if(obj.Alias)myStripChars(obj.Alias);
  return true;
}

// ================================================================

function showmeENH(content,w,h,scroll,wName) 
  {
  var myWidth = w;
  var myHeight = h;
  if (document.layers)
    var maxHeight = window.innerHeight - 40
  else
    var maxHeight = 700
  if (myHeight > maxHeight) myHeight = maxHeight;
  var win = window.open("",wName,"toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars="+scroll+",width="+myWidth+",height="+myHeight);
  win.document.open("text/html");
  win.document.open("text/html","replace"); // "replace" option destroys history
  win.document.write("<HTML><HEAD><TITLE>Merchant Resource Group: Information</TITLE></HEAD><LINK HREF=\"css/popup_style.css\" REL=\"STYLESHEET\" TYPE=\"TEXT/CSS\"><BODY bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#9900FF\" vlink=\"#9900FF\" alink=\"#9900FF\" MARGINHEIGHT=\"10\" MARGINWIDTH=\"10\" TOPMARGIN=\"10\" LEFTMARGIN=\"10\" OnLoad=\"self.focus()\"><div>"+content+"<br><br><strong><a href=\"javascript:self.close()\">close window</a></strong><br></div></BODY></HTML>");
  win.document.close();
  win.focus();
  }

function showmeENH2(content,w,h,scroll,wName) 
  {
  var myWidth = w;
  var myHeight = h;
  if (document.layers)
    var maxHeight = window.innerHeight - 40
  else
    var maxHeight = 700
  if (myHeight > maxHeight) myHeight = maxHeight;
  var win = window.open("",wName,"toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars="+scroll+",width="+myWidth+",height="+myHeight);
  win.document.open("text/html");
  win.document.open("text/html","replace"); // "replace" option destroys history
  win.document.write("<HTML><HEAD><TITLE>Merchant Resource Group: Information</TITLE></HEAD><BODY bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#9900FF\" vlink=\"#9900FF\" alink=\"#9900FF\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" OnLoad=\"self.focus()\">"+content+"</BODY></HTML>");
  win.document.close();
  win.focus();
  }

function showme(filename,w,h,scroll,wName) {
  //if (document.layers)var myWidth = w + 80;
  //if (document.layers)var myHeight = h + 400;
  var myWidth = w;
  var myHeight = h;
if (document.layers)
  var maxHeight = window.innerHeight - 40
else
  var maxHeight = 700
if (myHeight > maxHeight) myHeight = maxHeight;
  myHandle = window.open(filename,wName,'toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrollbars='+scroll+',width='+myWidth+',height='+myHeight)
}

function setValue(field,frm,val)
{
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      frm[i].value=val;
      //alert(frm[i].value);
    }
   }
}

function getObjByName(field,frm)
{
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      return frm[i];
    }
   }
}

function getObjOccurByName(field,frm,occur)
{
  findnum = 1;
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      if(findnum==occur)return frm[i];
      else findnum++;
    }
   }
}

function getValue(field,frm)
{
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      return frm[i].value;
    }
   }
}

function getValueOccur(field,frm,occur)
{
  findnum = 1;
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      if(findnum==occur){
         return frm[i].value;
         break;
      }else findnum++;
    }
   }
}

function setFocus(field,frm)
{
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      frm[i].focus();
    }
   }
}

function setFocusOccur(field,frm,occur)
{
  findnum = 1;
  for (i=0;i < frm.length;i++) 
   {
    if(frm[i].name==field){
      if(findnum==occur){
         frm[i].focus();
         break;
      }else findnum++;
    }
   }
}

function myStripSpaces(obj)
{
	var str = "";
	str = "" + obj.value;
      var space_re = new RegExp('\\s+\\g');
      //str = str.replace(space_re, '');
	while(str.indexOf(" ") != -1)
	{
		str = str.replace(space_re, '');
	}
	obj.value = str;
}

function myStripChars(obj)
{
	var str = "";
	str = "" + obj.value;
      var space_re = new RegExp('\\s+');
      var prd_re = new RegExp('\\.+');
      var comma_re = new RegExp('\,+');
	while(str.indexOf(" ") != -1 ||
		str.indexOf(".") != -1 ||
		str.indexOf(",") != -1)
	{
      str = str.replace(space_re, '');
      str = str.replace(prd_re, '');
      str = str.replace(comma_re, '');
	}
	obj.value = str;
}

function gourl(url)
{
  location = url;
}

function gopage(url,obj)
{
  //alert(url);
  obj.location.href = url;
}

//deleteuser
//setusergroup
//recount
//addlp
//subtractlp

function Delete(itemType,theName,theList)
{
  eval("var dl=document." + theList + ";");
  len = dl.elements.length;
  results = 0;
  for(var i = 0 ; i < len ; i++)
      {
      if (dl.elements[i].name == theName && dl.elements[i].checked)
       {results = results + 1;
        break;}else results = 0;
      }
  if(results > 0){
  var agree=confirm("WARNING: You are about to DELETE\nyour entries for the " + itemType + "\nyou have checked.\nAre you sure about this?");
  if (agree)
  {
   dl.actiontype.value = "deleteuser";
   dl.submit();
  }
  else
  {
   return false;
  }
}else alert("You must check off at\nleast one item you would\nlike to DELETE.")

}

function SetUserGroup(itemType,theName,theList)
{
  eval("var dl=document." + theList + ";");
  len = dl.elements.length;
  results = 0;
  for(var i = 0 ; i < len ; i++)
      {
      if (dl.elements[i].name == theName && dl.elements[i].checked)
       {results = results + 1;
        break;}else results = 0;
      }
  if(results > 0){
  var agree=confirm("WARNING: You are about to SET the USERGROUP\n setting for ALL the " + itemType + "\nyou have checked.\nAre you sure about this?");
  if (agree)
  {
   dl.actiontype.value = "setusergroup";
   dl.submit();
  }
  else
  {
   return false;
  }
}else alert("You must check off at\nleast one item you would\nlike to SET.")

}

function SetLPs(itemType,theName,theList,Type)
{
  eval("var dl=document." + theList + ";");
  len = dl.elements.length;
  results = 0;
  for(var i = 0 ; i < len ; i++)
      {
      if (dl.elements[i].name == theName && dl.elements[i].checked)
       {results = results + 1;
        break;}else results = 0;
      }
  if(results > 0){
  var agree=confirm("WARNING: You are about to\n" + Type + " Linking-Points " + ((Type=="add")?"to":"from") + " ALL the\n" + itemType + "s you have checked.\nAre you sure about this?");
  if (agree)
  {
   myStripSpaces(dl.LPs);
   dl.actiontype.value = "setlp";
   dl.LPs.value = ((Type=="add")?"+":"-") + dl.LPs.value;
   dl.submit();
  }
  else
  {
   return false;
  }
}else alert("You must check off at\nleast one item you would\nlike to " + Type + ((Type=="add")?"to":"from") + ".")

}

function ReCount(itemType,theName,theList)
{
  eval("var dl=document." + theList + ";");
  len = dl.elements.length;
  results = 0;
  for(var i = 0 ; i < len ; i++)
      {
      if (dl.elements[i].name == theName && dl.elements[i].checked)
       {results = results + 1;
        break;}else results = 0;
      }
  if(results > 0){
  var agree=confirm("WARNING: You are about to RESET seek/offer\ncounts for ALL the " + itemType + "\nyou have checked.\nAre you sure about this?");
  if (agree)
  {
   dl.actiontype.value = "recount";
   dl.submit();
  }
  else
  {
   return false;
  }
}else alert("You must check off at\nleast one item you would\nlike to SET.")

}

function Edit()
{
var dl=document.domainList;
  var len = dl.elements.length;
  var results = 0;
  for(var i = 0 ; i < len ; i++)
      {
      if (dl.elements[i].name == "Domain[]" && dl.elements[i].checked)
       {
        results = results + 1;
        //break;
       }
      }
if(results > 0){
  dl.Action.value = "edit";
  dl.pgmode.value = "DOMAINADDEDIT";
  dl.submit();
}else alert("You must select at\nleast one name\nto EDIT.");
}

function PopWin(url,w,h,scr)	// popup display
{
   nw = window.open(url,'ToppingMSG','width=' + w + ',height=' + h + ',toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=' + scr + ',resizable=1');
   return false;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}







function checkEmail(field)
{
	var i = field.value.indexOf("@");
	if (i==-1)
	{
		return false;
	}
	else if (field.value.substring(i).indexOf(".") == -1)
	{
		return false;
	}

	return true;
}

function checkValidDate(month, day)
{
	numMonth = month.value;
	numDay = day.value;
	if( (numMonth=="04" || numMonth=="06" || numMonth=="09" || numMonth=="11") && numDay=="31")
	{
		alert("This month does not have 31 days.");
		return false;
	}
	if(numMonth=="02" && (numDay=="31" || numDay=="30") )
	{
		alert("This month does not have that many days.");
		return false;
	}

	return true;

}

function form_reset(frm)
{
	frm.reset();
}

function MarkMe(obj) {
    if (obj.style.backgroundColor == "")
	{
	   obj.style.backgroundColor = "#FFFFCC"
	}
    else obj.style.backgroundColor = "";
}

/* Dynamic Version by: Nannette Thacker
 http://www.shiningstar.net
 Original by :  Ronnie T. Moore
 Web Site:  The JavaScript Source
 Use one function for multiple text areas on a page
 Limit the number of characters per textarea */

function textCounter(field,maxlimit) {
  if (field.value.length > maxlimit)
  {
  // if too long...trim it!
  field.value = field.value.substring(0, maxlimit);
  }
  return true;
}