<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-23-2009                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/

require_once ("config.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("includes/arrays.inc.php");
require_once ("classes/settings.class.php");
require_once ("classes/userside.class.php");
require_once ("classes/miscellaneous.class.php");
require_once ("classes/misc.class.php");
if (!isset($_SESSION['register_id']) OR $_SESSION['register_id'] == "") {
	header("Location: register.php");
	exit();
}

$arrSettings	= array();
$script		= "";
$message	= "";

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objU			= new userside($objDB);
	$objS			= new settings($objDB);
	$objMc			= new miscellaneous($objDB);
        $objM			= new misc($objDB);
	$couponDetails          = $objMc->get_coupon_code($_GET['couponid']);
	$objS->set_variables();
        //echo"<pre>";print_r($objS);echo"</pre>";	
         $arrCountry	= $objU->get_country_list();        
	if (isset($_POST['PYN']))
	 {
           
           	$message="";
		$objU->set_values($_POST);
		
		 $message=$objU->register_authorize($_SESSION['register_id']);
                // echo"mssss",$message;
		//exit;
		if ($message == "") 
		{
			header("Location:register_success.php");
			exit();
		}
		else
		{
		$objU->set_values($_POST);
		}
                $arrState	= $objU->get_state_list($objU->vCountry);
		$arrCounty	= $objU->get_county_list($objU->vState);
	} 
	else {
//            echo"else here";
//            exit;
            
	if ($message == "")
	{
		$array		= $objU->select($_SESSION['register_id']);
		$objU->set_values($array);
	}
	else
	{
	//echo "herre";
	$objU->set_values($_POST);
	}// end if 
            $arrState	= $objU->get_state_list($objU->vCountry);
            $arrCounty	= $objU->get_county_list($objU->vState);
	}
	$script		= $objU->get_script($message);
	//$message	= $objU->remove_script($message);
	
}
$checktypemode=($_GET['stype']!='')?$_GET['stype']:$_POST['stype'];
if($checktypemode!='')
{
	$_SESSION['sess_register_stype']=$checktypemode;
}//end if
else
{
	$checktypemode=$_SESSION['sess_register_stype'];
}//end else
include_once ("title.inc.php");
include_once ("tophtml.inc.php");
$ddlPaymentMethod = $siteSettings["paymentmethod"];
?>
<script type="text/javascript"  src="js/googlefix.js"></script>
<script type="text/javascript"  src="js/ajax.js"></script>
<script language="javascript" type="text/javascript">
function changeCSS(obj, type)
{
	if (type == 'text') {
		obj.className = 'commononetextbox';
	} else if (type == 'textarea') {
		obj.className = 'textbox_textarea';
	} else if (type == 'select') {
		obj.className = 'commononetextbox';
	} else if (type == 'text2') {
		obj.className = 'commononetextbox';
	} else {
		obj.className = 'commononetextbox';
	}
}
function clickConfirm(){
	var frm = document.frmPayment;
	var flag = false;
	if (frm.vFirstName.value == "") {
		alert("Please enter your firstname.");
		frm.vFirstName.focus();
		frm.vFirstName.className ='commononetextbox';
		return false;
	}
	if (frm.vLastName.value == "") {
		alert("Please enter your lastname.");
		frm.vLastName.focus();
		frm.vLastName.className ='commononetextbox';
		return false;
	}
	<?php
		if($_SESSION['sess_register_stype']=='CC')
		{
    ?>
	if (frm.nNumber.value == "") {
		alert("Please enter your cardnumber.");
		frm.nNumber.focus();
		frm.nNumber.className ='commononetextbox';
		return false;
	}
	if (frm.nCvv2.value == "") {
		alert("Please enter validation code of your card.");
		frm.nCvv2.focus();
		frm.nCvv2.className ='commononetextbox';
		return false;
	}
	if (frm.vMM.value == "") {
		alert("Please enter month of expiry date of your card.");
		frm.vMM.focus();
		
		return false;
	}
	if (frm.vYYYY.value == "") {
		alert("Please enter year of expiry date of your card.");
		frm.vYYYY.focus();
		
		return false;
	}
	<?php }//end if?>
	<?php
		if($_SESSION['sess_register_stype']=='ECHECK')
		{
    ?>
	if (frm.rBank.value == "") {
		alert("Please enter Routing Number of a Bank.");
		frm.rBank.focus();
		frm.rBank.className ='commononetextbox';
		return false;
	}
	
	if (frm.nAccountNumber.value == "") {
		alert("Please enter Bank Account Number.");
		frm.nAccountNumber.focus();
		frm.nAccountNumber.className ='commononetextbox';
		return false;
	}
	
	if (frm.txtAccountType.value == "") {
		alert("Please enter Account Type.");
		frm.txtAccountType.focus();
		frm.txtAccountType.className ='commononetextbox';
		return false;
	}
	
	if (frm.txtBankName.value == "") {
		alert("Please enter Bank Name.");
		frm.txtBankName.focus();
		frm.txtBankName.className ='commononetextbox';
		return false;
	}
	
	if (frm.txtBankHolderName.value == "") {
		alert("Please enter Bank Holder Name.");
		frm.txtBankHolderName.focus();
		frm.txtBankHolderName.className ='commononetextbox';
		return false;
	}
	<?php }//end if?>
	if (frm.vAddress.value == "") {
		alert("Please enter your billing address.");
		frm.vAddress.focus();
		frm.vAddress.className ='commononetextbox';
		return false;
	}
	
	if (frm.vCity.value =="") {
		alert("Please enter your city address.");
		frm.vCity.focus();
		frm.vCity.className ='commononetextbox';
		return false;
	}
	if (frm.vState.value =="") {
		alert("Please enter your state address.");
		frm.vState.focus();
		frm.vState.className ='commononetextbox';
		return false;
	}
	if (frm.vCountry.value =="") {
		alert("Please enter your country.");
		frm.vCountry.focus();
		frm.vCountry.className ='commononetextbox';
		return false;
	}
	if (frm.vPostCode.value =="") {
		alert("Please enter your postalcode.");
		frm.vPostCode.focus();
		frm.vPostCode.className ='commononetextbox';
		return false;
	}
	if (frm.vPhone.value=="") {
		alert("Please enter your phone number.");
		frm.vPhone.focus();
		frm.vPhone.className ='commononetextbox';
		return false;
	}
	if (frm.vEmail.value=="") {
		alert("Please enter your email address.");
		frm.vEmail.focus();
		frm.vEmail.className ='commononetextbox';
		return false;
	}
	
	return true;
}
function checkValue(t) {
  if(isNaN(t.value) || t.value.substring(0,1) == " " || t.value.length == 0 || parseFloat(t.value) < 0 ) {
	 if(t.name == "nNumber") {
		 t.value = "";
	 } else{
		t.value = "000";
	 }
  }
}
var ajax = new Array();
var sajax = new Array();
function getStateList(sel)
{
    
	var stateCode = sel.options[sel.selectedIndex].value;
        
	document.getElementById('girish_state').options.length = 0;	// Empty city select box
	if(stateCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'get_state_list.php?id='+stateCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createStateList(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}
function createStateList(index)
{
	var obj = document.getElementById('girish_state');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}

function getCountyList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.getElementById('girish_county').options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		var index = ajax.length;
		ajax[index] = new sack();
		
		ajax[index].requestFile = 'get_county_list.php?id='+countryCode;	// Specifying which file to get
		ajax[index].onCompletion = function(){ createCountyList(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
	}
}

function createCountyList(index)
{
	var obj = document.getElementById('girish_county');
	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
}
</script>

<div class="row">
	<div class="eight columns">
		<div class="search-rslts">
			<div class="row"><div class="inenr-hd"><h2>Pay Now</h2></div></div>
			<div class="row">
				<h2 class="headings2">
					Click below to complete the purchase of your <?php echo $objS->ValidityDayMembership ?> day(s) subscription
                   	<p>These details are for payment information only</p>
				</h2>
			</div>
			<div class="row">
				<form name="frmPayment" method="post" action="<?php echo $_SERVER['PHP_SELF']?>" onSubmit="return clickConfirm();">
                <input type="hidden" name="stype" value="<?php echo $_SESSION['sess_register_stype'];?>">
					<div class="newdesignforinput maintext1">
						<?php if(isset($message) && trim($message)!='')
					      {
						?>
						<div class="full_row">
							<div class="maintext1 warning"><?php echo $message;?></div>
						</div>
						<?php }//end if?>
						
						<div class="full_row">
							<div class="three columns">Subscription Amount</div>
							<div class="five columns margin_R_200">
								$ <?php echo ($_GET['couponid'])?0:$objS->membership_amount;?>
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">First Name <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vFirstName" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vFirstName)?>" size="30" maxlength="200">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Last Name</div>
							<div class="five columns margin_R_200">
								<input name="vLastName" type="text" class="commononetextbox"  onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vLastName)?>" size="30" maxlength="200">
							</div>
						</div>
						<?php 
							  //for authorize
							  if($_SESSION['sess_register_stype']=='CC' ||  $_SESSION['sess_register_stype']=='UP')
							  {
						?>
						
						<div class="full_row">
							<div class="three columns">Card Number  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<div class="nine columns">
								<input name="nNumber" type="text" class="commononetextbox" onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nNumber?>" size="30" maxlength="16">
								</div>
								<div class="two columns">
                      			<img src="images/visa_amex.gif" width="80" height="16" border="0">
								</div>
							</div>
						</div>
						
						<?php if($ddlPaymentMethod=="PRO"){ ?>
						<div class="full_row" id="showVal2">
							<div class="three columns">Card Type <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								TEXasdasdasd
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">asdasdasd</div>
							<div class="five columns margin_R_200">
								<select name="vPaymentMethodType" class="textbox txt-bx01">
								<option value="Visa">Visa</option>
								<option value="MasterCard">MasterCard</option>
								<option value="AMEX">AMEX</option>
								<option value="Discover">Discover</option>
								<option value="DinersClub">DinersClub</option>
								<!--                      	<option value="JCB">JCB</option>
								<option value="ProPayToProPay">ProPay To ProPay</option>
								<option value="Checking">Checking</option>
								<option value="Savings">Savings</option>-->
								</select>
							</div>
						</div>
                    <?php }?>
					
						<div class="full_row">
							<div class="three columns">Card Validation Code  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="nCvv2" type="text" class="commononetextbox"  onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nCvv2?>" size="30" maxlength="3">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Expiration Date (MM/YYYY)  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<div class="five columns"><input name="vMM" type="text" class="select-small" value="<?php echo addslashes($objU->vMM)?>" size="2" maxlength="2"></div>
								<div class="two columns" align="center">/</div>
								<div class="five columns"><input name="vYYYY" type="text" class="select-small"  value="<?php echo addslashes($objU->vYYYY)?>" size="4" maxlength="4"></div>
							</div>
						</div>
						<?php 
								}//end if
								//for echeck
								if($_SESSION['sess_register_stype']=='ECHECK')
								{
						?>
						
						<div class="full_row">
							<div class="three columns">Routing Number of a Bank  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="rBank" type="text" class="commononetextbox" onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->rBank?>" size="30" maxlength="16">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Bank Account Number  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="nAccountNumber" type="text" class="commononetextbox"  onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nAccountNumber?>" size="30" maxlength="50">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Account Type  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="txtAccountType" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo addslashes($objU->txtAccountType)?>" size="25" maxlength="50">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Bank Name  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="txtBankName" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->txtBankName?>" size="30" maxlength="50">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Bank Holder Name  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="txtBankHolderName" type="text" class="commononetextbox"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->txtBankHolderName?>" size="30" maxlength="50">
							</div>
						</div>
						<?php }//end if?>
						
						<div class="full_row">
							<div class="three columns">Address  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vAddress" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vAddress?>" size="30" maxlength="100">
							</div>
						</div>
						
						<!-- <tr>
						<td class="maintext1">Country</td>
						<td colspan="2" class="maintext1">
						<select name="vCountry" class="textbox3 txt-bx01" id="girish_country" onchange="getStateList(this)";>
						<option value="">-Select Country-</option>
						<?php foreach ($arrCountry as $key => $value) { ?>
						<option value="<?php echo stripslashes($value)?>" <?php echo stripslashes($objU->vCountry) == stripslashes($value) ? "selected" : ""?>>
						<?php echo stripslashes($value)?>
						</option>
						<?php } ?>
						</select></td>
						</tr>
						<tr>
						<td class="maintext1">State</td>
						<td colspan="2" class="maintext1"><select name="vState" class="textbox3 txt-bx01" id="girish_state">
						<?php foreach ($arrState as $key => $value) { ?>
						<option value="<?php echo stripslashes($value)?>" <?php echo $objU->vState == stripslashes($value) ? "selected" : ""?>>
						<?php echo stripslashes($value)?>
						</option>
						<?php } ?>
						</select>
						</td>
						</tr>-->
						
						
						<div class="full_row">
							<div class="three columns">City  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vCity" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vCity)?>" size="30" maxlength="100">
							</div>
						</div>
						<?php if($ddlPaymentMethod!="PRO"){?>
						
						<div class="full_row">
							<div class="three columns">Country</div>
							<div class="five columns margin_R_200">
								<select name="vCountry" class="textbox3 txt-bx01" id="girish_country" onchange="getStateList(this)";>
									<option value="">-Select Country-</option>
									<?php foreach ($arrCountry as $key => $value) { ?>
									<option value="<?php echo stripslashes($value)?>" <?php echo stripslashes($objU->vCountry) == stripslashes($value) ? "selected" : ""?>>
									<?php echo stripslashes($value)?>
									</option>
									<?php } ?>
								</select>
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">State</div>
							<div class="five columns margin_R_200">
								<select name="vState" class="textbox3 txt-bx01" id="girish_state">
									<?php foreach ($arrState as $key => $value) { ?>
									<option value="<?php echo stripslashes($value)?>" <?php echo $objU->vState == stripslashes($value) ? "selected" : ""?>>
									<?php echo stripslashes($value)?>
									</option>
									<?php } ?>
								</select>
							</div>
						</div>
                    	<?php }else{?>
						
						<div class="full_row" id="showVal18" <?php echo $display;?>>
							<div class="three columns">State <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<select name="vState" class="textbox txt-bx01">
									<?php foreach ($arrState as $key => $value) { ?>
									<option value="<?php echo $key?>" <?php echo $objU->vState == $key ? "selected" : ""?>>
									<?php echo $value?>
									</option>
									<?php } ?>
								</select>
							</div>
						</div>
						<?php }?>
						<div class="full_row">
							<div class="three columns">Postal Code  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vPostCode" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vPostCode?>" size="30" maxlength="100">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Phone  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vPhone" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vPhone?>" size="30" maxlength="100">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">Email  <span class="warning">*</span></div>
							<div class="five columns margin_R_200">
								<input name="vEmail" type="text" class="commononetextbox" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vEmail?>" size="30" maxlength="200">
							</div>
						</div>
						
						<div class="full_row">
							<div class="three columns">&nbsp;</div>
							<div class="five columns margin_R_200">
								<input name="PYN" type="submit" class="signupbutton" value="Pay Now">
							</div>
						</div>
						
					</div>
				</form>
				<div id="hide"><?php echo $script?></div>
			</div>
		</div>
	</div>
</div>


<?php include_once('bottomhtml.inc.php');?>