<?php
/*
/**
* CHRONOFORMS version 1.0 stable
* Copyright (c) 2006 Chrono_Man, ChronoEngine.com. All rights reserved.
* Author: Chrono_Man (ChronoEngine.com)
* See readme.html.
* Visit http://www.ChronoEngine.com for regular update and information.
**/

/* ensure that this file is called from another file */
defined( '_VALID_MOS' ) or die( 'Direct access to this file is prohibited.' );
class HTML_ChronoContact {
  function showChronoContact( $rows, $pageNav, $option ) {
    // HTML starts here, combined with short PHP commands for table creation
	
    global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
	
    mosCommonHTML::loadOverlib();
    ?>
    <form action="index2.php" method="post" name="adminForm">
	<table class="adminlist"><tr><td width="130px" valign="top">
	<table cellpadding="0" cellspacing="0" border="0" width="130px">
		<tr>
			<td width="130px" valign="top">
				<strong>Plugins</strong>
			</td>
		</tr>
		<tr>
			<td width="130px" valign="top">
				<?php
				$directory = $mosConfig_absolute_path.'/components/com_chronocontact/plugins/';
				$results = array();
				$handler = opendir($directory);
				while ($file = readdir($handler)) {
					if ( $file != '.' && $file != '..' && substr($file, -4) == '.php' )
						$results[] = str_replace(".php","", $file);
				}
				closedir($handler);
				foreach($results as $result){
					require_once($mosConfig_absolute_path."/components/com_chronocontact/plugins/".$result.".php");
					${$result} = new $result();
					?>
					<a style="display:block; " href="javascript:if (document.adminForm.boxchecked.value == 0){ alert('Please make a selection from the list to <?php echo ${$result}->result_TITLE; ?>');}else{submitbutton('<?php echo 'plugin_'.$result; ?>')}">
					<?php echo ${$result}->result_TITLE; ?></a><br>
					<?php
				}
				?>			
			</td>
			
		</tr>
	</table>
	</td><td>
    <table class="adminheading">
    <tr>
	  <th>Chrono Forms - <?php echo FORMS_MANAGER; ?></th>
    </tr>
	</table>
    <table class="adminlist">
	<tr>
	  <th width="20" class='title'>#</th>
	  <th width="5%" class='title'>Form ID</th>
	  <th width="20" class='title'><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>

	  <th width="20%" align="left" class='title'><?php echo NAME; ?></th>
	  <th width="60%" align="left" class='title'><?php echo LINK; ?></th>
	  <th width="20%" align="right" class='title'><?php echo DATA; ?></th>
	</tr>
    <?php
	$k = 0;
    for ($i=0, $n=count($rows); $i < $n; $i++) {
	  $row = $rows[$i];

		$link	= 'index2.php?option=com_chronocontact&task=editA&hidemainmenu=1&id='. $row->id;
		

	  //$checked 	= mosCommonHTML::CheckedOutProcessing( $row, $i );


	  ?>
	  <tr class="<?php echo "row$k"; ?>">
		<td width="20" align="center"><?php echo $i+$pageNav->limitstart+1;?></td>
		<td width="20" align="center"><?php echo $row->id; ?></td>
		<td width="20"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" /></td>
		
		<td width="20%" align="left" ><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->name; ?></a></td>
		<td width="60%" align="left" ><a target="_blank" href="<?php echo $mosConfig_live_site; ?>/index.php?option=com_chronocontact&amp;chronoformname=<?php echo $row->name; ?>">index.php?option=com_chronocontact&amp;chronoformname=<?php echo $row->name; ?></a></td>
		<?php
		$result = $database->getTableList();
		if (in_array($mosConfig_dbprefix."chronoforms_".$row->id, $result)) {
		?>
			<td width="20%" align="left" ><a href="#show" onclick="return listItemTask('cb<?php echo $i;?>','show')"><?php echo 'Show saved Data'; ?></a></td>
		<?php }else{ ?>
			<td width="20%" align="left" ><a href="#createtable" onclick="return listItemTask('cb<?php echo $i;?>','createtable')"><?php echo 'Create Table'; ?></a></td>
		<?php
		}
		?>
	  </tr>
      <?php
			$k = 1 - $k;
		}
    ?>
		<?php echo $pageNav->getListFooter(); ?>
	  </table>
	  </td></tr></table>
	  <input type="hidden" name="option" value="<?php echo $option; ?>" />
	  <input type="hidden" name="task" value="" />
	  <input type="hidden" name="boxchecked" value="0" />
	  <input type="hidden" name="hidemainmenu" value="0">
	  </form>
    <?php
	}

