<?php
$settings="1";
 include('header.php'); ?>

<script type="text/javascript" src="<?=$website?>/js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
	$('#custom_logo_input').live('change', function(){
		$("#previewlike").html('');
		$("#previewlike").html('<img src="../images/loader.gif" alt="Uploading...."/>');
		$("#custom_logo_form").ajaxForm(
		{
			target: '#previewlike'
		}).submit();
	});	
	
	$('#settings_update').on('click', function(e){
		e.preventDefault();
		
		$.ajax({
			type: 'POST',
			data: $('#settings_form_1').serialize() + '&' + $('#settings_form_2').serialize(),
			url: '?submit=1',
			dataType: 'html',
			processData: false,
			success: function(data){
				$('.ajax_reply').html($(data).find('.alert')[0]);
			}
		});
	});
	
});
</script>
 
 
<div class="grid_full page_wrap">

<legend><strong>Settings</strong></legend>
<?php
	if(isset($_POST['site_title'])){
		$type=array();
		$type[]=$_POST['expire_download'];
		$type[]=$_POST['site_url'];
		$type[]=$_POST['site_title'];
		$type[]=$_POST['site_meta_keywords'];
		$type[]=$_POST['site_meta_description'];
		$type[]=$_POST['site_header'];
		$type[]=$_POST['site_footer'];
		$type[]=$_POST['site_template'];
		$type[]=$_POST['site_language'];
		$type[]=$_POST['site_currency'];
		$type[]=$_POST['site_allow_registration'];
		$type[]=$_POST['site_require_registration'];
		$type[]=$_POST['site_max_file_size'];
		$type[]=$_POST['site_type_file'];
		$type[]=$_POST['site_file_hours'];
		$value=array();
		$value[]="expire_download";
		$value[]="site_url";
		$value[]="site_title";
		$value[]="site_meta_keywords";
		$value[]="site_meta_description";
		$value[]="site_header";
		$value[]="site_footer";
		$value[]="site_template";
		$value[]="site_language";
		$value[]="site_currency";
		$value[]="site_allow_registration";
		$value[]="site_require_registration";
		$value[]="site_max_file_size";
		$value[]="site_type_file";
		$value[]="site_file_hours";
		
			if(set_value($type,$value)){
				echo "<div class=\"alert alert-success\">Update Succesfully</div>";
			}else{
				echo "<div class=\"alert alert-error\">Error</div>";
			}
		
	}
?>

<div class="ajax_reply"></div>
<form action="" method="post" class="form-horizontal" id="settings_form_1">

<div class="tabbable tabs-left" style="margin-right: 0px;">
	<ul class="nav nav-tabs" id="myTab" style="width: 250px; margin-right: 0px; height: 300px;">
	  <li class="active"><a href="#home">General</a></li>
	  <li><a href="#design">Design</a></li>
	  <li><a href="#lang_currency">Language & Currency</a></li>
	  <li><a href="#files">Files</a></li>
	</ul>
 
