<?php
$optres['css'][] = $module_css_path . 'amodules/account/css/register.css';
$optres['js'][] = $path . 'amodules/account/js/register.js';
$optres['css'][] = $module_css_path . 'assets/css/bootstrap-dialog.min.css';
$optres['js'][] = $path . 'assets/js/bootstrap-dialog.min.js';

function random_char($string) { 
	$length = strlen($string); 
	$position = mt_rand(0, $length - 1); 
	return($string[$position]); 
} 

function random_string ($charset_string, $length) { 
	$return_string = random_char($charset_string); 
	for ($x = 1; $x < $length; $x++) 
	$return_string .= random_char($charset_string); 
	return($return_string); 
}

if(!function_exists("NewAdvGuid")) {
    // Generate Guid
    function NewAdvGuid($pref = "AD") {
        $s = strtoupper(md5(uniqid(rand(),true)));
        $guidText = $pref .
            (1010 + intval(date("Y"))) .
            date("mdHis") .
            substr($s,0,16);
        return $guidText;
    }
}
//seed random generator 
mt_srand((double)microtime() * 1000000); 
$charset = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTWXYZ"; 

$err = "";
$msg = "";
$member_id = isset($_SESSION['member_id']) ? intval($_SESSION['member_id']) : 0;

$gdpr = "off";

$rows_array = array ("shipmail", "shipname", "shipsurname", "companyname", "password", "shiptel", "shipfax", "shipdistrict", "shiparea", "shipcity", "shipdistrict_id", "shiparea_id", "shipcity_id", "shipaddress1", "shipaddress2", "shipzip", "billname", "billsurname", "billmail", "billtel", "billfax", "billaddress1", "billaddress2", "billdistrict", "billarea", "billcity", "register", "billcountry", "billzip", "shipmobile", "billmobile",
                "gdpr_25052018", "gdpr_25052018_dateon", "gdpr_25052018_ipon");
$required = array(
	"shipmail" => "E-mail", 
	"shipname"	=> "First Name", 
	"shipsurname"	=> "Last Name", 
	"shiptel"	=> "Telephone", 
	"shipdistrict"	=> "District", 
	"shipcity"	=> "Town / Village", 
	"shipaddress1" => "Address Line 1", 
	"shipzip"	=> "Postal Code"
);
$member_data = array();
foreach ($rows_array as $fld) {
	$member_data [$fld] = "";
}

$form_title = "Sign Up";
$form_button = "Sign Up";
$register_value = "insert";
$show_form = true;

$member_data = array(
    'shipmail'	=> '',
    'shipname'	=> '',
    'billname'	=> '',
    'shipsurname'	=> '',
    'companyname'	=> '',
    'shiptel'	=> '',
    'shipmobile'	=> '',
    'shipfax'	=> '',
    'billtel'	=> '',
    'shipdistrict'	=> '',
    'shiparea'	=> '',
    'shipcity'	=> '',
    'billaddress1'	=> '',
    'shipaddress1'	=> '',
    'shipaddress2'	=> '',
    'shipzip'	=> '',
    'catdom_id'	=> $domain_id,
    'gdpr_25052018' => $gdpr
);

// Hide sides
$cf_show_left_side = false;
$cf_show_right_side = false;

if(isset($_SESSION['member_id'])) {
	$member_id = intval($_SESSION['member_id']);
	$q = "SELECT * FROM members WHERE member_id='{$_SESSION['member_id']}';";
	$r = @mysql_query($q);
	if($r && mysql_num_rows($r) == 1) {
		
		$form_title = "Update Member Information";
		$form_button = "Save";
		$register_value = "update";
		
		$row = mysql_fetch_assoc($r);

		foreach ($row as $mk=>$mv) {
			//${$mk} = stripslashes(trim($mv));
			$member_data[$mk] = stripslashes($mv);
		}
	}

    $breadcrumbs [] = array(
        'link' => 'account/my_account.html',
        'title' => 'My Account'
    );

    $breadcrumbs [] = array(
        'link' => '',
        'title' => $form_title
    );
}
else {
    $breadcrumbs [] = array(
        'link' => '',
        'title' => $form_title
    );
}