  // this method represents the edit mask
  function editChronoContact( $row, $option ) {
   global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
		mosMakeHtmlSafe( $row, ENT_QUOTES );
		$tabs = new mosTabs(1);
		// JavaScript Code for checking forms starts here
		if(!$row->paramsall){
			$row->paramsall = "ccemail=
			bccemail=
			formmethod=post
			omittedfields=
			recip=Yes
			from_email=
			from_name=
			replyto_email=
			replyto_name=
			email_type=1
			debug=0
			mysql_type=1
			enmambots=No
			emailfield=
			subjectfield=
			ccfield=
			bccfield=
			fromemailfield=
			fromnamefield=
			uploads=No
			uploadfields=
			uploadmax=
			uploadmin=
			dvfields=
			dvrecord=Record #n
			imagever=No
			imtype=0
			validate=No
			validatetype=prototype
			val_required=
			val_validate_number=
			val_validate_digits=
			val_validate_alpha=
			val_validate_alphanum=
			val_validate_date=
			val_validate_email=
			val_validate_url=
			val_validate_date_au=
			val_validate_currency_dollar=
			val_validate_selection=
			val_validate_one_required=
			plugins=
			plugins_order=1
			onsubmitcode_order=2
			autogenerated_order=3
			mplugins_order=";
		}
		$paramsvalues = mosParseParams( $row->paramsall ); 
    ?>
	  <script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == "cancel") {
				submitform( pressbutton );
				return;
			}
			// do field validation
			if ((form.name.value == '')||(form.name.value.search(/ /) > -1)) {
				alert( "<?php echo ENTER_FORM_NAME; ?>" );
			}else if (form.emailresults.value == '2') {
				if ((form.extraemail.value == '')||(form.emailsubject.value == '')||(document.getElementById('paramsfrom_email').value == '')||(document.getElementById('paramsfrom_name').value == '')) {
					alert( "<?php echo REQUIRED_FIELDS; ?>" );
				} else {
					submitform( pressbutton );
				}
			} else {
				submitform( pressbutton );
			}
		}
		function addmenuitem(){
			var form = document.adminForm;
			if (form.menutext.value == '') {
				alert( "<?php echo MENU_LINK_TEXT; ?>" );
			} else {
				submitform( 'addmenuitem' );
			}
		}
		function toggleList(e){
			element = document.getElementById(e).style;
			element.display == 'none' ? element.display = 'block' :
			element.display='none';
		}
		function change_order1_plus(e){
			element = document.getElementById(e);
			if(trim(element.value) == "" ) element.value = "0";
			element.value = parseInt(element.value) + 1;
		}
		function change_order1_minus(e){
			element = document.getElementById(e);
			if(trim(element.value) == "" ) element.value = "0";
			parseInt(element.value) == 0 ? element.value = 0 :			
			element.value = parseInt(element.value) - 1;
		}
		function enable_order(e1, e2){
			element1 = document.getElementById(e1);
			element2 = document.getElementById(e2);
			if(element2.checked == true)element1.disabled = false;
			if(element2.checked == false)element1.disabled = true;
		}
		function change_order2_plus(e){
			element = document.getElementById(e);
			if(trim(element.value) == "" ) element.value = "0";
			element.value = parseInt(element.value) + 1;
		}
		function change_order2_minus(e){
			element = document.getElementById(e);
			if(trim(element.value) == "" ) element.value = "0";
			parseInt(element.value) == 0 ? element.value = 0 :			
			element.value = parseInt(element.value) - 1;
		}

	  </script>

	 <strong style="font-size:18px; "><?php echo $row->name; ?></strong> <?php echo "<script  type=\"text/javascript\" "
    . "src=\"$mosConfig_live_site/includes/js/overlib_mini.js\"></script>"; ?>
	<?php echo mosToolTip( TOOLTIP_TT ); ?> <?php echo TOOLTIP; ?>
	  <form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm">
	  <?php
		  	$tabs->startPane( 'chronoforms' );
	        $tabs->startTab( General, 'general' );
	  ?>
	<table border="0" cellpadding="3" cellspacing="0">
  <tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FORM_NAME_UNIQUE ); ?></td>
		<td><strong><?php echo FORM_NAME; ?>:</strong> <br><strong style="color:#FF0000 "><?php echo MUST_BE_UNIQUE; ?></strong></td>
		<td></td>
		<td><input type="text" class="inputbox" size="50" maxlength="500" name="name" value="<?php echo $row->name; ?>" /></td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( EMAIL_RESULTS ); ?></td>
		<td><strong><?php echo EMAIL_THE_RESULTS; ?> ?</strong> </td>
		<td></td>
		<td><select name="emailresults" id="emailresults" >
          <option value="0"<?php if($row->emailresults == 0){echo 'selected';}; ?>><?php echo NO; ?></option>
		  <option value="2"<?php if($row->emailresults == 2){echo 'selected';}; ?>><?php echo YES; ?></option>
        </select></td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( TO_WHICH_EMAILS ); ?></td>
		<td><strong><?php echo EMAIL_ADDRESSES; ?>:</strong> </td>
		<td></td>
		<td><input type="text" class="inputbox" size="50" maxlength="500" name="extraemail" id="extraemail" value="<?php echo $row->extraemail; ?>" /></td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( DEFAULT_SUBJECT ); ?></td>
		<td><strong><?php echo EMAIL__SUBJECT; ?>:</strong> </td>
		<td></td>
		<td><input type="text" class="inputbox" size="50" maxlength="500" name="emailsubject" id="emailsubject" value="<?php echo $row->emailsubject; ?>" /></td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( CC_EMAILS ); ?></td>
		<td><strong><?php echo CC__EMAILS; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[ccemail]" id="cc_email" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->ccemail; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( BCC_EMAILS ); ?></td>
		<td><strong><?php echo BCC__EMAILS; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[bccemail]" id="bcc_email" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->bccemail; ?>">
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FORM_TAG_CODE ); ?></td>
		<td><strong><?php echo FORM_TAG_ATTACH; ?>:</strong><br><strong style="color:#FF0000 "><?php echo SOMETHING_LIKE_ONSUBMIT; ?></strong> </td>
		<td></td>
		<td><input type="text" class="inputbox" size="100" maxlength="500" name="attformtag" value="<?php echo $row->attformtag; ?>" /></td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( FORM_METHOD ); ?></td>
		<td><strong><?php echo FORM__METHOD; ?>:</strong> </td>
		<td></td>
		<td>
		<select name="params[formmethod]" id="params[formmethod]">
		<option<?php if($paramsvalues->formmethod == 'post'){ echo ' selected';} ?> value="post"><?php echo POST; ?></option>
		<option<?php if($paramsvalues->formmethod == 'get'){ echo ' selected';} ?> value="get"><?php echo GET; ?></option>
		</select>
		</td>
	</tr>
	
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FIELDS_OMITTED ); ?></td>
		<td><strong><?php echo OMITTED__FIELDS; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[omittedfields]" id="params[omittedfields]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->omittedfields; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( RECORD_IP ); ?></td>
		<td><strong><?php echo RECORD_SEND_IP; ?>?</strong> </td>
		<td></td>
		<td>
		<select name="params[recip]" id="params[recip]">
			<option<?php if($paramsvalues->recip == 'Yes'){ echo ' selected';} ?> value="Yes"><?php echo YES; ?></option>
			<option<?php if($paramsvalues->recip == 'No'){ echo ' selected';} ?> value="No"><?php echo NO; ?></option>
		</select>
		</td>
	</tr>

	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FROM_EMAIL ); ?></td>
		<td><strong><?php echo FROM__EMAIL; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[from_email]" id="paramsfrom_email" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->from_email; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( FROM_NAME ); ?></td>
		<td><strong><?php echo FROM__NAME; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[from_name]" id="paramsfrom_name" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->from_name; ?>">
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( REPLYTO_EMAIL ); ?></td>
		<td><strong><?php echo REPLYTO__EMAIL; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[replyto_email]" id="params[replyto_email]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->replyto_email; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( REPLYTO_NAME ); ?></td>
		<td><strong><?php echo REPLYTO__NAME; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[replyto_name]" id="params[replyto_name]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->replyto_name; ?>">
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( EMAIL_TYPE ); ?></td>
		<td><strong><?php echo EMAIL__FORMAT; ?>:</strong> </td>
		<td></td>
		<td>
			<select name="params[email_type]" id="params[email_type]">
				<!--<option<?php if($paramsvalues->email_type == '0'){ echo ' selected';} ?> value="0">Form completed(under development)</option>-->
				<option<?php if($paramsvalues->email_type == '1'){ echo ' selected';} ?> value="1"><?php echo FIELDS_TITLES; ?></option>
				<option<?php if($paramsvalues->email_type == '2'){ echo ' selected';} ?> value="2"><?php echo MY_TEMPLATE; ?></option>
			</select>
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( DEBUG ); ?></td>
		<td><strong><?php echo DEBUG_; ?>:</strong> </td>
		<td></td>
		<td>
			<select name="params[debug]" id="params[debug]">
				<option<?php if($paramsvalues->debug == '0'){ echo ' selected';} ?> value="0"><?php echo OFF; ?></option>
				<option<?php if($paramsvalues->debug == '1'){ echo ' selected';} ?> value="1"><?php echo ON; ?></option>
			</select>
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( MYSQL_TYPE ); ?></td>
		<td><strong><?php echo MYSQL__TYPE; ?></strong> </td>
		<td></td>
		<td>
			<select name="params[mysql_type]" id="params[mysql_type]">
				<option<?php if($paramsvalues->mysql_type == '1'){ echo ' selected';} ?> value="1"><?php echo ENGINE; ?></option>
				<option<?php if($paramsvalues->mysql_type == '2'){ echo ' selected';} ?> value="2"><?php echo TYPE; ?></option>
			</select>
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( "Enable mambots to be applied to this form contents?" ); ?></td>
		<td><strong><?php echo ENABLE__MAMBOTS; ?>?</strong> </td>
		<td></td>
		<td>
		<select name="params[enmambots]" id="params[enmambots]">
			<option<?php if($paramsvalues->enmambots == 'No'){ echo ' selected';} ?> value="No"><?php echo NO; ?></option>
			<option<?php if($paramsvalues->enmambots == 'Yes'){ echo ' selected';} ?> value="Yes"><?php echo YES; ?></option>
		</select>
		</td>
	</tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( SPECIAL_FIELDS, 'spfields' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( EMAIL_FIELD ); ?></td>
		<td><strong><?php echo EMAIL__FIELD; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[emailfield]" id="params[emailfield]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->emailfield; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( SUBJECT_FIELD ); ?></td>
		<td><strong><?php echo SUBJECT__FIELD; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[subjectfield]" id="params[subjectfield]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->subjectfield; ?>">
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( CC_FIELD ); ?></td>
		<td><strong><?php echo CC__FIELD; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[ccfield]" id="params[ccfield]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->ccfield; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( BCC_FIELD ); ?></td>
		<td><strong><?php echo BCC__FIELD; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[bccfield]" id="params[bccfield]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->bccfield; ?>">
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FROMEMAIL_FIELD ); ?></td>
		<td><strong><?php echo FROMEMAIL__FIELD; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[fromemailfield]" id="params[fromemailfield]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->fromemailfield; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( FROMNAME_FIELD ); ?></td>
		<td><strong><?php echo FROMNAME__FIELD; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[fromnamefield]" id="params[fromnamefield]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->fromnamefield; ?>">
		</td>
	</tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( FORM_CODE, 'codes' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FORM_HTML ); ?></td>
		<td><strong><?php echo FORM__HTML; ?>:</strong><br><strong style="color:#FF0000 ">(<?php echo MAY_HAVE_PHP; ?>)</strong> </td>
		<td><a href="javascript:toggleList('html')">[+/-]</a></td>
		<td><textarea name="html" id="html" style="display:none" cols="80" rows="30"><?php echo $row->html; ?></textarea></td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( FORM_JS ); ?></td>
		<td><strong><?php echo FORM__JS; ?>:</strong><br><strong style="color:#FF0000 ">(<?php echo WITHOUT_SCRIPT_TAGS; ?>)</strong> </td>
		<td><a href="javascript:toggleList('scriptcode')">[+/-]</a></td>
		<td><textarea name="scriptcode" id="scriptcode" style="display:none" cols="80" rows="10"><?php echo $row->scriptcode; ?></textarea></td>
	</tr>

	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( FORM_ONSUBMIT_BEFORE ); ?></td>
		<td><strong><?php echo ONSUBMIT__BEFORE; ?>:</strong><br><strong style="color:#FF0000 ">(<?php echo MAY_HAVE_PHP; ?>)</strong> </td>
		<td><a href="javascript:toggleList('onsubmitcodeb4')">[+/-]</a></td>
		<td><textarea name="onsubmitcodeb4" id="onsubmitcodeb4" style="display:none" cols="80" rows="10"><?php echo $row->onsubmitcodeb4; ?></textarea></td>
	</tr>

	<tr>
		<td><?php echo mosToolTip( FORM_ONSUBMIT_AFTER ); ?></td>
		<td><strong><?php echo ONSUBMIT__AFTER; ?>:</strong><br><strong style="color:#FF0000 ">(<?php echo MAY_HAVE_PHP; ?>)</strong> </td>
		<td><a href="javascript:toggleList('onsubmitcode')">[+/-]</a></td>
		<td><textarea name="onsubmitcode" id="onsubmitcode" style="display:none" cols="80" rows="10"><?php echo $row->onsubmitcode; ?></textarea></td>
	</tr>

	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( EMAIL_TEMPLATE ); ?></td>
		<td><strong><?php echo EMAIL__TEMPLATE; ?>:</strong> </td>
		<td><a href="javascript:toggleList('emailtemplate')">[+/-]</a></td>
		<td><textarea name="emailtemplate" id="emailtemplate" style="display:none" cols="80" rows="10"><?php echo $row->emailtemplate; ?></textarea></td>
	</tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( FORM_URLS, 'urls' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( REDIRECT_URL ); ?></td>
		<td><strong><?php echo REDIRECT__URL; ?>:</strong> </td>
		<td></td>
		<td><input type="text" class="inputbox" size="50" maxlength="500" name="redirecturl" value="<?php echo $row->redirecturl; ?>" /><strong>  <?php echo REDIRECT_DESC; ?></strong></td>
	</tr>

	<tr>
		<td><?php echo mosToolTip( SUBMIT_URL ); ?></td>
		<td><strong><?php echo SUBMIT__URL; ?>:</strong><br><strong style="color:#FF0000 "><?php echo SUBMIT_DESC; ?></strong> </td>
		<td></td>
		<td><input type="text" class="inputbox" size="50" maxlength="500" name="submiturl" value="<?php echo $row->submiturl; ?>" /><strong> <?php echo SUBMIT_NOTE; ?></strong></td>
	</tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( ELEMENTS_TITLES, 'titlesx' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( ELEMENTS_TITLES_TT ); ?></td>
		<td><strong><?php echo ELEMENTS__TITLES; ?>:</strong><br><strong style="color:#FF0000 "><?php echo ELEMENTS_TITLES_EX; ?></strong> </td>
		<td><a href="javascript:toggleList('titles')">[+/-]</a></td>
		<td><textarea name="titles" id="titles" cols="80" rows="20"><?php echo $row->titlesall; ?></textarea></td>
	</tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( AUTOGENERATED_CODE, 'autogen' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( AUTOGENERATED_TT ); ?></td>
		<td><strong><?php echo AUTOGENERATED; ?>:</strong><br><strong style="color:#FF0000 "><?php echo AUTOGENERATED_NOTE; ?></strong> </td>
		<td><a href="javascript:toggleList('autogenerated')">[+/-]</a></td>
		<td><textarea name="autogenerated" id="autogenerated" cols="80" rows="20"><?php echo $row->autogenerated; ?></textarea></td>
	</tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( FILE_UPLOADS, 'uploads' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( ENABLE_UPLOADS_TT ); ?></td>
		<td><strong><?php echo ENABLE_UPLOADS; ?>:</strong><br><strong style="color:#FF0000 "></strong> </td>
		<td></td>
		<td>
		<select name="params[uploads]" id="params[uploads]">
			<option<?php if($paramsvalues->uploads == 'No'){ echo ' selected';} ?> value="No"><?php echo NO; ?></option>
			<option<?php if($paramsvalues->uploads == 'Yes'){ echo ' selected';} ?> value="Yes"><?php echo YES; ?></option>
		</select>
		</td>
	</tr>

	<tr>
		<td><?php echo mosToolTip( UPLOAD_FIELDS_TT ); ?></td>
		<td><strong><?php echo FILES_NAMES; ?>:</strong><br><strong style="color:#FF0000 "><?php echo FILES_NAMES_NOTE; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[uploadfields]" id="params[uploadfields]" class="inputbox" size="100" maxlength="500" value="<?php echo $paramsvalues->uploadfields; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( MAX_SIZE_TT ); ?></td>
		<td><strong><?php echo MAX_ALLOWABLE_SIZE; ?>:</strong><br><strong style="color:#FF0000 "><?php echo IN_KB; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[uploadmax]" id="params[uploadmax]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->uploadmax; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( MIN_SIZE_TT ); ?></td>
		<td><strong><?php echo MIN_ALLOWABLE_SIZE; ?>:</strong><br><strong style="color:#FF0000 "><?php echo IN_KB; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[uploadmin]" id="params[uploadmin]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->uploadmin; ?>">
		</td>
	</tr>

	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( DATAVIEW, 'dvfields' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( DATAVIEW_FIELDS_TT ); ?></td>
		<td><strong><?php echo DATAVIEW_FIELDS; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[dvfields]" id="params[dvfields]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->dvfields; ?>">
		</td>
	</tr>
	<tr style="background-color:#fff ">
		<td><?php echo mosToolTip( DATAVIEW_TITLES_TT ); ?></td>
		<td><strong><?php echo DATAVIEW_TITLES; ?>:</strong> </td>
		<td></td>
		<td>
		<?php if(!trim($paramsvalues->dvrecord)){$paramsvalues->dvrecord = "Record #n";} ?>
		<input type="text" name="params[dvrecord]" id="params[dvrecord]" class="inputbox" size="50" maxlength="500" value="<?php echo $paramsvalues->dvrecord; ?>">
		</td>
	</tr>
	</table>
	
	<?php
			$tabs->endTab();
            $tabs->startTab( ANTISPAM, 'antispam' );
            // :: HACK :: show GD capability
            if(function_exists('gd_info')){
          	  $gd_info = gd_info();
			  $imagever_ok = true;
			}else{
				$imagever_ok = false;
			}
            if($imagever_ok){
				if ( !$gd_info['GD Version'] ) {
					$imagever_ok = false;
					$gd_info['GD Version'] = "GD library not found.";
				} else {
					if ( $gd_info['FreeType Support'] ) {
						$gd_info['FreeType Support'] = 'Yes';
					} else {
						$gd_info['FreeType Support'] = 'No';
						$imagever_ok = false;
					}
					if ( $gd_info['PNG Support'] ) {
						$gd_info['PNG Support'] = 'Yes';
					} else {
						$gd_info['PNG Support'] = 'No';
						$imagever_ok = false;
					}
				}
			}
			?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip(USE_IMAGEVERIFICATION_TT); ?></td>
<?php
        if ( 1){//$imagever_ok ) {
            echo "<td><strong>".USE_IMAGEVER.":</strong><br><strong style='color:#FF0000' ></strong></td>
                <td>&nbsp;</td>
                <td>";
				?>
                <select name="params[imagever]" id="params[imagever]">
					<option<?php if($paramsvalues->imagever == 'No'){ echo ' selected';} ?> value="No"><?php echo NO; ?></option>
					<option<?php if($paramsvalues->imagever == 'Yes'){ echo ' selected';} ?> value="Yes"><?php echo YES; ?></option>
				</select>
				</td>
	</tr>
	<tr>
	<td><?php echo mosToolTip( FONTS_TT ); ?></td>
	<td><?php echo IMAGE_TYPE; ?> ?</td><td>
				<select name="params[imtype]" id="params[imtype]">
					<option<?php if($paramsvalues->imtype == '0'){ echo ' selected';} ?> value="0"><?php echo WITHOUT_FONTS; ?></option>
					<option<?php if($paramsvalues->imtype == '1'){ echo ' selected';} ?> value="1"><?php echo WITH_FONTS; ?></option>
				</select>
				<?php
		} else {
		    echo IMAGEVER_NOT_WORKING."
		      <input type='hidden' name='params[imagever]' id='params[imagever]' value ='No' />";
		}
?>
		</td>
	</tr>
	<?php if ( 1){//$imagever_ok ) { ?>
	<tr>
	   <td>&nbsp;</td>
	   <td>GD Version</td>
	   <td><?php echo $gd_info['GD Version']; ?></td>
	</tr>
		<tr>
	   <td>&nbsp;</td>
	   <td>FreeType Support</td>
	   <td><?php echo $gd_info['FreeType Support']; ?></td>
	</tr>
	</tr>
		<tr>
	   <td>&nbsp;</td>
	   <td>PNG Support</td>
	   <td><?php echo $gd_info['PNG Support']; ?></td>

	</tr>
	<?php } ?>
<?php
	if ( 1){//$imagever_ok ) {
	global $mainframe; ?>
	   <tr>
	       <td>&nbsp;</td>
	       <td>Sample image: </td>
	       <td><img src='<?php echo $mosConfig_live_site; ?>/components/com_chronocontact/chrono_verification.php<?php if($paramsvalues->imtype == '1'){ echo '?imtype=1';}else{ echo '?imtype=0';} ?>'></td>
	       </tr>
		   <?php
	}
?>
	<!-- // end hack -->
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( VALIDATION, 'validation' );
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( ENABLE_VALIDATION_TT ); ?></td>
		<td><strong><?php echo ENABLE_VALIDATION; ?> ?</strong> </td>
		<td></td>
		<td>
		<select name="params[validate]" id="params[validate]">
			<option<?php if($paramsvalues->validate == 'No'){ echo ' selected';} ?> value="No"><?php echo NO; ?></option>
			<option<?php if($paramsvalues->validate == 'Yes'){ echo ' selected';} ?> value="Yes"><?php echo YES; ?></option>
		</select>
		</td>
	</tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( VALIDATION_LIBRARY_TT ); ?></td>
		<td><strong><?php echo VALIDATION_LIBRARY; ?></strong> </td>
		<td></td>
		<td>
		<select name="params[validatetype]" id="params[validatetype]">
			<option<?php if($paramsvalues->validatetype == 'prototype'){ echo ' selected';} ?> value="prototype">prototype</option>
			<option<?php if($paramsvalues->validatetype == 'mootools'){ echo ' selected';} ?> value="mootools">mootools</option>
		</select>
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( REQUIRED_TT ); ?></td>
		<td><strong>1 - <?php echo REQUIRED; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_required]" id="params[val_required]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_required; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_NUM_TT ); ?></td>
		<td><strong>2- <?php echo VALID_NUM; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_number]" id="params[val_validate_number]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_number; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_DIGITS_TT ); ?></td>
		<td><strong>3- <?php echo VALID_DIGITS; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_digits]" id="params[val_validate_digits]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_digits; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_ALPHA_TT ); ?></td>
		<td><strong>4- <?php echo VALID_ALPHA; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_alpha]" id="params[val_validate_alpha]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_alpha; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_ALPHANUM_TT ); ?></td>
		<td><strong>5- <?php echo VALID_ALPHANUM; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_alphanum]" id="params[val_validate_alphanum]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_alphanum; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_DATE_TT ); ?></td>
		<td><strong>6- <?php echo VALID_DATE; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_date]" id="params[val_validate_date]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_date; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_EMAIL_TT ); ?></td>
		<td><strong>7- <?php echo VALID_EMAIL; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_email]" id="params[val_validate_email]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_email; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_URL_TT ); ?></td>
		<td><strong>8- <?php echo VALID_URL; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_url]" id="params[val_validate_url]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_url; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_DATEAU_TT ); ?></td>
		<td><strong>9- <?php echo VALID_DATEAU; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_date_au]" id="params[val_validate_date_au]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_date_au; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_CURR_DOLLAR_TT ); ?></td>
		<td><strong>10- <?php echo VALID_CURR_DOLLAR; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_currency_dollar]" id="params[val_validate_currency_dollar]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_currency_dollar; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_SELECTION_TT ); ?></td>
		<td><strong>11- <?php echo VALID_SELECTION; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_selection]" id="params[val_validate_selection]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_selection; ?>">
		</td>
	</tr>
	<tr>
		<td><?php echo mosToolTip( VALID_RADIO_TT ); ?></td>
		<td><strong>12- <?php echo VALID_RADIO; ?></strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[val_validate_one_required]" id="params[val_validate_one_required]" class="inputbox" size="50" value="<?php echo $paramsvalues->val_validate_one_required; ?>">
		</td>
	</tr>
	<tr><td colspan="4"><strong>Special thanks to "bouton" for referring to this feature!!</strong></td></tr>
	</table>
	<?php
			$tabs->endTab();
			$tabs->startTab( PLUGINS, 'plugins' );
			?>
			<table border="0" cellpadding="3" cellspacing="0">
	<tr><td colspan="3"><font style="font-size:12px; color:#FF0000; font-weight:bold; ">Pay attention: Some plugins work onsubmit the form event<br> and will do some database changes, please assure that plugins<br> are very well configured or this may end up saving wrong<br> data to the database tables!</font></td></tr>
	<tr style="background-color:#e1e1e1 ">
		<td>Hint</td>
		<td><strong>Plugin Name</strong> </td>
		
		<td>
		Enabled</td>
		<td>Plugin Run Order</td>
	</tr>	
	<?php
			$directory = $mosConfig_absolute_path.'/components/com_chronocontact/plugins/';
			$results = array();
			$handler = opendir($directory);
			while ($file = readdir($handler)) {
				if ( $file != '.' && $file != '..' && substr($file, -4) == '.php' )
					$results[] = str_replace(".php","", $file);
			}
			closedir($handler);
			$order = 0;
			$mplugins_order = explode(",", $paramsvalues->mplugins_order);
			foreach($results as $result){
			require_once($mosConfig_absolute_path."/components/com_chronocontact/plugins/".$result.".php");
			${$result} = new $result();
	?>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( ${$result}->result_TOOLTIP ); ?></td>
		<td><strong><?php echo ${$result}->result_TITLE; ?>:</strong> </td>
		
		<td>
		<input type="checkbox" onClick="enable_order('mplugins_order_<?php echo ${$result}->result_TITLE; ?>','plugins_order_<?php echo ${$result}->result_TITLE; ?>')" id="plugins_order_<?php echo ${$result}->result_TITLE; ?>" name="plugins[]" <?php if(in_array($result,explode(",",$paramsvalues->plugins)))echo "checked"; ?> class="inputbox" size="50" value="<?php echo $result; ?>">
		</td>
		<td><input type="text" maxlength="2" <?php if(in_array($result,explode(",",$paramsvalues->plugins))){ ?><?php }else{ ?>disabled="true"<?php } ?> size="2" name="mplugins_order[]" id="mplugins_order_<?php echo ${$result}->result_TITLE; ?>" value="<?php if(in_array($result,explode(",",$paramsvalues->plugins))){echo $mplugins_order[$order];} ?>">
		<a href="javascript:change_order1_plus('mplugins_order_<?php echo ${$result}->result_TITLE; ?>')">[+]</a>&nbsp;
		<a href="javascript:change_order1_minus('mplugins_order_<?php echo ${$result}->result_TITLE; ?>')">[-]</a>
		</td>
	</tr>	
	
	<?php
				if(in_array($result,explode(",",$paramsvalues->plugins))){
					$order++;
				}
			}	
	?>
	</table>
	
	<?php
		$tabs->endTab();
		$tabs->startTab( 'RunOrder', 'RunOrder' );
		if((!$paramsvalues->autogenerated_order)||(!$paramsvalues->onsubmitcode_order)||(!$paramsvalues->plugins_order)){
			$paramsvalues->autogenerated_order = 3;
			$paramsvalues->onsubmitcode_order = 2;
			$paramsvalues->plugins_order = 1;
		}
	?>
	<table border="0" cellpadding="3" cellspacing="0">
	<tr><td colspan="3"><font style="font-size:12px; color:#FF0000; font-weight:bold; ">Here you can change the order the different code blocks run, <br>valid values are 1 or 2 or 3 <br>using other values will result in the whole block doesn't executed!</font></td></tr>
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( "Order of Autogenerated block" ); ?></td>
		<td><strong><?php echo "Order of Autogenerated block"; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[autogenerated_order]" id="params_autogenerated_order" class="inputbox" size="1" maxlength="1" value="<?php echo $paramsvalues->autogenerated_order; ?>">
		<a href="javascript:change_order1_plus('params_autogenerated_order')">[+]</a>&nbsp;
		<a href="javascript:change_order1_minus('params_autogenerated_order')">[-]</a>
		</td>
	</tr>	
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( "Order of OnSubmit block" ); ?></td>
		<td><strong><?php echo "Order of OnSubmit block"; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[onsubmitcode_order]" id="params_onsubmitcode_order" class="inputbox" size="1" maxlength="1" value="<?php echo $paramsvalues->onsubmitcode_order; ?>">
		<a href="javascript:change_order1_plus('params_onsubmitcode_order')">[+]</a>&nbsp;
		<a href="javascript:change_order1_minus('params_onsubmitcode_order')">[-]</a>
		</td>
	</tr>	
	<tr style="background-color:#c9c9c9 ">
		<td><?php echo mosToolTip( "Order of Plugins block" ); ?></td>
		<td><strong><?php echo "Order of Plugins block"; ?>:</strong> </td>
		<td></td>
		<td>
		<input type="text" name="params[plugins_order]" id="params_plugins_order" class="inputbox" size="1" maxlength="1" value="<?php echo $paramsvalues->plugins_order; ?>">
		<a href="javascript:change_order1_plus('params_plugins_order')">[+]</a>&nbsp;
		<a href="javascript:change_order1_minus('params_plugins_order')">[-]</a>
		</td>
	</tr>	
	</table>
