
var m_s__ps_xchange_a__target_id = null;

function funct_ps_xchange_a(p_T,p_OBJ,p_V1,p_V2,p_V3,p_V4)
{
		
	// p_OBJ.value.length>0  nicht prüfen	
	if( 
	   funct_ps_xchange_a_B(1,0, p_V1+"_"+String(p_V2) ,null)==true  
	   &&  funct_ps_xchange_a_B(1,0,  p_V1+"_"+String(p_V2-1) ,null)==true 
	  )
	{
		var s_tmp = "";		
		var s_conf_a = funct_ps_xchange_a_B(2,0,  p_V1+"_"+String(p_V2-1) ,null);
		var sa_conf_a = s_conf_a.split('|');

		if( sa_conf_a.length >= 11 )
		{
			
			var s__set_new_actsortgrs = "";
			
			if( sa_conf_a.length >= 19 )
			{
				if( parseInt(sa_conf_a[17])==1 )
				{
					if( parseInt(p_OBJ.value) > 0  )
					{
						var sa_Set9IdTargetList = sa_conf_a[18].split('-');
						for (var i_Set9IdTargetList = 0; i_Set9IdTargetList < sa_Set9IdTargetList.length; i_Set9IdTargetList++)
						{
							var sa_Set9IdTargetList_elements = sa_Set9IdTargetList[i_Set9IdTargetList].split('/');
							if( sa_Set9IdTargetList_elements.length > 0 )
							{
								if( funct_ps_xchange_a_B(1,0, p_V1+"_"+sa_Set9IdTargetList_elements[0]+"x" ,null)==true )
								{
									var s_9x_conf_value = funct_ps_xchange_a_B(2,0, p_V1+"_"+sa_Set9IdTargetList_elements[0]+"x" ,null);
									if( s_9x_conf_value.length > 0 )
									{
										var sa_9x_conf_value = s_9x_conf_value.split('|');
										if( sa_9x_conf_value.length >= 3 )
										{
											if( parseInt(sa_9x_conf_value[0]) == 1 && parseInt(sa_9x_conf_value[2])>0 )
											{
												var sa_9x_conf_list = sa_9x_conf_value[1].split('-');	
												
												var b_f_rel = false;
												var i_new_targ = 0;
												var s_new_actsortgrs = "";
												var arr_check_obj = new Array();
												for (var i_sa_9x_conf_list = 0; i_sa_9x_conf_list < sa_9x_conf_list.length; i_sa_9x_conf_list++)
												{													
													var sa_9x_conf_listpos = sa_9x_conf_list[i_sa_9x_conf_list].split('/');
													if( sa_9x_conf_listpos.length >= 3 )
													{
														arr_check_obj.push( parseInt(sa_9x_conf_listpos[2]) );
														if(
														   p_V2 == sa_9x_conf_listpos[0]
														   &&  p_OBJ.value == sa_9x_conf_listpos[1] 
														   )
														{
															if( funct_ps_xchange_a_B(1,0, p_V1+"_"+String(parseInt(sa_9x_conf_listpos[2])+1) ,null)==true  )
																b_f_rel = true;
															else if( i_new_targ==0 )
															{
																i_new_targ = parseInt(sa_9x_conf_listpos[2]);
																
																if( sa_9x_conf_listpos.length >= 4 )
																	if( sa_9x_conf_listpos[3].length > 0 )
																		s_new_actsortgrs = sa_9x_conf_listpos[3];
															}
														}
													}
												}
												
												if( b_f_rel==false )
												{
													if( !(i_new_targ>0) )
													{
														var sa_9x_conf_value_default = sa_9x_conf_value[2].split('/');
														
														if( sa_9x_conf_value_default.length > 0 )
														{
															i_new_targ = parseInt(sa_9x_conf_value_default[0]);
															if( sa_9x_conf_value_default.length > 1 )
																if( sa_9x_conf_value_default[1].length > 0 )
																	s_new_actsortgrs = sa_9x_conf_value_default[1];
														}
													}
													
													if( i_new_targ > 0 )
													{
														if( funct_ps_xchange_a_B(1,0, p_V1+"_"+String(i_new_targ+1) ,null)==false  )
														{
															if( arr_check_obj.length>0 )
															{
																for (var check_obj in arr_check_obj)
																{
																	if( parseInt(arr_check_obj[check_obj]) > 0 && parseInt(arr_check_obj[check_obj]) != i_new_targ )
																	{
																		if( funct_ps_xchange_a_B(1,0, p_V1+"_"+String(parseInt(arr_check_obj[check_obj])+1) ,null)==true )
																		{																			
																			var obj_targ = document.getElementById(p_V1+"_"+String(parseInt(arr_check_obj[check_obj])+1));
																			
																			for( i=obj_targ.length-1; i>=0; i-- )
																				obj_targ.options[i] = null;
										
																			s__set_new_actsortgrs = s_new_actsortgrs;
																			
																			obj_targ.id = p_V1 +"_" + String(parseInt(i_new_targ+1)); 
																			obj_targ.name = p_V1 +"_" + String(parseInt(i_new_targ+1)); 
																		
																			break;
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			
			
		
			var sa_conditional = sa_conf_a[9].split('-');
			var arr_Objects = new Array();
			arr_Objects[0] = new Object();
			arr_Objects[0]["TYPE"] = 1;
			arr_Objects[0]["ID"] = p_V1+"_"+String(p_V2);
			arr_Objects[0]["CONF"] = s_conf_a;
			arr_Objects[0]["SELECTED"] = p_OBJ.value;
			arr_Objects[0]["SELECTBOXTYPE"] = parseInt(sa_conf_a[10]);
			
			s_tmp = "";
			if( sa_conf_a.length > 15 )
				if( parseInt(sa_conf_a[16])>0 )
					s_tmp = funct_ps_xchange_a_B(6,0,p_V1+"_"+sa_conf_a[16],null);
			
			arr_Objects[0]["BASEUI"] = s_tmp;
			
								
			
			for (var i_conditional = 0; i_conditional < sa_conditional.length; i_conditional++)
			{
				if( parseInt(sa_conditional[i_conditional])>0 )
				{
					if( 
					   funct_ps_xchange_a_B(1,0, p_V1+"_"+sa_conditional[i_conditional] ,null)==true  
					   &&  funct_ps_xchange_a_B(1,0,  p_V1+"_"+String(parseInt(sa_conditional[i_conditional])-1) ,null)==true 
					  )
					{						
						var s_conf_x = funct_ps_xchange_a_B(2,0,  p_V1+"_"+String(parseInt(sa_conditional[i_conditional])-1) ,null);
						var sa_conf_x = s_conf_x.split('|');
		
						if( sa_conf_x.length >= 11 )
						{
							
							if( parseInt(sa_conf_x[5]) > 1  )
							{	
							
								var s_SELECTED = funct_ps_xchange_a_B(3,0,  p_V1+"_"+sa_conditional[i_conditional] ,null);								
								
								var i_Objects = arr_Objects.length;
								arr_Objects[i_Objects] = new Object();
								arr_Objects[i_Objects]["TYPE"] = 0;
								arr_Objects[i_Objects]["ID"] = p_V1+"_"+sa_conditional[i_conditional];
								arr_Objects[i_Objects]["CONF"] = s_conf_x;
								arr_Objects[i_Objects]["SELECTED"] = s_SELECTED;
								arr_Objects[i_Objects]["SELECTBOXTYPE"] = parseInt(sa_conf_x[10]);
																
								s_tmp = "";
								if( sa_conf_x.length > 15 )
									if( parseInt(sa_conf_x[16])>0 )
										s_tmp = funct_ps_xchange_a_B(6,0,p_V1+"_"+sa_conf_x[16],null);
								
								arr_Objects[i_Objects]["BASEUI"] = s_tmp;
								
								
								
								// löschen + aber aktuellen lassen 
								for( i=document.getElementById(p_V1+"_"+sa_conditional[i_conditional]).length-1; i>=0; i-- )
									if( document.getElementById(p_V1+"_"+sa_conditional[i_conditional]).options[i].selected != true )
										document.getElementById(p_V1+"_"+sa_conditional[i_conditional]).options[i] = null;
								
							}
						}
					}
				}
			}
						
			
			if( arr_Objects.length > 1 )
			{
				
				var s_url = p_V3 + "webcentre.aspx?e003c6b449e847c8b4a67da331dc552f=11&xT=5";
								
				s_url += "&UIS=" + String(p_V4);
				s_url += "&X_OBJECTS=" + String(arr_Objects.length);
				
				if( funct_ps_xchange_a_B(1,0, p_V1+"_actsortgrs" ,null)==true  )
				{
					if( s__set_new_actsortgrs.length > 0 )
						document.getElementById(p_V1+"_actsortgrs").value = s__set_new_actsortgrs;
						
					var s_actsortgrs = funct_ps_xchange_a_B(2,0, p_V1+"_actsortgrs" ,null);
					if( s_actsortgrs.length > 0 )
						s_url += "&actsortgrs=" + s_actsortgrs;
				}
				
				if( funct_ps_xchange_a_B(1,0, p_V1+"_sortgrs" ,null)==true  )
				{
					var s_sortgrs = funct_ps_xchange_a_B(2,0, p_V1+"_sortgrs" ,null);
					if( s_sortgrs.length > 0 )
						s_url += "&sortgrs=" + s_sortgrs;
				}
				
				
				for (var i_Objects = 0; i_Objects < arr_Objects.length; i_Objects++) 
					for (var Eigenschaft in arr_Objects[i_Objects])
						s_url += "&" + Eigenschaft + "_" + String(i_Objects) + "=" + arr_Objects[i_Objects][Eigenschaft];


				// aus: XGEOjs_HRObj.js 
				var o = new XgeoCLASS_HttpRequestObject( 0 );
				var oReq = o.getHttpRequestObject();
				if( oReq!=null )
				{
					var m_iMonthsCount = 1;
					var m_sUI = "";
					var m_iDUPLTYPE = 1;
							
					var bOpenAsynchron = true;
					
					
					// oReq.open('get' , s_url , bOpenAsynchron );
					oReq.open('get' , encodeURI(s_url) , bOpenAsynchron );
					
							
					oReq.onreadystatechange = function()
					{
						if( oReq.readyState==4 )
						{
							if ( oReq.status == 200 )
							{
								
								var arrXgeoArray = new Array();
								var s_Response = oReq.responseText;								
								s_Response = s_Response.replace (/^\s+/, '').replace (/\s+$/, '');// TRIM
								//arrXgeoArray = JS04e019be2771( 2 , arrXgeoArray , s_Response );
								arrXgeoArray = JS04e019be2771( 1 , arrXgeoArray , s_Response );
																
								for( var i1 = 0; i1 < arrXgeoArray.length; i1++ )
								{	
									if( typeof arrXgeoArray[i1] == "object"  &&  arrXgeoArray[i1] != null )
									{
										if( !arrXgeoArray[i1].length )
										{
											var ob_Property1 = arrXgeoArray[i1];
											for( var property1 in ob_Property1 )
											{
												if( typeof ob_Property1[property1] != "object"  ||  ob_Property1[property1] == null )
												{
												}
												else
												{
													if( property1=="box" )
													{														
														// [1.]box
														
														var hs__ActBox = null;
														var i__ActBox__type = -1;
														var s__ActBox__id = null;
														var s__ActBox__selected = null;
														var i__ActBox__count = -1;
														var i__ActBox__ItemCount = 0;
														var s__ActBox__returntype = null;
														var s__ActBox__selectboxerrordefault = null;	
														var s__ActBox__returnvalue = null;
														var s__ActBox__returnvalueB = null;
														
														
														var s__ActBox__check_pre_id = null;
														
														var arr_box = ob_Property1[property1];
														for( var i_box = 0; i_box < arr_box.length; i_box++ )
														{
															
														
															if( typeof arr_box[i_box] == "object"  &&  arr_box[i_box] != null )
															{
																if( !arr_box[i_box].length )
																{
																	var ob_Property_box = arr_box[i_box];
																	for( var property_box in ob_Property_box )
																	{
																		if( typeof ob_Property_box[property_box] != "object"  ||  ob_Property_box[property_box] == null )
																		{
																			// [1.1.]id   +   [1.2.]type   +   [1.3.]selected    +   [1.4.]count	+	[1.5.]returntype	+	[1.6.]selectboxerrordefault		+		[1.7.]returnvalue

																			switch (property_box)
																			{
																				
																				case "id":
																				
																					hs__ActBox = null;
																					i__ActBox__type = -1;
																					s__ActBox__id = null;
																					s__ActBox__selected = null;
																					i__ActBox__count = -1;
																					i__ActBox__ItemCount = 0;
																					
																					s__ActBox__id = ob_Property_box[property_box];
																					
																					if( document.getElementById(s__ActBox__id) )
																						hs__ActBox = document.getElementById(s__ActBox__id);
																					else
																						s__ActBox__id = null;
																					
																					break;
																				case "type":
																					i__ActBox__type = parseInt(ob_Property_box[property_box]);																					
																					break;
																				case "selected":
																					s__ActBox__selected = ob_Property_box[property_box];
																					break;
																				case "count":
																					i__ActBox__count = parseInt(ob_Property_box[property_box]);
																					break;
																				case "returntype":
																					s__ActBox__returntype = ob_Property_box[property_box];
																					break;
																				case "returnvalue":
																					s__ActBox__returnvalue = ob_Property_box[property_box];
																					break;
																				case "returnvalueB":
																					s__ActBox__returnvalueB = ob_Property_box[property_box];
																					break;
																				case "selectboxerrordefault":
																					s__ActBox__selectboxerrordefault = ob_Property_box[property_box];
																					break;
																				default:
																					break;
																			}
																		}
																		else
																		{
																			if( i__ActBox__count<=0 )
																			{
																				
																			}
																			else if( property_box=="item" )
																			{
																				// [1.8.]item
																				
																				if( 
																				   
																				   	funct_ps_xchange_a_B( 5,0, s__ActBox__id ,null ).length > 0 
																					&& hs__ActBox != null
																					&& i__ActBox__type != 1
																					
																				   	&&  
																					(
																						funct_ps_xchange_a_B( 5,0, s__ActBox__id ,null ) !=  funct_ps_xchange_a_B( 5,0, s__ActBox__check_pre_id ,null ) 
																						||  i__ActBox__ItemCount > 0 
																				    )
																				   
																				  )
																				{
																					
																					if( i__ActBox__ItemCount==0 )
																					{
																						s__ActBox__check_pre_id = s__ActBox__id;
																					
																						
																						// löschen
																						for( i=hs__ActBox.length-1; i>=0; i-- )
																							hs__ActBox.options[i] = null;
																						
																					
																					}																																										
																					
																					
																					var arr_item = ob_Property_box[property_box];
																					for( var i_item = 0; i_item < arr_item.length; i_item++ )
																					{
																						if( typeof arr_item[i_item] == "object"  &&  arr_item[i_item] != null )
																						{
																							if( !arr_item[i_item].length )
																							{
																								var ob_Property_item = arr_item[i_item];
																								for( var property_item in ob_Property_item )
																								{
																									if( typeof ob_Property_box[property_box] != "object"  ||  ob_Property_box[property_box] == null )
																									{																									
																										// nichts	
																									}
																									else
																									{
																										// aus item:   [1.8.1.]value  +  [1.8.2.]text 
																										
																										if( property_item == "value" )
																										{	
																											var b_selected = false;
																											if( 
																											   funct_ps_xchange_a_B( 5,0, s__ActBox__selected ,null ).length > 0 
																											   && funct_ps_xchange_a_B( 5,0, s__ActBox__selected ,null ) == ob_Property_item[property_item]
																											   )
																											{
																												b_selected = true;																									
																											}
																											
																											var s_value = "";
																											if( ob_Property_item[property_item]!=null )
																												s_value = ob_Property_item[property_item];
																												
																											hs__ActBox.options[i__ActBox__ItemCount] = new Option( "" , s_value , false , b_selected );
																											
																										}
																										else if( property_item == "text" )
																										{
																											if( hs__ActBox.options[i__ActBox__ItemCount]!=null )
																												hs__ActBox.options[i__ActBox__ItemCount].text = ob_Property_item[property_item];																											
																											
																											i__ActBox__ItemCount++;
																										}
																									}
																								}
																							}																						
																						}
																					}
																				}
																			}																			
																		}
																	}
																}
															}
														}
														
														
														
														if( i__ActBox__count<=0 )
														{
															if( hs__ActBox != null )
															{
																// löschen + aber den 1ten lassen 
																for( i=hs__ActBox.length-1; i>=1; i-- )
																	hs__ActBox.options[i] = null;
																							
															}
														}
														
														
														
														if( funct_ps_xchange_a_B(5,0,s__ActBox__returntype,null)=="1" )
														{
															if( hs__ActBox != null && funct_ps_xchange_a_B(5,0,s__ActBox__selectboxerrordefault,null).length > 0 )
															{
																if( hs__ActBox.length > 0 )
																{
																	var s_default_x = hs__ActBox.options[0].text;
																	
																	//var ob_hs__ThisBox = hs__ActBox;
																	//window.setTimeout( function(){ ob_hs__ThisBox.options[0].text = s_default_x; } , 1500 );																	
																	window.setTimeout( "document.getElementById('" + s__ActBox__id + "').options[0].text = '" + s_default_x + "'" , 1500 );
																	
																	hs__ActBox.options[0].text = s__ActBox__selectboxerrordefault;
																}
															}
														}
														
														
														if( funct_ps_xchange_a_B(5,0,s__ActBox__returnvalue,null)=="2" )
														{
															if( funct_ps_xchange_a_B(1,0, p_V1+"_0" ,null)==true )
															{
																if( parseInt(s__ActBox__returnvalueB)>0 )
																{
																	if( m_s__ps_xchange_a__target_id == null )
																		m_s__ps_xchange_a__target_id = document.getElementById(p_V1+"_0").value;
								
																	document.getElementById(p_V1+"_0").value = parseInt(s__ActBox__returnvalueB);
																}
																else if( m_s__ps_xchange_a__target_id != null )
																	document.getElementById(p_V1+"_0").value = m_s__ps_xchange_a__target_id;
															}		
														}
													}
												}
											}
										}										
									}									
								}
								
																
							}
						}
					};			
					oReq.send(null);
				}
				o = null;
						
			}
		}
		
		
		
	}	
}




function funct_ps_xchange_a_B(p_T,p_T1,p_V1,p_V2)
{
	try
	{
		if( p_T==1 )
		{
			if( document.getElementById(p_V1) )
				return true;
			
			return false;
		}
		else if( p_T==2 )
		{
			if( document.getElementById(p_V1) )
				return document.getElementById(p_V1).value;
				
			return "";
		}
		else if( p_T==3 )
		{
			for (i = 0; i < document.getElementById(p_V1).length; ++i)
				if (document.getElementById(p_V1).options[i].selected == true)
					return document.getElementById(p_V1).options[i].value;
				
			return "";
		}
		else if( p_T==4 )
		{
			
		}
		else if( p_T==5 )
		{
			if( p_V1==null )
				return "";
			else
				return p_V1;
		}
		else if( p_T==6 )
		{
			if( document.getElementById(p_V1) )
				for (i = 0; i < document.getElementById(p_V1).length; ++i)
					if (document.getElementById(p_V1).options[i].selected == true)
						return document.getElementById(p_V1).options[i].value;
				
			return "";
		}
	
	}
	catch(e){}
}



