<?php 
$file_name		= "index?page=add_invoice_basic_details";
$form_action	= "insert";
$button_value 	= "Add Sites";
$table_name 	= "sites";
$page_name      = "Add Sites";
$id	 = "";
$vat = "";
$query_string = "";
################################################## START INSERT ##################################################
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'insert'){	
	utility::addslashesOnAllInput(array("query_string"));
	// image upload 
	$logo_name		=	$_FILES['logo']['name'];
	$dir			=	"../images/logo/";
	$image_path		=	$dir.$logo_name;
	move_uploaded_file($_FILES['logo']['tmp_name'], $image_path);
	// end image upload 
	$other_fields		= $_REQUEST['other_fields'];
    $site_name = $_REQUEST['site_name'];
	$site_url = $_REQUEST['site_url'];
	$site_alias_name = $_REQUEST['site_alias_name'];
	$info_email = $_REQUEST['info_email'];
	$account_email = $_REQUEST['account_email'];
	$sales_email = $_REQUEST['sales_email'];
	$company_phone = $_REQUEST['company_phone'];
	$company_website = $_REQUEST['company_website'];
	$company_fax = $_REQUEST['company_fax'];
	$company_address = $_REQUEST['company_address'];
	$company_bank_account = $_REQUEST['company_bank_account'];
	$vat_reg_number = $_REQUEST['vat_reg_number']; // vat_reg_number showing on invoice
	$company_reg_number = $_REQUEST['company_reg_number']; // company_reg_number showing on invoice
	$shipping = $_REQUEST['shipping'];
	$vat = $_REQUEST['vat'];
	$left_menu_font_color = $_REQUEST['left_menu_font_color'];
	$left_menu_bg_color = $_REQUEST['left_menu_bg_color'];
	$top_menu_font_color = $_REQUEST['top_menu_font_color'];
	$top_menu_bg_color = $_REQUEST['top_menu_bg_color'];
	$heading_background_color = $_REQUEST['heading_background_color'];
	$theme_background_color = $_REQUEST['theme_background_color'];
	$theme_text_color = $_REQUEST['theme_text_color'];
	$site_background_color = $_REQUEST['site_background_color'];
	$updated_on = Utility::setFormatedDate(date($config->dateFormat));
	$updated_by = $_SESSION['user_id'];
	
    $sql= "INSERT INTO $table_name (other_fields,site_name,site_url,site_alias_name,info_email,account_email,sales_email,company_phone,company_website,company_fax,company_address,company_bank_account,vat_reg_number,company_reg_number,shipping,vat,left_menu_font_color,left_menu_bg_color,top_menu_font_color,top_menu_bg_color,heading_background_color,theme_background_color,theme_text_color,site_background_color,logo_name,updated_on,updated_by) VALUES('$other_fields',','$site_name','$site_url','$site_alias_name','$info_email','$account_email','$sales_email','$company_phone','$company_website','$company_fax','$company_address','$company_bank_account','$vat_reg_number','$company_reg_number','$shipping','$vat','$left_menu_font_color','$left_menu_bg_color','$top_menu_font_color','$top_menu_bg_color','$heading_background_color','$theme_background_color','$theme_text_color','$site_background_color','$logo_name','$updated_on','$updated_by')";
    mysqli_query($conn,$sql);
	
	$tmp = ucfirst(str_replace("_"," ", $table_name));
    header("Location: $file_name&message=$tmp added sucessfully");
    exit();
}
################################################# END INSERT #################################################

