<?php
include("config.php");
include("phpmailer/class.phpmailer.php");
function sendEmail($subject,$toEmail,$message,$fromEmail,$from_name)
{
 $body = stripslashes($message); 
 $mail = new PHPMailer();
 $mail->WordWrap = 50; // set word wrap 
 $mail->IsHTML;
 $mail->From = $fromEmail;
 $mail->FromName = html_entity_decode($from_name,ENT_QUOTES);
 $mail->AddAddress($toEmail);
 $mail->Subject = $subject;
 $mail->Body = $body; // message body sent
 $mail->AltBody = $body;
 $mail->Send();
}

if(isset($_POST['SUBMIT']))
{
   $name= stripslashes(htmlentities(trim($_POST['cname']),ENT_QUOTES));
	$to=  stripslashes(htmlentities(trim($_POST['cemail']),ENT_QUOTES));
	$subject= 'Spinhalf: Enquiry form';
	$mesg= stripslashes(htmlentities(trim($_POST['msg'])));
	$captchacode=$_POST['captchacode'];
	
	if(strtoupper($_SESSION['security_code']) != strtoupper($_POST['captchacode']))
  {
			
   $error1= "You have entered wrong captcha code.";
 }

 if($error1=='') 
 {
 
$admin_email = 'support@spinhalf.softdemo.info';
$admin_name = 'Spin Half';

$messages= '<!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>Untitled Document</title>
</head>

<body>
<table font-size="15px" width="600" cellspacing="0" cellpadding="5" align="center" style="border:4px solid #999999;">
  <tr>
  <td colspan="2"><a href="'.YOURSITE_URL.'" style="font-family:Times New Roman, Times, serif; color: #FFFFFF; font-weight: normal;"><img src="http://spinhalf.softdemo.info/images/logo.jpg" border="0" /></a></td></tr>
  
  
  <tr>
  
    <td height="26"><strong>Dear '.Admin.',</strong></td>
  </tr>
  <tr>
    <td colspan="2"10px" height="51" float="left">Here are the details of the user, which may have some queries or desiring to know about the site.</td>
	
	   
  </tr>
  
  <tr>
  <td width="105"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000; font-weight:bold; float:left; margin-left:8px;">Name:</td>
  <td width="274"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000;">'.$name.'</td>
  </tr>
  <tr>
  <td width="105"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000; font-weight:bold; float:left; margin-left:9px;">Email:</td>
  <td width="274"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000;"><a href="mailto:'.$to.'">'.$to.'</a></td>
  </tr>
  
   <tr>
  <td width="105"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000; font-weight:bold; float:left; margin-left:8px;">subject:</td>
  <td width="274"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000;">'.$subject.'</td>
  </tr>
  
  
  
  
  <tr>
  <td width="105"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000; font-weight:bold; float:left; margin-left:12px;">Message:</td>
  <td width="274"  align="left" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#000000;">'.nl2br(strip_tags(html_entity_decode($mesg))).'</td>
  </tr>

  <tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  </tr>
  
 <tr>
    <td><strong>Support Team
   </strong><br/>Spin Half
   </td>
   </tr>
   </table>
</body>
</html>';



// Enter your email address
//$to =AdminEmail();
//$to="sales@spinhalf.com";
$to="sales@spinhalf.com";

$send_contact=sendEmail($subject,$to,$messages,$admin_email,$admin_name); //mail($to,$subject,$messages,$header);

// Check, if message sent to your email 
// display message "We've recived your information"
	$_SESSION['succ_msg'] = "Thank you for contacting with us. One of our representatives will contact you soon.";
	header('location:contact.php');
	exit;
	
}

 
}

?>
<!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>Spin Half</title>
<script type="text/javascript">
function trim(txt_value) 
{ return (txt_value.replace(/^\s|\s*$/g,"")); }
function isValidEmail( emailField )
{ 
   // var emailregex=/^[\w]+\+?\w*@[\w]+\.[\w.]+\w$/; 
   var emailregex=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-zA-Z]{2,6}(?:\.[a-zA-Z]{2})?)$/i;
    var match=emailField.match( emailregex ); 
    if ( !match ) 
    { 
       return false; 
    }
    else
    {
       return true; 
    }
}

function val_regform()
{
	if(document.regform.cname.value=='' || document.regform.cname.value=='Your Name (required)')
	{
		alert("Please enter first name.");
		document.regform.cname.focus();
		return false;
	}
	
	
	if(document.regform.cemail.value=='' || document.regform.cemail.value=='Your Email (required)')
	{
		alert("Please enter email address.");
		document.regform.cemail.focus();
		return false;
	}
	if(document.regform.cemail.value!='')
	{
		if(!isValidEmail(document.regform.cemail.value))
		{
			alert("Please enter valid email address.");
			document.regform.cemail.focus();
			return false;
		}
		
	}
	
	if(document.regform.captchacode.value=='')
	{
		alert("Please enter captcha code.");
		document.regform.captchacode.focus();
		return false;
	}
}
function twiterbox()
{
	document.getElementById("twiter_box").style.display="block";
}

function twiterboxhide()
{
	document.getElementById("twiter_box").style.display="none";
}

function rssbox()
{
	document.getElementById("rss_box").style.display="block";
}