$member_domain_id = $domain_id;
foreach($member_data as $mk=>$mk_val) {
    ${$mk} = $mk_val;
}


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

	$register_action = mysql_real_escape_string($_POST['register_action']);
	
	if($register_action == "update") {

        $member_data['updated_at'] = date("Y-m-d H:i:s");

		// We have an update
		foreach ($_POST as $pk=>$pv) {
			if(in_array($pk, array_keys($required)) && trim($pv) == "") {
				$err .= '<br/><strong>' . $required[$pk] . '</strong> is a required field.';
			}
			
			if(isset($member_data[$pk])) $member_data[$pk] = is_array($pv) ? $pv : trim(stripslashes($pv));
		}

        if(isset($_SESSION['member_id'])) {
            $member_id = intval($_SESSION['member_id']);
            $q = "SELECT * FROM members WHERE member_id='{$_SESSION['member_id']}';";
            $r = @mysql_query($q);
            if ($r && mysql_num_rows($r) == 1) {
                $row = mysql_fetch_assoc($r);
                if($row['gdpr_25052018'] == "off") {
                    $member_data['gdpr_25052018'] = "on";
                    $member_data['gdpr_25052018_dateon'] = date("Y-m-d H:i:s");
                    $member_data['gdpr_25052018_ipon'] = $_SESSION['visitor_ip'];
                }
            }
        }

		
		if(isset($_POST['new_password']) && trim($_POST['new_password']) != "") {
			$new_password = trim($_POST['new_password']);
			$new_password_repeat = trim($_POST['new_password_repeat']);
			
			if($new_password !== $new_password_repeat) {
				$err .= '<br/>The <strong>New Password</strong> and <strong>New Password Repeat</strong> do not match.';
			}
			else {
				$member_data['password'] = $new_password;
				$_POST['new_password'] = '';
				$_POST['new_password_repeat'] = '';
			}
		}
		
		
		if($err == "") {
            $u_vals = array();
            foreach($member_data as $mk=>$mv) {
                if(in_array($mk, $rows_array)) {
                    $u_vals [] = "`$mk`=" . "'" . mysql_real_escape_string($mv) . "'";
                }
            }

			/*$i_flds = array_keys($member_data);
			$i_vals = array_values($member_data);
			$u_vals = array();
			foreach ($member_data as $mk=>$mv) {
				$u_vals [] = "`$mk`=" . "'" . mysql_real_escape_string($mv) . "'";
			}*/
			
			$u_vals_str = implode(", ", $u_vals);
			$q = "update members set $u_vals_str where member_id='" . $_SESSION['member_id'] . "';";
			$r = @mysql_query($q);
			if($r && mysql_affected_rows() != -1) {
				$msg = "<br/>You have successfully updated your Member Information data.";
			}
			else {
				$err .= "<br/>Error while updating Member Information data.<br>$q | " . mysql_error();
			}
			
			
		}
		
		foreach ($_POST as $pf=>$pv) {
			${$pf} = is_array($pv) ? $pv : trim(stripslashes($pv));
		}
		
	}
	
	if($register_action == "insert") {
		// We have a new registration
		foreach ($_POST as $pk=>$pv) {
			if(in_array($pk, array_keys($required)) && trim($pv) == "") {
				$err .= '<br/><strong>' . $required[$pk] . '</strong> is a required field.';
			}
			
			if(isset($member_data[$pk])) $member_data[$pk] = is_array($pv) ? $pv : trim(stripslashes($pv));
		}

        $member_data['created_at'] = date("Y-m-d H:i:s");
        $member_data['updated_at'] = date("Y-m-d H:i:s");
		$member_data['password'] = random_string($charset, 8);
		$member_data['cust_code'] = NewAdvGuid('CU');

        if($_POST['gdpr_25052018'] == "off") {
            $err .= "<br>In order to register you must consent!";
        }
        else {
            $member_data['gdpr_25052018'] = "on";
            $member_data['gdpr_25052018_dateon'] = date("Y-m-d H:i:s");
            $member_data['gdpr_25052018_ipon'] = $_SESSION['visitor_ip'];
        }
		
		if(trim($_POST['shipmail']) != "") {
			$shipmail = trim($_POST['shipmail']);

            if (!filter_var($shipmail, FILTER_VALIDATE_EMAIL)) {
                $err .= "Invalid email format";

                function getUserIP()
                {
                    $client  = @$_SERVER['HTTP_CLIENT_IP'];
                    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
                    $remote  = $_SERVER['REMOTE_ADDR'];

                    if(filter_var($client, FILTER_VALIDATE_IP))
                    {
                        $ip = $client;
                    }
                    elseif(filter_var($forward, FILTER_VALIDATE_IP))
                    {
                        $ip = $forward;
                    }
                    else
                    {
                        $ip = $remote;
                    }

                    return $ip;
                }


                $user_ip = getUserIP();

                $f = fopen(dirname(__FILE__). "/../../emails.log", "a+");
                fwrite($f, $shipmail . "|" . $user_ip . "\n");
                fclose($f);

            }
            else {

                $q = "SELECT * FROM members WHERE shipmail='" . mysql_real_escape_string($shipmail) . "';";
                $r = @mysql_query($q);
                if ($r && mysql_num_rows($r) > 0) {
                    $err .= 'The e-mail address you have entered <b>already exists</b> in our member\'s list. Please use another e-mail address or <a href="account/forgot.html" class="small10" >request</a> your password to be sent to your e-mail if you have forgotten it.';
                }
            }
		}
		
		if($err == "") {
			$i_flds = array_keys($member_data);
			$i_vals = array_values($member_data);
			$u_vals = array();
			foreach ($i_vals as $mk=>$mv) {
				$u_vals [] = "'" . mysql_real_escape_string(trim($mv)) . "'";
			}
			
			$i_flds_str = implode(", ", $i_flds);
			$q = "insert into members ($i_flds_str) values (" . implode(", ", $u_vals) . ");";
			$r = @mysql_query($q);
			if($r && mysql_affected_rows() == 1) {
				
				// Send the email with the password
				include_once(dirname(__FILE__) . "/../classes/class.phpmailer.php");
				
				$mail = new PHPMailer();
				$mail->IsSMTP();
				//$mail->SMTPDebug  = 2;
				//Ask for HTML-friendly debug output
				//$mail->Debugoutput = 'html';
				//Set the hostname of the mail server
				$mail->Host       = "mail.cyprusnet.com";
				//Set the SMTP port number - likely to be 25, 465 or 587
				$mail->Port       = 26;
				//Whether to use SMTP authentication
				$mail->SMTPAuth   = true;
				
				$mail->Username   = "noreply@cyprusnet.com"; // SMTP account username
				$mail->Password   = "6673759NO";        // SMTP account password
				
				
			
				$body = '<table border="1" cellpadding="3" cellspacing="0">';
				$body .= '<tr><td align="left">Username:</td><td align="left"><strong>' . $shipmail . '</strong></td></tr>';
				$body .= '<tr><td align="left">Password:</td><td align="left"><strong>' . $member_data['password'] . '</strong></td></tr>';
				$body .= '</table>';
				
				$subject = "CyprusNet Account Details";
				
				$from_name = $_SERVER['HTTP_HOST'];
				$from_email = "noreply@cyprusnet.com";
				
				$mail->From = "noreply@cyprusnet.com";
				$mail->FromName = $_SERVER['HTTP_HOST'];
				//$mail->ReplyTo = $from_email;
				
				$mail->AddReplyTo($from_email, $from_name);
				
				$mail->Subject = $subject;
				
				$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
				$mail->IsHTML(true);
				$mail->MsgHTML($body);
				
				$mail->AddAddress($shipmail);
				
				
				//print $body;
				$msg = "<br/>You have successfully created your account.";
				
				if(!$mail->Send()) {
					$err .= '<br/>Failed to e-mail you your account password! Please use the <Forgot password> link at a later time.';
				} 
				else {
					$msg .= "<br/>Your sign up was successful. Please login when you receive your password on your e-mail account <strong>$shipmail</strong>.";
				}
				
				
				/***************************************************************/
				
				$show_form = false;
				
			}
			else {
				$err .= "<br/>Error while creating your account.<br>$q | " . mysql_error();
			}
			
			
		}

		foreach ($_POST as $pf=>$pv) {
			${$pf} = is_array($pv) ? $pv : trim(stripslashes($pv));
		}
	}
	
}

