<?php
	/*
	osCommerce, Open Source E-Commerce Solutions 
	http://www.oscommerce.com 
	
	Copyright (c) 2003 osCommerce 
	
	osCommRes, Services Oline 
	http://www.oscommres.com 
	Copyright (c) 2005 osCommRes 
	
	Freeway eCommerce 
	http://www.zac-ware.com/freeway 
	Copyright (c) 2007 ZacWare
	
	Released under the GNU General Public License
	*/
	// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	require('includes/application_top.php');
	tep_get_last_access_file(); 
	$server_date = getServerDate(true);	
	
	function tep_cfg_select_option_infobox($select_array, $key_value, $key = '') {
		$string = '';
		for ($i=0, $n=sizeof($select_array); $i<$n; $i++) {
			$name = ((tep_not_null($key)) ? 'infobox_' .$key  : 'infobox_display');
			$string .= '<input type="radio" name="' . $name . '" value="' . $select_array[$i] . '"';
			if ($key_value == $select_array[$i]) $string .= ' CHECKED';
				$string .= '> ' . $select_array[$i];
		}
		return $string;
	}
	
	function tep_get_templates() {
		$templates_query = tep_db_query("select template_id, template_name from " . TABLE_TEMPLATE . " order by template_id");
		while ($template = tep_db_fetch_array($templates_query)) {
			$template_array[] = array('id' => $template['template_id'],
									'name' => $template['template_name']);
		}
	return $template_array;
	}
	
	$command=(isset($HTTP_GET_VARS['command'])?$HTTP_GET_VARS['command']:'');
	$gID=(isset($HTTP_GET_VARS['gID'])?$HTTP_GET_VARS['gID']:'2');
	$cID=(isset($HTTP_GET_VARS['cID'])?$HTTP_GET_VARS['cID']:'');
	$page=(isset($HTTP_GET_VARS['page'])?$HTTP_GET_VARS['page']:'');
	$flag=(isset($HTTP_GET_VARS['flag'])?$HTTP_GET_VARS['flag']:'');
	$location=(isset($HTTP_GET_VARS['location'])?$HTTP_GET_VARS['location']:'');
	$col=(isset($HTTP_GET_VARS['col'])?$HTTP_GET_VARS['col']:'');
	if($command!=''){
		echo $command . '{}' . $cID . '||';
		switch($command){
			case 'get_details':
				echo do_get_details($cID);
			break;
			case 'new':
			case 'edit':
			case 'new_info':
				echo get_edit_details($cID);
			break;
			case 'insert':
			case 'update':
				if($command=='insert')
					$id=0;
				echo save_details($cID);
			break;	
			case 'delete':
				echo delete_details($cID,false);
			break;	
			case 'delete_confirm':
				echo delete_details($cID,true);
			break;
			case 'set_template':
			case 'realign_template':
				$search_fnd=false;
				echo get_info_details();
			break;
			case 'set_flag':
				echo get_status_change($cID,true);
			break;
			case 'setflagcolumn':
				echo get_status_change($cID,false);
			break;	
			case 'change_position':
				 get_position_change($cID,$location,$col);
			break;
		}
		exit;
	}	
	
	$template = tep_get_templates();
	$template_array = array();
	
	for ($i = 0, $n = sizeof($template); $i < $n; $i++) {
		$template_array[] = array('id' => $template[$i]['id'],
								'text' => $template[$i]['name']);
	}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
		<title><?php echo TITLE; ?></title>
		<style type="text/css">
			#pup {position:absolute; visibility:hidden; z-index:200; width:130; }
		</style>
		<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
		<script language="javascript" src="includes/menu.js"></script>
		<script language="javascript" src="includes/general.js"></script>
		<script language="javascript" src="includes/http.js"></script>
		<script>
    		var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
			var i=0;
			var ajx_start=false;
			var prev_id='';
			var gID='<?php echo $gID;?>';
			var page_id=1;
			var close_obj=false;
			var form_obj=false;
			var row_expand=false;
			
			function resize() {
				if (navigator.appName == 'Netscape') i = 40;
				window.resizeTo(document.images[0].width + 30, document.images[0].height + 60 - i);
			}
			
			function do_close(id) {
				var head=document.getElementById('head_' + id);
				var data=document.getElementById('data_' + id);
				if(data.style.display=='' && data.innerHTML!='' && close_obj==false)  {
					data.style.display="none";
					data.innerHTML='';
					head.style.display='';
					row_expand=false;
					ajx_start=false;
					prev_id='';
				}
				close_obj=false;
				if(form_obj==true){
					 ajx_start=false;
					 return;
				 }
			}
			
			function ValidateForm(){
				close_obj=true;
				var command='';
				var id=document.getElementById('infobox_id').value;
				var action=document.getElementById('info_action').value;
				if(action=='delete'){
					do_page_fetch(gID,id,'delete_confirm');
					prev_id='';
				} else {
					if(check_form()==true){ 
						form_obj=false;
						if(action=='insert'){
							page_id=1;
							do_page_fetch(gID,0,'insert');
						}else if(action=='update')	{
							do_page_fetch(gID,id,'update');
						}else if(action=='new_info'){
							command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=insert');?>' + '&page=1&gID=' + gID;
							do_post_command('infoboxes',command);
						}
					}
				}
				return false; 		
			}
			
			function check_form() {
				var error = 0;
				var error_message = "<?php echo JS_ERROR; ?>";
				
				var infobox_file_name = document.infoboxes.infobox_file_name.value;
				var box_heading = document.infoboxes.box_heading.value;
				var box_template= document.infoboxes.box_template.value;
				var infobox_define = document.infoboxes.infobox_define.value;  
				var hexval = document.infoboxes.hexval.value;  
				
			
				if( (infobox_file_name == "") || (str_trim(infobox_file_name)=="") ) {
					error_message = error_message + "<?php echo JS_INFO_BOX_FILENAME; ?>";
					error = 1;
				}
				
				if( (box_template == "") || (str_trim(box_template)=="") ){
				    error_message=error_message + "<?php echo JS_INFO_BOX_TEMPLATE; ?>";
					error = 1;
				}
				if( (box_heading == "") || (str_trim(box_heading)=="") ) {
					error_message = error_message + "<?php echo JS_INFO_BOX_HEADING; ?>";
					error = 1;
				}
				
				if (infobox_define == "" || infobox_define == "BOX_HEADING_????" || str_trim(infobox_define)=="") {
					error_message = error_message + "<?php echo JS_BOX_HEADING; ?>";
					error = 1;
				}
				
				if( (hexval == "") || (str_trim(hexval)=="") ) {
					error_message = error_message + "<?php echo JS_BOX_COLOR_ERROR;?>";
					error = 1;
				}
				
				if (error == 1) {
					alert(error_message);
					close_obj=true;
					form_obj=true;
					return false;
				} else {
					return true;
				}
			}
			
			function change_status(id,flag){
				close_obj=true;
				command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=set_flag');?>' + '&gID=' + gID + '&flag=' + flag + '&cID=' + id;
				do_get_command(command);
			}
			function change_column(id,column){
				close_obj=true;
				command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=setflagcolumn');?>' + '&gID=' + gID + '&flag=' + column + '&cID=' + id;
				do_get_command(command);
			}
			
			function change_position(id,location,col,order){
				close_obj=true;
				command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=change_position');?>' + '&gID=' + gID + '&flag=' + order + '&cID=' + id + '&location=' + location + '&col=' + col;
				do_get_command(command);
			}
			
			function do_page_fetch(gid,cid,action){ 
				if(document.getElementById('gID'))gid = document.getElementById('gID').options[document.getElementById('gID').selectedIndex].value;
				if(ajx_start) return;
				else {
					ajx_start=true;
				} 
				var command;
				if(action!='new_info'){
					if(document.getElementById('new_details'))document.getElementById('new_details').style.display="none";
					if(document.getElementById('span_new'))document.getElementById('span_new').style.display="none";
					if(document.getElementById('span_new'))document.getElementById('span_new').innerHTML="";
				}	
				
				document.getElementById('infobox_id').value=cid; 
				command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=');?>'  + action + '&gID=' + gid + '&cID=' + cid;
				switch(action){  
					case 'get_details':
						var head=document.getElementById('head_' + cid);
						var data=document.getElementById('data_' + cid); 
						if(prev_id!=cid) {
							row_expand=false;
							close_obj=false;
							form_obj=false;
						}
						if(data.style.display=="none" && row_expand==false){ 
						row_expand=true;
							data.style.display="";
							document.getElementById('data_' + cid).innerHTML=document.getElementById('loading').innerHTML;
							//alert(document.getElementById('data_' + cid).innerHTML);
							if(prev_id!='' && document.getElementById('head_' + prev_id)){
								document.getElementById('head_' + prev_id).style.display="";
								document.getElementById('data_' + prev_id).innerHTML="";
								document.getElementById('data_' + prev_id).style.display="none";
							}
							prev_id=cid;
							head.style.display="none";
							if(document.getElementById('img_new'))
							document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
							display_flag=1;
						}
					break;
					case 'new':
					case 'edit':close_obj=true;
						if(action=='new')
							document.getElementById('info_action').value='insert';
						else 
							document.getElementById('info_action').value='update';
							document.getElementById('span_details').style.display="none";
							document.getElementById('span_delete').style.display="none";
							document.getElementById('span_edit').style.display="";
							document.getElementById('span_edit').innerHTML=document.getElementById('loading').innerHTML;
							
							display_flag=0;
					break;
					case 'insert':
						if(prev_id!='' && document.getElementById('head_' + prev_id)){
							document.getElementById('head_' + prev_id).style.display="";
							document.getElementById('data_' + prev_id).style.display="none";
						}
						prev_id='';
						if(document.getElementById('span_edit')) document.getElementById('span_edit').style.display="none";
						if(document.getElementById('span_details')) document.getElementById('span_details').style.display="none";
						if(document.getElementById('span_delete')) document.getElementById('span_delete').style.display="none";
						do_post_command('infoboxes',command);
						return;
					break;
					case 'update':
						document.getElementById('span_edit').style.display="none";
						document.getElementById('span_delete').style.display="none";
						document.getElementById('span_details').style.display="";
						document.getElementById('span_details').innerHTML=document.getElementById('loading').innerHTML;
						do_post_command('infoboxes',command);
						return;
					break;
					case 'new_info':
						document.getElementById('info_action').value='new_info';
						if(document.getElementById('span_details')) document.getElementById('span_details').style.display="none";
						if(document.getElementById('span_edit')) document.getElementById('span_edit').style.display="none";
						if(document.getElementById('span_delete')) document.getElementById('span_delete').style.display="none";
						if(prev_id!='' && document.getElementById('head_' + prev_id)){
							document.getElementById('head_' + prev_id).style.display="";
							document.getElementById('data_' + prev_id).innerHTML="";
							document.getElementById('data_' + prev_id).style.display="none";
						}
						prev_id='';
						document.getElementById('new_details').style.display="";
						document.getElementById('span_new').style.display="";
						document.getElementById('span_new').innerHTML=document.getElementById('loading').innerHTML;
						display_flag=0;
					break;
					case 'delete':close_obj=true;
						document.getElementById('info_action').value='delete';
						document.getElementById('span_delete').style.display="";
						document.getElementById('span_delete').innerHTML=document.getElementById("loading").innerHTML;
						document.getElementById('span_details').style.display="none";
					break;
					case 'delete_confirm':
						document.getElementById('span_delete').innerHTML=document.getElementById("loading").innerHTML;
						document.getElementById('span_details').style.display="none";
					prev_id='';
					break;
					case 'close_info': close_obj=true;
					var span_details=document.getElementById("span_details");
					var span_edit=document.getElementById("span_edit");				
					var span_delete=document.getElementById("span_delete");
					var img_save = document.getElementById('img_save');
					document.getElementById('new_details').style.display="none";
					document.getElementById('span_new').style.display="none";
					
					if(span_edit.style.display=="") span_edit.style.display="none";
					if(span_delete.style.display=="") span_delete.style.display="none"; 	 			   	  	 	 			   	  	
					span_details.style.display="";
					if(img_save) img_save.style.display="none"; 
					if(document.getElementById("img_ids")){
					var tr_obj=document.getElementById("img_ids");
					if(tr_obj.childNodes[1].childNodes[0].src==img_src+'template/img_edit_hover.gif')	
						tr_obj.childNodes[1].childNodes[0].src=img_src+'template/img_edit.gif';
					if(tr_obj.childNodes[2].childNodes[0].src==img_src+'template/img_trash_hover.gif')	
						tr_obj.childNodes[2].childNodes[0].src=img_src+'template/img_trash.gif';	 	 			   	  			
					 }	 			   	  	  	 			   	  	 	 			   	  	
				
						ajx_start=false;
						return;
					break;
					case 'close': 
						document.getElementById('new_details').style.display="none";
						document.getElementById('span_new').style.display="none";
						ajx_start=false;
						if(document.getElementById('img_new'))
						document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
						display_flag=1;
						return;
					break;
				} 
				do_get_command(command);
			}	
			
			function do_result(result){
				var splt=Array();
				splt=result.split("{}");
				var spl_arr=Array();
				var sp1=splt[1];
				spl_arr=sp1.split("||");
				switch(splt[0]){
					case 'get_details':
						document.getElementById('head_' + spl_arr[0]).style.display="none";
						document.getElementById('data_' + spl_arr[0]).style.display="";
						document.getElementById('data_' + spl_arr[0]).innerHTML=spl_arr[1];
						//alert(document.getElementById('data_' + spl_arr[0]).innerHTML);
					break;	
					case 'new':
					case 'edit':
						document.getElementById('img_save').style.display="";
						document.getElementById('span_edit').innerHTML=spl_arr[1];
					break;
					case 'update':
						document.getElementById('img_save').style.display="none";
						if(document.getElementById("img_ids")){
							var tr_obj=document.getElementById("img_ids");
							if(tr_obj.childNodes[1].childNodes[0].src==img_src+'template/img_edit_hover.gif')	
								tr_obj.childNodes[1].childNodes[0].src=img_src+'template/img_edit.gif';
							if(tr_obj.childNodes[2].childNodes[0].src==img_src+'template/img_trash_hover.gif')	
								tr_obj.childNodes[2].childNodes[0].src=img_src+'template/img_trash.gif';	 	 			   	  			
						}	 			   	  	  	 			   	  	 	 			   	  	
						var details=Array();
						details=spl_arr[1].split("{#}");
						var sarr=Array();
						sarr=details[1].split("{##}");
						document.getElementById('head_' + spl_arr[0]).innerHTML=sarr[1];
						document.getElementById('span_details').innerHTML=details[0];
						document.getElementById('row_heading').innerHTML=sarr[0];
					break;
					case 'insert':
						document.getElementById('span_new').style.display="none";
						document.getElementById('span_new').innerHTML="";
						document.getElementById('new_details').style.display="none";
						var id_value=Array();
						id_value=spl_arr[1].split('{|}');
						var details=Array();
						details=id_value[1].split("{#}");	
						var row=document.getElementById('info_table');
						var row_obj=row.insertRow(row.rows.length-2);
						var row_len=(row.rows.length);
						var cell_obj=row_obj.insertCell(0);
						cell_obj.className="dataTableContent";
						var classname;
						cell_obj.innerHTML=details[0];  
						row_obj.onmouseover=function (){rowOverEffect(this)};
						row_obj.onmouseout=function (){rowOutEffect(this)};
						row_obj.id="row_" + id_value[0];
						row_obj.onclick=function(){ ((document.getElementById("data_" + id_value[0]).style.display=='none')?do_page_fetch(gID,id_value[0],'get_details'):'')};
						if((row_len % 2) == 0) classname="dataTableRowEven";
						else classname="dataTableRowOdd";
						row_obj.className=classname;
						row_obj.height="25";
						command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=realign_template');?>' + '&page=1&gID=' + gID + '&cID=' + id_value[0];
						do_get_command(command);
					break;
					case 'new_info':
						document.getElementById('span_new').innerHTML=spl_arr[1];
					break;
					case 'delete':
						document.getElementById('img_save').style.display="";
						document.getElementById('span_delete').innerHTML=spl_arr[1];
					break;	
					case 'delete_confirm':
						document.getElementById('info_table').deleteRow(document.getElementById('head_' +spl_arr[0]).parentNode.parentNode.rowIndex);
						command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=set_template');?>' + '&page=' + page_id + '&gID=' + gID;
						do_get_command(command);
					break;
					case 'set_template':
						var dis_array=Array();
						dis_array=spl_arr[1].split('{#}');
						if(dis_array[1]==1){ 
							if(document.getElementById('install_new'))document.getElementById('install_new').style.display="";
						} else if(dis_array[1]==0) {
								if(document.getElementById('install_new'))document.getElementById('install_new').style.display="none";
						}		
						document.getElementById('ajax_details').innerHTML=dis_array[0];
						//do_page_fetch(gID,spl_arr[0],'get_details');
					break;
					case 'realign_template':
						var dis_array=Array();
						dis_array=spl_arr[1].split('{#}');
						if(dis_array[1]==1){ 
							if(document.getElementById('install_new'))document.getElementById('install_new').style.display="";
						} else if(dis_array[1]==0) {
								if(document.getElementById('install_new'))document.getElementById('install_new').style.display="none";
						}		
						document.getElementById('ajax_details').innerHTML=dis_array[0];
						do_page_fetch(gID,spl_arr[0],'get_details');
					break;
					case 'set_flag' : 
					case 'setflagcolumn':
						//var details=Array();
						//details=spl_arr[1].split("{##}");	
						//document.getElementById('head_' + spl_arr[0]).innerHTML=details[1];
						//document.getElementById('row_heading').innerHTML=details[0];
						command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=realign_template');?>' + '&page=' + page_id + '&gID=' + gID + '&cID=' + spl_arr[0];
						do_get_command(command);
					break;
					case 'change_position':
						command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=realign_template');?>' + '&page=' + page_id + '&gID=' + gID + '&cID=' + spl_arr[0];
						do_get_command(command);
					break;
				}
				ajx_start=false;
			}
			
			function showColor(val) { 
				document.infoboxes.hexval.value = val; 
			} 
			
	 function do_hover_change(element,eve){ 
		 var span_details=document.getElementById("span_details"); 
		 var span_edit=document.getElementById("span_edit");
		 var span_delete=document.getElementById("span_delete");
	  	 if(element){		   		    		    
		    var img_get_src=element.childNodes[0];
			if(img_get_src){
			    if(img_get_src.src==img_src+'template/img_edit.gif') {
					if(span_edit && span_edit.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_edit_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_edit_hover.gif' && span_edit && span_edit.style.display=="none") img_get_src.src=img_src+'template/img_edit.gif';
			    if(img_get_src.src==img_src+'template/img_trash.gif') {
					if(span_delete && span_delete.style.display=="" && eve==1 || eve==2){
					 	img_get_src.src=img_src+'template/img_trash_hover.gif';
					}  		   		 	 			 	 			
			    }else if(eve==3 && img_get_src.src==img_src+'template/img_trash_hover.gif' && span_delete && span_delete.style.display=="none") img_get_src.src=img_src+'template/img_trash.gif';
		  }
		 }		 
	 }  
	  var display_flag=1;	
	function do_hover_change1(element,mode){ 
	if(display_flag==1){
		if (element.mode && mode==element.mode) return;
		if (mode==2)
			element.firstChild.src=element.firstChild.src.replace(".gif","_hover.gif");
		else
			element.firstChild.src=element.firstChild.src.replace("_hover.gif",".gif");
	}
	element.mode=mode;
	} 	

	/*		function do_hover_change(element,mode){
				if (element.mode && mode==element.mode) return;
				if (mode==2)
					element.firstChild.src=element.firstChild.src.replace(".","_hover.");
				else
					element.firstChild.src=element.firstChild.src.replace("_hover.",".");
				element.mode=mode;
			}
	*/		
			
			function do_change_template(obj){
				command='<?php echo tep_href_link(FILENAME_INFOBOX_CONFIGURATION,'command=set_template');?>' + '&page=' + page_id + '&gID=' + obj.value;
				gID=obj.value;
				do_get_command(command);
			}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
		<script language="javascript" src="includes/popup.js"></script>
		<script language="javascript"><!--
						var baby=new Array();
						baby[1]="";	
						var cEvent = 0;
				//function popupWindow(url) {
				//window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=450,height=300%,screenX=150,screenY=150,top=150,left=150')
				
			//}


				function popupWindow(action){ 
				var contentText;
					switch(action){
						case 'filename':
							contentText='<?php echo addslashes(TEXT_INFOBOX_HELP_FILENAME);?>';
							break;
						case 'heading':
							contentText='<?php echo addslashes(TEXT_INFOBOX_HELP_HEADING);?>';
							break;
						case 'template':
							contentText='<?php echo addslashes(TEXT_INFOBOX_HELP_DEFINE);?>';
							break;
						case 'define':
							contentText='<?php echo addslashes(TEXT_INFOBOX_HELP_DEFINE);?>';
							break;
					}
					
					content='<table border="0" cellspacing="0" cellpadding="4" class="formArea" width="100%"><tr><td class=smallText>';
					content+=contentText;
					content+='</td></tr></table>';
					popwidth=250;
					baby[1]=content;
					if (baby[1]!="")
					{
						popup("1","#ffffff");
					}	
}
//--></script>
	<!-- header //-->
	<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
	<!-- header_eof //-->
	<!-- body //-->
	<table border="0" width="100%" cellspacing="2" cellpadding="2">
		<tr> 
		<!-- body_text //-->
			<td width="100%" valign="top">
				<table border="0" width="100%" cellspacing="2" cellpadding="3">
					<tr >
						<td>
							<table border="0" width="100%" cellspacing="0" cellpadding="0">
								<tr class="dataTableHeadingRow" style="height:25px">
									<td align="left" valign="bottom">
									<?php 
									$avail_boxes = 0;
									if(sizeof($template_array)>0)
									$gID = $template_array[0]['id'];
									$templates_query = tep_db_query("select template_id, template_name from " . TABLE_TEMPLATE . " where template_id = " . $gID);
									$template = tep_db_fetch_array($templates_query);
									 if (file_exists(DIR_FS_TEMPLATES.$template['template_name']."/boxes") && ($handle = opendir(DIR_FS_TEMPLATES.$template['template_name']."/boxes"))) {
										/* This is the correct way to loop over the directory. */
											while (false !== ($file = readdir($handle))) { 
												if(is_file(DIR_FS_TEMPLATES .$template['template_name']. '/boxes/' . $file) && stristr($infobox_list.".,..", $file) == FALSE){
													$avail_boxes ++;
												}
											}
											closedir($handle);
										} 
										if ($avail_boxes>0){	
									 ?>
									<span id="install_new"><?php echo '<a href="javascript:do_page_fetch(' . $gID . ',\'\',\'new_info\');" id="img_new" onmouseover="javascript:do_hover_change1(this,2);" onmouseout="javascript:do_hover_change1(this,1);">' . tep_image('images/template/img_new.gif',IMAGE_BUTTON_NEW,'','',' align="absbottom"') .'</a>';?></span></td>
									<?php } ?>
									<td class="dataTableHeadingContent" align="right"><?php echo TEXT_INFO_TEMPLATE . tep_draw_separator('pixel_trans.gif','10','10') . tep_draw_pull_down_menu('gID', $template_array,  $gID,'onChange="javascript:do_change_template(this);"'); ?></td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<center>
							<table border="0" width="100%" cellspacing="0" cellpadding="0">
								<tr>
									<td valign="top">
										<table border="0" width="100%" cellspacing="0" cellpadding="2">
											<tr>
												<td valign="top"><?php echo tep_draw_form('infoboxes',FILENAME_INFOBOX_CONFIGURATION,'','post','onSubmit="return ValidateForm();"');?>
																<input type="hidden" id="infobox_id"><input type="hidden" id="info_action">
													<table border="0" width="100%" cellspacing="0" cellpadding="2">
														<tr class="dataTableHeadingRow">
															<td class="dataTableHeadingContent" colspan="7"><?php echo TABLE_HEADING_INFOBOX_FILE_NAME; ?></td>
														</tr>
														<div id="loading" style="display:none"><div style="height:30px;margin-left:30px"><img src="images/24-1.gif"></div></div>
														<tr><td id="ajax_details" colspan="7">
															<?php get_info_details(); ?>
														</td></tr>		
														<tr><td><?php echo tep_draw_separator('pixel_trans.gif','50','50');?></td></tr>
													</table>
												</td>
											</tr>	
										</table>
									</td>
								</tr>
							</table>
							</center>
						</td>
		<!-- body_text_eof //-->
					</tr>
				</table>
			</td>	
		<!-- body_eof //-->
		</tr>
		<script>
			document.getElementById('gID').value='<?php echo $gID?>';
		</script>
		<!-- footer //-->
		<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
		<!-- footer_eof //-->
	</table>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); 
		
	function get_info_details(){
		global $HTTP_GET_VARS,$gID,$command,$template_array;
		tep_template_box_check($gID);
		$count_left_active = 0;
		$count_right_active = 0;
		$totInf_boxes = 0;
		$avail_boxes=0;
		$display='0';
		
		$templates_query = tep_db_query("select template_id, template_name from " . TABLE_TEMPLATE . " where template_id = " . $gID);
		$template = tep_db_fetch_array($templates_query);
		if (file_exists(DIR_FS_TEMPLATES.$template['template_name']."/boxes") && ($handle = opendir(DIR_FS_TEMPLATES.$template['template_name']."/boxes"))) {
			/* This is the correct way to loop over the directory. */
				while (false !== ($file = readdir($handle))) { 
					if(is_file(DIR_FS_TEMPLATES .$template['template_name']. '/boxes/' . $file) && stristr($infobox_list.".,..", $file) == FALSE){
						$avail_boxes ++;
					}
				}
				closedir($handle); 
			
			if(sizeof($template_array)>0 && $gID=='2')$gID = $template_array[0]['id'];
			$configuration_query = tep_db_query("select *  from " . TABLE_INFOBOX_CONFIGURATION . " where template_id = '" . $gID . "' order by display_in_column,location");
			
			echo '<table cellpadding="0" cellspacing="0" border="0" width="100%"  id="info_table">'; 
			if(tep_db_num_rows($configuration_query)>0){
			 ?>
					<tr id="new_details" style="display:none" class="openContent">
						<td>	
							<table cellpadding="0" cellspacing="0" border="0" width="100%">
								<tr class="openContent_top">
									<td class="inner_title"><?php echo TEXT_NEW_INFOBOX;?></td>
									<td width="240" align="right"><input type="image" src="images/template/img_savel.gif" alt="save" title="save" border="0">&nbsp;&nbsp;<a href="javascript:do_page_fetch('','','close');"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</td>
								</tr>
								<tr><td><div id="span_new" style="display:none"></div></td></tr>
							</table>
						</td>
					</tr>					  
			
			<?php   $row=0;
				while ($configuration = tep_db_fetch_array($configuration_query)) {
					if($row %2 ==0) $class="dataTableRowEven";
					else $class="dataTableRowOdd"; $row++;
					
					$totInf_boxes++;
					$cfgloc = $configuration['location'];
					$cfgValue = $configuration['infobox_display'];
					$cfgcol = $configuration['display_in_column'];
					$cfgtemp = $configuration['box_template'];
					$cfgkey = $configuration['infobox_define'];
					$cfgfont = $configuration['box_heading_font_color'];
					if (($cfgcol == 'left') && ($cfgValue != 'no')) { 
						$count_left_active++;
					} else if (($cfgcol == 'right') && ($cfgValue != 'no')){
						$count_right_active++; 
					}
					
					$infobox_list .= $configuration['infobox_file_name']. ",";
					
					echo '<tr id="defaultSelected" height="25" class="'. $class . '" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="javascript:if(document.getElementById(\'data_' . $configuration['infobox_id']. '\').style.display==\'none\') do_page_fetch(\''.$gID . '\',\''. $configuration['infobox_id'] . '\',\'get_details\');">' . "\n";
					
					if ($configuration['infobox_display'] == 'yes') {
						$display= tep_image(DIR_WS_IMAGES . 'template/icon_active.gif', '', 10, 10);
					} else {
						$display=tep_image(DIR_WS_IMAGES . 'template/icon_inactive.gif', '', 10, 10) ;
					}
					
					if (strtolower($configuration['display_in_column']) == 'left') {
					   $display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_left.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_column(\''.$cID . '\',\'right\'); "');
					} else {
					   $display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_right.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_column(\''.$cID. '\',\'left\'); "');
					}
					  
					?>
							<td class="dataTableContent"><div id="head_<?php echo $configuration['infobox_id'];?>"><?php echo $display . tep_draw_separator('pixel_trans.gif','10','10') . $display_column . tep_draw_separator('pixel_trans.gif','10','10') ;?><font color="<?php echo $cfgfont ;?>"><?php echo $configuration['box_heading'] ; ?></font></div><div id="data_<?php echo $configuration['infobox_id'];?>" style="display:none"></div></td>
						</tr>
			<?php
				}  	?>
						<tr><td height="20"></td></tr>
						<tr class="dataTableRowEvenOver">
							<td class="dataTableContent" align="center"><?php echo '<br>There are currently <br>'. $count_left_active . ' active boxes in the left column and <br>'. $count_right_active . ' active boxes in the right column' . '<br><br>'?></td>
						</tr>	
			<?php }		
			if($avail_boxes>0){ 
					$display='1';
			}
			else if($avail_boxes == 0){
				$display='0';
			?>
			<tr>
				<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td class="infoBoxContent" align="center">
								<?php echo "This template does not have any infoboxes to install. Please put the infoboxes that you want to install in this template's boxes directory."; ?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<?php
			} 
			
		} else { $display='0';?>
			<tr>
				<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td class="infoBoxContent" align="center">
								<?php echo "This template does not have any infoboxes to install. Please put the infoboxes that you want to install in this template's boxes directory."; ?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		<?php } ?>
	<?php  
	
	echo '</table>' ;
	if($command!='')
		 echo '{#}' . $display;  ?>
	<?php }
	
	function do_get_details($cID){
		global $gID; 
		
		$queryl=tep_db_query("select min(location) as min,max(location) as max from " .TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='left'");
		$resultl=tep_db_fetch_array($queryl);
		
		$queryr=tep_db_query("select min(location) as min,max(location) as max from " .TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='right'");
		$resultr=tep_db_fetch_array($queryr);
		
		
		$configuration_query = tep_db_query("select *  from " . TABLE_INFOBOX_CONFIGURATION . " where template_id = '" . $gID . "' and infobox_id='" . $cID . "' order by display_in_column,location");
		$configuration=tep_db_fetch_array($configuration_query);
		
		$row=0;
		$result='<table width="100%" border="0" cellspacing="0" cellpadding="0"   class="openContent">'.
					'<tr heigth="40" bgcolor="#EDF1FE"  class="openContent_top" onClick="do_close(\''. $cID . '\');">';  	
				$result.='<td width="40" valign="top" align="center">&nbsp;</td>';
		if ($configuration['infobox_display'] == 'yes') {
			$display=tep_image(DIR_WS_IMAGES . 'template/icon_active.gif', '', 10, 10,'onClick="javascript:change_status(\''.$cID . '\',\'no\'); "') ;
		} else {
			$display=tep_image(DIR_WS_IMAGES . 'template/icon_inactive.gif', '', 10, 10,' onClick="javascript:change_status(\''.$cID. '\',\'yes\'); "');
		}		
		
		if (strtolower($configuration['display_in_column']) == 'left') {
			$display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_left.gif', '', 10, 10,' onClick="javascript:change_column(\''.$cID . '\',\'right\'); "');
			if($resultl['min'] < $configuration['location'])
				$display_sort_order=tep_image(DIR_WS_IMAGES . 'template/img_arrow_up.gif', '', 10, 10,' onClick="javascript:change_position(\''.$cID . '\',\'' . $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'up\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
			if($resultl['max'] > $configuration['location'])
				$display_sort_order.= tep_image(DIR_WS_IMAGES . 'template/img_arrow_down.gif', '', 10, 10,' onClick="javascript:change_position(\''.$cID . '\',\''. $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'down\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
		} else {
			$display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_right.gif', '', 10, 10,' onClick="javascript:change_column(\''.$cID. '\',\'left\'); "');
			if($resultr['min'] < $configuration['location'])
				$display_sort_order=tep_image(DIR_WS_IMAGES . 'template/img_arrow_up.gif', '', 10, 10,' onClick="javascript:change_position(\''.$cID . '\',\'' . $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'up\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
			if($resultr['max'] > $configuration['location'])
				$display_sort_order.= tep_image(DIR_WS_IMAGES . 'template/img_arrow_down.gif', '', 10, 10,' onClick="javascript:change_position(\''.$cID . '\',\''. $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'down\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
		}	
		
				$result.='<td align="left" valign="middle" width="350" class="inner_title" id="row_heading" style="cursor:hand;cursor:pointer">'. $display . tep_draw_separator('pixel_trans.gif','10','10') . $display_column . tep_draw_separator('pixel_trans.gif','10','10') . $display_sort_order . '<font color="' . $configuration['box_heading_font_color'] . '">'. $configuration['box_heading'].'</font></td>'.
						 '<td width="470" align="left" class="main" valign="top">'.
							'<table border="0" cellspacing="0" cellpadding="0" style="width:100;height:30px;display:inline;position:relative;">'.
								'<tr class="img_move" id="img_ids">'.
									'<td class="cell_bg_popm_left" width="10">&nbsp;</td>';
						$result.=   '<td width="10%" onclick="javascript:do_hover_change(this,1);do_page_fetch('.$gID . ',' . $cID . ',\'edit\');" onmouseover="javascript:do_hover_change(this,2);" onmouseout="javascript:do_hover_change(this,3);"><img alt="Edit" title="Edit" src="images/template/img_edit.gif"></td>'.
									'<td width="10%" onclick="javascript:do_hover_change(this,1);do_page_fetch(' .$gID . ',' . $cID . ',\'delete\');" onmouseover="javascript:do_hover_change(this,2);" onmouseout="javascript:do_hover_change(this,3);"><img alt="Delete" title="Delete" src="images/template/img_trash.gif"></td>'.			  	    
									'<td class="cell_bg_popm_right" width="10">&nbsp;</td>'.
								'</tr>'.
							'</table>'.
						'</td>';
			   $result.='<td width="240" align="right" id="img_save" style="display:none"><img src="images/template/img_savel.gif" alt="save" title="save" border="0" onClick="javascript:ValidateForm();">&nbsp;&nbsp;<img src="images/template/img_closel.gif" alt="close" title="close" border="0" style="cursor:hand;cursor:pointer" onClick="javascript:do_page_fetch('. $gID . ',' . $cID .',\'close_info\');">&nbsp;&nbsp;</td>'.
					'</tr>';
		   $result.='<tr><td width="40" valign="top" align="center">&nbsp;</td><td colspan="4">'.
		   					'<div id="span_details">'.
								'<table cellpadding="2" cellspacing="2" border="0" width="100%">';
						   $result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr>';
						   $result.='<tr><td class="main" width="150">' . TEXT_FILENAME . '</td><td class="main">' . $configuration['infobox_file_name']. '</td><td class="main" width="125">' . TEXT_TITLE . '</td><td class="main" width="175">' . $configuration['box_heading'] . '</td><tr>';
						   $result.='<tr><td class="main" width="125">' . TABLE_HEADING_TEMPLATE . '</td><td class="main" width="175">' . $configuration['box_template'] . '</td><td class="main" width="150" nowrap="nowrap">' . TABLE_HEADING_KEY . '</td><td class="main" >' . $configuration['infobox_define' ]. '</td><tr>';
						   $result.='<tr><td>' . tep_draw_separator('pixel_trans.gif','20','20') . '</td></tr>';
		 				 $result.='</table></div>'.
						'</td></tr>';
		    $result.='<tr><td colspan="5"><span id="span_edit" style="display:none"></span></td></tr>';
		    $result.='<tr><td colspan="5"><span id="span_delete" style="display:none"></span></td></tr>';
		$result .='</table>';
		return $result;
	}
	
	function get_edit_details($cID){
		global $gID;
		$configuration_query = tep_db_query("select *  from " . TABLE_INFOBOX_CONFIGURATION . " where template_id = '" . $gID . "' and infobox_id='" . $cID . "'order by display_in_column,location");
		$configuration=tep_db_fetch_array($configuration_query);
		
		$templates_query = tep_db_query("select template_id, template_name from " . TABLE_TEMPLATE . " where template_id = " . $gID);
		$template = tep_db_fetch_array($templates_query);
		
		if ($handle = opendir(DIR_FS_TEMPLATES.$template['template_name']."/boxes")) {
			/* This is the correct way to loop over the directory. */
			while (false !== ($file = readdir($handle))) { 
				if(is_file(DIR_FS_TEMPLATES .$template['template_name']. '/boxes/' . $file) && stristr($infobox_list.".,..", $file) == FALSE){
					$dirs[] = $file;
					$dirs_array[] = array('id' => $file,
					'text' => $file);
				}
			}
			closedir($handle); 
		}	
		
		if(tep_db_num_rows($configuration_query)>0)
			$cInfo=new objectInfo($configuration);
		?>
			<table border="0" width="100%" cellspacing="2" cellpadding="2">
				<tr>
					<td class="main" width="125"><?php echo TEXT_FILENAME;?></td>
					<td class="main" width="250"><?php echo (tep_db_num_rows($configuration_query)>0)?tep_draw_input_field('infobox_file_name',$cInfo->infobox_file_name,'size="20"','true'):tep_draw_pull_down_menu('infobox_file_name',$dirs_array,'', "style='width:150;'", 'true');?></td>
					<td width="50"><span onMouseOver="javascript:popupWindow('filename')" onMouseOut="javascript:kill();"><?php echo tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO)  ;?></span></td>
					<td class="main" width="125"><?php echo TEXT_INFOBOX_HEADING;?></td>
					<td class="main" width="250"><?php	echo tep_draw_input_field('box_heading',$cInfo->box_heading,'size="25"','true'); ?></td>
					<td width="50"><span onMouseOver="javascript:popupWindow('heading')" onMouseOut="javascript:kill();"><?php echo tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO);	?></span></td>
				</tr>
				<tr>	
					<td class="main" width="125" nowrap="nowrap"><?php echo TEXT_BOX_TEMPLATE;?></td>
					<td class="main" width="250"><?php echo tep_draw_input_field('box_template',$cInfo->box_template,'size="25"','true'); ?></td>
					<td width="50"><span onMouseOver="javascript:popupWindow('template')" onMouseOut="javascript:kill();"><?php echo tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO);?></span></td>
					<td class="main" width="125"><?php echo TEXT_DEFINE_KEY;?></td>
					<td  class="main" width="250"><?php echo tep_draw_input_field('infobox_define',$cInfo->infobox_define,'size="35"','true');?></td>
					<td width="50"><span onMouseOver="javascript:popupWindow('define')" onMouseOut="javascript:kill();"><?php echo tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO);?></span></td>
				</tr>
				<tr>	
					<td class="main" width="125" valign="top"><?php echo TEXT_COLOR;?></td>
					<td colspan="5" class="main">
					<?php color_code();?><a><img usemap="#colmap" src="images/colortable.gif" align=center border="0"></a>
					<?php  echo  tep_draw_input_field('hexval',$cInfo->box_heading_font_color,'size="10"','true');?>
					</td>
				</tr>
				<tr><td colspan="6"><?php echo tep_draw_separator('pixel_trans.gif','20','20');?></td></tr>
			</table>
	<?php
	}	
	
	function save_details($cID){ 
		global $HTTP_POST_VARS,$gID;
		$server_date = getServerDate(true);
		if ($cID<=0) {
			$position_query=tep_db_query("select max(location) position from " . TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='left' ");
			$position=tep_db_fetch_array($position_query);
			
			$location=tep_template_box_align($gID,$HTTP_POST_VARS["location"],$HTTP_POST_VARS['configuration']["display_in_column"],"add",true); //($HTTP_POST_VARS["column"]!=$HTTP_POST_VARS["previous_column"]?true:false)
			$sql_array=array(
							"template_id"=>$gID,
							"infobox_file_name"=>tep_db_prepare_input($HTTP_POST_VARS['infobox_file_name']),
							"infobox_define"=>tep_db_prepare_input($HTTP_POST_VARS['infobox_define']),
							"display_in_column"=>'left',
							"infobox_display"=>'yes',
							"location"=>$position['position'] + 1,
							"box_heading"=>tep_db_prepare_input($HTTP_POST_VARS['box_heading']),
							"box_template"=>tep_db_prepare_input($HTTP_POST_VARS['box_template']),
							"date_added"=>$server_date ,
							"box_heading_font_color" =>tep_db_prepare_input($HTTP_POST_VARS['hexval']));
			tep_db_perform(TABLE_INFOBOX_CONFIGURATION,$sql_array);
			$cID = tep_db_insert_id();
			$new=true;
			echo $cID . '{|}';
		} elseif ($cID>0) { 
			if ($HTTP_POST_VARS['location']!=$HTTP_POST_VARS["previous_location"] || $HTTP_POST_VARS["previous_column"]!=$HTTP_POST_VARS['infobox_column']){
				//tep_template_box_align($gID,$HTTP_POST_VARS["previous_location"],$HTTP_POST_VARS["previous_column"],"remove");
				//$location=tep_template_box_align($gID,$HTTP_POST_VARS["location"],$HTTP_POST_VARS['infobox_column'],"add",true); //($HTTP_POST_VARS["column"]!=$HTTP_POST_VARS["previous_column"]?true:false)
			} else {
				$location=$HTTP_POST_VARS["location"];
			}
			$sql_array=array(
							"template_id"=>$gID,
							"infobox_file_name"=>tep_db_prepare_input($HTTP_POST_VARS['infobox_file_name']),
							"infobox_define"=>tep_db_prepare_input($HTTP_POST_VARS['infobox_define']),
							"box_heading"=>tep_db_prepare_input($HTTP_POST_VARS['box_heading']),
							"box_template"=>tep_db_prepare_input($HTTP_POST_VARS['box_template']),
							"box_heading_font_color"=>tep_db_prepare_input($HTTP_POST_VARS['hexval']),
							"last_modified"=>$server_date
			);
			tep_db_perform(TABLE_INFOBOX_CONFIGURATION,$sql_array,"update","infobox_id = '" . (int)$cID . "'");
			$new=false;
		}
		echo get_updated_details($cID,$new);
	}
	
	function get_updated_details($cID,$new){
		global $gID;
		tep_template_box_check($gID);
		
		$queryl=tep_db_query("select min(location) as min,max(location) as max from " .TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='left'");
		$resultl=tep_db_fetch_array($queryl);
		
		$queryr=tep_db_query("select min(location) as min,max(location) as max from " .TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='right'");
		$resultr=tep_db_fetch_array($queryr);
		
		$configuration_query = tep_db_query("select *  from " . TABLE_INFOBOX_CONFIGURATION . " where template_id = '" . $gID . "' and infobox_id='" . $cID . "'order by display_in_column,location");
		$configuration = tep_db_fetch_array($configuration_query); 
		
		if ($configuration['infobox_display'] == 'yes') {
			$display=tep_image(DIR_WS_IMAGES . 'template/icon_active.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_status(\''.$configuration['infobox_id'] . '\',\'no\'); "');
			$displays= tep_image(DIR_WS_IMAGES . 'template/icon_active.gif', '', 10, 10);
		} else {
			$display=tep_image(DIR_WS_IMAGES . 'template/icon_inactive.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_status(\''.$configuration['infobox_id'] . '\',\'yes\'); "');
			$displays= tep_image(DIR_WS_IMAGES . 'template/icon_inactive.gif', '', 10, 10);
		}
		
		if (strtolower($configuration['display_in_column']) == 'left') {
			$display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_left.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_column(\''.$configuration['infobox_id'] . '\',\'right\'); "') ;
			$displays_column= tep_image(DIR_WS_IMAGES . 'template/arrow_left.gif', '', 10, 10);
			if($resultl['min'] < $configuration['location'])
				$display_sort_order=tep_image(DIR_WS_IMAGES . 'template/img_arrow_up.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\'' . $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'up\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
			if($resultl['max'] > $configuration['location'])
				$display_sort_order.= tep_image(DIR_WS_IMAGES . 'template/img_arrow_down.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\''. $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'down\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
		} else {
			$display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_right.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_column(\''.$configuration['infobox_id'] . '\',\'left\'); "');
			$displays_column= tep_image(DIR_WS_IMAGES . 'template/arrow_right.gif', '', 10, 10);
			if($resultr['min'] < $configuration['location'])
				$display_sort_order=tep_image(DIR_WS_IMAGES . 'template/img_arrow_up.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\'' . $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'up\'); "')  . tep_draw_separator('pixel_trans.gif','10','10');
			if($resultr['max'] > $configuration['location'])
				$display_sort_order.=tep_image(DIR_WS_IMAGES . 'template/img_arrow_down.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\''. $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'down\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
		}
		
		if($new){
			$result='<div id="head_'. $configuration['infobox_id'] .'">'.  $displays . tep_draw_separator('pixel_trans.gif','10','10'). $display_column . tep_draw_separator('pixel_trans.gif','10','10') . $configuration['box_heading']. tep_draw_separator('pixel_trans.gif','10','10') . $configuration['location'].'</div><div id="data_'. $configuration['infobox_id'].'" style="display:none"></div>';
		} else {
			$result= '<table cellpadding="2" cellspacing="2" border="0" width="100%">';
				$result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr>';
				$result.='<tr><td class="main" width="125">' . TEXT_TITLE . '</td><td class="main" width="175">' . $configuration['box_heading'] . '</td><td class="main" width="125">' . TEXT_FILENAME . '</td><td class="main">' . $configuration['infobox_file_name']. '</td><tr>';
				$result.='<tr><td class="main" width="125">' . TABLE_HEADING_TEMPLATE . '</td><td class="main" width="175">' . $configuration['box_template'] . '</td><td class="main" width="128" nowrap="nowrap">' . TABLE_HEADING_KEY . '</td><td class="main">' . $configuration['infobox_define' ]. '</td><tr>';
				$result.='<tr><td colspan="4">' . tep_draw_separator('pixel_trans.gif','10','10') . '</td></tr>';
			$result.='</table>';
		} 
		return $result . '{#}' . $display . tep_draw_separator('pixel_trans.gif','10','10') . $display_column. tep_draw_separator('pixel_trans.gif','10','10') . $display_sort_order . '<font color="' . $configuration['box_heading_font_color'] . '">' . $configuration['box_heading'] . '</font>{##}' .  $displays . tep_draw_separator('pixel_trans.gif','10','10') .  $displays_column . tep_draw_separator('pixel_trans.gif','10','10'). '<font color="' . $configuration['box_heading_font_color'] . '">' . $configuration['box_heading'] . '</font>' ;
	}                            
	
	function get_status_change($cID,$status=false){
		global $flag,$gID,$server_date;
		
		if($status){
			tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set infobox_display = '" . $flag . "',last_modified='" . $server_date  . "' where infobox_id = '" . (int)$cID . "'");
		} else { 
			$info_query=tep_db_query("select location,display_in_column from " . TABLE_INFOBOX_CONFIGURATION . " where infobox_id='" . $cID. "'");
			if (tep_db_num_rows($info_query)>0) {
				$info_result=tep_db_fetch_array($info_query);
				tep_template_box_align(gID,$info_result["location"],$info_result["display_in_column"],"remove");
				tep_template_box_align($gID,$info_result["location"],$flag,"add",true);
				tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set display_in_column = '" . $flag . "',last_modified='" . $server_date  . "' where infobox_id = '" . (int)$cID . "'");
			}
		}

		$queryl=tep_db_query("select min(location) as min,max(location) as max from " .TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='left'");
		$resultl=tep_db_fetch_array($queryl);
		
		$queryr=tep_db_query("select min(location) as min,max(location) as max from " .TABLE_INFOBOX_CONFIGURATION . " where template_id='" . $gID . "' and display_in_column='right'");
		$resultr=tep_db_fetch_array($queryr);
		
		$configuration_query = tep_db_query("select *  from " . TABLE_INFOBOX_CONFIGURATION . " where template_id = '" . $gID . "' and infobox_id='" . $cID . "'order by display_in_column,location");
		$configuration = tep_db_fetch_array($configuration_query);
		
		if ($configuration['infobox_display'] == 'yes') {
			$display=tep_image(DIR_WS_IMAGES . 'template/icon_active.gif', '', 10, 10,' style="cursor:hand;cursor:pointer" onClick="javascript:change_status(\''.$configuration['infobox_id'] . '\',\'no\'); "');
		} else {
			$display=tep_image(DIR_WS_IMAGES . 'template/icon_inactive.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_status(\''.$configuration['infobox_id'] . '\',\'yes\'); "');
		}
		
		if (strtolower($configuration['display_in_column']) == 'left') {
			$display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_left.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_column(\''.$configuration['infobox_id'] . '\',\'right\'); "');
			if($resultl['min'] < $configuration['location'])
				$display_sort_order=tep_image(DIR_WS_IMAGES . 'template/img_arrow_up.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\'' . $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'up\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
			if($resultl['max'] > $configuration['location'])
				$display_sort_order.=tep_image(DIR_WS_IMAGES . 'template/img_arrow_down.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\''. $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'down\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
		} else {
			$display_column=tep_image(DIR_WS_IMAGES . 'template/arrow_right.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_column(\''.$configuration['infobox_id'] . '\',\'left\'); "');
			if($resultr['min'] < $configuration['location'])
				$display_sort_order= tep_image(DIR_WS_IMAGES . 'template/img_arrow_up.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\'' . $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'up\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
			if($resultr['max'] > $configuration['location'])
				$display_sort_order.=  tep_image(DIR_WS_IMAGES . 'template/img_arrow_down.gif', '', 10, 10,'style="cursor:hand;cursor:pointer" onClick="javascript:change_position(\''.$cID . '\',\''. $configuration['location'] . '\',\''. $configuration['display_in_column'] . '\',\'down\'); "') . tep_draw_separator('pixel_trans.gif','10','10');
		}
		return $display . tep_draw_separator('pixel_trans.gif','10','10') . $display_column . tep_draw_separator('pixel_trans.gif','10','10') . $display_sort_order . $configuration['box_heading']. tep_draw_separator('pixel_trans.gif','10','10') . '{##}' . $display . tep_draw_separator('pixel_trans.gif','10','10') . $display_column . tep_draw_separator('pixel_trans.gif','10','10') . $configuration['box_heading']. tep_draw_separator('pixel_trans.gif','10','10') . $configuration['location'];
	}
	
	function get_position_change($cID,$location,$col){
		global $gID,$flag,$server_date;
		$query=tep_db_query("select max(location) as max,min(location) as min from " . TABLE_INFOBOX_CONFIGURATION);
		$result=tep_db_fetch_array($query);
		
		if($flag=='up'){
			tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set location=location+1,last_modified='" . $server_date  . "' where location='". ($location-1) . "' and display_in_column='". $col . "' and infobox_display='yes'" );
			tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set location=location-1,last_modified='" . $server_date  . "' where location='" . $location . "' and infobox_id='" . $cID . "' and display_in_column='". $col . "' and infobox_display='yes'");
		} else if($flag=='down'){
			tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set location=location-1,last_modified='" . $server_date  . "' where location='". ($location+1) . "' and display_in_column='". $col . "' and infobox_display='yes'" );
			tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set location=location+1,last_modified='" . $server_date  . "' where location='" . $location . "' and infobox_id='" . $cID . "' and display_in_column='". $col . "' and infobox_display='yes'");
		}
		
	//	tep_template_box_realign($gID,$col);
		
	}
	
	function get_display_change($cID){
		global $gID,$flag,$server_date;
		
		$info_query=tep_db_query("select location,display_in_column from " . TABLE_INFOBOX_CONFIGURATION . " where infobox_id='" . $cID. "'");
		if (tep_db_num_rows($info_query)>0) {
			$info_result=tep_db_fetch_array($info_query);
			//tep_template_box_align(gID,$info_result["location"],$info_result["display_in_column"],"remove");
			//tep_template_box_align($gID,$info_result["location"],$flag,"add",true);
			tep_db_query("update " . TABLE_INFOBOX_CONFIGURATION . " set display_in_column = '" . $flag . "',last_modified='" . $server_date  . "' where infobox_id = '" . (int)$cID . "'");
		}
	}
	
	function delete_details($cID,$delete){
		global $gID;
		if($delete){
			$cID = tep_db_prepare_input($cID);;
			$info_query=tep_db_query("select location,display_in_column from " . TABLE_INFOBOX_CONFIGURATION . " where infobox_id='" . tep_db_input($cID) . "'");
			if (tep_db_num_rows($info_query)>0){
				$info_result=tep_db_fetch_array($info_query);
				tep_template_box_align($gID,$info_result["location"],$info_result["display_in_column"],"remove");
				tep_db_query("delete from " . TABLE_INFOBOX_CONFIGURATION . " where infobox_id = '" . tep_db_input($cID) . "'");
			}
		} else {
			$result.='<table cellpadding="2" cellspacing="2" border="0" width="100%">'.
						'<tr><td width="15">' . tep_image('images/template/img_trash.gif') . '</td><td class="inner_title">' . TEXT_INFO_HEADING_DELETE_INFOBOX . '</td></tr>';
						$result.='<tr><td width="15"></td><td class="main">' . TEXT_INFO_DELETE_INTRO . '</td></tr>';
						$result.='<tr><td colspan="2">'. tep_draw_separator('pixel_trans.gif','10','10') . '</td<tr>'.
					'</table>' ;
			return $result;
		}	
	}
	
	function color_code(){ ?>
		<map name="colmap"> 
		<area shape="rect" coords="1,1,7,10" href="javascript:showColor('#00FF00')"> 
		<area shape="rect" coords="9,1,15,10" href="javascript:showColor('#00FF33')"> 
		<area shape="rect" coords="17,1,23,10" href="javascript:showColor('#00FF66')"> 
		<area shape="rect" coords="25,1,31,10" href="javascript:showColor('#00FF99')"> 
		<area shape="rect" coords="33,1,39,10" href="javascript:showColor('#00FFCC')"> 
		<area shape="rect" coords="41,1,47,10" href="javascript:showColor('#00FFFF')"> 
		<area shape="rect" coords="49,1,55,10" href="javascript:showColor('#33FF00')"> 
		<area shape="rect" coords="57,1,63,10" href="javascript:showColor('#33FF33')"> 
		<area shape="rect" coords="65,1,71,10" href="javascript:showColor('#33FF66')"> 
		<area shape="rect" coords="73,1,79,10" href="javascript:showColor('#33FF99')"> 
		<area shape="rect" coords="81,1,87,10" href="javascript:showColor('#33FFCC')"> 
		<area shape="rect" coords="89,1,95,10" href="javascript:showColor('#33FFFF')"> 
		<area shape="rect" coords="97,1,103,10" href="javascript:showColor('#66FF00')"> 
		<area shape="rect" coords="105,1,111,10" href="javascript:showColor('#66FF33')"> 
		<area shape="rect" coords="113,1,119,10" href="javascript:showColor('#66FF66')"> 
		<area shape="rect" coords="121,1,127,10" href="javascript:showColor('#66FF99')"> 
		<area shape="rect" coords="129,1,135,10" href="javascript:showColor('#66FFCC')"> 
		<area shape="rect" coords="137,1,143,10" href="javascript:showColor('#66FFFF')"> 
		<area shape="rect" coords="145,1,151,10" href="javascript:showColor('#99FF00')"> 
		<area shape="rect" coords="153,1,159,10" href="javascript:showColor('#99FF33')"> 
		<area shape="rect" coords="161,1,167,10" href="javascript:showColor('#99FF66')"> 
		<area shape="rect" coords="169,1,175,10" href="javascript:showColor('#99FF99')"> 
		<area shape="rect" coords="177,1,183,10" href="javascript:showColor('#99FFCC')"> 
		<area shape="rect" coords="185,1,191,10" href="javascript:showColor('#99FFFF')"> 
		<area shape="rect" coords="193,1,199,10" href="javascript:showColor('#CCFF00')"> 
		<area shape="rect" coords="201,1,207,10" href="javascript:showColor('#CCFF33')"> 
		<area shape="rect" coords="209,1,215,10" href="javascript:showColor('#CCFF66')"> 
		<area shape="rect" coords="217,1,223,10" href="javascript:showColor('#CCFF99')"> 
		<area shape="rect" coords="225,1,231,10" href="javascript:showColor('#CCFFCC')"> 
		<area shape="rect" coords="233,1,239,10" href="javascript:showColor('#CCFFFF')"> 
		<area shape="rect" coords="241,1,247,10" href="javascript:showColor('#FFFF00')"> 
		<area shape="rect" coords="249,1,255,10" href="javascript:showColor('#FFFF33')"> 
		<area shape="rect" coords="257,1,263,10" href="javascript:showColor('#FFFF66')"> 
		<area shape="rect" coords="265,1,271,10" href="javascript:showColor('#FFFF99')"> 
		<area shape="rect" coords="273,1,279,10" href="javascript:showColor('#FFFFCC')"> 
		<area shape="rect" coords="281,1,287,10" href="javascript:showColor('#FFFFFF')"> 
		<area shape="rect" coords="1,12,7,21" href="javascript:showColor('#00CC00')"> 
		<area shape="rect" coords="9,12,15,21" href="javascript:showColor('#00CC33')"> 
		<area shape="rect" coords="17,12,23,21" href="javascript:showColor('#00CC66')"> 
		<area shape="rect" coords="25,12,31,21" href="javascript:showColor('#00CC99')"> 
		<area shape="rect" coords="33,12,39,21" href="javascript:showColor('#00CCCC')"> 
		<area shape="rect" coords="41,12,47,21" href="javascript:showColor('#00CCFF')"> 
		<area shape="rect" coords="49,12,55,21" href="javascript:showColor('#33CC00')"> 
		<area shape="rect" coords="57,12,63,21" href="javascript:showColor('#33CC33')"> 
		<area shape="rect" coords="65,12,71,21" href="javascript:showColor('#33CC66')"> 
		<area shape="rect" coords="73,12,79,21" href="javascript:showColor('#33CC99')"> 
		<area shape="rect" coords="81,12,87,21" href="javascript:showColor('#33CCCC')"> 
		<area shape="rect" coords="89,12,95,21" href="javascript:showColor('#33CCFF')"> 
		<area shape="rect" coords="97,12,103,21" href="javascript:showColor('#66CC00')"> 
		<area shape="rect" coords="105,12,111,21" href="javascript:showColor('#66CC33')"> 
		<area shape="rect" coords="113,12,119,21" href="javascript:showColor('#66CC66')"> 
		<area shape="rect" coords="121,12,127,21" href="javascript:showColor('#66CC99')"> 
		<area shape="rect" coords="129,12,135,21" href="javascript:showColor('#66CCCC')"> 
		<area shape="rect" coords="137,12,143,21" href="javascript:showColor('#66CCFF')"> 
		<area shape="rect" coords="145,12,151,21" href="javascript:showColor('#99CC00')"> 
		<area shape="rect" coords="153,12,159,21" href="javascript:showColor('#99CC33')"> 
		<area shape="rect" coords="161,12,167,21" href="javascript:showColor('#99CC66')"> 
		<area shape="rect" coords="169,12,175,21" href="javascript:showColor('#99CC99')"> 
		<area shape="rect" coords="177,12,183,21" href="javascript:showColor('#99CCCC')"> 
		<area shape="rect" coords="185,12,191,21" href="javascript:showColor('#99CCFF')"> 
		<area shape="rect" coords="193,12,199,21" href="javascript:showColor('#CCCC00')"> 
		<area shape="rect" coords="201,12,207,21" href="javascript:showColor('#CCCC33')"> 
		<area shape="rect" coords="209,12,215,21" href="javascript:showColor('#CCCC66')"> 
		<area shape="rect" coords="217,12,223,21" href="javascript:showColor('#CCCC99')"> 
		<area shape="rect" coords="225,12,231,21" href="javascript:showColor('#CCCCCC')"> 
		<area shape="rect" coords="233,12,239,21" href="javascript:showColor('#CCCCFF')"> 
		<area shape="rect" coords="241,12,247,21" href="javascript:showColor('#FFCC00')"> 
		<area shape="rect" coords="249,12,255,21" href="javascript:showColor('#FFCC33')"> 
		<area shape="rect" coords="257,12,263,21" href="javascript:showColor('#FFCC66')"> 
		<area shape="rect" coords="265,12,271,21" href="javascript:showColor('#FFCC99')"> 
		<area shape="rect" coords="273,12,279,21" href="javascript:showColor('#FFCCCC')"> 
		<area shape="rect" coords="281,12,287,21" href="javascript:showColor('#FFCCFF')"> 
		<area shape="rect" coords="1,23,7,32" href="javascript:showColor('#009900')"> 
		<area shape="rect" coords="9,23,15,32" href="javascript:showColor('#009933')"> 
		<area shape="rect" coords="17,23,23,32" href="javascript:showColor('#009966')"> 
		<area shape="rect" coords="25,23,31,32" href="javascript:showColor('#009999')"> 
		<area shape="rect" coords="33,23,39,32" href="javascript:showColor('#0099CC')"> 
		<area shape="rect" coords="41,23,47,32" href="javascript:showColor('#0099FF')"> 
		<area shape="rect" coords="49,23,55,32" href="javascript:showColor('#339900')"> 
		<area shape="rect" coords="57,23,63,32" href="javascript:showColor('#339933')"> 
		<area shape="rect" coords="65,23,71,32" href="javascript:showColor('#339966')"> 
		<area shape="rect" coords="73,23,79,32" href="javascript:showColor('#339999')"> 
		<area shape="rect" coords="81,23,87,32" href="javascript:showColor('#3399CC')"> 
		<area shape="rect" coords="89,23,95,32" href="javascript:showColor('#3399FF')"> 
		<area shape="rect" coords="97,23,103,32" href="javascript:showColor('#669900')"> 
		<area shape="rect" coords="105,23,111,32" href="javascript:showColor('#669933')"> 
		<area shape="rect" coords="113,23,119,32" href="javascript:showColor('#669966')"> 
		<area shape="rect" coords="121,23,127,32" href="javascript:showColor('#669999')"> 
		<area shape="rect" coords="129,23,135,32" href="javascript:showColor('#6699CC')"> 
		<area shape="rect" coords="137,23,143,32" href="javascript:showColor('#6699FF')"> 
		<area shape="rect" coords="145,23,151,32" href="javascript:showColor('#999900')"> 
		<area shape="rect" coords="153,23,159,32" href="javascript:showColor('#999933')"> 
		<area shape="rect" coords="161,23,167,32" href="javascript:showColor('#999966')"> 
		<area shape="rect" coords="169,23,175,32" href="javascript:showColor('#999999')"> 
		<area shape="rect" coords="177,23,183,32" href="javascript:showColor('#9999CC')"> 
		<area shape="rect" coords="185,23,191,32" href="javascript:showColor('#9999FF')"> 
		<area shape="rect" coords="193,23,199,32" href="javascript:showColor('#CC9900')"> 
		<area shape="rect" coords="201,23,207,32" href="javascript:showColor('#CC9933')"> 
		<area shape="rect" coords="209,23,215,32" href="javascript:showColor('#CC9966')"> 
		<area shape="rect" coords="217,23,223,32" href="javascript:showColor('#CC9999')"> 
		<area shape="rect" coords="225,23,231,32" href="javascript:showColor('#CC99CC')"> 
		<area shape="rect" coords="233,23,239,32" href="javascript:showColor('#CC99FF')"> 
		<area shape="rect" coords="241,23,247,32" href="javascript:showColor('#FF9900')"> 
		<area shape="rect" coords="249,23,255,32" href="javascript:showColor('#FF9933')"> 
		<area shape="rect" coords="257,23,263,32" href="javascript:showColor('#FF9966')"> 
		<area shape="rect" coords="265,23,271,32" href="javascript:showColor('#FF9999')"> 
		<area shape="rect" coords="273,23,279,32" href="javascript:showColor('#FF99CC')"> 
		<area shape="rect" coords="281,23,287,32" href="javascript:showColor('#FF99FF')"> 
		<area shape="rect" coords="1,34,7,43" href="javascript:showColor('#006600')"> 
		<area shape="rect" coords="9,34,15,43" href="javascript:showColor('#006633')"> 
		<area shape="rect" coords="17,34,23,43" href="javascript:showColor('#006666')"> 
		<area shape="rect" coords="25,34,31,43" href="javascript:showColor('#006699')"> 
		<area shape="rect" coords="33,34,39,43" href="javascript:showColor('#0066CC')"> 
		<area shape="rect" coords="41,34,47,43" href="javascript:showColor('#0066FF')"> 
		<area shape="rect" coords="49,34,55,43" href="javascript:showColor('#336600')"> 
		<area shape="rect" coords="57,34,63,43" href="javascript:showColor('#336633')"> 
		<area shape="rect" coords="65,34,71,43" href="javascript:showColor('#336666')"> 
		<area shape="rect" coords="73,34,79,43" href="javascript:showColor('#336699')"> 
		<area shape="rect" coords="81,34,87,43" href="javascript:showColor('#3366CC')"> 
		<area shape="rect" coords="89,34,95,43" href="javascript:showColor('#3366FF')"> 
		<area shape="rect" coords="97,34,103,43" href="javascript:showColor('#666600')"> 
		<area shape="rect" coords="105,34,111,43" href="javascript:showColor('#666633')"> 
		<area shape="rect" coords="113,34,119,43" href="javascript:showColor('#666666')"> 
		<area shape="rect" coords="121,34,127,43" href="javascript:showColor('#666699')"> 
		<area shape="rect" coords="129,34,135,43" href="javascript:showColor('#6666CC')"> 
		<area shape="rect" coords="137,34,143,43" href="javascript:showColor('#6666FF')"> 
		<area shape="rect" coords="145,34,151,43" href="javascript:showColor('#996600')"> 
		<area shape="rect" coords="153,34,159,43" href="javascript:showColor('#996633')"> 
		<area shape="rect" coords="161,34,167,43" href="javascript:showColor('#996666')"> 
		<area shape="rect" coords="169,34,175,43" href="javascript:showColor('#996699')"> 
		<area shape="rect" coords="177,34,183,43" href="javascript:showColor('#9966CC')"> 
		<area shape="rect" coords="185,34,191,43" href="javascript:showColor('#9966FF')"> 
		<area shape="rect" coords="193,34,199,43" href="javascript:showColor('#CC6600')"> 
		<area shape="rect" coords="201,34,207,43" href="javascript:showColor('#CC6633')"> 
		<area shape="rect" coords="209,34,215,43" href="javascript:showColor('#CC6666')"> 
		<area shape="rect" coords="217,34,223,43" href="javascript:showColor('#CC6699')"> 
		<area shape="rect" coords="225,34,231,43" href="javascript:showColor('#CC66CC')"> 
		<area shape="rect" coords="233,34,239,43" href="javascript:showColor('#CC66FF')"> 
		<area shape="rect" coords="241,34,247,43" href="javascript:showColor('#FF6600')"> 
		<area shape="rect" coords="249,34,255,43" href="javascript:showColor('#FF6633')"> 
		<area shape="rect" coords="257,34,263,43" href="javascript:showColor('#FF6666')"> 
		<area shape="rect" coords="265,34,271,43" href="javascript:showColor('#FF6699')"> 
		<area shape="rect" coords="273,34,279,43" href="javascript:showColor('#FF66CC')"> 
		<area shape="rect" coords="281,34,287,43" href="javascript:showColor('#FF66FF')"> 
		<area shape="rect" coords="1,45,7,54" href="javascript:showColor('#003300')"> 
		<area shape="rect" coords="9,45,15,54" href="javascript:showColor('#003333')"> 
		<area shape="rect" coords="17,45,23,54" href="javascript:showColor('#003366')"> 
		<area shape="rect" coords="25,45,31,54" href="javascript:showColor('#003399')"> 
		<area shape="rect" coords="33,45,39,54" href="javascript:showColor('#0033CC')"> 
		<area shape="rect" coords="41,45,47,54" href="javascript:showColor('#0033FF')"> 
		<area shape="rect" coords="49,45,55,54" href="javascript:showColor('#333300')"> 
		<area shape="rect" coords="57,45,63,54" href="javascript:showColor('#333333')"> 
		<area shape="rect" coords="65,45,71,54" href="javascript:showColor('#333366')"> 
		<area shape="rect" coords="73,45,79,54" href="javascript:showColor('#333399')"> 
		<area shape="rect" coords="81,45,87,54" href="javascript:showColor('#3333CC')"> 
		<area shape="rect" coords="89,45,95,54" href="javascript:showColor('#3333FF')"> 
		<area shape="rect" coords="97,45,103,54" href="javascript:showColor('#663300')"> 
		<area shape="rect" coords="105,45,111,54" href="javascript:showColor('#663333')"> 
		<area shape="rect" coords="113,45,119,54" href="javascript:showColor('#663366')"> 
		<area shape="rect" coords="121,45,127,54" href="javascript:showColor('#663399')"> 
		<area shape="rect" coords="129,45,135,54" href="javascript:showColor('#6633CC')"> 
		<area shape="rect" coords="137,45,143,54" href="javascript:showColor('#6633FF')"> 
		<area shape="rect" coords="145,45,151,54" href="javascript:showColor('#993300')"> 
		<area shape="rect" coords="153,45,159,54" href="javascript:showColor('#993333')"> 
		<area shape="rect" coords="161,45,167,54" href="javascript:showColor('#993366')"> 
		<area shape="rect" coords="169,45,175,54" href="javascript:showColor('#993399')"> 
		<area shape="rect" coords="177,45,183,54" href="javascript:showColor('#9933CC')"> 
		<area shape="rect" coords="185,45,191,54" href="javascript:showColor('#9933FF')"> 
		<area shape="rect" coords="193,45,199,54" href="javascript:showColor('#CC3300')"> 
		<area shape="rect" coords="201,45,207,54" href="javascript:showColor('#CC3333')"> 
		<area shape="rect" coords="209,45,215,54" href="javascript:showColor('#CC3366')"> 
		<area shape="rect" coords="217,45,223,54" href="javascript:showColor('#CC3399')"> 
		<area shape="rect" coords="225,45,231,54" href="javascript:showColor('#CC33CC')"> 
		<area shape="rect" coords="233,45,239,54" href="javascript:showColor('#CC33FF')"> 
		<area shape="rect" coords="241,45,247,54" href="javascript:showColor('#FF3300')"> 
		<area shape="rect" coords="249,45,255,54" href="javascript:showColor('#FF3333')"> 
		<area shape="rect" coords="257,45,263,54" href="javascript:showColor('#FF3366')"> 
		<area shape="rect" coords="265,45,271,54" href="javascript:showColor('#FF3399')"> 
		<area shape="rect" coords="273,45,279,54" href="javascript:showColor('#FF33CC')"> 
		<area shape="rect" coords="281,45,287,54" href="javascript:showColor('#FF33FF')"> 
		<area shape="rect" coords="1,56,7,65" href="javascript:showColor('#000000')"> 
		<area shape="rect" coords="9,56,15,65" href="javascript:showColor('#000033')"> 
		<area shape="rect" coords="17,56,23,65" href="javascript:showColor('#000066')"> 
		<area shape="rect" coords="25,56,31,65" href="javascript:showColor('#000099')"> 
		<area shape="rect" coords="33,56,39,65" href="javascript:showColor('#0000CC')"> 
		<area shape="rect" coords="41,56,47,65" href="javascript:showColor('#0000FF')"> 
		<area shape="rect" coords="49,56,55,65" href="javascript:showColor('#330000')"> 
		<area shape="rect" coords="57,56,63,65" href="javascript:showColor('#330033')"> 
		<area shape="rect" coords="65,56,71,65" href="javascript:showColor('#330066')"> 
		<area shape="rect" coords="73,56,79,65" href="javascript:showColor('#330099')"> 
		<area shape="rect" coords="81,56,87,65" href="javascript:showColor('#3300CC')"> 
		<area shape="rect" coords="89,56,95,65" href="javascript:showColor('#3300FF')"> 
		<area shape="rect" coords="97,56,103,65" href="javascript:showColor('#660000')"> 
		<area shape="rect" coords="105,56,111,65" href="javascript:showColor('#660033')"> 
		<area shape="rect" coords="113,56,119,65" href="javascript:showColor('#660066')"> 
		<area shape="rect" coords="121,56,127,65" href="javascript:showColor('#660099')"> 
		<area shape="rect" coords="129,56,135,65" href="javascript:showColor('#6600CC')"> 
		<area shape="rect" coords="137,56,143,65" href="javascript:showColor('#6600FF')"> 
		<area shape="rect" coords="145,56,151,65" href="javascript:showColor('#990000')"> 
		<area shape="rect" coords="153,56,159,65" href="javascript:showColor('#990033')"> 
		<area shape="rect" coords="161,56,167,65" href="javascript:showColor('#990066')"> 
		<area shape="rect" coords="169,56,175,65" href="javascript:showColor('#990099')"> 
		<area shape="rect" coords="177,56,183,65" href="javascript:showColor('#9900CC')"> 
		<area shape="rect" coords="185,56,191,65" href="javascript:showColor('#9900FF')"> 
		<area shape="rect" coords="193,56,199,65" href="javascript:showColor('#CC0000')"> 
		<area shape="rect" coords="201,56,207,65" href="javascript:showColor('#CC0033')"> 
		<area shape="rect" coords="209,56,215,65" href="javascript:showColor('#CC0066')"> 
		<area shape="rect" coords="217,56,223,65" href="javascript:showColor('#CC0099')"> 
		<area shape="rect" coords="225,56,231,65" href="javascript:showColor('#CC00CC')"> 
		<area shape="rect" coords="233,56,239,65" href="javascript:showColor('#CC00FF')"> 
		<area shape="rect" coords="241,56,247,65" href="javascript:showColor('#FF0000')"> 
		<area shape="rect" coords="249,56,255,65" href="javascript:showColor('#FF0033')"> 
		<area shape="rect" coords="257,56,263,65" href="javascript:showColor('#FF0066')"> 
		<area shape="rect" coords="265,56,271,65" href="javascript:showColor('#FF0099')"> 
		<area shape="rect" coords="273,56,279,65" href="javascript:showColor('#FF00CC')"> 
		<area shape="rect" coords="281,56,287,65" href="javascript:showColor('#FF00FF')"> 
		</map> 
<?php } ?>