<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  require_once "/var/www/vhosts/janizm.co.uk/httpdocs/cmsAdmin/lib/viewer_functions.php";
  //require_once "C:/Users/Dani/Documents/xampp-win32-1.6.6a/xampp/htdocs/janizm/cmsAdmin/lib/viewer_functions.php";

  list($contactRecords, $contactMetaData) = getRecords(array(
    'tableName'   => 'contact',
    'where'       => whereRecordNumberInUrl(1),
    'limit'       => '1',
  ));
  $contactRecord = @$contactRecords[0]; // get first record

  // show error message if no matching record is found
  if (!$contactRecord) {
    print "Record not found!";
    exit;
  }

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="<?php echo $contactRecord['metakeywords'] ?>" />
<meta name="description" content="<?php echo $contactRecord['metadescription'] ?>" />
<link href="css/janizm.css" rel="stylesheet" type="text/css" />
<title><?php echo $contactRecord['title'] ?></title>
</head>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10563878-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<body>
<?php include("navigation/ie6death.php"); ?>
	<div class="container">
       	<?php include("navigation/navigation.php"); ?>
        <div class="mainText">
            <?php echo $contactRecord['content'] ?>
			<?php
				$nasaadresa = "d.sternalski@btinternet.com";  //please replace this with your address
				$mail = @$_POST['Email'];
				$porukaa = @$_POST['Message'];
				$poruka = str_replace("\r", '<br />', $porukaa);
				//START OF THANKS MESSAGE
				//you may edit $thanks message. this is a message which displays when user sends mail from your site
				$thanks = "
				<p><strong>Your message has sucessfuly been sent!<br></strong></p>
				<p>$poruka</p>
				<p>You will recive a copy of the message at your email address <strong>($mail). We will reply you soon as possible</strong></p>";
				//do not edit nothing below this line  until comment (ME) say so if you don't have skills with PHP
				//END OF THANKS MESSAGE
				
				if(@$_POST['submitform']) 
				{
					$Name = $_POST['Name'];
					$Email = $_POST['Email'];
					$Message = $_POST['Message'];
					$require = $_POST['require'];
					$browser = @$HTTP_USER_AGENT;
					$ip = $_SERVER['REMOTE_ADDR'];
				
					$dcheck = explode(",",$require);
					while(list($check) = each($dcheck)) 
					{
						if(!$$dcheck[$check]) {
						@$error .= "You have not filled this filed(s): <b>$dcheck[$check]</b>.<br>";
						}
					}
					if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
					$error .= "Wrong e-mail.<br>This e-mail address <b>$Email</b> - is not valid. Please enter correct e-mail address.";
					}
					if(@$error)
					{
					echo $error;
					echo '<br><a href="#" onClick="history.go(-1)">Please try again.</a>';
					}
					else
					{
				//START OF INCOMING MESSAGE (this message goes to your inbox)
				$message = "
				Name: $Name:
				E-mail: $Email
				
				Message: $Message
				
				-----------------------------
				Browser: $browser
				IP: $ip
				";
				//END OF INCOMING MESSAGE (this message goes to your inbox)
				
				$subject = "Message from www.janizm.co.uk - Message was sent by $Name"; //subject OF YOUR INBOX MESSAGE sent to you
				
				$subject2 = "You have succesfully sent message from www.janizm.com!"; //subject of OUTGOING MESSAGE - edit this
				//OUTGOING MESSAGE TEXT
				$message2 = "You have sent a message to www.janizm.co.uk:
				-----------------------------
				From: $Name:
				E-mail: $Email
					
				Message: $Message
				
				-----------------------------
				";
				//END OF outgoing MESSAGE
				
				
				mail($nasaadresa,"$subject","$message","From: $Name <$Email>");
				mail($Email,"$subject2","$message2","From: <$nasaadresa>");
				echo "$thanks";
					}
				}
				else{
				//this is contact form down here, please edit if you know what are you doing... or the contact form may not be working.
				echo '
				<form class="contactform" name="contactform" action="'.@$PHP_SELF.'" method="post">
				<input type="hidden" name="require" value="Name,Email,Message">
				  <table width="444" align="center">
					<tr>
					  <td colspan="2" align="center">
						<p></td>
					</tr>
					<tr>
					  <td valign="top" align="right"><b>Name:</b></td>
					  <td valign="top">
						<input name="Name" size="39">
					  </td>
					</tr>
					<tr>
					  <td valign="top" align="right"><b>E-mail:</b></td>
					  <td valign="top">
						<input name="Email" size="39">
					  </td>
					</tr>
					<tr>
					  <td valign="top" align="right"><b>Message:</b></td>
					  <td valign="top">
						<textarea name="Message" rows="10" cols="30"></textarea>
					  </td>
					</tr>
					<tr>
					  <td colspan="2" align="center"><p align="right"><br>
						<input type="submit" value="Send" name="submitform">
						<input type="reset" value="Reset" name="reset"></p>
					  </td>
					</tr>
				  </table>
				</form>';
				}
				?>
		</div>
    </div>
    <?php include("navigation/footer.php"); ?>
</body>
</html>
