
 <script language="javascript">
   var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
   var lang=new Array();
   var file_name="<?php echo $file_name;?>";
  <?php 
   	$languages = tep_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) echo "lang[".$i."]=".$languages[$i]['id'].";\n";    
   ?>
    var n=lang.length;		   	  	  	            
	var attributes_array=new Array();
	var values_arr=new Array();
	var pname="";
	var cname="";
	var attrb_cnt=0;
	var splt=Array()
	var tax_rates = new Array();
	<?php
		$tax_class_query = tep_db_query("SELECT tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
		while ($tax_class = tep_db_fetch_array($tax_class_query))  echo 'tax_rates["' . $tax_class['tax_class_id'] . '"] = ' . tep_get_tax_rate_value($tax_class['tax_class_id']) . ';' . "\n";			 				
	?>
	function doRound(x, places) {
  		return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
	}
	function ValidateForm(response){
		 var frm=document.new_product;
 	 	 var action_type=frm.action_type.value;
		 var cID="";	 
 	 	 if(action_type!='new_category' && document.getElementById("cPath") && document.getElementById("cPath").value>0) cID=document.getElementById("cPath").value;
 	 	 if(response && action_type=='new_category') {
			cID=response;
 	 	 	action_type='edit_category';	
 	 	 } 
 	 	 var pID="";
 	 	 if(action_type!='new' && !pID && frm.product_id && frm.product_id.value>0) pID=frm.product_id.value;
 	 	 if(response>0 && action_type=='new'){
 	 	 	pID=response;
 	 	 	action_type='edit';
 	 	 }
		 if((action_type=='new' || action_type=='edit') && document.getElementById("actions") && document.getElementById("actions").value!="") {
		 	document.getElementById("actions").value="";
			if(document.getElementById("new_category")) document.getElementById("new_category").style.display="none";
		 }
 	 	 command="<?php echo tep_href_link($file_name);?>?cID="+cID+"&pID="+pID;
 	 	 	if(action_type=='new_category' || action_type=='edit_category')
 	 	 		command+="&action=update_category"; 	 	 	
 	 	 	if(action_type=='delete_category' || action_type=='move_category') 
 	 	 		command+="&action="+action_type+"_confirm";			 	 	 			
 	 	 	if(action_type=='new' || action_type=='edit')
				command+="&action=update_product";
		 	if(action_type=='delete' || action_type=='copy' || action_type=='move' || action_type=='attrib')
				command+="&action="+action_type+"_confirm";
		if(command!=""){ 
			do_post_command('new_product',command);
		    if((action_type=='new' || action_type=='edit') && document.getElementById("actions") && document.getElementById("actions").value!="" && document.getElementById("new_category")) document.getElementById("new_category").innerHTML=""; 				
			return false;	
		}
	}						
 function expand_category(id,category,category_id,book_id){ 
 	if(category==1 ){ 
	document.getElementById('img_new').firstChild.src=document.getElementById('img_new').firstChild.src.replace('_hover.gif','.gif');
	}
		var res_display=document.getElementById("res_display");
		if(document.getElementById("image_type")) document.getElementById("image_type").value='';
		var chk_cid=document.getElementById("cPath");
		
		var chk_pid=document.getElementById("product_id");
		if(id==0 && category==2 &&  chk_cid && chk_cid.value>0){
		 id=chk_cid.value;
		}
		
		if(category>=3 && category<=5  && chk_cid && chk_pid && document.getElementById("data_"+chk_pid.value+"_"+chk_cid.value) && document.getElementById("head_"+chk_pid.value+"_"+chk_cid.value)) {			
			document.getElementById("data_"+chk_pid.value+"_"+chk_cid.value).style.display="";
			document.getElementById("head_"+chk_pid.value+"_"+chk_cid.value).style.display="none";	
		}
		//if(category_id>0 && category==1 && chk_cid && chk_cid.value!=category_id) toggle_category_panel(chk_cid.value,1,true);						
		var c_obj=document.getElementById("cPath");
 	 	if(category_id>0 && document.new_product && document.new_product.product_id){			
			var old_ids=document.new_product.product_id.value;
			if(c_obj) var old_cate_id=c_obj.value;
			var pre_data_id=document.getElementById("data_"+old_ids+"_"+old_cate_id);
			var pre_head=document.getElementById("head_"+old_ids+"_"+old_cate_id);						 		
			if(category!=11 && document.getElementById("span_details_"+category_id)) {				
				document.getElementById("span_details_"+category_id).innerHTML="";
				if(document.getElementById("img_save_"+category_id)) document.getElementById("img_save_"+category_id).style.display="none";
			}
			var loadings=document.getElementById("loading");
			if(loadings) loadings.style.display="none";
			if(category_id>0 && category==1 && pre_head && pre_head.innerHTML!='') pre_head.innerHTML="";									
		}
		if(category_id>0 && id>0 && document.new_product && document.new_product.product_id && document.new_product.product_id.value=="") document.new_product.product_id.value=id;
		else if(id>0 && (category>=2 || category<=5) && document.new_product && c_obj && c_obj.value=="") c_obj.value=id;
			if(category_id>0 && id>0 && document.new_product.product_id.value>0 && document.new_product.product_id.value!=id){
			   var head=document.getElementById("head_"+id+"_"+old_cate_id);
			   if(head && head.style.display=="") head.style.display="none";
			   if(category!=12 &&  category!=13 && pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="";
			   document.new_product.product_id.value=id;
		}
		if(c_obj && category_id>0 && category<12 || category>15) c_obj.value=category_id;
		if(!category_id && document.getElementById("span_details_"+id)) {
			var img_div=document.getElementById("img_save_"+id);
			document.getElementById("span_details_"+id).innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";
		}
 	 	if(category){
 	 		if(!category_id && c_obj) var cid=c_obj.value;
 	 		var span_details=document.getElementById("span_details");
			var data_id=document.getElementById("data_"+id+"_"+category_id);
			var head=document.getElementById("head_"+id+"_"+category_id);
			var action_type=document.getElementById("action_type");
			var img_save=document.getElementById("img_save");
			var img_new=document.getElementById("img_new");
			if(span_details && category_id>0 && category<12 || category>15) span_details.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";								   						
 	 		if(category>=2 && category<=5) if(img_div) img_div.style.display=""; 	 		
 	 		if(img_new && category>=3 && category<=5){ 
 	 			img_new.href="javascript:expand_category("+id+",2);";
 	 			if(document.getElementById("link_category")) document.getElementById("link_category").href="javascript:expand_category("+id+",2);";
 	 		}if(img_new && (category==1 && category_id>0) || category>=6 && category<=10 && category==11 || category==14 || category==15 ){ 	 			
 	 			img_new.href="javascript:expand_category("+id+",6,"+category_id+");";
 	 			if(document.getElementById("link_product")) document.getElementById("link_product").href="javascript:expand_category("+id+",6,"+category_id+");";
			}
 	 		switch(category){ 
 	 			case 1:  	 				 			   	 			   	 			 	  	 			
					if(document.getElementById('image_type')) document.getElementById('image_type').value="true";
					var tr1=document.getElementById("img_ids");
					var imgsrc;
					var node;
					if(tr1)
					for(var j=0;j<tr1.cells.length;j++){
						td=tr1.cells[j];
						imgsrc='';
						for(var i=0;i<td.childNodes.length;i++){
							node=td.childNodes[i];
							if(node.tagName=='IMG'){
								imgsrc=node.src;
								if(imgsrc==img_src+'template/img_edit_hover.gif')
								   td.childNodes[i].src = img_src+'template/img_edit.gif';
								else if(imgsrc==img_src+'template/img_trash_hover.gif')
								   td.childNodes[i].src = img_src+'template/img_trash.gif';
								else if(imgsrc==img_src+'template/img_copy_hover.gif')
								   td.childNodes[i].src = img_src+'template/img_copy.gif';
								else if(imgsrc==img_src+'template/img_move_hover.gif')
								   td.childNodes[i].src = img_src+'template/img_move.gif';
								else if(imgsrc==img_src+'template/img_attrib_hover.gif')
								   td.childNodes[i].src = img_src+'template/img_attrib.gif';
								break;
							}
						}
					}
				 if(head && span_details){ 	 			 	 	 			    	 			    	 			    	 			   
 	 			   if(head.style.display==""){ 	 			   	   	 			   	   	 			   	   	 			   	   	 			   	  
 	 			   	  if(span_details.style.display==""){
 	 			   	    head.style.display="none";
 	 			   	  	data_id.style.display="";
 	 			   	  }else 
 	 			   	  	span_details.style.display="";												 	 			   	   	 			   	  	 			   	  	
 	 			   }else {
	 	 			 	if(head) head.style.display=="";
	 	 			 	if(pre_data_id && pre_data_id.style.display=="none") pre_data_id.style.display="none";	 	 			 			 	 	 			  	 		 	 		 	 			 		 	 			 	
	 	 			 	if(!category_id) {
	 	 			 		if(img_div) img_div.style.display="none";
	 	 			 		command="<?php echo tep_href_link($file_name,'action=get_category_details');?>&cID="+cid;
	 	 			 	}else command="<?php echo tep_href_link($file_name,'action=get_details');?>&pID="+id+"&cID="+category_id;		 	 			 	
 	 			   }
 	 			 }else {
 	 			 	if(pre_head && pre_head.style.display=="") pre_head.style.display="none"; 	 			 	
 	 			 	if(data_id && data_id.style.display=="")   data_id.style.display="none";
 	 			 	if(head) {
 	 			 	 	head.style.display=""; 	 			 	 	 	 			 	  	 			
 	 			 		head.innerHTML="<img src='images/24-1.gif' alt='Loading...' title='Loading...'>";	 			 		
 	 			 	} 	 			 	 				
					if(!category_id) {
						if(img_div) img_div.style.display="none";
						command="<?php echo tep_href_link($file_name,'command=fetch_sub_list');?>&show_order=AN&cID="+cid;
					}else command="<?php echo tep_href_link($file_name,'action=get_details');?>&pID="+id+"&cID="+category_id;						
 	 			 }
 	 			break;
 	 			case 2: 	 				 	 				 	 			 	 					 	 					
 	 					if(action_type) action_type.value='new_category'; 	 					  	 			
 	 					if(cid && document.getElementById("img_save_"+cid)) document.getElementById("img_save_"+cid).style.display="";	
						if(span_details) span_details.style.display='none';
 	 					command="<?php echo tep_href_link($file_name,'action=edit_category');?>&chk_ID="+cid; 	
 	 			break; 	 			
 	 			case 3:	 	 				 	 				
 	 					if(action_type) action_type.value='edit_category'; 	 					 	 					 	 				
 	 					command="<?php echo tep_href_link($file_name,'action=edit_category');?>&cID="+id; 
 	 			break;
 	 			case 4:	 	 				 	 				
 	 					if(action_type) action_type.value='delete_category'; 	 					 	 		 	 				 	 					 	 					
 	 					command="<?php echo tep_href_link($file_name,'action=delete_category');?>&cID="+id; 	 	 	 					 	 			
 	 			break;
				case 5:	 	 				 	 				 	 					
 	 					if(action_type) action_type.value='move_category'; 	 					
 	 					command="<?php echo tep_href_link($file_name,'action=move_category');?>&cID="+id; 	 	 	 					 	 			
 	 			break;
 	 			case 6:
 	 					if(!category_id && document.getElementById("cPath"))
 	 						category_id=document.getElementById("cPath").value;
 	 					if(action_type) action_type.value='new';
 						command="<?php echo tep_href_link($file_name,'action=edit_product');?>&cID="+category_id;
				break; 	 			 	 	
 	 			case 7:	 	 				 	 				
 	 					if(action_type) action_type.value='edit';
 	 					command="<?php echo tep_href_link($file_name,'action=edit_product');?>&pID="+id+"&cID="+category_id; 	 	 	 					 	 			
				break;
 	 			case 8:	 	 				 	 				
 	 					if(action_type) action_type.value='delete';
 	 					command="<?php echo tep_href_link($file_name,'action=delete_product');?>&pID="+id+"&cID="+category_id;
 	 			break;
 	 			case 9:	 	 				 	 				
 	 					if(action_type) action_type.value='copy';
 	 					command="<?php echo tep_href_link($file_name,'action=copy_product');?>&pID="+id+"&cID="+category_id; 	 	 	 					 	 			
 	 			break;
 	 			case 10:	 	 				 	 				
 	 					if(action_type) action_type.value='move';
 	 					command="<?php echo tep_href_link($file_name,'action=move_product');?>&pID="+id+"&cID="+category_id; 	 	 	 					 	 			
 	 			break;									
				case 11:										
					if(action_type) action_type.value='attrib';
 	 					command="<?php echo tep_href_link($file_name,'action=attrib');?>&pID="+id+"&cID="+category_id;
				break;
				case 12:
				case 13:
					var s_order=document.new_product.sort_order;
					if(document.new_product.cPath) var cat_id=document.new_product.cPath.value;
					if(head) var tbl_tr_obj=head.parentNode.parentNode;																									
					var pos_cnt=0;																																	
					pos="pos_up";
					if(category==8) pos="pos_down";
					command="<?php echo tep_href_link($file_name);?>?pID="+id+"&pos="+category_id+"&action="+pos+"&cPath="+cat_id;					
					if(s_order) s_order.value=pos;
					if(tbl_tr_obj && (tbl_tr_obj.rowIndex==0 && pos=='pos_up' || tbl_tr_obj.parentNode.rows.length==tbl_tr_obj.rowIndex+1 && pos=='pos_down')) return;
				break;
				case 14:
					if(img_src && id){ 	 					 	 					
 	 					if(c_obj) cat_id=c_obj.value; 	 					
 	 					var data_id=document.getElementById("data_"+category_id+"_"+cat_id); 	 					 	 					
 	 					if(data_id) var img=data_id.childNodes[0]; 	 					 	 				
 	 					if(img_src+"template/icon_active.gif"==id.src){
 	 						img.src=id.src=img_src+"template/icon_inactive.gif"; 	 						 	 						
 	 						command="<?php echo tep_href_link($file_name,'action=setflag');?>&pID="+category_id+"&flag=0";
 	 					}else if(img_src+"template/icon_inactive.gif"==id.src){
 	 						img.src=id.src=img_src+"template/icon_active.gif";
 	 						command="<?php echo tep_href_link($file_name,'action=setflag');?>&pID="+category_id+"&flag=1";
 	 					} 	 						
 	 				}
				break;	
				case 15:
					location.href="<?php echo tep_href_link(FILENAME_SESSIONS);?>"+ "?ecPath=" +category_id+"&eID="+id;
				return;			
 	 		}
 	 		if(command!="") {
				do_get_command(command);
			}
 	 	}
	  }
	  
	  function print_details(category,result){ 
 	 	var no_result="";
 	 	if(result.substr(0,15)=='No Record Found'){
 	 		no_result="No Record Found";
 	 	}else if(result!='' && result.length>0 && category!='edit' && result.substr(0,15)!='No Record Found'){ 	 		 	 		
			splt_str=result.split("{}");
 	 		var  categories_id="";
 	 		var  categories_name=""; 	 		 								 	 		
 	 		var  product_id="";
			var  product_name="";
			var  product_description="";
			var  product_quantity="";
			var  product_price="";
			var  product_date_added="";
			var  product_last_modified="";		
			var  product_status="";			
			var  product_image="";			
			var  sort_order="";
			var  product_date_available="";											
						
 	 		categories_id=splt_str[0];
 	 		categories_name=splt_str[1]; 		
 	 		product_id=splt_str[2];
			product_name=splt_str[3];
			product_description=splt_str[4];
			product_quantity=splt_str[5];
			product_price=splt_str[6];
			product_date_added=splt_str[7];
			product_last_modified=splt_str[8];
			product_status=splt_str[9];
			product_image=splt_str[10];
			sort_order=splt_str[11];
			product_date_available=splt_str[12];
 	 	}
 	 	var c_obj=document.getElementById("cPath");
 		if(document.new_product && document.new_product.product_id) var id=document.new_product.product_id.value;
 		if(document.new_product && c_obj) var category_id=c_obj.value;
 		var span_details=document.getElementById("span_details");
 		var head=document.getElementById("head_"+id+"_"+category_id);
 		var data_id=document.getElementById("data_"+id+"_"+category_id);
 		var res_display=document.getElementById("res_display");
		var img_save=document.getElementById("img_save");
		//if(img_save && category!='get_details') img_save.style.display="";
		if(c_obj) category_id=c_obj.value;
		var require_image=product_image;		
		if("<?php echo $file_name;?>"=='products_mainpage.php') require_image='small/'+product_image;
 	 	switch(category){
 	 		case 'get_details':
 	 		if(head  && no_result!="")
				head.innerHTML=no_result;
 	 		else if(head && no_result==""){  
	 	 		if(head && data_id)	{
					head.style.display="";
					data_id.style.display="none";
				}
				if(data_id) data_id.innerHTML='<img src="images/template/'+((product_status==0)?'icon_inactive.gif':'icon_active.gif')+'" alt="" border="0"><img src="images/pixel_trans.gif" alt="" border="0" height="10" width="5">'+product_name;
				head.innerHTML="<table width='100%' border='0' cellspacing='0' cellpadding='0' class='openContent'>"+
				"<tr heigth='40' class='openContent_top'>"+
				  "<td width='10'></td>"+
				  "<td width='20' valign='middle' align='center'><img onclick='javascript:expand_category(this,14,"+product_id+");' src='images/template/"+((product_status==0)?"icon_inactive.gif":"icon_active.gif")+"'></td>"+
				  "<td width='40' valign='middle' align='center'>"+((sort_order!="")?"<a href='javascript:expand_category("+product_id+",12,"+sort_order+");'><img alt='Up' title='Up' border='0' src='images/template/img_arrow_up.gif'></a>&nbsp;<a href='javascript:expand_category("+product_id+",13,"+sort_order+");'><img alt='Down' title='Down' border='0' src='images/template/img_arrow_down.gif'></a>":"")+"</td>"+
				  "<td align='left' valign='middle' width='350' class='main'>"+product_name+"</td>"+
				  "<td width='470' align='left' class='main' valign='top'>"+
				  	"<table border='0' cellspacing='0' cellpadding='0' style='height:30px;display:inline;position:relative;'>"+
				  	 "<tr class='img_move' id='img_ids'>"+
						 "<td class='cell_bg_popm_left' width='10'>&nbsp;</td>"+
						 (("<?php echo $file_name;?>"=="events_mainpage.php")?"<td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category("+product_id+",15,"+category_id+");'><img alt='Sessions' title='Sessions' id='img_move' src='images/template/img_message.gif'></td>":"")+
						 "<td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category("+product_id+",7,"+category_id+");'><img alt='Edit' title='Edit' src='images/template/img_edit.gif'></td>"+
						 "<td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category("+product_id+",8,"+category_id+");'><img alt='Delete' title='Delete' src='images/template/img_trash.gif'></td>"+
						 "<td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category("+product_id+",9,"+category_id+");'><img alt='Copy' title='Copy' id='img_copy' src='images/template/img_copy.gif'></td>"+					
						 "<td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category("+product_id+",10,"+category_id+");'><img alt='Move' title='Move' id='img_move' src='images/template/img_move.gif'></td>"+
						 "<td width='10%' onmouseover='javascript:change_class(this,2);' onmouseout='javascript:change_class(this,3);' onclick='javascript:change_class(this,1);expand_category("+product_id+",11,"+category_id+");'>"+((attrib_icon)?"<img alt='Attributes' title='Attributes' id='img_attributes' src='images/template/img_attrib.gif'>":"")+"</td>"+						 					 
						 "<td class='cell_bg_popm_right' width='10'>&nbsp;</td>"+
				  	 "</tr>"+
				  	"</table>"+
				  "</td>"+
				  "<td width='240' align='right' id='img_save' style='display:none'>"+
					  "<input type='image' id='product_save_button_"+product_id+"' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;"+
					  "<a href='javascript:expand_category("+product_id+",1,"+category_id+")'><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;"+
				  "</td>"+
				"</tr>"+
				"<tr style='height:10'><td id='loading' style='display:none' colspan='5'><img src='images/24-1.gif' alt='Loading...' title='Loading...'></td></tr>"+				
				"<tr>"+
				  "<td colspan='8' class='main'><span id='span_details'>"+
				  	"<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+
				  		"<tr>"+
				  			"<td width='50'>&nbsp;</td>"+
				  			"<td width='130' valign='top' align='left'><img src='../images/"+require_image+"' border='0' width='100'></td>"+
				  			"<td width='300' valign='top'>"+
				  				"<table width='100%' border='0' cellspacing='5' cellpadding='0' class='main'>"+
				  					"<tr>"+
				  						"<td align='left' nowrap='nowrap' width='50%' valign='top'><?php echo TEXT_DATE_ADDED;?></td>"+
				  						"<td align='left' nowrap='nowrap' width='50%' valign='top'>"+product_date_added+"</td>"+
				  					"</tr>"+
				  					"<tr>"+
				  						"<td align='left' nowrap='nowrap' width='50%'><?php echo TEXT_LAST_MODIFIED;?></td>"+
				  						"<td align='left' nowrap='nowrap' width='50%'>"+product_last_modified+"</td>"+
				  					"</tr>"+
				  					((product_quantity>0)?"<tr>"+
				  						"<td align='left' width='50%' nowrap='true'><?php echo TEXT_QUANTITY;?></td>"+
				  						"<td align='left' width='50%' nowrap='true'>"+product_quantity+"</td>":"")+
				  					"</tr>"+
				  					"<tr>"+
				  						"<td align='left' width='50%' nowrap='true'><?php echo TEXT_PRODUCTS_PRICE_INFO;?></td>"+
				  						"<td align='left' width='50%' nowrap='true'>"+product_price+"</td>"+
				  					"</tr>"+
				  				"</table>"+
				  			"</td>"+
				  			"<td align='left' valign='top' class='main'><div style='width:100%;height:100;overflow:auto;'>"+
				  			  	product_description	+		  			  
				  			"</div></td>"+			  			
				  		"</tr><tr><td colspan='8'><img src='images/pixel_trans.gif' border='0' alt='' width='100%' height='20'></td></tr>"+							  			  		
				  	"</table></span>"+			  			  		
				  "</td>"+
			"</table>";			
			 if(document.getElementById('action_type')) document.getElementById('action_type').value="";
			 block_time=false;
 	 		} 	 	
 	 	break;
 	 	case 'delete_success':			  	    	  	    	
			 if(head && data_id) {
			 	var tbl_obj=head.parentNode.parentNode.parentNode.parentNode;			 				 				 	
			 	if(tbl_obj) tbl_obj.deleteRow(head.parentNode.parentNode.rowIndex);
			 	data_id.innerHTML=head.innerHTML="";
			 	data_id.style.display=head.style.display="none";			 		
			 }			 				
			 if(res_display){ 	    	 	
 	    	 	res_display.innerHTML="<?php echo TEXT_PRODUCT_DELETED_SUCCESS;?>";
 	    	 	res_display.style.display="";
 	    	 }
			 if(result !='' && result > 0){
				 toggle_category_panel(result,0,true);
				 toggle_category_panel(result,1,true);
			 }
 	 	break;		
		case 'attrib_success':
			 if(res_display){
 	    	 	res_display.style.display=""; 	    	 	
 	    	 	res_display.innerHTML="<?php echo TEXT_PRODUCT_ATTRIB_MOVED_SUCCESS;?>"; 	    	 	 	    	 	
 	    	 	if(head && data_id) {
 	    	 		head.style.display="none";
 	    	 		data_id.style.display="";
 	    	 	} 	    	 	 
 	    	 }
		break;	 
 	 	case 'copy_error':
 	 	case 'copy_success': 	 		 
 	    	 if(res_display){ 	    	 	
 	    	 	var res="";
 	    	 	if(category=='copy_error') {
 	    	 		res_display.style.display=""; 	    	 		
 	    	 		res_display.innerHTML="<?php echo ERROR_CANNOT_LINK_TO_SAME_PRODUCT_CATEGORY;?>";
 	    	 	}else if(category=='copy_success') { 	    	 		 	    	 		 	    	 		 
 	    	 		res_display.innerHTML="<?php echo TEXT_PRODUCT_COPIED_SUCCESS;?>";
 	    	 		res_display.style.display=""; 	    	 			  	 		    
	  	 		    if(result==category_id){
	  	 		    	toggle_category_panel(result,0,true);	  	 		    	  	 		    	  	 		    	  	 		    
	  	 		    	toggle_category_panel(result,1,true);
	  	 		    }else
	  	 		    	toggle_category_panel(result,0);	  	 		    	  	 		    	  	 		    	  	 		    	  	 		    	
	  	 		    
 	    	 	}  	    	 	
 	    	 	if(head && data_id) {
 	    	 		head.style.display="none";
 	    	 		data_id.style.display="";
 	    	 	} 	    	 	 
 	    	 }
 	 	break;
 	    case 'move_success': 	    	 	    	  	    	 
 	    	 if(res_display){ 	    	 	 	    	 	
 	    	 	toggle_category_panel(result,0,true);	  	 		    	  	 		    	  	 		    	  	 		    
	  	 		toggle_category_panel(result,1,true);
 	    	 	if(result!=category_id){	  	 		
	  	 		    toggle_category_panel(category_id,0,true);
	  	 		    toggle_category_panel(result,0);
 	    	 	}
 	    	 	res_display.innerHTML="<?php echo TEXT_PRODUCT_MOVED_SUCCESS;?>";
 	    	 	res_display.style.display=""; 	    	 	
 	    	 } 	    	 
 	    break; 	    			
		case 'sort_order_success':
		case 'sort_order_error':
			if(document.new_product.sort_order) var s_order=document.new_product.sort_order.value;															
			if(category=='sort_order_success'){			  			   
			   if(head)  {
				var tbl_obj=head.parentNode.parentNode;
				var up_href=head.childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[0];
			    var down_href=head.childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[2];			    
			    var new_pos=result.substr(result.indexOf('sort_order_success'));			    
			    if(up_href && down_href && new_pos){
					up_href.href="javascript:expand_category("+id+",12,"+new_pos+")";
					down_href.href="javascript:expand_category("+id+",13,"+new_pos+")";
			    }
				var x=1;
				if(s_order && s_order!="" && s_order=="pos_up") x=-1;								
				var row=tbl_obj;
				var index=row.rowIndex;
				var count=tbl_obj.parentNode.rows.length;				
				if (x==-1 && index==0) return;
				if (x==1 && index==count-1) return;
				if (x==-1){
				   row.parentNode.insertBefore(row,row.parentNode.rows[index-1]);
				} else {
					if (index==row.parentNode.rows.length-2)
						row.parentNode.appendChild(row);
					else
						row.parentNode.insertBefore(row,row.parentNode.rows[index+2]);
				}																 							
  		      }			   			   					            	            	      		               	      	    	 	 			  
			}else if(category=='sort_order_error'){
				res_display.style.display=""; 	    	 	
			    res_display.innerHTML="<?php echo ERROR_IN_DATABASE_TRY_AGAIN;?>"; 	    	 	 	    	 	 	    	 	 	    	 	 
			}
		break;		
		case 'new_product':						
			var pID=0;
			if(document.getElementById("product_id")) pID=document.getElementById("product_id").value;
			if(categories_id){
				if(document.getElementById("id_product_list_"+categories_id)){
					var tab_obj=document.getElementById("id_product_list_"+categories_id);
					var row=tab_obj.insertRow(tab_obj.rows.length);
					var row_cell=row.insertCell(0);
					row_cell.innerHTML='<div id="data_'+product_id+'_'+categories_id+'"><img src="images/template/'+((product_status==0)?'icon_inactive.gif':'icon_active.gif')+'" border="0"><img src="images/pixel_trans.gif" alt="" border="0" height="10" width="5">'+product_name+'</div><div class="openContent" id="head_'+product_id+'_'+categories_id+'" style="display: none;"></div>';												
				}
				if(row){
					row.onclick=function () {((document.getElementById("head_"+product_id+"_"+categories_id) && document.getElementById("head_"+product_id+"_"+categories_id).style.display=='none')?expand_category(product_id,1,categories_id):'')};
					row.style.height="15px";
					if(row.rowIndex%2==0) row.className="dataTableRowOdd";
					else row.className="dataTableRowEven";
					row.onmouseover=function (){rowOverEffect(this)};
					row.onmouseout=function (){rowOutEffect(this)};
				}
				if(res_display){
		    	 	res_display.innerHTML="<?php echo TEXT_PRODUCT_INSERTED_SUCCESS;?>";
	 	    	 	res_display.style.display=""; 	    	 	
 				}
			}
			if(!document.getElementById("data_"+pID+"_"+categories_id)) expand_category(categories_id,1);
			else expand_category(pID,1,categories_id);
		break;
		case 'copy_details':			
			if(result=='copy_success') result="<?php echo TEXT_PRODUCT_COPIED_SUCCESS;?>";
			if(res_display){							
				res_display.innerHTML=result;
				res_display.style.display="";
			}
		break;
		case 'new_main_category':
		case 'new_category': 
			if(result!="") result_splt=result.split('{}');
			if(document.getElementById("new_category")) document.getElementById("new_category").style.display="none";
			//if(document.getElementById("img_new_hove")) document.getElementById("new_category").style.display="none";
			//var img_get_src=this.childNodes[0];	
			var img_ids = document.getElementById('img_ids');
			
			var p_id="";
			var c_name="";
			var c_id="";
			if(result_splt[0]) p_id=result_splt[0];
			if(result_splt[1]) c_name=result_splt[1];
			if(result_splt[2]) c_id=result_splt[2];		
			var tbl_obj=document.getElementById("search_result_details").childNodes[0];
			if(document.getElementById("search_result_details").childNodes.length>1) tbl_obj=document.getElementById("search_result_details").childNodes[1];
			if(category=='new_category' && c_id>0){
				var tbl_obj=document.getElementById("parent_"+c_id);
				var tbl_obj=document.getElementById("tr_id_"+c_id).parentNode;
				if(document.getElementById("span_details_"+c_id)) document.getElementById("span_details_"+c_id).innerHTML="";
				toggle_category_panel(c_id,0,true);
				toggle_category_panel(c_id,1,true);
				return;	
			}
			var row_obj=tbl_obj.insertRow(tbl_obj.rows.length);	
			var row_cell=row_obj.insertCell(0);		
				row_cell.innerHTML='<table id="parent_'+p_id+'" border="0" cellpadding="10" cellspacing="0" width="100%">'+
				'<tr id="tr_id_'+p_id+'">'+
				'<td valign="top">'+
				'<input id="panel_'+p_id+'_pgno" value="1" type="hidden">'+
				'<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
					'<tbody><tr height="20">'+
					'<td>'+
					'<table border="0" cellpadding="0" cellspacing="0" width="100%">'+
						'<tbody><tr>'+
							'<td class="contentTitle1" style="cursor: pointer;" onclick="javascript:toggle_category_panel('+p_id+',1);"><span id="span_category_'+p_id+'" style="background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; padding-right: 5px;">'+c_name+'</span></td><td align="right" width="15"><a href="javascript:toggle_category_panel('+p_id+',0);"><img src="images/template/panel_down.gif" id="panel_'+p_id+'_img" border="0"></a></td>'+
						'</tr>'+
					'</tbody></table>'+
					'</td>'+
				'</tr><tr height="5"><td></td>'+
				'</tr><tr><td style="padding-left: 15px;">'+
				'<div id="panel_'+p_id+'_content" style="display: none;"></div>'+				
				'</td></tr></tbody></table></td></tr></table>';
				if(category=='new_main_category' && category_id>0) toggle_category_panel(category_id,0,true);
				expand_category(0,1);
		break;
		case 'edit_category':
			if(result!=""){
				result_splt=result.split("{}");
				if(result_splt[0] && document.getElementById("span_category_"+result_splt[0])) {
					document.getElementById("span_category_"+result_splt[0]).innerHTML=result_splt[1];	
				}
					if(result_splt[2]!="" && document.getElementById("span_details_"+result_splt[0])){
						document.getElementById("span_details_"+result_splt[0]).innerHTML=result_splt[2];
						if(document.getElementById("img_save_"+result_splt[0])){
							var obj=document.getElementById("img_save_"+result_splt[0]).parentNode;							
							//obj.childNodes[3].innerHTML=result_splt[1];
							document.getElementById("img_save_"+result_splt[0]).style.display="none";
						
							var tr1=document.getElementById("img_ids");
							if(document.getElementById("image_type")) document.getElementById("image_type").value="true";
							var imgsrc;
							var node;
							if(tr1)
							for(var j=0;j<tr1.cells.length;j++){
								td=tr1.cells[j];
								imgsrc='';
								for(var i=0;i<td.childNodes.length;i++){
									node=td.childNodes[i];
									if(node.tagName=='IMG'){
										imgsrc=node.src;
										if(imgsrc==img_src+'template/img_edit_hover.gif')
										   td.childNodes[i].src = img_src+'template/img_edit.gif';
										else if(imgsrc==img_src+'template/img_trash_hover.gif')
										   td.childNodes[i].src = img_src+'template/img_trash.gif';
										else if(imgsrc==img_src+'template/img_copy_hover.gif')
										   td.childNodes[i].src = img_src+'template/img_copy.gif';
										else if(imgsrc==img_src+'template/img_move_hover.gif')
										   td.childNodes[i].src = img_src+'template/img_move.gif';
										else if(imgsrc==img_src+'template/img_attrib_hover.gif')
										   td.childNodes[i].src = img_src+'template/img_attrib.gif';
										break;
									}
								}
							}
						}
					}
				}
			
			
		break;
		case 'delete_category_success':
			if(result!=""){
				if(document.getElementById("tr_id_"+result)){
					var tbl_obj=document.getElementById("tr_id_"+result).parentNode;															 				 				 				
					if(tbl_obj && result>0 && document.getElementById("tr_id_"+result)) tbl_obj.deleteRow(document.getElementById("tr_id_"+result).rowIndex);
				}
			 	if(res_display){
 	    	 		res_display.innerHTML="<?php echo TEXT_CATEGORY_DELETED_SUCCESS;?>";
 	    	 		res_display.style.display="";
 	    	 	}	
			}
		break;
		case 'move_category_success':
 			if(result!=""){
			 	var category_id=0;
			 	if(c_obj) category_id=c_obj.value;
			 	var tbl_obj=document.getElementById("tr_id_"+category_id).parentNode;
				if(tbl_obj) tbl_obj.deleteRow(document.getElementById("tr_id_"+category_id).rowIndex);								
 	    	 	if(result!==category_id){
	  	 		    toggle_category_panel(category_id,0,true);
	  	 		    toggle_category_panel(result,0);
 	    	 	}
			 	if(res_display){ 	    	 	
 	    	 		res_display.innerHTML="<?php echo TEXT_CATEGORY_MOVED_SUCCESS;?>";
 	    	 		res_display.style.display="";
 	    	 	}	
			}
		break;
		
		case 'move_category_failure':
 			if(result!=""){
			 	var category_id=0;
			 	if(c_obj) category_id=c_obj.value;
			 	var tbl_obj=document.getElementById("tr_id_"+category_id).parentNode;
				if(tbl_obj) tbl_obj.deleteRow(document.getElementById("tr_id_"+category_id).rowIndex);								
 	    	 	if(result!==category_id){
	  	 		    toggle_category_panel(category_id,0,true);
	  	 		    toggle_category_panel(result,0);
 	    	 	}
			 	if(res_display){ 	    	 	
 	    	 		res_display.innerHTML="<?php echo ((defined('ERROR_CANNOT_MOVE_EVENTS_CATEGORY_TO_PARENT'))?ERROR_CANNOT_MOVE_EVENTS_CATEGORY_TO_PARENT:ERROR_CANNOT_MOVE_SUBSCRIPTION_CATEGORY_TO_PARENT); ?>";
 	    	 		res_display.style.display="";
 	    	 	}
			    location.href='<?php echo ((defined('ERROR_CANNOT_MOVE_EVENTS_CATEGORY_TO_PARENT'))?FILENAME_EVENTS_MAINPAGE:FILENAME_SUBSCRIPTIONS_MAINPAGE); ?>';
			}
		break;
		
		case 'update_blocked_detail':
			var res_array=result.split('{}');
			document.getElementById('show_details_'+selected_book_id).innerHTML=res_array[0];
			select_rec_details(res_array[1],res_array[2]);
		break;
		case 'blocked_detail':
			document.getElementById('show_details').innerHTML=result;
			open_divs('D');
		break;	
		case 'add_new_blocked_detail':
			document.getElementById('show_details').innerHTML=result;
			open_divs('D');
		break;	
		case 'save_new_blocked_detail':
			document.getElementById('show_details').style.display="none";
			get_booking_list(result);
			action_flag="";
		break;
		case 'save_blocked_detail':
			document.getElementById('show_details').style.display="none";
			document.getElementById('ajax_details').innerHTML=result;
		break;
		case 'delete_blocked_detail':
			document.getElementById('show_details_'+selected_book_id).innerHTML=result;
		break;
		case 'confirm_delete_blocked_detail':
			selected_book_id="";
			document.getElementById('show_details_'+selected_book_id).style.display='none';
			document.getElementById('ajax_details').innerHTML=result;
		break;	
 	 	} 	 	
		if(document.getElementById('res_display') && document.getElementById('res_display').style.display=="") setTimeout("document.getElementById('res_display').style.display='none'",2500);
 	 	clearTimeout();		
	  } 
   function change_class(obj,eve){ 		
		 	var action_type=""; 
			var img_get_src=obj.childNodes[0];					
		 	var img_type="";
			if(document.getElementById("action_type")) action_type=document.getElementById("action_type").value;		 			 		   		    		    
		   
		    if(document.getElementById("image_type").value=='true'){
			action_type='';
			}			
			
			var ret_type=false;
			var img_ids = document.getElementById('img_ids');
			if(img_get_src){
				if(img_get_src.src==img_src+'template/img_new.gif') { 
					if((action_type=="edit" || action_type=="new_category") && eve==1 || eve==2)
				 		img_get_src.src=img_src+'template/img_new_hover.gif';
		    	}else if(eve==3 && img_get_src.src==img_src+'template/img_new_hover.gif'){ 	
					if(action_type=="edit" || action_type=="new_category") return;
					else img_get_src.src=img_src+'template/img_new.gif';
				}	
				if(img_get_src.src==img_src+'template/img_edit.gif') {
					if((action_type=="edit" || action_type=="edit_category") && 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'){ 	
					if(action_type=="edit" || action_type=="edit_category") return;
					else img_get_src.src=img_src+'template/img_edit.gif';
				}
				if(img_get_src.src==img_src+'template/img_trash.gif') {
					if((action_type=="delete" || action_type=="delete_category") && 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'){ 				
					if(action_type=="delete" || action_type=="delete_category") return;
					else img_get_src.src=img_src+'template/img_trash.gif';
				}				
				if(img_get_src.src==img_src+'template/img_copy.gif') {
					if(action_type=="copy" && eve==1 || eve==2)
				 		img_get_src.src=img_src+'template/img_copy_hover.gif';					
		    	}else if(eve==3 && img_get_src.src==img_src+'template/img_copy_hover.gif'){ 				
					if(action_type=="copy") return;
					else img_get_src.src=img_src+'template/img_copy.gif';
				}
				if(img_get_src.src==img_src+'template/img_attrib.gif') {
					if(action_type=="attrib" && eve==1 || eve==2)
				 		img_get_src.src=img_src+'template/img_attrib_hover.gif';
		    	}else if(eve==3 && img_get_src.src==img_src+'template/img_attrib_hover.gif'){
					if(action_type=="attrib") return;
					else img_get_src.src=img_src+'template/img_attrib.gif';
				}
			    if(img_get_src.src==img_src+'template/img_move.gif') {
					if((action_type=="move" || action_type=="move_category") && eve==1 || eve==2)
				 		img_get_src.src=img_src+'template/img_move_hover.gif';
		    	}else if(eve==3 && img_get_src.src==img_src+'template/img_move_hover.gif'){
					if(action_type=="move" || action_type=="move_category") return;
					else img_get_src.src=img_src+'template/img_move.gif';
				}
		  }		 		 
	  }		
	 function do_close_new_category(){ 
	 	if(document.getElementById("new_category")) document.getElementById("new_category").style.display='none';
		return false;
	 } 	     	 	  	 	  	 	 
	</script>
	