################################################## START EDIT ##################################################
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit'){	
	$form_action 	= "update";
	$button_value 	= "Update";
	$page_name      = "Project Settings";
	$query_string 	=  (isset($_POST['query_string'])) ? $_POST['query_string'] : $_SERVER['QUERY_STRING'];
	
	
	if(isset($_REQUEST['delete_image']) && $_REQUEST['delete_image'] == '1'){
		$dir	=	"../images/logo/";
		if(file_exists($dir.$_REQUEST['hidden_logo'])){ 
			unlink($dir.$_REQUEST['hidden_logo']);	
		}
	}
	
	
	$id = $_REQUEST['id'];
    $sql= "SELECT * FROM sites WHERE id = $id";
    $result_edit = mysqli_query($conn,$sql);
    $row_edit = mysqli_fetch_array($result_edit);

    $id= $row_edit['id'];
    $other_fields= stripslashes($row_edit['other_fields']);
    $site_name= $row_edit['site_name'];
	$site_url = $row_edit['site_url'];
	$site_alias_name = $row_edit['site_alias_name'];
	$info_email = $row_edit['info_email'];
	$account_email = $row_edit['account_email'];
	$sales_email = $row_edit['sales_email'];
	$company_phone = $row_edit['company_phone'];
	$company_website = $row_edit['company_website'];
	$company_fax = $row_edit['company_fax'];
	$company_address = $row_edit['company_address'];
	$company_bank_account = $row_edit['company_bank_account'];
	$vat_reg_number = $row_edit['vat_reg_number']; // vat_reg_number showing on invoice	
	$company_reg_number = $row_edit['company_reg_number']; // company_reg_number showing on invoice	
	$shipping = $row_edit['shipping'];
	$vat = $row_edit['vat'];
	$left_menu_font_color = $row_edit['left_menu_font_color'];
	$left_menu_bg_color = $row_edit['left_menu_bg_color'];
	$top_menu_font_color = $row_edit['top_menu_font_color'];
	$top_menu_bg_color = $row_edit['top_menu_bg_color'];
	$heading_background_color = $row_edit['heading_background_color'];
	$theme_background_color = $row_edit['theme_background_color'];
	$theme_text_color = $row_edit['theme_text_color'];
	$site_background_color = $row_edit['site_background_color'];
	$logo_name = $row_edit['logo_name'];
}
################################################# END EDIT ################################################# 


