<link href="style/reset.css" rel="stylesheet" type="text/css" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobivation</title>

<script type="text/javascript">var _siteRoot='index.php',_root='index.php';</script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>

<link href="style/home.css" rel="stylesheet" type="text/css" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="js/dom_img_rollover.js"></script>
</head>
<?php 
include 'wcp/function/classes.php';
$cryptinstall='include/crypt/cryptographp.fct.php';
include('include/crypt/cryptographp.fct.php');

$prodlist=getList("product_id,product_name,product_brief_desc,product_logo","tb_products","");
$getprodlist=getList("prod.product_id,prod.paypal_text,prod.product_name,prod.product_price,prod.product_logo,prod.product_desc","tb_products prod","where product_id=".$_GET['prodid']);

function valid_email($email)
{
   $isValid = true;
   $atIndex = strrpos($email, "@");
   if (is_bool($atIndex) && !$atIndex)
   {
      $isValid = false;
   }
   else
   {
      $domain = substr($email, $atIndex+1);
      $local = substr($email, 0, $atIndex);
      $localLen = strlen($local);
      $domainLen = strlen($domain);
      if ($localLen < 1 || $localLen > 64)
      {
         // local part length exceeded
         $isValid = false;
      }
      else if ($domainLen < 1 || $domainLen > 255)
      {
         // domain part length exceeded
         $isValid = false;
      }
      else if ($local[0] == '.' || $local[$localLen-1] == '.')
      {
         // local part starts or ends with '.'
         $isValid = false;
      }
      else if (preg_match('/\\.\\./', $local))
      {
         // local part has two consecutive dots
         $isValid = false;
      }
      else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
      {
         // character not valid in domain part
         $isValid = false;
      }
      else if (preg_match('/\\.\\./', $domain))
      {
         // domain part has two consecutive dots
         $isValid = false;
      }
      else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
                 str_replace("\\\\","",$local)))
      {
         // character not valid in local part unless 
         // local part is quoted
         if (!preg_match('/^"(\\\\"|[^"])+"$/',
             str_replace("\\\\","",$local)))
         {
            $isValid = false;
         }
      }
      if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
      {
         // domain not found in DNS
         $isValid = false;
      }
   }
   return $isValid;
}

function valid_captcha($param_code)
{		
	//echo '<br>' . 'Param code: ' . $param_code;
  if (chk_crypt($param_code)) return true;
  else return false;
}

if ( isset($_POST['btnSubmit']) )
{	

	//echo 'valid email: ' . valid_email( $_POST['txt_email'] );
	//echo '<br>valid captcha: ' . valid_captcha( $_POST['code'] );

	if (
		!isset($_POST['txt_full_name']) ||
		!isset($_POST['txt_message']) ||
		!isset($_POST['txt_email']) ||		
		!valid_email($_POST['txt_email']) ||
		strlen(trim($_POST['txt_full_name'])) <= 0 ||
		strlen(trim($_POST['txt_message'])) <= 0 ||
		strlen(trim($_POST['txt_email'])) <= 0 
		//!valid_captcha($_POST['code']
	   ) 		
	{
		?>
        <script language="javascript" type="text/javascript">
			alert('All fields are compulsory. You might also want to check whether the email address is valid.');
		</script>
        <?php
	}
	else
	{
		if (isset($_POST['txt_company']) && strlen(trim($_POST['txt_company'])) > 0) $company = $_POST['txt_company'];
		else $company = 'N/A';
		
		if (isset($_POST['txt_phone'])  && strlen(trim($_POST['txt_phone'])) > 0) $phone = $_POST['txt_phone'];
		else $phone = 'N/A';

		if (isset($_POST['txt_country']) && strlen(trim($_POST['txt_country'])) > 0) $country = $_POST['txt_country'];
		else $country = 'N/A';
		
		$mail_content = '<strong>Dear Mobivation,</strong>,<br><br>' . 
						'There\'s a message sent to you from your website on ' . date('l') . ', ' . date('d M Y') . '.<br><br>' .
						'<strong>Sender\'s name</strong>: ' . $_POST['txt_full_name'] . '<br><br>' .
						'<strong>Company</strong>: ' . $company . '<br><br>' .
						'<strong>Phone</strong>: ' . $phone . '<br><br>' .
						'<strong>Email</strong>: ' . $_POST['txt_email'] . '<br><br>' .
						'<strong>Country</strong>: ' . $country . '<br><br>' .
						'<strong>Message content</strong>:<br>' .
						$_POST['txt_message'];			
						
		$mail_subject = 'Mobivation: Web Inquiry';

		// To send HTML mail, the Content-type header must be set		
		$headers = 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";		
		$headers .= 'Reply-To: ' . $_POST['txt_email'] . "\r\n";
		
		$spool = mail('support@mobivation.com.sg',$mail_subject,$mail_content,$headers);
		//$spool = mail('ignatius.steven@gmail.com',$mail_subject,$mail_content,$headers);
			
		if ($spool == TRUE)
		{
			?>
			<script language="javascript" type="text/javascript">
				alert('Thank you, your inquiry has been sent');
			</script>
			<?php
		}
	}
}

