<?/*
Copyright (C) 2003 Media Net Link, Inc. Danville, CA 94526 USA

This file is part of AthenaRMS.

AthenaRMS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

AthenaRMS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/?>
<SCRIPT LANGUAGE="JavaScript">

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;

	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}

	return result;
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}

	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}

  return result;

}

function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;

 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();
			result = false;
		}
	}

	return result;
}


function validInt(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;

 	if (result)
 	{
 		var num = parseInt(formField.value);
 		if (isNaN(num))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();
			result = false;
		}
	}

	return result;
}


function validDate(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;

 	if (result)
 	{
 		var elems = formField.value.split("/");

 		result = (elems.length == 3); // should be three components

 		if (result)
 		{
 			var month = parseInt(elems[0]);
  			var day = parseInt(elems[1]);
 			var year = parseInt(elems[2]);
			result = allDigits(elems[0]) && (month > 0) && (month < 13) &&
					 allDigits(elems[1]) && (day > 0) && (day < 32) &&
					 allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4));
 		}

  		if (!result)
 		{
 			alert('Please enter a date in the format MM/DD/YYYY for the "' + fieldLabel +'" field.');
			formField.focus();
		}
	}

	return result;
}

function validateForm(theForm)
{
	// Customize these calls for your form

	// Start ------->
	if (!validRequired(theForm.subject,"Subject"))
		return false;

	if (!validRequired(theForm.first_name,"First Name"))
		return false;

	if (!validRequired(theForm.last_name,"Last Name"))
		return false;

	if (!validEmail(theForm.email,"Email Address",true))
		return false;

	if (!validRequired(theForm.comments,"Details of Request"))
		return false;

	// <--------- End

	return true;
}
</SCRIPT>

<script type="javascript">
   function openit(sURL){
     newwindow=open(sURL,'rlrpopupnav','width=440,height=350,directories=no,location=no,menubar=no,scrollbars=auto,status=no,toolbar=no,resizable=no,left=10%,top=10%,screenX=10%,screenY=10%');
   }
</script>


<!-- 2002/11/22 10:59:07 -->

<!-- remote person_id  -->

<body bgcolor="white" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!-- end header -->

<br />

<!-- begin sub header -->

<?php
  require_once 'crm.php';
  $crm = new Crm ();
  $crm_id = $crm->CRM_ID_By_Host_Path ();
  $crm_rec = $crm->Select_by_CRM_ID ($crm_id);
  $crm_name = $crm_rec->Get('crm_name');
?>

<center>

<table border="0" class="maintable" cellpadding="0" cellspacing="0">

<form action="submit" method="post" onsubmit="return validateForm(this)" id="form1" name="form1" enctype="multipart/form-data">

<tr>
  <td><img src="../img/console-fill-top-corn-left.gif" width="15" height="30" alt="" /></td>
  <td nowrap="nowrap" align="left" class="textsm" valign="top" background="../img/console-fill-vert-line-top.gif">

<table width='100%' border="0" height="23" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td class="textsm" align="left" valign="middle"><b class="supnavrmsttyl"><?php echo $crm_name; ?> request</b><!--:&nbsp;<font class='textsm'>support@<?php echo $SERVER_NAME; ?></font>--></td>
<td class="navlnk" align="right" valign="middle">

<font class="supnavnote">(red indicates required fields)</font>

</td>
</tr></table>


 </td>
  <td><img src="../img/console-fill-top-corn-right.gif" width="14" height="30" alt="" /></td>
</tr>
<tr>
  <td background="../img/console-fill-vert-line-left.gif"><img src="../img/cldot.gif" width="4" height="1" alt="" /></td>
  <td width="550" align="center">

    <table bgcolor="#e6f0ce" cellpadding="5" border="0" cellspacing="0" width="100%">
    <tr><td class="textsm" ALIGN="center" NOWRAP="nowrap" WIDTH="100%">

<!-- end sub header -->

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD ALIGN="center" VALIGN="top">

<!-- collum 1 -->
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">

<tr>
  <td class="red">Subject: </td>
  <td class="textsm"><input class="textsm" size='20' type="text" name="subject" value="<?= $subject ?>" /></td>
</tr>

<tr>
  <td class="red">First Name: </td>
  <td class="textsm"><input class="textsm" size='20' type="text" name="first_name" value="<?= htmlentities($first_name) ?>" /></td>
</tr>
<tr>
  <td class="red">Last Name: </td>
  <td><input class="textsm" type="text" size='20' name="last_name" value="<?= htmlentities($last_name) ?>" /></td>
</tr>
</table> </TD>


<TD ALIGN="center" VALIGN="top"><IMG ALT="" SRC="../img/cldot.gif" WIDTH="10" HEIGHT="1"></TD>


<TD ALIGN="center" VALIGN="top">
<!-- collum 2 -->

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">

<tr>
  <td class="red">Email: </td>
  <td><input class="textsm" type="text" size='20' name="email" value="<?= $email ?>" /></td>
</tr>
<tr>
  <td class="textsm">Company: </td>
  <td><input class="textsm" type="text" size='20' name="company" value="<?= htmlentities($company) ?>" /></td>
</tr>
<tr>
  <td class="textsm">Phone: </td>
  <td><input class="textsm" type="text" size='20' name="work_phone" value="<?= $work_phone ?>" /></td>
</tr>
</table>

<tr>
<td colspan='3' align='left' class="textsm">&nbsp;Attach File: <input type="file" size='20' class="textsm" name="afile" /></td>
</tr>

 </TD>
</TR>
</TABLE>

<br />

<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0">

<tr>
  <td class="red" ALIGN="LEFT">Please specify details of request:<br /><textarea CLASS="textsm" name="comments" rows="5" cols="70"><?php echo htmlentities($comments) ?></textarea></td>
</tr>
</table>

<br />

<table cellspacing="0" cellpadding="1" border="0" bgcolor="#506B1D">
<tr>
<td><input class="textsm" type="submit" name="submit" value="Submit Request" /></td>
</tr>
</table>

<?php
  if ($wpid = $crm_rec->Get ('web_page_id')) {
    require_once 'attribute_display.php';

    $ad = new Attribute_Display ();
    #$ad->Set_Edit_Flag (0);

    #print $ad->show_page ($wpid);
  }
?>

<!-- begin footer nav -->

</td></tr></table>

</td>
  <td background="../img/console-fill-vert-line-right.gif"><img src="../img/cldot.gif" width="4" height="1" alt="" /></td>
</tr>
<tr>
  <td> <img src="../img/console-fill-btm-corn-left.gif" width="15" height="11" alt="" /></td>
  <td background="../img/console-fill-vert-line-btm.gif"><img src="../img/cldot.gif" width="1" height="11" alt="" /></td>
  <td> <img src="../img/console-fill-btm-corn-right.gif" width="14" height="11" alt="" /></td>
</tr>

</form>

</table>

</center>