################################################## START UPDATE ################################################## 
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'update'){    
	utility::addslashesOnAllInput(array("query_string"));
	$id= $_REQUEST['id'];
	
    ///////////////////// updating logo image ///////////////////////////////////////
 	$hidden_logo		=	$_REQUEST['hidden_logo'];
	$dir				=	"../images/logo/";
	$old_image			=	$dir.$hidden_logo;	
	$logo_name			=	$_FILES['logo']['name'];	
	if($logo_name !='')
	{
		unlink($dir.$_REQUEST['hidden_logo']);		
		$logo_name = $_REQUEST['id']."_".$_FILES['logo']['name'];
		$logo1			=	$dir.$logo_name;
		move_uploaded_file($_FILES['logo']['tmp_name'], $logo1);
	}else{
		$logo_name			=	$_REQUEST['hidden_logo'];
	}
	///////////////////// End updating logo image ///////////////////////////////////////
	
	$site_name= $_REQUEST['site_name'];
	$other_fields = $_REQUEST['other_fields'];
	$site_url = $_REQUEST['site_url'];
	$site_alias_name = $_REQUEST['site_alias_name'];
	$info_email = $_REQUEST['info_email'];
	$account_email = $_REQUEST['account_email'];
	$sales_email = $_REQUEST['sales_email'];
	$company_phone = $_REQUEST['company_phone'];
	$company_website = $_REQUEST['company_website'];
	$company_fax = $_REQUEST['company_fax'];
	$company_address = $_REQUEST['company_address'];
	$company_bank_account = $_REQUEST['company_bank_account'];
	$vat_reg_number = $_REQUEST['vat_reg_number']; // vat_reg_number showing on invoice
	$company_reg_number = $_REQUEST['company_reg_number']; // company_reg_number showing on invoice
	$shipping = $_REQUEST['shipping'];
	$vat = $_REQUEST['vat'];
	$left_menu_font_color = $_REQUEST['left_menu_font_color'];
	$left_menu_bg_color = $_REQUEST['left_menu_bg_color'];
	$top_menu_font_color = $_REQUEST['top_menu_font_color'];
	$top_menu_bg_color = $_REQUEST['top_menu_bg_color'];
	$heading_background_color = $_REQUEST['heading_background_color'];
	$theme_background_color = $_REQUEST['theme_background_color'];
	$theme_text_color = $_REQUEST['theme_text_color'];
	$site_background_color = $_REQUEST['site_background_color'];
    $updated_on = Utility::setFormatedDate(date($config->dateFormat));
	$updated_by = $_SESSION['user_id'];

	$sql= "UPDATE sites SET site_name = '$site_name',other_fields = '$other_fields',site_url = '$site_url',site_alias_name = '$site_alias_name',info_email = '$info_email',account_email = '$account_email',sales_email = '$sales_email',company_phone = '$company_phone',company_website = '$company_website',company_fax = '$company_fax',company_address = '$company_address',company_bank_account = '$company_bank_account',vat_reg_number = '$vat_reg_number',company_reg_number = '$company_reg_number',shipping = '$shipping',vat = '$vat',left_menu_font_color = '$left_menu_font_color',left_menu_bg_color = '$left_menu_bg_color',top_menu_font_color = '$top_menu_font_color',top_menu_bg_color = '$top_menu_bg_color',heading_background_color = '$heading_background_color',theme_background_color = '$theme_background_color',theme_text_color = '$theme_text_color',site_background_color = '$site_background_color',logo_name = '$logo_name', updated_on = '$updated_on', updated_by = '$updated_by' WHERE id = $id";
    mysqli_query($conn,$sql);
	
	// ------------------ Upadte Shipping Policy ----------------------------------------------
	/*if(isset($_REQUEST['weight_start'])){
		$site_id = $id;
		$sql = "DELETE FROM site_shipping_policy WHERE site_id=$id";
		mysqli_query($conn,$sql);
		foreach($_REQUEST['weight_start'] as $key=>$val){
			$weight_start = $val;
			$weight_end = $_REQUEST['weight_end'][$key];
			$shipping_text = $_REQUEST['shipping_text'][$key];
			$shipping = $_REQUEST['shipping'][$key];
			
			$query = "INSERT INTO site_shipping_policy(site_id,weight_start,weight_end,shipping_text,shipping) VALUES('".$site_id."','".$weight_start."','".$weight_end."','".$shipping_text."','".$shipping."')";
			mysqli_query($conn,$query);
		}
	}*/
	
	$shipping_to_delete = $_REQUEST['shipping_to_delete'];
	if($shipping_to_delete !=""){
		$shipping_to_delete = substr($shipping_to_delete,0,-1);
		mysqli_query($conn,"DELETE FROM  site_shipping_policy WHERE id IN($shipping_to_delete)");
		mysqli_query($conn,"DELETE FROM  site_shipping_policy_delivery_options WHERE site_shipping_policy_id IN($shipping_to_delete)");
	}	
	
	if(isset($_REQUEST['weight_start'])){
		foreach($_REQUEST['weight_start'] as $key=>$val){
		
			if(utility::getTableFieldById("site_shipping_policy","id","id",$key,$id)){
				$site_shipping_policy_id = $key;
				$weight_start = $_REQUEST['weight_start'][$key];
				$weight_end = $_REQUEST['weight_end'][$key];
				$shipping_text = $_REQUEST['shipping_text'][$key];
				$shipping = $_REQUEST['shipping'][$key];
				
				
				echo $query = "UPDATE site_shipping_policy SET 
						weight_start = '".$weight_start."',
						weight_end = '".$weight_end."',
						shipping_text = '".$shipping_text."',
						shipping = '".$shipping."'
						WHERE id = '".$site_shipping_policy_id."'";						
						mysqli_query($conn,$query);
			}else{
				$weight_start = $_REQUEST['weight_start'][$key];
				$weight_end = $_REQUEST['weight_end'][$key];
				$shipping_text = $_REQUEST['shipping_text'][$key];
				$shipping = $_REQUEST['shipping'][$key];
					
				echo $query = "INSERT INTO site_shipping_policy(site_id,weight_start,weight_end,shipping_text,shipping) 
						VALUES('".$id."','".$weight_start."','".$weight_end."','".$shipping_text."','".$shipping."')";
						mysqli_query($conn,$query);
			}

			
		   
		}
		$result = 1;
	}
	
	
	// ------------------ End Upadte Shipping Policy ----------------------------------------------
	
	$query_string = (isset($_REQUEST['query_string']) && !empty($_REQUEST['query_string'])) ? $_REQUEST['query_string'] : "";
  	$query_string = str_ireplace("page=add_invoice_basic_details", "page=view", $query_string);
	$query_string = "&".$query_string;
	$tmp = ucfirst(str_replace("_"," ", $table_name));
    //header("Location: $file_name&message=$tmp updated sucessfully$query_string");
    header("Location: $file_name&message=$tmp updated sucessfully&page=add_invoice_basic_details&action=edit&id=1");
    exit();
}
################################################# END UPDATE ################################################# 
?>
<section class="content-header">
  <h1>
	<?=$page_name;?>
  </h1>