<?php
	$tabs->endTab();
	$tabs->endPane();
?>

		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="task" value="" />
	</form>
  <?php
	}

	function maketableChronoContact( $row, $option, $html_message  ) {
   global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
		mosMakeHtmlSafe( $row, ENT_QUOTES );
		?>
		<?php echo "<script  type=\"text/javascript\" "
    . "src=\"$mosConfig_live_site/includes/js/overlib_mini.js\"></script>"; ?>

	  <form action="index2.php" method="post" name="adminForm">
	  <?php if($html_message == '</table>'){ echo NOTENOUGH_FIELDS;}
	  else if($html_message == 'exists') { echo TABLE_ALREADY_EXISTS;}
	  else { ?>
		<?php echo $html_message; ?>
		<input type="submit" name="submit2" value="Create Table">
		<?php } ?>
	  <input type="hidden" name="option" value="<?php echo $option; ?>" />
	  <input type="hidden" name="formid" value="<?php echo $row->id; ?>" />
	  <input type="hidden" name="task" value="finalizetable" />
	  <input type="hidden" name="boxchecked" value="0" />
	  <input type="hidden" name="hidemainmenu" value="0">
	  </form>
	<?php
		}

	function settings( $option, $params, $id ) {
		global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
		?>
		<script type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
		<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
		<form action="index2.php" method="post" name="adminForm">
		<table style="width:75%;" class="adminheading">
		<tr>
			<th class="config">
			ChronoForms Global Settings
			</th>
		</tr>
		</table>

		<table style="width:75%;" class="adminform">
		<tr>
			<th>
			Parameters
			</th>
		</tr>
		<tr>
			<td>
			<?php
			echo $params->render();
			?>
			</td>
		</tr>
		</table>

		<input type="hidden" name="id" value="<?php echo $id; ?>" />
		<input type="hidden" name="option" value="<?php echo $option ?>" />
		<input type="hidden" name="task" value="" />
		</form>

		<?php

		}

