<?php/* index.php */?>
<?php include("app/design/html/head.php"); ?>

<div class="col-main">
	<div class="cms">
	<div class="loader_success"></div>
	<div class="contact_add" style="float: right">
	<h2>Other Way to Contact Us</h2>
	<?php if(phoneNumber()) { ?><p><strong>Phone Number : </strong><?php echo phoneNumber(); ?></p> <?php } ?>
	<?php if(email()) { ?><p><strong>Email Address : </strong><?php echo email(); ?></p> <?php } ?>
	<?php if(address()) { ?><p><strong>Address : </strong><?php echo address(); ?></p> <?php } ?>
	</div>
	<input type="hidden" class="emailaddress_admin" value="<?php echo email(); ?>" />
	
	<div class="loader_mail" style="position: absolute;">Sending the Email. Please Wait. . .</div>
	
	<div class="Cotactform">
		<div class="personal_info">
			<p>
			<label>First Name: </label><br />
			<input type="text" name="fname" class="fname email_text" />
			</p>
			<p>
			<label>Last Name: </label><br />
			<input type="text" name="lname" class="lname email_text" />
			</p>
			<p>
			<label>Your Email Address: </label><br />
			<input type="text" id="validate" name="email" class="email email_text" />
			</p>
			<p>
			<label>Message: </label><br />
			<textarea class="message" style="width: 580px; height: 225px;"></textarea>
			</p>
			<p>
			<br />
			<button class="send"><span>Send</span></button>
			</p>
		</div>
	</div>
</div>
</div>
<script>
			
	$(document).ready( function() {
		$('.send').attr("disabled", true);
	$('.loader_mail').hide()
		$('.loader_success').text()
	$("#validate").keyup( function(){
		
		

			var email = $("#validate").val();
			
			if(email != 0)
			{
				if(isValidEmailAddress(email))
				{
			
						$("#validate").removeClass("error"); 
						$('.send').removeAttr("disabled")

					} else {
							$("#validate").addClass("error");
							$('.send').attr("disabled", true);
							
				
					};
				
			} else {
						$('.send').attr("disabled", true);
						$("#validate").removeClass("error"); 
				}
				});			

		
	
	
		$('.send').click( function() {
			var fname = $('.fname').val()
			var lname = $('.lname').val()
			var email = $('.email').val()
			var message = $('.message').val()
			var admin = $('.emailaddress_admin').val()
			if(fname == ""){
					$('.fname').addClass('error')
			}else if(lname == ""){
					$('.lname').addClass('error')
			}else if(message == ""){
					$('.message').addClass('error')
			}else{
				$('.fname').removeClass('error')
				$('.lname').removeClass('error')
				$('.message').removeClass('error')
					$('.loader_mail').show()
						$('.loader_mail').html('Sending the Email. Please Wait. . .')
				$.ajax({
				type: "POST",
				data: ({fname: fname, lname: lname, email: email, message: message, admin: admin}),
				url:"email.php",
				success: function(response) {
				$('.loader_success').fadeIn()
				$('.loader_success').html("Your Email Has Been Sent. .");
				$('.loader_mail').fadeOut()
				$('.fname').val('');
				$('.lname').val('');
				$('.message').val('');
				$('.email').val('');
				}
				})
				
				
				}
		})
	})
	function isValidEmailAddress(emailAddress) {
 		var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
 		return pattern.test(emailAddress);
	}
</script>

<?php include("app/design/html/footer.php"); ?>