<?
session_start();
ob_start();

	if($_SESSION['lang']=='')
	{
		$_SESSION['lang'] = "en";
	}
	include 'languages/lang_logedin_'.$_SESSION['lang'].'.php';
	include 'languages/lang_common_'.$_SESSION['lang'].'.php';
   include("include/db.inc.php");
   include("include/bit_functions.inc.php");
   include("include/mail.php");
   $db1=new db;
   $db1->open();
  mysql_query("SET NAMES 'utf8'");  $currency_symbol_new=symbol_currency();
   $headermsg="Create Your Account";
   if(isset($_POST['register']))
   {
     extract($_POST);
     $sql_chk="select id from user where email='$email' or uname='$uname'";
     $res_chk=mysql_query($sql_chk);
	if(mysql_num_rows($res_chk)>0)
	 {
  ?>
<script type=text/javascript language=javascript>
alert("<?=_SORY_ADDRESS_DIFF_EMAIL_?>");
window.location.href="index.php";
</script>
<?
	 }

else
		 {

		  $bday = $year."-".$month."-".$day;
		  $ccode=substr(md5($email),0,10);
  		  $sql="insert into user (id,gender,first_name,last_name,uname,bday,password,email,ccode,stat_date)
		  values('','$gender','$fname','$lname','$uname','$bday','$password','$email','$ccode',now())";
 		 $res=mysql_query($sql) or die(mysql_error().$sql);
		 $i_id=mysql_insert_id();
		 mysql_query("insert into friends set user_id='1', fr_id='$i_id', status='1'");
		$reg = "yes";
		}

  if($reg ==="yes")
   {
   			register_mail($fname,$email,$ccode,$i_id);
		    mysql_query("insert into newsletter_subscribe set email='".$email."',uid='$i_id'");
			//confirm_newsletter($email,$i_id);

			header("location:loginconfirm.php?id=".$i_id);

   }

  }

?>


<script src="include/validation.js"></script>

<script language="javascript">
function validate()
{
	var fname=trim(document.form1.fname.value);
	if(is_empty(fname))
	{
		alert("<?=_PLZ_FIRST_NAME_?>");
		document.form1.fname.focus();
		return false;
	}
	var lname=trim(document.form1.lname.value);
	if(is_empty(lname))
	{
		alert("<?=_PLX_UR_LNAME_?>");
		document.form1.lname.focus();
		return false;
	}


	var day=trim(document.form1.day.value);
	var month=trim(document.form1.month.value);
    var year=trim(document.form1.year.value);


   if(day==0 || month==0 || year==0 )
	{
		alert("Please enter your date of birth!");
		document.form1.day.focus();
		return false;
	}
	<? $minyear=date('Y')-18;  ?>

	if(year > <?=$minyear?>)
	{
		alert("You must be more than 18 year old!");
		document.form1.year.focus();
		return false;
	}
	var uname=trim(document.form1.uname.value);
	if(is_empty(uname))
	{
		alert("<?=_PLZ_URS_UNAME_?>");
		document.form1.uname.focus();
		return false;
	}

	var password=trim(document.form1.password.value);
	if(is_empty(password))
	{
		alert("<?=_PLZ_ENR_PASS_?>");
		document.form1.password.focus();
		return false;
	}


	var email=document.form1.email;
	if (trim(email.value) == 0) {
		alert("<?=_PLS_UYR_EMAIL_?>");
		email.focus();
		return false;
	} else if (email.value.indexOf("@") < 0) {
		alert("<?=_INCORRE_EMAIL_ADDRE_?>");
		email.focus();
		return false;
	} else if (email.value.indexOf(".") < 0) {
		alert("<?=_PLZ_RE_ENTR_?>");
		email.focus();
		return false;
	} else if (trim(email.value).indexOf(" ") >= 0) {
		alert("Incorrect email address. Please re-enter.");
		email.focus();
		return false;
	}

	var terms=document.form1.terms;
	if (!terms.checked) {
		alert("You must agree the terms & conditions .");
		terms.focus();
		return false;
	}

return true;
}
</script>

<script language="javascript">

function memberlogin()
{
	if((/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmlogedin.email.value))!=true)
	{
		alert("Invalid E-mail Address! Please re-enter.")
		document.frmlogedin.email.focus();
		return false;
	} else if(document.frmlogedin.password.value=='') {
		alert("<?=_PLZ_ENR_PASS_?>");
		document.frmlogedin.password.focus();
		return false;
	} else {
	  return true;
	}

}
</script>

