<?php
 //If the form is submitted
 if(isset($_POST['submit'])) {

     //Check to make sure that the name field is not empty
     if(trim($_POST['contactname']) == '') {
         $hasError = true;
     } else {
        $name = trim($_POST['contactname']);
     }
     //Check to make sure that the subject field is not empty
    if(trim($_POST['subject']) == '') {
         $hasError = true;
     } else {
         $subject = trim($_POST['subject']);
     }

    //Check to make sure sure that a valid email address is submitted
    if(trim($_POST['email']) == '')  {
         $hasError = true;
     } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", trim($_POST['email']))) {
         $hasError = true;
     } else {
         $email = trim($_POST['email']);
     }

    //Check to make sure comments were entered
     if(trim($_POST['message']) == '') {
         $hasError = true;
    } else {
        if(function_exists('stripslashes')) {
             $comments = stripslashes(trim($_POST['message']));
       } else {
            $comments = trim($_POST['message']);
        }
     }

    //If there is no error, send the email
     if(!isset($hasError)) {
        $emailTo = 'youremail@yoursite.com'; //Put your own email address here
        $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments";
        $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

        mail($emailTo, $subject, $body, $headers);
        $emailSent = true;
 }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/index.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" href="css/slimbox2.css" type="text/css" media="screen" />
<!--[if IE 6]>
	<link href="css/ie6.css" type="text/css" rel="stylesheet" />

    <script src="js/dd_belated_png.js"></script>
	<script>DD_belatedPNG.fix('#logo a, .h-box-1 img, .h-box-2 img, .brochure img');</script>
<![endif]-->

<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="js/slideswitch.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="js/slimbox2.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript">

	$(document).ready(function(){
		 $("#contactform").validate();
	});
</script>

<title>美中文化交流促进协会 > 联系我们</title>
</head>

<body>
<div id="body-wrapper">
    <div class="clearfix">
        <div id="logo">
            <a href="homepage.html"></a>
        </div>
    </div>

    <div class="main-menu-wrapper">
        <div id="myslidemenu" class="jqueryslidemenu">
            <ul class="primary-menu">
                 <li><a href="index.html">首页</a></li>
                <li><a href="events.html">近期活动</a></li>
                <li><a href="gallery.html">新闻图片</a></li>
                <li><a href="contact.php">联系我们</a></li>
            </ul>
        </div>
    </div>

    <div id="left">
		<div class="interior-header">
        	<h2>联系我们</h2>
            <!--<p class="intheader-paragraph">
                Have a question? Want to leave feedback or just say hi? Please don’t hesitate to complete the form below if you want to
                discuss ways we could help you reach your objectives.
            </p>-->
        </div>
        <div class="interior-content">

			 <?php if(isset($hasError)) { //If errors are found ?>
                <div class="contact-error">
                	<p>请您查看输入的资料是否正确。</p>
                </div>
            <?php } ?>

            <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
            	<div class="contact-success">
                    <p>
                        谢谢，您的信件已发出！
                    </p>
                </div>
            <?php } ?>

            <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="contactform"><!-- Contact form -->
            	<fieldset class="contact-fieldset">
           			<h3>请给我们您的宝贵意见</h3>
                	<ul>
                    	<li>
                        	<label for="contactname">姓名:</label>
                            <input type="text" name="contactname" id="contactname" value="" class="contact-input required" />
                        </li>
                    	<li>
                        	<label for="email">Email:</label>
                            <input type="text" id="email" name="email" class="contact-input required email" />
                        </li>
                    	<li>
                        	<label for="subject">题目:</label>
                            <input type="text" name="subject" id="subject" class="contact-input required" />
                        </li>
						<li>
                        	<label for="message">内容:</label>
                            <textarea rows="6" cols="40" id="message" name="message" class="contact-textarea required"></textarea>
                        </li>
                        <li>
                        	<input type="submit" value="发送" name="submit" class="contact-submit" />
                        </li>
                    </ul>
                </fieldset>
            </form>

		</div>

    </div>
    <div id="right">
		<div class="address-box"><!-- address & map section -->
        	<h3>地址</h3>
            <address>
            	<span>
                    43-41 156 St. 1 FL. <br />
                    Flushing, NY 11355 <br />
                    U.S.A.
				</span>
                <span>
                    Phone: (718) 358-3714<br />
                    Fax: (212) 969-9851 <br />
                    Email: <a href="mailto://info@ucceda.org">info@ucceda.org</a>
                </span>
            </address>
        </div>

        <!--
        <div class="newsletter">
			<h3>Sign up for Newsletter</h3>
            <form action="#" method="post">
            	<fieldset class="newsletter-fieldset">
                    <input type="text" class="newsletter-input" value="Your email address" name="newsletter" />
                    <input type="submit" value="" class="input-arrow" />
                </fieldset>
            </form>
            <p>We will keep you up to date with news, events and other great features.</p>
        </div>
        -->

    </div>
    <div id="footer">
    	<ul>
        	<li><a href="index.html">首页</a></li>
        	<li><a href="events.html">近期活动</a></li>
        	<li><a href="gallery.html">新闻图片</a></li>
        	<li><a href="contact.php">联系我们</a></li>
        </ul>
        <div class="copyright">&copy; 2014 <a href="#">www.ucceda.org</a>. All rights reserved.</div>
    </div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$(".brochure").click(function(){//makes entire area "brochure" clickable
    	window.location=$(this).find("a").attr("href");return false;
	});

});
</script>
</body>
</html>