</section>
<section class="content">
	<div class="row">
		<form class="form-horizontal" method="post" name="form1" id="form1" action="index?page=add_invoice_basic_details&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data">
		<div class="col-md-12">
			<!-- general form elements -->
              <div class="box box-primary">
                  <div class="box-body">
                    
					<div class="form-group">
                      <label for="Company Address" class="col-sm-3 control-label">Company Address</label>
                      <div class="col-sm-8">
						<textarea class="form-control" rows="5" id="company_address" name="company_address" placeholder="Company Address"><?php echo stripslashes($company_address);?></textarea>
                      </div>
                    </div>
					
					<div class="form-group">
                      <label for="Company Reg. Number" class="col-sm-3 control-label">Company Reg. Number</label>
                      <div class="col-sm-8">
                        <input type="text" id="company_reg_number" name="company_reg_number" value="<?php echo $company_reg_number;?>" class="form-control" placeholder="Company Reg. Number">
                      </div>
                    </div>
					
					<div class="form-group">
                      <label for="Vat Reg. Number" class="col-sm-3 control-label">Vat Reg. Number</label>
                      <div class="col-sm-8">
                        <input type="text" id="vat_reg_number" name="vat_reg_number" value="<?php echo $vat_reg_number;?>" class="form-control" placeholder="Vat Reg. Number">
                      </div>
                    </div>
					
					
				
                  </div><!-- /.box-body -->
                  <div class="box-footer">
					<input type="hidden" id="id" name="id" value="<?php echo $id;?>">
					<input type="hidden" id="query_string" name="query_string" value="<?php echo $query_string;?>">
                    <button type="submit" id="submit" name="submit" value="<?php echo $button_value;?>" class="btn btn-primary">Submit</button>
                  </div>
              </div><!-- /.box -->
		</div>
		</form>
	</div>
</section>
<script>
CKEDITOR.replace('service_details');  
</script>