$new_password = isset($_POST['new_password']) ? $_POST['new_password'] : '';
$new_password_repeat = isset($_POST['new_password_repeat']) ? $_POST['new_password_repeat'] : '';



if($show_form) {
	$webpage_title_en = $form_title . ' | ' . $domain_content_title;
	$meta['description'] = $domain_content_title . ' | Become a member of the Cyprus Network. Sign up free and list your business.';
	//echo '<h1 class="page-header">', $form_title, '</h1>';
	?>
<style>
    .register-container {
        display: flex;
        height: 100%;
    }

    .register-container p {
        font-size: 14px!important;
    }

    .register-container #gdpr-box {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .register-container #gdpr-box .box {
        width: 50%;
    }

    @media (max-width: 768px) {
        .register-container #gdpr-box .box {
            width: 95%;
            margin: 10px;
        }
    }

</style>
<script>

</script>
<section class="article <?php echo ($member_data['gdpr_25052018'] == "off" ) ? "register-container": ""; ?>" id="register-container">
    <?php
    if($member_data['gdpr_25052018'] == "off" ) {
        ?>
        <div id="gdpr-box" class="">
            <div class="box box-danger">
                <div class="box-header with-border">
                    <b>EU GDPR Consent</b>
                </div>
                <div class="box-body">
                    <p>By registering on <b><?= $ultra_domainname; ?></b> you will be using our services.</p>

                    <p>During the registration process you will be asked to provide us with some personal data.</p>

                    <p>We will request from you only such personal data that is required by our services to function
                        correctly.

                    <p>The personal data you will be providing is going to be stored in our database and is going to be
                        subject to our Privacy Policy.</p>

                    <p>In order to use our services you must consent to our use of your personal data. Any time after
                        registration you have the right to request that your personal data to be erased from our
                        database.</p>

                    <p>Please read our <a href="/article/privacy-policy.html" target="_blank">Privacy Policy</a> in
                        order to understant how we will be using your data.</p>
                </div>
                <div class="box-footer text-center">

                    <a href="/article/privacy-policy.html" class="btn btn-warning pull-left" target="_blank">Read
                        More</a>
                    <button type="button" id="reg-accept" class="btn btn-success pull-right">I want to register!
                    </button>
                </div>
            </div>
        </div>
        <?php
    }
    ?>
    <div class="article-body <?php echo ($member_data['gdpr_25052018'] == "off" ) ? "hidden": ""; ?>" id="register-module">
        <div class="row">
            <div class="col-sm-6 col-sm-offset-2">

                    <form action="account/my_info.html" class="form-horizontal" method="post" role="form" id="register-form" onsubmit="return Check('register-form');">
                        <input name="gdpr_25052018" id="gdpr" type="hidden" value="<?=$member_data['gdpr_25052018'];?>">
                        <?php
                        if($err != "") {
                            echo '<div class="alert alert-danger alert-dismissible" role="alert">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><strong>Errors Occured</strong><hr class="no-margin">' . $err . '</div>';
                        }

                        if($msg != "") {
                            echo '<div class="alert alert-success alert-dismissible" role="alert">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><strong>Successful Operation</strong><hr class="no-margin">' . $msg . '</div>';
                        }
                        ?>


                        <div class="register-box box box-primary">
                            <div class="box-header with-border">
                                <h1 class="no-margin"><i class="fa fa-briefcase fa-lg"></i> <?=$form_title;?></h1>
                            </div>
                            <div class="box-body">
                                <div class="alert alert-info alert-dismissible fade in" role="alert">
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <p>
                                        <?php
                                        if($member_id == 0) {
                                            echo '<b>To become a member of the Cyprus Network please fill in the following form.</b><br>';
                                        }
                                        ?>
                                        Fields marked with an asterix <span class="req">*</span> are required.
                                    </p>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">E-mail <span class="req">*</span></label>
                                    <div class="col-md-7">
                                        <input name="shipmail" value="<?php echo $shipmail;?>" id="shipmail" class="form-control input-sm" maxlength="80" type="email" />
                                        <span class="help-block">(will be used to login)</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        First Name <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipname" value="<?php echo $shipname;?>" id="shipname" class="form-control input-sm" maxlength="80" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Middle Name
                                    </label>
                                    <div class="col-md-7">
                                        <input name="billname" value="<?php echo $billname;?>" id="billname" class="form-control input-sm" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Last Name <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipsurname" value="<?php echo $shipsurname;?>" id="shipsurname" class="form-control input-sm" maxlength="80" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Company
                                    </label>
                                    <div class="col-md-7">
                                        <input name="companyname" value="<?php echo $companyname;?>" id="companyname" class="form-control input-sm" maxlength="80" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Telephone <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shiptel" value="<?php echo $shiptel;?>" id="shiptel" class="form-control input-sm" maxlength="30" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Mobile
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipmobile" value="<?php echo $shipmobile;?>" id="shipmobile" class="form-control input-sm" maxlength="30" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Fax
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipfax" value="<?php echo $shipfax;?>" id="shipfax" class="form-control input-sm" maxlength="30" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Business Phone
                                    </label>
                                    <div class="col-md-7">
                                        <input name="billtel" value="<?php echo $billtel;?>" id="billtel" class="form-control input-sm" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        District <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">

                                        <select name="shipdistrict" id="shipdistrict" class="form-control input-sm">
                                            <option value="" selected="selected">
                                                Please select
                                            </option>
                                            <option value="Nicosia" <?php echo ($shipdistrict == "Nicosia") ? 'selected="selected"' : '';?>>
                                                Nicosia
                                            </option>
                                            <option value="Limassol" <?php echo ($shipdistrict == "Limassol") ? 'selected="selected"' : '';?>>
                                                Limassol
                                            </option>
                                            <option value="Larnaca" <?php echo ($shipdistrict == "Larnaca") ? 'selected="selected"' : '';?>>
                                                Larnaca
                                            </option>
                                            <option value="Paphos" <?php echo ($shipdistrict == "Paphos") ? 'selected="selected"' : '';?>>
                                                Paphos
                                            </option>
                                            <option value="Famagusta" <?php echo ($shipdistrict == "Famagusta") ? 'selected="selected"' : '';?>>
                                                Famagusta
                                            </option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Area
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shiparea" value="<?php echo $shiparea;?>" id="shiparea" class="form-control input-sm" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Town/Village <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipcity" value="<?php echo $shipcity;?>" id="shipcity" class="form-control input-sm" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        P.O. BOX
                                    </label>
                                    <div class="col-md-7">
                                        <input name="billaddress1" value="<?php echo $billaddress1;?>" id="billaddress1" class="form-control input-sm" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Address line 1 <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipaddress1" value="<?php echo $shipaddress1;?>" id="shipaddress1" class="form-control input-sm" maxlength="80" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Address line 2
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipaddress2" value="<?php echo $shipaddress2;?>" id="shipaddress2" class="form-control input-sm" maxlength="80" type="text" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        Postal code <span class="req">*</span>
                                    </label>
                                    <div class="col-md-7">
                                        <input name="shipzip" value="<?php echo $shipzip;?>" id="shipzip" class="form-control input-sm" maxlength="5" type="text" />
                                    </div>
                                </div>
                            </div>
                            <div class="box-footer text-left">
                                <input name="module_page" id="module_page" value="account" type="hidden" />
                                <input name="account_url" id="account_url" value="my_info" type="hidden" />
                                <input name="domain_id" id="domain_id2" value="<?php echo $member_domain_id;?>" type="hidden" />
                                <input name="register" id="register2" value="yes" type="hidden" />
                                <input name="register_action" id="register-action2" value="<?php echo $register_value;?>" type="hidden" />
                                <button name="submit" type="submit" class="btn btn-primary btn-sm"><?php echo $form_button;?></button>
                            </div>
                        </div>
                    <?php
                    if($member_id > 0) {
                        ?>
                        <br>
                        <div class="box box-warning">
                            <div class="box-header with-border">
                                <b>Change Password</b>
                            </div>
                            <div class="box-body">
                                <div class="form-group">
                                    <label class="control-label col-md-3">New Password</label>
                                    <div class="col-md-7">
                                        <input type="password" name="new_password" value="<?php echo $new_password;?>" class="form-control input-sm">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3">New Password Repeat</label>
                                    <div class="col-md-7">
                                        <input type="password" name="new_password_repeat" value="<?php echo $new_password_repeat;?>" class="form-control input-sm">
                                    </div>
                                </div>
                            </div>
                            <div class="box-footer text-left">
                                <button name="change_password" type="submit" class="btn btn-warning btn-sm">Change</button>
                            </div>

                        </div>

                        <?php
                    }
                    ?>

                    </form>
	            </div>
            </div>
        </div>
    </section>
	<?php
}
?>
<script type="text/javascript">
function Check(form_id) {
    var form = document.getElementById(form_id);
    console.log(form.shipdistrict.options[form.shipdistrict.selectedIndex].value);
	missinginfo = "";
	<?php 
	if(!isset($_SESSION["member_id"])){
		?>
		if ((form.shipmail.value.length < 4) || 
		(form.shipmail.value.indexOf('@') == -1) || 
		(form.shipmail.value.indexOf('.') == -1)) {
			missinginfo += "\n     -  Email address";
		}
		if ((form.shipmail.value.indexOf('\'') >0) || (form.shipmail.value.indexOf('\"') >0)) {
			missinginfo += "\n     -  Member Email address should not have apostrophes";
		}
		<?php 
	}
	?>
	
	if (form.shipname.value.length < 1) {
		missinginfo += "\n     -  First Name";
	}
	
	if (form.shipsurname.value.length < 1) {
	missinginfo += "\n     -  Last Name";
	}
	if (form.shiptel.value.length < 4) {
	missinginfo += "\n     -  Telephone";
	}
	if (form.shipdistrict.options[form.shipdistrict.selectedIndex].value == "") {
	missinginfo += "\n     -  District";
	}
	if (form.shipcity.value == "") {
	missinginfo += "\n     -  Town/Village";
	}
	if (form.shipaddress1.value == "") {
	missinginfo += "\n     -  Address Line 1";
	}
	if (form.shipzip.value == "") {
	missinginfo += "\n     -  Postal Code";
	}
	if (missinginfo != "") {
	missinginfo ="_____________________________\n" +
	"You failed to correctly fill in your:\n" +
	missinginfo + "\n_____________________________" +
	"\nPlease re-enter and submit again!";
	BootstrapDialog.show({
        type: BootstrapDialog.TYPE_DANGER,
        title: 'Errors Occured',
        message: missinginfo,
        buttons: [{
            label: 'Ok',
            action: function(dlg) {
                dlg.close();
            }
        }]
    });
	return false;
	}
}
</script>