<div class="tab-content" style="height: 288px;">
	<div class="tab-pane active" id="home">
		<div class="control-group">
			<label class="control-label" for="inputUsername">Expire files in :</label>
			<div class="controls">
				<input type="text" name="expire_download" id="inputUsername" value="<?php echo get_value('expire_download'); ?>">hours
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Site URL:</label>
			<div class="controls">
				<input type="text" name="site_url" id="inputUsername" value="<?php echo get_value('site_url'); ?>">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Title:</label>
			<div class="controls">
				<input type="text" name="site_title" id="inputUsername" value="<?php echo get_value('site_title'); ?>">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Meta Keywords:</label>
			<div class="controls">
				<textarea name="site_meta_keywords" id="inputUsername" ><?php echo get_value('site_meta_keywords'); ?></textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Meta Description:</label>
			<div class="controls">
				<textarea name="site_meta_description" id="inputUsername" ><?php echo get_value('site_meta_description'); ?></textarea>
			</div>
		</div>
	</div>
	<div class="tab-pane" id="design">
		<div class="control-group">
			<label class="control-label" for="inputUsername">Header:</label>
			<div class="controls">
				<textarea name="site_header" id="inputUsername" ><?php echo get_value('site_header'); ?></textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Footer:</label>
			<div class="controls">
				<textarea name="site_footer" id="inputUsername" ><?php echo get_value('site_footer'); ?></textarea>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Template:</label>
			<div class="controls">
				<select name="site_template">
				<?php
					//path to directory to scan
					$directory = "../templates/";
					//get all files in specified directory
					$files = glob($directory . "*");
					//print each file name
					foreach($files as $file){
						//check to see if the file is a folder/directory
						if(is_dir($file)){
							$name=str_replace("../templates/","",$file);
							echo "<option value=\"$name\" ";
							if(get_value("site_template") == $name) { echo "selected"; } 
								echo " >$name</option>";
							}
					}
				?>
				</select>
			</div>
		</div>
		</form>
		<div class="control-group">
			<label class="control-label" for="input01">Upload image logo:</label>
			<div class="controls">
				<form id="custom_logo_form" method="post" enctype="multipart/form-data" action="<?=$website?>/ajaximage.php" class="form-horizontal imagini_upload">
					<input type="file" name="photoimg" id="custom_logo_input" />
					<input type="hidden" name="type" value="custom_logo">
					<input type="hidden" name="ida" value="1">
					<input type="hidden" name="idu" value="">
					<div id="previewlike" class="ajax_upload_preview"><img src="../uploads/<?php echo get_value('custom_logo'); ?>"></div>
				</form>
			</div>
		</div>
		<div id='logo_preview'></div>
		<form action="" method="post" class="form-horizontal" id="settings_form_2">
	</div>
	<div class="tab-pane" id="lang_currency">
		<div class="control-group">
			<label class="control-label" for="inputUsername">Language:</label>
			<div class="controls">
				<select name="site_language">
					<option value="en" <?php if(get_value("site_language") =="en"){ echo "selected"; } ?>>English</option>
					<option value="ro" <?php if(get_value("site_language") =="ro"){ echo "selected"; } ?>>Romana</option>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Currency:</label>
			<div class="controls">
			<select name="site_currency">
				<option value="USD" <?php if(get_value("site_currency") =="USD"){ echo "selected"; } ?>>USD</option>
				<option value="EUR" <?php if(get_value("site_currency") =="EUR"){ echo "selected"; } ?>>EUR</option>
				<option value="AUD" <?php if(get_value("site_currency") =="AUD"){ echo "selected"; } ?>>AUD</option>
				<option value="BRL" <?php if(get_value("site_currency") =="BRL"){ echo "selected"; } ?>>BRL</option>
				<option value="GBP" <?php if(get_value("site_currency") =="GBP;"){ echo "selected"; } ?>>GBP</option>
				<option value="CAD" <?php if(get_value("site_currency") =="CAD"){ echo "selected"; } ?>>CAD</option>
				<option value="CZK" <?php if(get_value("site_currency") =="CZK"){ echo "selected"; } ?>>CZK</option>
				<option value="DKK" <?php if(get_value("site_currency") =="DKK"){ echo "selected"; } ?>>DKK</option>
					
				<option value="HKD" <?php if(get_value("site_currency") =="HKD"){ echo "selected"; } ?>>HKD</option>
				<option value="HUF" <?php if(get_value("site_currency") =="HUF"){ echo "selected"; } ?>>HUF</option>
				<option value="ILS" <?php if(get_value("site_currency") =="ILS"){ echo "selected"; } ?>>ILS</option>
				<option value="JPY" <?php if(get_value("site_currency") =="JPY"){ echo "selected"; } ?>>JPY</option>
				<option value="MYR" <?php if(get_value("site_currency") =="MYR"){ echo "selected"; } ?>>MYR</option>
				<option value="MXN" <?php if(get_value("site_currency") =="MXN"){ echo "selected"; } ?>>MXN</option>
				<option value="NZD" <?php if(get_value("site_currency") =="NZD"){ echo "selected"; } ?>>NZD</option>
				<option value="NOK" <?php if(get_value("site_currency") =="NOK"){ echo "selected"; } ?>>NOK</option>
				<option value="PHP" <?php if(get_value("site_currency") =="PHP"){ echo "selected"; } ?>>PHP</option>
					
				<option value="PLN" <?php if(get_value("site_currency") =="PLN"){ echo "selected"; } ?>>PLN</option>
				<option value="SGD" <?php if(get_value("site_currency") =="SGD"){ echo "selected"; } ?>>SGD</option>
				<option value="SEK" <?php if(get_value("site_currency") =="SEK"){ echo "selected"; } ?>>SEK</option>
				<option value="CHF" <?php if(get_value("site_currency") =="CHF"){ echo "selected"; } ?>>CHF</option>
				<option value="TWD" <?php if(get_value("site_currency") =="TWD"){ echo "selected"; } ?>>TWD</option>
				<option value="THB" <?php if(get_value("site_currency") =="THB"){ echo "selected"; } ?>>THB</option>
			</select>
			</div>
		</div>
	</div>
	<div class="tab-pane" id="files">
		<div class="control-group">
			<label class="control-label" for="inputUsername">Max file size:</label>
			<div class="controls">
				<input type="text" name="site_max_file_size" id="inputUsername" class="input-mini" value="<?php echo get_value("site_max_file_size"); ?>">MB
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputUsername">Type File Allow:</label>
			<div class="controls">
				<input type="text" name="site_type_file" id="inputUsername" value="<?php echo get_value("site_type_file"); ?>">
			</div>
		</div>
	
	</div>
</div>

</div>
 
	<div class="clearfix"></div>
	
	<div style="margin: 20px 0 30px;text-align: center;"><input type="submit" name="submit" class="btn btn-primary btn-large" style="width: 300px;" id="settings_update" value="Save Settings" /></div>

</form>
</div>

</div>

<?php include('footer.php'); ?>