<? /*
<style>
#colorbox{
	top:100px;
}
</style>
<td width="100%" align="center" valign="top" bgcolor="" class="red">
<h1><?php echo $page_name;?> </h1><br>
<form method="post" name="form1" id="form1" action="index?page=add&action=<? echo $form_action; ?>" onsubmit="return validateForm(this)" enctype="multipart/form-data" >
     <table border=1; style="width:500px;height:120px; margin:20px 0px 0px 20px; clear:both;"> 
		 <tr valign="top">		  
			<td style="border:0x solid red">
				<div id="ed_pro_div"><label class="ed_pro_label" for="site_name">Site name:</label><input class="ed_pro_input"  style="width:250px;"style="width:250px;" type="text" id="site_name" name="site_name" value="<?php echo $site_name;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="site_url">Site URL:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="site_url" name="site_url" value="<?php echo $site_url;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="site_alias_name">Site Alias Name:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="site_alias_name" name="site_alias_name" value="<?php echo $site_alias_name;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="info_email">Info Email:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="info_email" name="info_email" value="<?php echo $info_email;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="account_email">Account Email:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="account_email" name="account_email" value="<?php echo $account_email;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="sales_email">Sales Email:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="sales_email" name="sales_email" value="<?php echo $sales_email;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="company_phone">Company Phone:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="company_phone" name="company_phone" value="<?php echo $company_phone;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="company_fax">Company Fax:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="company_fax" name="company_fax" value="<?php echo $company_fax;?>"></div>
				<div id="ed_pro_div_textarea"><label class="ed_pro_label" for="company_address">Company Address:</label>
				<textarea cols="40" rows="5" id="company_address" name="company_address"><?php echo $company_address;?></textarea></div>
				<div id="ed_pro_div_textarea" style="height: 60px;"><label class="ed_pro_label" for="company_bank_account">Company Bank Account:</label><textarea cols="40" rows="3" id="company_bank_account" name="company_bank_account"><?php echo $company_bank_account;?></textarea></div>
				<br>
				<div id="ed_pro_div" style="margin-bottom:10px;"><label class="ed_pro_label" for="vat_reg_number">Vat Reg. Number:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="vat_reg_number" name="vat_reg_number" value="<?php echo $vat_reg_number;?>"></div>
				<!--<div id="ed_pro_div" style="height:40px;"><label class="ed_pro_label" for="shipping">Shipping:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="shipping" name="shipping" value="<?php echo $shipping;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="vat">Vat:</label><input class="ed_pro_input"  style="width:250px;"type="text" id="vat" name="vat" value="<?php echo $vat;?>"></div>-->
			</td>  
			<td style="border:0px solid red">
				<div id="ed_pro_div"><label class="left_menu_font_color" for="left_menu_font_color">Left Menu Font Color:</label><input class="color" style="margin-left:39px; width:250px;" type="text" id="left_menu_font_color" name="left_menu_font_color" value="<?php echo $left_menu_font_color;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="left_menu_bg_color">Left Menu Bg Color:</label><input class="color" style=" width:250px;" type="text" id="left_menu_bg_color" name="left_menu_bg_color" value="<?php echo $left_menu_bg_color;?>"></div>
				<div id="ed_pro_div"><label class="top_menu_font_color" for="top_menu_font_color">Top Menu Font Color:</label><input class="color" style="margin-left:39px; width:250px;" type="text" id="top_menu_font_color" name="top_menu_font_color" value="<?php echo $top_menu_font_color;?>"></div>
				<div id="ed_pro_div"><label class="top_menu_bg_color" for="top_menu_bg_color">Top Menu Bg Color:</label><input class="color" style="margin-left:45px; width:250px;" type="text" id="top_menu_bg_color" name="top_menu_bg_color" value="<?php echo $top_menu_bg_color;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="heading_background_color">Heading Background Color:</label><input class="color" style=" width:250px;" type="text" id="heading_background_color" name="heading_background_color" value="<?php echo $heading_background_color;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="theme_background_color">Theme Background Color:</label><input class="color" style=" width:250px;" type="text" id="theme_background_color" name="theme_background_color" value="<?php echo $theme_background_color;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="theme_text_color">Theme Text Color:</label><input class="color" type="text" style=" width:250px;" id="theme_text_color" name="theme_text_color" value="<?php echo $theme_text_color;?>"></div>
				<div id="ed_pro_div"><label class="ed_pro_label" for="site_background_color">Site Background Color:</label><input class="color" type="text" style=" width:250px;" id="site_background_color" name="site_background_color" value="<?php echo $site_background_color;?>"></div>
				
				<!--------------------  Image Uploder -------------------------------------->
				<div id="ed_pro_div" style="height:50px;"><label class="upload_logo" for="upload_logo">Upload Logo:</label><input type="file" style="margin-left:80px;border:0px solid red;width:180px;" name="logo" style="width:200px" ></div>
						<?				
						if(isset($_REQUEST['action']) && $_REQUEST['action']=='edit'){
						 if (is_file('../images/logo/'.$logo_name)) {
								$image_path ="<img src='../../images/logo/$logo_name' width='200px' style='margin-left:165px;'>&nbsp;<a id='delete_image' href='#'>Delete</a>";  					 	
							}else{
								$image_path ="<img style='margin:10px 0 0 130px;' src='../../images/logo/no_image.gif'>";	
							}
							echo $image_path;
						}?>
				<input type="hidden" name="hidden_logo" value="<? echo $logo_name;?>">
				<!-------------------- End Image Uploder -------------------------------------->
				<div id="ed_pro_div" style="margin-bottom:10px;"><label class="ed_pro_label" for="free_shipping_on_cost_above">Free shipping on anything Over &pound;</label><input class="ed_pro_input"  style="width:250px;"type="text" id="free_shipping_on_cost_above" name="free_shipping_on_cost_above" value="<?php echo $free_shipping_on_cost_above;?>"></div>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<div style="border:1px solid #000000;width:96%;">
				<h1>Shipping Policy</h1>
				<table id="multi_table" width="95%">
					<?php $display = (isset($result_edit) && $result_edit!="")? "" : "display:none;";?>
					<tr style="<?=$display;?>">
						<td>Weight Start</td>
						<td>Weight End</td>
						<!--<td>Shipping Text</td>
						<td>Shipping</td>-->
						<td>Options</td>
						<td>Delete</td>
					</tr>
					<?php
						if($result_edit){
						while($row_edit = mysqli_fetch_array($result_edit)){
						$weight_start = $row_edit['weight_start'];
						$weight_end = $row_edit['weight_end'];
						$shipping_text = $row_edit['shipping_text'];
						$shipping = $row_edit['shipping'];
					?>
					<tr>
						<td>
							<input type='text' style='width:80px;' class='weight_start' value='<?php echo $weight_start;?>'  name='weight_start[<?=$row_edit['id']?>]'/>
						</td>
						<td>
							<input type='text' style='width:80px;' class='weight_end' value='<?php echo $weight_end;?>'  name='weight_end[<?=$row_edit['id']?>]'/>
						</td>
						<!--<td>
							<input type='text' style='width:300px;' class='shipping_text' value='<?php echo $shipping_text;?>'  name='shipping_text[<?=$row_edit['id']?>]'/>
						</td>
						<td>
							<input type='text' style='width:80px;' class='shipping' value='<?php echo $shipping;?>' name='shipping[<?=$row_edit['id']?>]'/>
						</td>-->
						<td>
							<a class='colorbox' href='<?php echo $siteURL ?>/sites/index?page=ajax_action&action=site_shipping_policy_delivery_options&id=<?=$row_edit['id'];?>&start=<?=$_REQUEST['start'];?>'>Add options for this weight bracket</a>
						</td>
						<td>
							<a alt="<?=$row_edit['id']?>" class='delete_row' href='#'><img src='../../images/del.gif' /></a>
						</td>
					</tr>	
					<? } } ?>
				</table>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center" style="border:0px solid red">
			<!----------------------------- Link for Multi add row -------------------------------------------->	
			<div id="multi_row" style="float:left;margin-left:20px;cursor:pointer;border:0px solid red;font-weight:bold;">Add New Shipping (+)</div>
			<!----------------------------- End Link for Multi add row ------------------------------------------->
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center" style="border:0x solid red">	
					<input type="hidden" id="id" name="id" value="<?php echo $id;?>">
					<input type="hidden" id="query_string" name="query_string" value="<?php echo $query_string;?>">
					<input type="hidden" id="shipping_to_delete" name="shipping_to_delete" value="">
					<input type="submit" id="submit" name="submit" value="<?php echo $button_value;?>" style="margin-top: 30px;">
			</td>
		</tr>         
		<tr>
			<td colspan="2" align="center" style="border:0x solid red">&nbsp;</td>
		</tr>
     </table>	
</form>
</td>

<script type="text/javascript">
$(document).ready(function() {
	$("#delete_image").click(function(){		
		if(confirm("Are you sure! You want to delete the picture?")){
			var new_url = 'index?'+$("#query_string").attr("value")+'&delete_image=1';		
			$("#form1").attr("action",new_url)		
			$("#submit").click();
		}
	});
	
	$('#multi_row').click(function(){
		var weight_start = "<input type='text' style='width:80px;' class='weight_start'  name='weight_start[]'/>";
		var	weight_end	= "<input type='text' style='width:80px;' class='weight_end'  name='weight_end[]'/>";
		var shipping_text = ""; //"<input type='text' style='width:300px;' class='shipping_text'  name='shipping_text[]'/>";
		var shipping = ""; //"<input type='text' style='width:80px;' class='shipping'  name='shipping[]'/>";
		var del = "<a class='delete_row' href='#'><img src='../../images/del.gif' /></a>";
		var new_row_for_apply = "<tr ><td>"+weight_start+"</td><td>"+weight_end+"</td><td>"+shipping_text+"</td><td>"+shipping+"</td><td>"+del+"</td></tr>";
		$("#multi_table").append(new_row_for_apply);
		$("#multi_table").find('tr').first().show();
	});
	
	$(".delete_row").live("click",function(){
		if(confirm("Are you sure you want to delete? If yes then click update to save data.")){
			$("#shipping_to_delete").val($("#shipping_to_delete").val()+$(this).attr("alt")+",");
			$(this).parent().parent().remove();
		}
		
	});
	
	$('#booking_form').live('submit',function(){
	   var form_data 	= $("#booking_form").serialize();	   
		$.ajax({
			async: false,
			type: "POST",
			url: site_url+"/sites/index?page=ajax_action&action=site_shipping_policy_delivery_options&perform_action=update",
			data: form_data,
			success: function(result){
				var resultObj = jQuery.parseJSON(result);
				if(resultObj.status == "success"){					
					alert(resultObj.message);
					window.location = document.location.href;
				}else{
					alert(resultObj.message);
				}
			}
		});	
		return false;	
	});
	
	$(".colorbox").colorbox({view_div:true, fastIframe:false, width:"65%", height:"80%", transition:"fade", scrolling   : true, reposition:true});	
});	
</script>
*/?>