function submitcustomform()
{
 frm = document.getElementById("customform");
 resu = myvalidate_form(frm);
 if (resu !== false){
  frm.submit();
  }
}
function changecustomform()
{
 frm = document.getElementById("customform");
 frm.submit();
}

function myvalidate_required(field,alerttxt)
{
with (field){
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function myvalidate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
};


function myvalidate_num(field,alerttxt)
{
with (field){
  if (isNaN(value))
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function myvalidate_notequal(field1,field2,alerttxt)
{
  if (field1.value == field2.value)
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
}


function myvalidate_form(thisform){

with (thisform)
{
  if (!default1.checked){
    plot = "Red plot : \n";
    if (ystart1!==null){
      if (myvalidate_required(ystart1, plot+"Start scale Must be filled out!")==false)
        {ystart1.focus();return false;}
	  if (myvalidate_num(ystart1,plot+"Start scale Must be a number")==false)
        {ystart1.focus();return false;}
    };
    
    if (yend1!==null){
      if (myvalidate_required(yend1,plot+"End scale Must be filled out!")==false)
        {yend1.focus();return false;}  
	  if (myvalidate_num(yend1,plot+"End scale Must be a number")==false)
        {yend1.focus();return false;}  
	
	if ((ystart1!==null)&&(yend1!==null)){
	  if (myvalidate_notequal(ystart1,yend1,plot+"Start and End Scale Must be different!")==false)
        {ystart1.focus();return false;}
	};
	
    };
  };
  
  if (!default2.checked){
    plot = "Blue plot : \n";
    if (ystart2!==null){
      if (myvalidate_required(ystart2,plot+"Start scale Must be filled out!")==false)
        {ystart2.focus();return false;}
	  if (myvalidate_num(ystart2,plot+"Start scale Must be a number")==false)
        {ystart2.focus();return false;}
    }
    
    if (yend2!==null){
      if (myvalidate_required(yend2,plot+"End scale Must be filled out!")==false)
        {yend2.focus();return false;}  
	  if (myvalidate_num(yend2,plot+"End scale Must be a number")==false)
        {yend2.focus();return false;}  
		
	if ((ystart2!==null)&&(yend2!==null)){
	  if (myvalidate_notequal(ystart2,yend2,plot+"Start and End Scale Must be different!")==false)
        {ystart2.focus();return false;}
	};
	
    }
  }
}  
return true;
}