function showdataChronoContact( $rows, $pageNav, $option, $formid ) {
    // HTML starts here, combined with short PHP commands for table creation
    global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
    mosCommonHTML::loadOverlib();
	$database->setQuery( "SELECT * FROM #__chrono_contact WHERE id='".$formid."'" );
	$formdata = $database->loadObjectList();
	$paramsvalues = mosParseParams( $formdata[0]->paramsall );
	$dvfields = $paramsvalues->dvfields;
	$dvlist = array();
	if ( !empty($dvfields) ) {
	  $dvlist = explode(",", $dvfields);
	}
    ?>
    <form action="index2.php" method="post" name="adminForm">
    <table class="adminheading">
    <tr>
	  <th>
	  <?php
		if( mosGetParam($_GET, 'formid', 0) ){
			$database->setQuery("SELECT name FROM #__components WHERE admin_menu_link = 'option=com_chronocontact&task=show&formid=".mosGetParam($_GET, 'formid', 0)."'");
			echo $title = $database->loadResult();
		}else{
		
	  ?>	  
	  Chrono Forms - <?php echo STORED_DATA; ?>
	  <?php } ?>
	  </th>
    </tr>
	</table>
   <table class="adminlist">
	<tr>
	  <th width="20px" class='title'>#</th>
	  <th width="20px" class='title'><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($rows); ?>);" /></th>

	  <th class='title' width="20%"><?php echo RECORD_ID; ?></th>
	  <th class='title' width="20%" align="center"><?php echo DATE_TIME; ?></th>
	  <?php foreach($dvlist as $dvitem){ ?>
	  	<th class='title' width="20%" align="center"><?php echo $dvitem; ?></th>
	  <?php } ?>
	</tr>
	<?php
	$htmlstring = $formdata[0]->html;
	    /**
	     * Find all the 'name's in the html-string and add to the $matches array
	     */
	    preg_match_all('/name=("|\').*?("|\')/i', $htmlstring, $matches);
	    /**
	     * clean the matches array
	     */
	    $names = array();
	    foreach ( $matches[0] as $name ) {
	        $name = preg_replace('/name=("|\')/i', '', $name);
	        $name = preg_replace('/("|\')/', '', $name);
	        $name = preg_replace('/name=("|\')/', '', $name);
	        if ( strpos($name, '[]') ) {
	            $name = str_replace('[]', '', $name);
	        }
	        $names[] = trim($name);
	    }
	    $names = array_unique($names);
		
	?>
    <?php
	$k = 0;
    for ($i=0, $n=count($rows); $i < $n; $i++) {
	  $row = $rows[$i];

	  /*$link	= 'index2.php?option=com_chronoperfilador&task=editA&hidemainmenu=1&id='. $row->id;
	  $img  = $row->published ? 'tick.png' : 'publish_x.png';
	  $task = $row->published ? 'unpublish' : 'publish';
      $alt = $row->published ? 'Published' : 'Unpublished';*/

	  //$checked 	= mosCommonHTML::CheckedOutProcessing( $row, $i );


	  ?>
	  <tr class="<?php echo "row$k"; ?>">
		<td  width="20px" align="center"><?php echo $i+$pageNav->limitstart+1;?></td>
		<td width="20px"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->cf_id; ?>_<?php echo $formid; ?>" onclick="isChecked(this.checked);" /></td>

		<td width="20%"><a href="#viewdata" onclick="return listItemTask('cb<?php echo $i;?>','viewdata')">
		<?php 
		$dvrecord = $paramsvalues->dvrecord;
		foreach ( $names as $fname) {
			if ( is_a($fname, $row) ) {
				$dvrecord = preg_replace("/\\{".$fname."\\}/", $row->$fname, $dvrecord);
			}
		}
		echo str_replace("#n", $i, $dvrecord);
		?>
		</a></td>

		<td width="20%" align="left"><?php echo $row->recordtime; ?></td>
		<?php foreach($dvlist as $dvitem){ ?>
	  		<td width="20%" align="left"><?php echo $row->$dvitem; ?></td>
		<?php } ?>
	  </tr>
      <?php
			$k = 1 - $k;
		}
    ?>
		<?php echo $pageNav->getListFooter(); ?>
	  </table>
	  <input type="hidden" name="option" value="<?php echo $option; ?>" />
	  <input type="hidden" name="task" value="show" />
	  <input type="hidden" name="formid[]" value="<?php echo $formid; ?>" />
	  <input type="hidden" name="cidxx[]" value="<?php echo $formid; ?>" />
	  <input type="hidden" name="boxchecked" value="0" />
	  <input type="hidden" name="hidemainmenu" value="0">
	  </form>
    <?php
	}
  function viewdataChronoContact( $row, $option, $tablename, $formid ) {
   global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
		mosMakeHtmlSafe( $row, ENT_QUOTES );
		$tables = array( $tablename );
 		$result = $database->getTableFields( $tables );
		$table_fields = array_keys($result[$tablename]);
		?>
		<form action="index2.php" method="post" name="adminForm">

<table cellpadding="0" cellspacing="0" border="0" width="100%" class="adminlist">
<tr><td width="50%"><strong><?php echo FIELD_NAME ; ?></strong></td><td width="50%"><strong><?php echo FIELD_DATA; ?></strong></td></tr>
<?php
$k = 0;
foreach($table_fields as $table_field){
?>
<tr class="<?php echo "row$k"; ?>"><td width="50%">
<strong><?php echo $table_field ; ?>	:</strong>  </td><td width="50%"><?php echo $row->$table_field ; ?>
</td></tr>
<?php $k = 1 - $k; } ?>
</table>
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
	  <input type="hidden" name="task" value="" />
	  <input type="hidden" name="formid" value="<?php echo $formid; ?>" />
	  <input type="hidden" name="boxchecked" value="0" />
	  <input type="hidden" name="hidemainmenu" value="0">
	  </form>
		<?php
		}
		
	function restoreChronoContact( $id, $option ){
	global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
	?>
	<form action="index2.php" method="post" name="adminForm" enctype="multipart/form-data">

<table cellpadding="0" cellspacing="0" border="0" width="100%" class="adminlist">
<tr><td><?php echo CHOOSE_CFBAK; ?>: &nbsp;<input type="file" name="file"></td></tr>
<tr><td><input type="submit" value="submit file"></td></tr>
</table>
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
	  <input type="hidden" name="task" value="restore2" />
	  <input type="hidden" name="formid" value="<?php echo $id; ?>" />
	  <input type="hidden" name="boxchecked" value="0" />
	  <input type="hidden" name="hidemainmenu" value="0">
	  </form>
	<?php
	}
	function menu_creator( $option ){
	global $database, $mainframe, $my, $mosConfig_absolute_path, $mosConfig_dbprefix, $mosConfig_list_limit, $mosConfig_live_site;
	require_once($mosConfig_absolute_path."/administrator/components/com_chronocontact/languages/english.chronocontact.php");
	?>
	<strong>This page is to help you add a menu link to the admin components menu to take you directly to the "show saved data" of some form you choose</strong><br><br>
	<form action="index2.php" method="post" name="adminForm" enctype="multipart/form-data">
		<table cellpadding="0" cellspacing="0" border="0" width="100%" class="adminlist">
			<tr>
				<td><?php echo "Form"; ?>:</td>
				<td>
				<select name="form_id">
				<?php
				$database->setQuery("SELECT * FROM #__chrono_contact");
				$forms = $database->loadObjectList();
				foreach($forms as $form){
				?>
				<option value="<?php echo $form->id; ?>"><?php echo $form->name; ?></option>
				<?PHP } ?>
				</select>
				</td>
			</tr>
			<tr>
				<td><?php echo "Parent"; ?>:</td>
				<td>
				<select name="parent">
				<option value="0"><?php echo 'Root'; ?></option>
				<?php
				$database->setQuery("SELECT * FROM #__components");
				$parents = $database->loadObjectList();
				foreach($parents as $parent){
				?>
				<option value="<?php echo $parent->id; ?>"><?php echo $parent->name; ?></option>
				<?PHP } ?>
				</select>
				</td>
			</tr>
			<tr>
				<td><?php echo "Link Text"; ?>:</td>
				<td>
				<input type="text" name="linktext" value="">
				</td>
			</tr>
			<tr>
				<td><?php echo "Order"; ?>:</td>
				<td>
				<input type="text" name="ordering" value="">
				</td>
			</tr>
			<tr>
				<td><?php echo "Icon"; ?>:</td>
				<td>
				<select name="icon">
				<?php
				$directory = $mosConfig_absolute_path.'/includes/js/ThemeOffice/';
				$results = array();
				$handler = opendir($directory);
				while ($file = readdir($handler)) {
					if ($file != '.' && $file != '..')
						$results[] = $file;
				}
				closedir($handler);
				foreach($results as $result){
				?>
				<option value="<?php echo $result; ?>"><?php echo $result; ?></option>
				<?PHP } ?>
				</select>
				</td>
			</tr>
		</table>
	<input type="hidden" name="option" value="<?php echo $option; ?>" />
	<input type="hidden" name="task" value="restore2" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="hidemainmenu" value="0">
	</form>
	  <?php
	  }
}
?>