function rssboxhide()
{
	document.getElementById("rss_box").style.display="none";
}
</script>
<link href="css/style_sheet.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'/>
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Condensed' rel='stylesheet' type='text/css'/>
<link rel="shortcut icon" href="favicon.ico" />
<style type="text/css">
.twtr-widget
{
margin-right:-5px;
}
</style>
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="css/ie7.css" />
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="css/ie8.css" />
<![endif]-->
<!--[if IE 9]>
<link rel="stylesheet" type="text/css" href="css/ie9.css" />
<![endif]--> 
<!-- logo slide effect js -->
</head>
<body class="inner">
<div id="main_wrapper">
  <!--[if !IE]>main_wrapper div start here<![endif]-->
  <div id="inner">
    <!--[if !IE]>inner div start here<![endif]-->
    <?php
	include("includes/header.php");
	?>
    <div id="middle_container">
    <div style="float:right;display:none; position:relative; top:-121px; margin-right:0px;" class="twtr-widget" id="twiter_box">
<script src="http://widgets.twimg.com/j/2/widget.js" charset="utf-8"></script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 10,
  interval: 30000,
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#333333',
      color: '#ffffff'
    },
    tweets: {
      background: '#000000',
      color: '#ffffff',
      links: '#4aed05'
    }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    behavior: 'all'
  }
}).render().setUser('testmode321').start();
</script>
</div>
<div class="twtr-widget" id ="rss_box"  style="float:right; display:none; position:relative; width:400px; height:700px; overflow:auto; top:-121px; right:110px; margin-right:0px; background-color:#CCCCCC;">
    <?php

$news = simplexml_load_file('http://news.google.co.uk/news?pz=1&cf=all&ned=uk&hl=en&as_scoring=r&as_maxm=4&q=web+design&as_qdr=a&as_drrb=q&as_mind=6&as_minm=3&cf=all&as_maxd=5&output=rss');

foreach($news->channel->item as $item) {
 //echo $item->title . "<br>";
 echo $item->description ."<br>";
}
?>
</div>
   
      <div class="contact_sec">
	  
	  
        <h2>Contact Us</h2>
        <?php if($succ_msg!='') {?>                       
  <p align="left" style="color:#024176;font-size:15px;text-align:center; margin-top:0px; padding-top:3px; margin-left:-380px; padding-top:13px; font-weight:bold;"><?php echo @$succ_msg; ?></p>
  						 <?php } ?>
                         <?php if($_SESSION['succ_msg']!='') {?>                       
  <p align="left" style="color:#006600;font-size:15px;text-align:left; margin-top:0px; padding-top:3px;padding-top:13px; font-weight:bold;"><?php echo $_SESSION['succ_msg']; $_SESSION['succ_msg']=''; unset($_SESSION['succ_msg']);?></p>
  						 <?php } ?>
		<span style="color:#CC0000;"><?php echo $error1;?></span>
       
        <p>We are London based. Tel no.02033XXXXXX <a href="mailto:sales@spinhalf.com" title="sales@spinhalf.com">sales@spinhalf.com</a> <br/> Mobile no. 07968XXXXXX Partners - XXXXX XXXXXXX &amp; XXXXX XXXXXXXXX<br />
</p>
<div class="contact_form_txt_bg">
<!--<form method="post" action="#" name="regform" onsubmit="return val_regform();">-->
<form method="post" action="" name="regform" onsubmit="return val_regform();">
 <label>
    <input name="cname" type="text" value="<?php echo ($_POST['cname']!=''?$_POST['cname']:'Your Name (required)');?>" onfocus="if(this.value == 'Your Name (required)'){this.value = '';}" onblur="if(this.value == ''){this.value='Your Name (required)';}" />
    </label>
</div>
<div class="contact_form_txt_bg">
 <label>
    <input name="cemail" type="text" value="<?php echo ($_POST['cemail']!=''?$_POST['cemail']:'Your Email (required)');?>" onfocus="if(this.value == 'Your Email (required)'){this.value = '';}" onblur="if(this.value == ''){this.value='Your Email (required)';}" />
    </label>
</div>
<div class="contact_form_txt_bg">
 <label>
    <input name="csub" type="text" value="<?php echo ($_POST['csub']!=''?$_POST['csub']:'Subject');?>" onfocus="if(this.value == 'Subject'){this.value = '';}" onblur="if(this.value == ''){this.value='Subject';}"  />
    </label>
</div>
<div class="contact_message_bg">
 <label>
    <textarea name="msg" cols="4" rows="5" onfocus="if(this.value == 'Your Message'){this.value = '';}" onblur="if(this.value == ''){this.value='Your Message';}"  ><?php echo ($_POST['msg']!=''?$_POST['msg']:'Your Message');?></textarea>
    </label>
    </div>
    <div style="clear:both">
   <!-- <span>*Type in the characters you see below:</span>
    </div>
<div style="float:left; padding-top:10px;">
 <label>
    <input name="captchacode" type="text" maxlength="6" style="height:24px;" />
    </label>
</div>

<div>
<img src="CaptchaSecurityImages.php?width=90&height=30" alt="Enter displaying code" style="padding-top:-4px; float:left; padding-left:7px;"/>
    
</div> -->

<div class="contact_form_txt_bg" style="background-image:none" >

 
<!--<src="images/submit_button.png" alt="SUBMIT" title="SUBMIT" class="submit" /></a>  -->
   <input type="hidden" name="SUBMIT" value="SUBMIT" />
    <input type="image" src="images/submit_button.png" style="width:auto; margin-left:-5px; margin-top:-5px;" alt="SUBMIT" title="SUBMIT" class="submit" />  
</div>

  </form>         
</div>

    </div>
  </div>
</div>
</div>
 <?php
	include("includes/footer.php");
	?>
</div>
<!--[if !IE]>main div end here<![endif]-->
</body>
</html>
