// JavaScript Document
function MM_findObj(n, d) 
{ 
  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 && d.getElementById) x=d.getElementById(n); return x;
}


function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}



function theform_Validator(theForm)
{

  if (theForm.FirstName.value == "")
  {
    alert("Please enter a value for the \"FirstName\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.FirstName.value.length > 35)
  {
    alert("Please enter at most 35 characters in the \"FirstName\" field.");
    theForm.FirstName.focus();
    return (false);
  }

  if (theForm.LastName.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.LastName.value.length > 35)
  {
    alert("Please enter at most 35 characters in the \"Last Name\" field.");
    theForm.LastName.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"E-mail Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"E-mail Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Company.value == "")
  {
    alert("Please enter a value for the \"Company\" field.");
    theForm.Company.focus();
    return (false);
  }

  if (theForm.Company.value.length > 80)
  {
    alert("Please enter at most 80 characters in the \"Company\" field.");
    theForm.Company.focus();
    return (false);
  }

  if (theForm.Address1.value == "")
  {
    alert("Please enter a value for the \"Address\" field.");
    theForm.Address1.focus();
    return (false);
  }

  if (theForm.Address1.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Address\" field.");
    theForm.Address1.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }

  if (theForm.State.selectedIndex < 0)
  {
    alert("Please select one of the \"State\" options.");
    theForm.State.focus();
    return (false);
  }

  if (theForm.State.selectedIndex == 0)
  {
    alert("The first \"State\" option is not a valid selection.  Please choose one of the other options.");
    theForm.State.focus();
    return (false);
  }

  if (theForm.Zip.value == "")
  {
    alert("Please enter a value for the \"Zip Code\" field.");
    theForm.Zip.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter a value for the \"Phone Number\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Fax.value == "")
  {
    alert("Please enter a value for the \"Fax Number\" field.");
    theForm.Fax.focus();
    return (false);
  }

  if (theForm.Revenues.selectedIndex < 0)
  {
    alert("Please select one of the \"Annual Company Revenues\" options.");
    theForm.Revenues.focus();
    return (false);
  }

  if (theForm.Revenues.selectedIndex == 0)
  {
    alert("The first \"Annual Company Revenues\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Revenues.focus();
    return (false);
  }

  if (theForm.Offices.selectedIndex < 0)
  {
    alert("Please select one of the \"Sales Offices\" options.");
    theForm.Offices.focus();
    return (false);
  }

  if (theForm.Offices.selectedIndex == 0)
  {
    alert("The first \"Sales Offices\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Offices.focus();
    return (false);
  }

  if (theForm.Reps.selectedIndex < 0)
  {
    alert("Please select one of the \"Sales Reps\" options.");
    theForm.Reps.focus();
    return (false);
  }

  if (theForm.Reps.selectedIndex == 0)
  {
    alert("The first \"Sales Reps\" option is not a valid selection.  Please choose one of the other options.");
    theForm.Reps.focus();
    return (false);
  }
  return (true);
}

function loadXmlFile(filename)
{
	try //Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	}
	catch(e)
	{
		try //Firefox, Mozilla, Opera, etc.
		{
			xmlDoc=document.implementation.createDocument("","",null);
		}
		catch(e)
		{
			alert(e.message);
			return;
		}
	}
	
	xmlDoc.async=false;
	
	xmlDoc.load(filename);
	
	return xmlDoc;
}

function getRootChildren(xmlDoc)
{
	return xmlDoc.documentElement.childNodes;
}

function checkNodeType(nodevalue,nt)
{
	if(nodevalue.nodeType==nt)
		return true;
	else
		return false;
}

function getAttributes(nodeval,category)
{
	var i;
	
	retval = new Array ();

	alert(nodeval.attributes.length);
	
	if(nodeval.attributes.length>0)
	{
		for(i=0;i<nodeval.attributes.length;i++)
		{
			if(category=='nodename')
				retval=nodeval.attributes[i].nodeName;
			else
				retval=nodeval.attributes[i].nodeValue;
		}
	}
	return retval;
}