?>
<body>
<div id="page">
<div id="container">
  <?php include "menu.php"; ?>
  <div id="top_content">     
    <table width="850" border="0" align="center" cellpadding="1" cellspacing="4" class="upper_three_columns">
      <tr>
        <td>
        <table>
        	<tr>
            	<td><p><span class="page_title">Contact Us</span></p>
                  <p>&nbsp;</p>
                  <p>&nbsp;</p>
                  <p>If at this stage you are:</p>
                  <p>&nbsp;</p>
                  <p>a. Thinking about working together with us? <br />
                    b. 
                    Integrating a system or need a custom IT solution? <br />
                    c. 
                    Want to get a quote? <br />
                    d. Need some IT help?</p>
                  <p>e. Want to know more about us?<br />
                    <br />
                Then drop us a message! Fill in the form below and we'll reply you back as soon as possible!</p></td>
            </tr>
        </table>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <form method="post" action="contact.php">        
<table width="100%" border="0" class="page_header" style="border-collapse:separate; border-spacing:20px;">
        <tr>
          <td valign="top">                  Full name *<br />
            <input name="txt_full_name" type="text" class="input_textfield" id="input_text" size="63" />
          </td>
        </tr>
        <tr>
          <td valign="top">E-mail  *<br />
          <input name="txt_email" type="text" class="input_textfield" id="input_text" size="63" /></td>
        </tr>
        <tr>
          <td valign="top">Phone number<br />
          <input name="txt_phone" type="text" class="input_textfield" id="input_text" size="63" /></td>
        </tr>
        <tr>
          <td valign="top">How can we help you? *<br />
          <textarea name="txt_message" cols="66" rows="7" class="input_textfield" id="input_textarea"></textarea></td>
		</tr>
		<!--
         <tr>
           <td valign="top"><?php echo dsp_crypt(0,1); ?> <span class="my_font1"><br />            
            Input the captcha code *</span><br />
           <input type="text" name="code"  id="input_text" class="blankbackground" /></td>
		 </tr>
		-->
         <tr>
          <td valign="top"><input type="submit" name="btnSubmit" id="input_button" value="Submit" class="submit_contact" />            <br /></td>
		</tr>		
      </table>
      </form>
        </td>
      </tr>                
    </table>
    <div id="nothing" style="clear:both"> </div>
    <?php include "footer.php"; ?>
  </div>
</div>
<script type="" text="" javascript="">
if(!window.slider) 
var slider={};
slider.data=[<?php
$prodlist2=getList("product_id,product_name,product_brief_desc,product_logo","tb_products","");
$strTemp="";				
if (count($prodlist2) > 0)
{	
	while($row=mysql_fetch_array($prodlist2) ){
		$strTemp = $strTemp . "{'id':'prod" . $row['product_id'] . "','client':'" . $row['product_name'] . "','desc':'" . $row['product_brief_desc'] . "'},";
	}
	if (substr($strTemp, -1) == ","){
		$strTemp = substr_replace($strTemp,'',-1,1);
	}
	echo $strTemp;
}?>];
</script>
</body>
</html>