<link href="<?=_BASEURLCSSNEW_?>/regist.css" rel="stylesheet" type="text/css" />
<div id="special_regist">
<div class="title"><div class="normaltextorangebold19c"> <img src="<?=_BASEURLMEDIA_?>/logo.png" /> </div></div><br />

<table width="95%" border="0" cellspacing="0" cellpadding="0" id="cumpanel" align="center" bgcolor="#FFFFFF">
  <tr>
    <td valign="top" width="48%"><form method="post" action="login.php" name="frmlogedin" target="_parent" onsubmit="return memberlogin();">
<div class="mem"><h3><?=_MEM_LOG_?></h3></div>
<br />
<?=_EMAIL_ID_?>
<div class="bm10px"><input type="text" class="inputtext" name="email" value="Email ID" onClick="_delete_login_fields(this, 'Email ID', this.value);" style="width:240px"/></div>
<?=_PASS_?>
<div class="bm10px"><input type="password" class="inputtext" name="password" value="Password" onClick="_delete_login_fields(this, 'Password', this.value);" style="width:240px" /></div>

<div><input type="submit" class="inputsubmitbig" value="Login" name="submit" />
<a href="#" class="close">
<input type="button" class="inputsubmitbigc"  value="Cancel"  onclick="cls()" /></a></div>
</form>
</td>
    <td valign="top" width="10px"><div class="divider"></div></td>
    <td valign="top" width="48%">

     <form name="form1" action="logedin.php" method="post" onSubmit="return validate();">
     <div class="mem"><h3><?=_REGISTRA_?></h3></div>
<br />
<?=_FIRT_NAME_?>
<div class="bm10px"><input name="fname" type="text" class="inputtext" style="width:240px"/></div>
<?=_LNAME_?>
<div class="bm10px"><input name="lname" type="text" class="inputtext" style="width:240px"  /></div>
Gender:
<div class="bm10px"><input type="radio" name="gender" value='male' checked="checked" /><?=_MALEE_?>&nbsp;&nbsp;&nbsp;<input type="radio" name="gender" value='female'  /><?=_FEMLSSS_?></div>
<?=_DOBB_?>
<div class="bm10px"><select name="day" class="whiteselect" style="width:70px"  >
        <option value="">--Day--</option>
        <?
			for ( $day = 1; $day <= 31; $day += 1) {
			echo "<option value='".$day."'>$day</option>";
				}
					?>
</select>
      <select name="month" class="whiteselect"   style="width:98px" >
        <option value="">--<?=_MM1_?>--</option>
        <option value="1"><?=_JAN1_?></option>
        <option value="2"><?=_FB1_?></option>
        <option value="3"><?=_M_RCH1_?></option>
        <option value="4"><?=_APR1_?></option>
        <option value="5"><?=_M_A_Y1_?></option>
        <option value="6"><?=_J_U_N1_?></option>
        <option value="7"><?=_JU_LY1_?></option>
        <option value="8"><?=_AUG_UST1_?></option>
        <option value="9"><?=_SEP_T1_?></option>
        <option value="10"><?=_OC_T1_?></option>
        <option value="11"><?=_NOV1_?></option>
        <option value="12"><?=_DEC1_?></option>
      </select>
      <select name="year" class="whiteselect"  style="width:72px"  >
        <option value="">--Year--</option>
        <?
			for ( $year = date('Y') - 100; $year <= date('Y')-18; $year += 1) {
				echo "<option value='".$year."'>$year</option>";
			}
	    ?>
      </select> </div>
<?=_UNAME_?>
<div class="bm10px"><input name="uname" type="text" class="inputtext"  style="width:240px"  /></div>
<?=_PASS_?>
<div class="bm10px"><input name="password" type="password" class="inputtext"  style="width:240px" /></div>
<?=_EMLSS_?>
<div class="bm10px"><input name="email" type="text" class="inputtext"  style="width:240px"  /></div>

<div class="bm10px"><input name="terms" type="checkbox" id="terms" value="checkbox"><?=_HAV_UND_?>
<a href="<?=_BASEURL_?>/terms.php"><?=_TERM_COND_?></a>.
</div>

<div class="bm10px"><input type="submit" name="register" value="<?=_REGISSS_?>" class="inputsubmitbig"  /><a href="#" class="close">
<input type="button" class="inputsubmitbigc"  value="Cancel"  onclick="cls()" /></a></div>
</form></td>
  </tr>
</table>

</div>










