
Array.prototype.inArray = function(element) {
	//alert(element)
	for (var i in this) { 
		if (this[i] === element) return true; 
	}	
	return false;

}

function getTranslationValues(mat_uid){
	
	 var inputfields = document.getElementsByName("titel_beschreibung");  
	  
	   var fields_per_row = 2;
	   var filter_number = new RegExp("\\d+", "g");
	   var jsons = new Array();
	   var collect_next_fields = new Array();
	   var  json_string = "";
	  
	   if(inputfields.length > 0){
		   for (i = 0, j = 1, k = 1; i<inputfields.length; i++, j++) {			   
					   //console.log("j: "+j)
		 			   collect_next_fields.push(inputfields[i]);
			   if(j == 1){
				   if(inputfields[i].id.search(/sylang_uid/) != -1){				   
					   var syslang_uid = inputfields[i].id.match(filter_number);	
				   }// end if
			   }// end if
			   		   
			   
		  	   if(j == fields_per_row){
		  		 //console.log("next id: "+inputfields[i].id);
		  		// console.log("input value 1: "+inputfields[i-1].value);
		  		   //console.log("input value 2: "+inputfields[i].value);
				   //console.log("syslang_uid: "+syslang_uid);		  		   
		  		   j = 0;				   			   
				   if(collect_next_fields[0] != null && collect_next_fields[1] != null){ // Kondition abhängig von der Variable fields_per_row erweitern
					 
					   //solving the double quotes json_escape-Problem
					  //&quot;
					   collect_next_fields[0].value = collect_next_fields[0].value.replace(/"/g,'%26quot;');
					   collect_next_fields[1].value = collect_next_fields[1].value.replace(/"/g,'%26quot;');
					   //console.log(collect_next_fields[0].value);
					   //collect_next_fields[1].value = collect_next_fields[1].value.replace(/"/g,'\\"');
					   json = '{"titel":"'+ collect_next_fields[0].value+'", "beschreibung":"'+collect_next_fields[1].value+'" ,"sys_language_uid":"'+ syslang_uid+'", "mat_id":"'+ mat_uid+'"}';
					   collect_next_fields = new Array();
					   jsons.push(json);
				   }// end if
			   }// end if		  
					
		   }// end for 
	   }// end if
	   json_string = jsons.join(",");
	   //console.log(json_string);
	   return "["+json_string+"]";
	   //return json_string;
	   //console.log(json_string);
	
	
	
}// end function



function openEditDialog(clicked_obj, datenblatt_json){
	
	jQuery('#dialog').dialog("open");
	//alert("line 6");
	//Dialog			
	jQuery('#dialog').dialog({
		//autoOpen: true,
		width: 800,
		title : datenblatt_json["titel_original"]+" - bearbeiten",	
		modal : true,		
		buttons: {
			"Speichern": function() { 
				
			var json = { 
					myArray: [
			      			  {
			      				  'uid': jQuery('#mat_nr').val(),
			      				  'product_pid': pid_
			      			  },
				      
				      		  {
								
			      				  'titel' 	   : jQuery('#mat_titel').val(),
			      				  'beschreibung' : jQuery('#mat_beschreibung').val(),						
			      				  'hersteller' : jQuery('#hersteller_list option:selected').val()
			      				  
			                  
							  },
							  
							  {		
								  'jetsizes' 	   : jQuery('#jetsizes').val(),
								  'pressure_low' : jQuery('#pressure_low').val(),
								  'pressure_high' : jQuery('#pressure_high').val(),
								  'pressure_low_rcmd' : jQuery('#pressure_low_rcmd').val(),
								  'pressure_high_rcmd' : jQuery('#pressure_high_rcmd').val(),								  
								  'material': jQuery('#mat_nr').val()
								  
								  
						      }
							 ],
					translations: [getTranslationValues(jQuery('#mat_nr').val())]
							
							 
							 
							
						  
				         
				};
		          //console.log(JSON.stringify(json));
			$.ajax({
		        type: "POST",
		        url: "index.php?eID=px_satalackdatenblaetter",
		        context: jQuery(this),
		        data: "action=update&json_string="+JSON.stringify(json),
		       
		        dataType: "text",
		        success: function(data, text) {
					
				 //alert(data);
				 sendLDBrequest(actual_hersteller_id,language, branche, page_id, 1);
				 jQuery(this).dialog("close");
										
		       	},
		        error: function(xhr, ajaxOptions, thrownError) {
					
		  		 alert(xhr.status);
		         alert(thrownError);
		         jQuery(this).dialog("close");					 

		         }
		      }); // End ajax method
		
			}, 
			"Abbrechen": function() {
				
				jQuery(this).dialog("close");
				jQuery(this).dialog("destroy");
			} 
		},
		open: function(event, ui) { 
			 // jQuery(this).load('Sample.htm');
			// jQuery(this).load('TEST');
			//alert(datenblatt_json["titel"]);
			
			for (var property in datenblatt_json) {
				if(property = "hersteller_list"){
					var hersteller_array = datenblatt_json[property];
					var hersteller_selectbox = '<select name="hersteller" id="hersteller_list">'// <option >&nbsp;</option>'
					for (var hersteller_id in hersteller_array) {
						//console.log(hersteller_array[hersteller_id]);
						 
						hersteller_selectbox += ' <option value='+hersteller_id+' '+(actual_hersteller_id == hersteller_id? "selected":"")+'>'+hersteller_array[hersteller_id]+'</option>';
						
					}// end for
					hersteller_selectbox +=  '</select>';
				}// end if
			}// end for
			
			var language_tr_rows = "";
			var counter = 0;
			var language_tr_rows1 = '';
			var language_tr_rows1_content = '';
			var language_tr_rows2 = '';
			var language_tr_rows2_content = "";
			var mat_titel = "";
			var mat_beschreibung = "";
			
			var mat_array = new Array();
			var mat_titel_uid_list = new Array();			
			for (var prop in datenblatt_json) {
				if(prop == "mat_language_list"){
					var language_mat_objects = datenblatt_json[prop];
					//console.log("prop: "+prop)
					//alert(datenblatt_json["uid"]);
					
					for (var k in language_mat_objects) {
						
						//console.log("k: "+k);
						//console.log("object k: "+language_mat_objects[k]);
						var language_mat_array = language_mat_objects[k];
						
						//console.log(property);						
						
						for (var props in language_mat_array) {
							//console.log("props: "+props)
							//console.log("props: "+language_mat_array[props])
							mat_array.push(language_mat_array)
						}// end for
						
					}// end for
					
				}// end if
			}// end for
			
			
			
			//console.log("datenblatt[mat_language_list] :"+datenblatt_json['mat_language_list'][0])
			for (var property in datenblatt_json) {
				if(property == "language_list"){
					var language_objects = datenblatt_json[property];
					//alert(datenblatt_json["uid"]);
					for (var key in language_objects) {
						
						//console.log("key: "+key);
						//console.log("object key: "+language_objects[key]);
						var language_array = language_objects[key];
						
						//console.log(property);						
						
						for (var properties in language_array) {				
							
							
							if(properties == "title"){
								
								
								
								sys_lang_title = language_array[properties];
								counter++;
								/*
								console.log("properties: "+properties);
								console.log("language_array properties: "+language_array[properties]);
								console.log("counter: "+counter);
								*/
								//console.log(language_array['mat_uid');
								mat_titel = "";
								mat_beschreibung = "";
								for (var index in mat_array) {
									mat_arr = mat_array[index];
									
									for (var ind in mat_arr) {
										
										if(mat_arr[ind] == datenblatt_json["uid"]){
											if(language_array['uid'] == mat_arr['sys_language_uid']){
												/*
												console.log("ind: "+ind);
												console.log("mat_array uid: "+mat_arr[ind]);
												console.log("mat array titel: "+mat_arr['titel'])
												console.log("mat sys_lang_uid: "+mat_arr['sys_language_uid'])
												console.log("lang_sys_uid: "+language_array['uid'])
												console.log(mat_titel_uid_list.inArray(mat_arr['uid']))
												*/
												if(mat_titel_uid_list.inArray(mat_arr['uid']) == false){
													mat_titel = mat_arr['titel'];
													mat_beschreibung = mat_arr['beschreibung'];
													//solving the double quotes problem in input fields
													mat_titel = mat_titel.replace(/"/g,'&quot;');
													mat_beschreibung = mat_beschreibung.replace(/"/g,'&quot;');
													mat_titel_uid_list.push(mat_arr['uid']);														
												}// end if													
											}// end if
										}// end if
										
										
									}// end for
																		
									//mat_array
								}// end for
								
								
								if(counter == 1){
									
									language_tr_rows1 = '<tr><td>'+(language_array['title']== null ?'':language_array['title'])+'</td><td>&nbsp;</td>';														
									
									language_tr_rows1_content = ' <tr><td><input name="titel_beschreibung" id="sylang_uid_'+language_array['uid']+'" value="'+mat_titel+'"></td>'+
									'<td><input name="titel_beschreibung"  value="'+mat_beschreibung+'"></td>';
								}// end if
								if(counter == 2){
									language_tr_rows2 = '<td>'+(language_array['title']== null?'':language_array['title'])+'</td></tr>';												
									language_tr_rows2_content = '<td><input name="titel_beschreibung" id="sylang_uid_'+language_array['uid']+'" value="'+mat_titel+'"></td>'+
									'<td ><input name="titel_beschreibung"  value="'+mat_beschreibung+'"></td></tr>';
									language_tr_rows += language_tr_rows1 + language_tr_rows2+language_tr_rows1_content+language_tr_rows2_content;									
									counter = 0;
									
								}// end if								
								
							}// end if
							
							
							
						}// end for
					}// end for
					//language_tr_rows +=  '</select>';
				}// end if
			}// end for
			
			//solving the double quotes problem in input fields
			datenblatt_json["titel_original"] = datenblatt_json["titel_original"].replace(/"/g,'&quot;');
			datenblatt_json["beschreibung_original"] = datenblatt_json["beschreibung_original"].replace(/"/g,'&quot;');
			//datenblatt_json["titel_original"] = datenblatt_json["titel_original"].replace(/"/g,'&quot;');
			//alert("titel original: "+datenblatt_json["titel_original"]);
			jQuery(this).html('<form id="editfrmMaterial" >'+
						
			'<table  border="0" cellspacing="5" style="text-align:left;">'+	
				'<tbody>'+	
				
					'<tr >'+
					    '<th style="text-align:left;font-weight: bolder;">Titel</th>'+
					    '<th style="text-align:left;font-weight: bolder;">Beschreibung</th>'+
					    '<th style="text-align:left;font-weight: bolder;">Düsengröße</th>'+					   
					    '<th style="text-align:left;font-weight: bolder;">Druck (bar)</th>'+
					    '<th style="text-align:left;font-weight: bolder;">Hersteller</th>'+
				    '</tr>'+
				    '<tr>'+
				    '<td colspan="3">&nbsp;</td><td><span style="margin-right:111px;">Zerstäubungsdruck</span> </td>'+
				    '</tr>'+
				   
				    '<tr>'+
				    
						'<td><input type="hidden" id="mat_nr" value="'+datenblatt_json["uid"]+'"><input id="mat_titel" value="'+datenblatt_json["titel_original"]+'"></td>'+
						'<td><input id="mat_beschreibung" value="'+datenblatt_json["beschreibung_original"]+'"></td>'+
						'<td><input id="jetsizes" value="'+datenblatt_json["jetsizes"]+'"></td>'+
						'<td >'+
							'von &nbsp;<input id="pressure_low" value="'+datenblatt_json["pressure_low"]+'" size="10">&nbsp;bis &nbsp;<input id="pressure_high" value="'+datenblatt_json["pressure_high"]+'" size="10">'+
							
						'</td>'+					
						'<td>'+hersteller_selectbox+'</td>'+
					'</tr>'+
					 '<tr>'+
					    '<td colspan="3">&nbsp;</td><td><span style="margin-right:111px;">Materialdruck </span> </td>'+
					 '</tr>'+
					'<tr>'+
					'<td colspan="3">&nbsp;</td><td>von &nbsp;<input id="pressure_low_rcmd" value="'+datenblatt_json["pressure_low_rcmd"]+'" size="10">&nbsp;bis &nbsp;<input id="pressure_high_rcmd" value="'+datenblatt_json["pressure_high_rcmd"]+'" size="10"></td>'+
					'</tr>'+
					'<tr><td colspan="5">&nbsp;</td></tr><tr><th colspan="5" style="text-align:left;font-weight: bolder;">Weitere Übersetzungen für Titel und Beschreibung</th ></tr>'+language_tr_rows+
				'</tbody>'+
			'</table>'+
			
			
			'</form>');
			


		},
		beforeClose: function(event, ui) {
			//alert(" beforeclose");			
			jQuery(this).dialog("destroy");
		},
		
		position:{
			my: 'center',
			at: 'right',
			of: clicked_obj			
		}

	});


	/*
	alert("line 20: "+dialog_link_id);


	// Dialog Link
	jQuery(dialog_link_id).click(function(){	
	jQuery('#dialog').dialog("open");
		alert("clicked");
		return false;
	});
	
	*/
/*
//hover states on the static widgets
jQuery(dialog_link_id+", ul#icons li").hover(
	function() { jQuery(this).addClass("ui-state-hover"); }, 
	function() { jQuery(this).removeClass("ui-state-hover"); }
);
*/
}// end function




function openDeleteDialog(clicked_obj, $mat_id, $mat_titel){
	
	jQuery('#dialog').dialog("open");
	//alert("line 6");
	//Dialog			
	jQuery('#dialog').dialog({
		//autoOpen: true,
		width: 300,
		title : $mat_titel,	
		modal : true,		
		buttons: {
			"Löschen": function() { 
				
			
			$.ajax({
		        type: "POST",
		        url: "index.php?eID=px_satalackdatenblaetter",
		        context: jQuery(this),

		        data: {
					'action':'delete',
					'uid':$mat_id,
					'product_pid': pid_,
					'hersteller_id': actual_hersteller_id
				},
		       
		        dataType: "text",
		        success: function(data, text) {
						
					//alert(data);
					sendLDBrequest(actual_hersteller_id,language, branche, page_id, 1);
					jQuery(this).dialog("close");												

		       	},
		        error: function(xhr, ajaxOptions, thrownError) {
					
              		 alert(xhr.status);
                     alert(thrownError);
                     jQuery(this).dialog("close");					 

		         }
		      }); // End ajax method
		
			}, 
			"Abbrechen": function() {
				
				jQuery(this).dialog("close");
				jQuery(this).dialog("destroy");
			} 
		},
		open: function(event, ui) { 
			 jQuery(this).html('<div id="confirm_wrap" style="text-align:center;"><span>Soll das Material mit der Bezeichnung <strong>"'+$mat_titel+'"</strong> gelöscht werden? </span> </div>')
			


		},
		beforeClose: function(event, ui) {
			//alert(" beforeclose");			
			jQuery(this).dialog("destroy");
		},
		
		position:{
			my: 'center',
			at: 'right',
			of: clicked_obj			
		}

	});
}// end function


function addPistole(clicked_obj, $mat_id, $mat_titel, json_string){
	
	jQuery('#dialog').dialog("open");
	//alert("line 6");
	//Dialog			
	jQuery('#dialog').dialog({
		//autoOpen: true,
		height: 700,
		width: 500,
		title : $mat_titel,	
		//modal : true,		
		buttons: {
			"Hinzufügen": function() { 
			//alert(selected_pisitole);	
			
			$.ajax({
		        type: "POST",
		        url: "index.php?eID=px_satalackdatenblaetter",
		        context: jQuery(this),
		        data: {
					'action':'add',
					'uid':$mat_id,
					'product_pid': pid_,
					'selected_psitole': selected_pisitole,
					'hersteller_id': actual_hersteller_id
				},
		       
		        dataType: "text",
		        success: function(data, text) {
						
					//alert(data);
					/*
					console.log("sende: actual_herstell_id: "+actual_hersteller_id)
					console.log("sende: language: "+language)
					console.log("sende: branche: "+branche)
					*/
					//console.log("sende: page_id_: "+page_id_)
					
					
					window.location.href = window.location.pathname + "?id="+selected_pisitole+"&hersteller="+actual_hersteller_id+"&branche_="+branche+"&pid="+pid_+"&active_tab=2&L="+language+"&no_cache=1";
					//sendLDBrequest(actual_hersteller_id,language, branche, selected_psitole);
					jQuery(this).dialog("close");												

		       	},
		        error: function(xhr, ajaxOptions, thrownError) {
					
              		 alert(xhr.status);
                     alert(thrownError);
                     jQuery(this).dialog("close");					 

		         }
		      }); // End ajax method
		
				
				
				
			}, 
			"Abbrechen": function() {
				
				jQuery(this).dialog("close");
				jQuery(this).dialog("destroy");
			} 
		},
		open: function(event, ui) { 
			//alert(JSON.stringify(json_data)); 
			//json_string = JSON.stringify(json_string);
			//console.log(json_string)
			jQuery(this).html('<div id="confirm_wrap" style="text-align:center;"><span>Bitte wählen Sie eine Pistole aus, die dem aktuell gewählten Hersteller und Material zugeordnet werden soll.  </span> </div><div id="tree_wrap" style="text-align:left;background:none;" class="treemenu"></div>')
			
			 jQuery("#tree_wrap").jstree({ 
				
				 "json_data" : {
					"data" : [
						{ 
							"data" : "Produkte", 
							'state' : "open",
							"children" : json_string
						}
						
					]

					
				},
				 "themes" : {
					 "theme" : "default",
					 "dots" : true,
					 "icons" : true
				 },				
				
				
				"plugins" : [ "themes", "json_data" ]
			});
			


		},
		beforeClose: function(event, ui) {
			//alert(" beforeclose");			
			jQuery(this).dialog("destroy");
		},
		
		position:{
			my: 'center',
			at: 'right',
			of: clicked_obj			
		}

	});


}// end function





function addNewMaterial(clicked_obj, datenblatt_json){
	
	jQuery('#dialog').dialog("open");
	//alert("line 6");
	//Dialog			
	jQuery('#dialog').dialog({
		//autoOpen: true,
		width: 800,
		title : "Neues Material hinzufügen",	
		modal : true,		
		buttons: {
			"Hinzufügen": function() { 
				
			var json = { 
					myArray: [
			      			  {
			      				  //'uid': jQuery('#mat_nr').val(),
			      				  'product_pid': pid_
			      			  },
				      
				      		  {
								
			      				  'titel' 	   : jQuery('#mat_titel').val(),
			      				  'beschreibung' : jQuery('#mat_beschreibung').val(),						
			      				  'hersteller' : jQuery('#hersteller_list option:selected').val(),
			      				  'sys_language_uid':language, 
			      				  'pid'		   : "3989"
			                  
							  },
							  
							  {		
								  'jetsizes' 	   : jQuery('#jetsizes').val(),
								  'pressure_low' : jQuery('#pressure_low').val(),
								  'pressure_high' : jQuery('#pressure_high').val(),
								  'pressure_low_rcmd' : jQuery('#pressure_low_rcmd').val(),
								  'pressure_high_rcmd' : jQuery('#pressure_high_rcmd').val(),
								  'material' : "last_inserted_id",
								  'product_pid': pid_,
								  'pid'		   : "3990"
								  
						      }
							 ]
							 
							 
						/*	declare as second array 
						"test2": [
						          {	'jetsizes' 	   : jQuery('#jetsizes').val(),
									'pressure_low' : jQuery('#pressure_low').val(),
									'pressure_high' : jQuery('#pressure_high').val(),
									'pressure_low_rcmd' : jQuery('#pressure_low_rcmd').val(),
									'pressure_high_rcmd' : jQuery('#pressure_high_rcmd').val()
						          }
				          ]
				         */
				};
		          //alert(JSON.stringify(json));
			$.ajax({
		        type: "POST",
		        url: "index.php?eID=px_satalackdatenblaetter",
		        context: jQuery(this),
		        data: "action=insert&json_string="+JSON.stringify(json),
		       
		        dataType: "text",
		        success: function(data, text) {
					
				 //alert(data);
				 sendLDBrequest(actual_hersteller_id,language, branche, page_id, 1);
				 jQuery(this).dialog("close");
										
		       	},
		        error: function(xhr, ajaxOptions, thrownError) {
					
		  		 alert(xhr.status);
		         alert(thrownError);
		         jQuery(this).dialog("close");					 

		         }
		      }); // End ajax method
		
			}, 
			"Abbrechen": function() {
				
				jQuery(this).dialog("close");
				jQuery(this).dialog("destroy");
			} 
		},
		open: function(event, ui) { 
			 // jQuery(this).load('Sample.htm');
			// jQuery(this).load('TEST');
			//alert(datenblatt_json["titel"]);
			
			for (var property in datenblatt_json) {
				if(property = "hersteller_list"){
					var hersteller_array = datenblatt_json[property];
					var hersteller_selectbox = '<select name="hersteller" id="hersteller_list">'// <option >&nbsp;</option>'
					for (var hersteller_id in hersteller_array) {
						//console.log(hersteller_array[hersteller_id]);
						 
						hersteller_selectbox += ' <option value='+hersteller_id+' '+(actual_hersteller_id == hersteller_id? "selected":"")+'>'+hersteller_array[hersteller_id]+'</option>';
						
					}// end for
					hersteller_selectbox +=  '</select>';
				}// end if
			}// end for
			
			jQuery(this).html('<form id="editfrmMaterial" >'+
						
			'<table  border="0" cellspacing="5" style="text-align:left;">'+	
				'<tbody>'+	
				
					'<tr >'+
					    '<th style="text-align:left;font-weight: bolder;">Titel</th>'+
					    '<th style="text-align:left;font-weight: bolder;">Beschreibung</th>'+
					    '<th style="text-align:left;font-weight: bolder;">Düsengröße</th>'+					   
					    '<th style="text-align:left;font-weight: bolder;">Druck (bar)</th>'+
					    '<th style="text-align:left;font-weight: bolder;">Hersteller</th>'+
				    '</tr>'+
				    '<tr>'+
				    '<td colspan="3">&nbsp;</td><td><span style="margin-right:111px;">Materialdruck </span> </td>'+
				    '</tr>'+
				   
				    '<tr>'+
				    
						'<td><input type="hidden" id="mat_nr" value=""><input id="mat_titel" value=""></td>'+
						'<td><input id="mat_beschreibung" value=""></td>'+
						'<td><input id="jetsizes" value=""></td>'+
						'<td >'+
							'von &nbsp;<input id="pressure_low" value="" size="10">&nbsp;bis &nbsp;<input id="pressure_high" value="" size="10">'+
							
						'</td>'+					
						'<td>'+hersteller_selectbox+'</td>'+
					'</tr>'+
					 '<tr>'+
					    '<td colspan="3">&nbsp;</td><td><span style="margin-right:111px;">Zerstäubungsdruck </span> </td>'+
					 '</tr>'+
					'<tr>'+
					'<td colspan="3">&nbsp;</td><td>von &nbsp;<input id="pressure_low_rcmd" value="" size="10">&nbsp;bis &nbsp;<input id="pressure_high_rcmd" value="" size="10"></td>'+
					'</tr>'+
				'</tbody>'+
			'</table>'+
			
			
			'</form>');
			


		},
		beforeClose: function(event, ui) {
			//alert(" beforeclose");			
			jQuery(this).dialog("destroy");
		},
		
		position:{
			my: 'center',
			at: 'right',
			of: clicked_obj			
		}

	});
}// end function

function setSelectedPistole(node_uid){
	//alert(node_uid);
	
	if(document.getElementById("link_node_"+selected_pisitole) != null){
		node_ele = document.getElementById("link_node_"+selected_pisitole);
		node_ele.style.color = "black";
	}// end if
	selected_pisitole=node_uid;
	node_ele = document.getElementById("link_node_"+selected_pisitole);
	node_ele.style.color = "#E60000";
	clickedPistole_colorChange = node_uid;
	return false;	
}// end function

function onMouseOutChangeColor(clicked_ele, node_uid){
	//alert(node_uid);
	
	if(clickedPistole_colorChange != node_uid){		
		clicked_ele.style.color = "black";
	}// end if	
	return false;	
}// end function





function vergleichePistolenDialog(clicked_obj, products, hersteller_id, branche, page_id, language, prefix_id){
	
	jQuery('#dialog').dialog("open");
	//alert("line 6");
	//Dialog			
	jQuery('#dialog').dialog({
		//autoOpen: true,
		width: 350,
		title : "Pistolen vergleichen",	
		modal : true,		
		buttons: {
			"Vergleichen": function() {				
			var products_param = "";
			var i = 0;
		    jQuery(':checkbox:checked').each(function(i){
		    	products_param += prefix_id+"[comp_pid]["+i+"]="+jQuery(this).val()+"&";		    	
		    	i = i+1;		    		
		    	
		    	
		    });
		
		    params = "id="+page_id+"&"+prefix_id+"[hersteller]="+hersteller_id+"&"+prefix_id+"[compare_products_print]=1&"+prefix_id+"[branche]="+branche+"&"+prefix_id+"[print]=1&"+products_param+"L="+language+"&no_cache=1&type=123";   
		    //console.log("products params: "+products_param);
		    //console.log(params);
		    //window.location.href = "index.php?"+params;
		    jQuery(this).dialog("close");
			jQuery(this).dialog("destroy");
		    window.open("index.php?"+params, "_blank");

		   
			}, 
			"Abbrechen": function() {
				
				jQuery(this).dialog("close");
				jQuery(this).dialog("destroy");
			} 
		},
		open: function(event, ui) { 
			
			checkbox_list = "";
			for (var property in products) {
				
				var products_objects = products[property];
				//alert(datenblatt_json["uid"]);
				for (var key in products_objects) {
					//console.log("key: "+key);					
					
						if(key == "title"){						
							title = products_objects[key];
							uid = products_objects['uid'];
							pid = products_objects['pid'];							
							checkbox_list += ' <tr><td><input type="checkbox" name="title" id="product_uid_'+uid+'" value="'+uid+'"></td><td>'+title+'</td>';						
						}// end if					
				
				}// end for
							
			}// end for	
			
			
			jQuery(this).html('<form id="compareProducts" >'+
						
			'<table  border="0" cellspacing="5" style="text-align:left;">'+	
				'<tbody>'+					
				checkbox_list+
				'</tbody>'+
			'</table>'+
			
			
			'</form>');
			


		},
		beforeClose: function(event, ui) {
			//alert(" beforeclose");			
			jQuery(this).dialog("destroy");
		}
		
		/*position:{
			my: 'center',
			at: 'right',
			of: clicked_obj			
		}*/

	});


	/*
	alert("line 20: "+dialog_link_id);


	// Dialog Link
	jQuery(dialog_link_id).click(function(){	
	jQuery('#dialog').dialog("open");
		alert("clicked");
		return false;
	});
	
	*/
/*
//hover states on the static widgets
jQuery(dialog_link_id+", ul#icons li").hover(
	function() { jQuery(this).addClass("ui-state-hover"); }, 
	function() { jQuery(this).removeClass("ui-state-hover"); }
);
*/
}// end function









