<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
// +----------------------------------------------------------------------+
?>
<?php echo $javascript->link('jquery.js'); ?>
<script language="javascript" type="text/javascript">
function chk(thisform){
     	
		var i=0;		
		var fcs_fld=new Array();
		var illegalChars = /\W/; /* For User name validtion*/
		var illegalChars1 = /[\W_]/;  /* For Password validtion*/
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   /* For Email Address*/
		
		var errorstr = '';		
	    var msgstr = "Sorry, we cannot complete your request.\nKindly provide us the missing or incorrect information enclosed below.\n\n";
		
		if ($.trim($('#email').val())=='') { errorstr += "- Please enter Email Address.\n";   fcs_fld[i]='email'; i++;}		
		if ($.trim($('#email').val())!='') 
		{
		 if(reg.test($.trim($('#email').val())) == false) { errorstr += "- Invalid Email Address.\n";   fcs_fld[i]='email'; i++;}
		}	
			
		//if ($('#cpword').val() == '') { errorstr += "- Please Enter Current Password.\n"; fcs_fld[i]='cpword'; i++; }		
		
		if ($.trim($('#cpword').val())!='') 
		{
				var chk_pswd=$('#npword').val();
				 if (chk_pswd.indexOf(' ') != -1) 
				 { errorstr += "- Password cannot contain spaces.\n";  fcs_fld[i]='npword'; i++;}		
				 
				if ($.trim($('#npword').val())=='')  { errorstr += "- Please Enter New Password.\n";  fcs_fld[i]='npword'; i++;}	
				 	
				 	
				if ($.trim($('#npword').val())!='') 
				{
				 if ($.trim($('#npword').val()).length < 6) { errorstr += "- Password should contain atleast 6 characters.\n";   fcs_fld[i]='npword'; i++;}
				}		
				/*
				if ($.trim($('#npword').val()).length >= 6 ) {
				  if (illegalChars1.test($('#npword').val())) { errorstr += "- The password should contain letters and numbers only.\n";   fcs_fld[i]='npword'; i++;}
				}		
				*/		
				if ($.trim($('#npword').val()).length >= 6 && $.trim($('#npword').val())!='') {
				if ($.trim($('#rpword').val())=='') { errorstr += "- Please Confirm Password.\n";   fcs_fld[i]='rpword'; i++;}
				}
				if ($.trim($('#rpword').val())!='') {
				if ($.trim($('#npword').val()) != $.trim($('#rpword').val())) { errorstr += "- Password Mismatch.\n";  fcs_fld[i]='rpword'; i++;}					
				}
		 }		
		
	if (errorstr != '')
	{
		msgstr = msgstr + errorstr;
		alert(msgstr);
		$('#'+fcs_fld[0]+'').focus();$('#'+fcs_fld[0]+'').select();
		return false;
	}
	else
	{
	    thisform.submit();
		return true;
	}
} 
</script>
            <div align="center">
            	<h2 class="title text-center mainhd">My Account</h2>
            </div>
            <br />
      <?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>

            <div align="left" id="item_details_admin">
              <!--items display area start -->
              <div align="center" id="items_display_area_admin">
                <div align="left" class="inner_content_area_admin">
              <form name="pword" action="" method="post" class="chngpwrd">
                  
				   <div id="admin_heading">My Profile</div>
				  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent" class="lft-cell01">
                      <p class="maintext_inner">User Name</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell">
                     <span class="toplinks">
						
                       <p class="maintext_inner"><?php echo $uname; ?></p>
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent" class="lft-cell01">
                      <p class="maintext_inner">Email Address</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell">
                      <span class="toplinks">
						<input type="text" name="email" id="email" value="<?php echo $email; ?>" class="box2_admin" size="27">
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent" class="lft-cell01">
                      <p class="maintext_inner">Current Password</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell">
                     <span class="toplinks">
                         <input type="password" name="cpword" value="" id="cpword" class="box2_admin" size="27" maxlength="25">
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent" class="lft-cell01">
                      <p class="maintext_inner">New Password</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell">
                      <span class="toplinks">
						<input type="password" name="npword" id="npword" class="box2_admin" size="27" maxlength="25">
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  <div id="grid_admin">
                    <div align="left" id="inner_leftcontent" class="lft-cell01">
                      <p class="maintext_inner">Confirm New Password</p>
                    </div>
                    <div align="right" id="inner_rightcontent" class="ryt-cell">
                    <span class="toplinks">
						<input type="password" name="rpword" id="rpword" class="box2_admin" size="27" maxlength="25">
                      
                        </span>
                    </div>
                    <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                  </div>
                  <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
                 
                 <div id="admin_bottom" style="padding-bottom:10px ">
				<div align="left" id="inner_leftcontent" class="lft-cell01">
				  <p class="maintext_inner">&nbsp;</p>
				</div>
				<div align="right" id="inner_rightcontent" class="ryt-cell">
					<span class="toplinks">		
					<input type="button" value="Save" onClick="return chk(document.pword);" class="btn-usr01" >
					<input type="button" value="Cancel" onClick="window.location.href='<?php echo $sitebase.$sitefolder;?>/users/myaccount/'" class="btn-gry01" >
					
					</span>
				</div>
				<div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
			</div>
                </div>
                <!--form area end -->
				</form>
              </div>
              <div align="left" class="float_clear1"></div>
            </div>
            <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif');?></div>
			