
  	function getExVendID(ids)
  	{
  		var id_types = ids.split(",");
  		
  		for(var i = 0; i < id_types.length; i++)
  		{
  			if(id_types[i].indexOf("EXVENID-") != -1)
  			{
  				//alert(id_types[i]);
  				return id_types[i].substring(8);
  			}
  		}
  	}
  
  	function getExClientID(ids)
  	{
  		var id_types = ids.split(",");
  		
  		for(var i = 0; i < id_types.length; i++)
  		{
  			if(id_types[i].indexOf("EXCLID-") != -1)
  			{
  				//alert(id_types[i]);
  				return id_types[i].substring(7);
  			}
  		}
  	}
  	
  	// This function adds and deletes from a group
  	function addDelToGroup(elementID,idString,add_or_delete)
  	{
  		
  		if(elementID.indexOf("dz-vendGroup-") != -1)
  		{
  			// elementID example would be "dz-vendGroup-75"
  			// So we want to get the "75" which is 13 characters into the string
			var group_id = 	elementID.substring(13);
			//alert(add_or_delete);
			if(add_or_delete == "add")
				addVendorToGroup(group_id,getExVendID(idString));
			else if(add_or_delete == "delete")
				deleteVendorFromGroup(group_id,getExVendID(idString));
				
  		}
  		else if(elementID.indexOf("WatchGroup") != -1)
  		{	
  			if(add_or_delete == "add")
  				addToWatchGroup(getExClientID(idString));
  			else if(add_or_delete == "delete")
  				deleteFromWatchGroup(getExClientID(idString));
  		}
  	}
	
	function addToWatchGroup(ex_client_id)
	{
		if( top.hidden_action )
			top.hidden_action.document.location='add_exmember.html?add_group=true&ex_client_id='+ex_client_id;
		else
		{
			AjaxRequest.post (
			  {
				'url': '/exchange/background.html',
				'onSuccess': function(oResponse) 
					{ 
						if( oResponse.responseText.length > 0 ) 
							alert(oResponse.responseText); 
					},
				'onError': function(oResponse) 
					{ 
						alert( "Unable to add preferred partner to watch group.  Please click your browser's REFRESH button to resolve the issue." ); 
					},
				'parameters':{ 'add_group':'true', 'ex_client_id':ex_client_id }


			  }
			);
		}
			
	}
	
  	function addVendorToGroup( groupID, vendorID )
	{
		if( top.hidden_action )
			top.hidden_action.document.location='add_exmember.html?add_group=true&vendor_group_id='+groupID+'&ex_vendor_id='+vendorID;
		else
		{
			AjaxRequest.post (
			  {
				'url': '/exchange/background.html',
				'onSuccess': function(oResponse) 
					{ 
						if( oResponse.responseText.length > 0 ) 
							alert(oResponse.responseText); 
					},
				'onError': function(oResponse) 
					{ 
						alert( "Unable to add preferred partner to group.  Please click your browser's REFRESH button to resolve the issue." );
					},
				'parameters':{ 'add_group':'true', 'vendor_group_id':groupID, 'ex_vendor_id':vendorID }
			  }
			);
		}
	
	}
	
  	function addClientToAccepted( clientID )
	{
		if( top.hidden_action )
			top.hidden_action.document.location='add_exmember.html?ex_client_id='+clientID;
		else
		{
			AjaxRequest.post (
			  {
				'url': '/exchange/background.html',
				'onSuccess': function(oResponse) 
					{ 
						if( oResponse.responseText.length > 0 ) 
							alert(oResponse.responseText); 
					},
				'onError': function(oResponse) 
					{ 
						alert( "Unable to add client to Clients Accepted.  Please click your browser's REFRESH button to resolve the issue." );
					},
				'parameters':{ 'ex_client_id':clientID }
			  }
			);
		}
	}
  	
	function deleteFromPreferredPartners( vendorID )
	{
		if( top.hidden_action )
			top.hidden_action.document.location='add_exmember.html?delete_vendor=true&ex_vendor_id='+vendorID;
		else
		{
			AjaxRequest.post (
			  {
				'url': '/exchange/background.html',
				'onSuccess': function(oResponse) 
					{ 
						if( oResponse.responseText.length > 0 ) 
							alert(oResponse.responseText); 
							
						getObj("myConnection[1]").style.display = "none";
						//window.location.replace(window.location.href); 
					},
				'onError': function(oResponse) 
					{ 
						alert( 'Unable to remove from Preferred Partners.' ); 
					},
				'parameters':{ 'delete_vendor':'true', 'ex_vendor_id':vendorID }


			  }
			);
		}
	}
	
	function deleteVendorFromGroup( group_id,ex_vendor_id )
	{
		//alert('add_exmember.html?delete_from_group=true&vendor_group_id='+group_id+'&ex_vendor_id='+ex_vendor_id);
		if( top.hidden_action )
			top.hidden_action.document.location='add_exmember.html?delete_from_group=true&vendor_group_id='+group_id+'&ex_vendor_id='+ex_vendor_id;
		else
		{
			AjaxRequest.post (
			  {
				'url': '/exchange/background.html',
				'onSuccess': function(oResponse) 
					{ 
						if( oResponse.responseText.length > 0 ) 
							alert(oResponse.responseText); 
					},
				'onError': function(oResponse) 
					{ 
						alert( "Unable to remove preferred partner from group.  Please click your browser's REFRESH button to resolve the issue." ); 
					},
				'parameters':{ 'delete_from_group':'true', 'ex_vendor_id':ex_vendor_id, 'vendor_group_id':group_id }


			  }
			);
		}		

	}
	
	function deleteFromWatchGroup(ex_client_id)
	{
		if( top.hidden_action )
			top.hidden_action.document.location='add_exmember.html?delete_exclient=true&ex_client_id='+ex_client_id;
		else
		{
			AjaxRequest.post (
			  {
				'url': '/exchange/background.html',
				'onSuccess': function(oResponse) 
					{ 
						if( oResponse.responseText.length > 0 ) 
							alert(oResponse.responseText); 
					},
				'onError': function(oResponse) 
					{ 
						alert( "Unable to remove preferred partner from watch group.  Please click your browser's REFRESH button to resolve the issue." );
					},
				'parameters':{ 'delete_exclient':'true', 'ex_client_id':ex_client_id }


			  }
			);
		}
			
	}
	
	function editGroup(vendor_group_id)
	{
		editgrpwin = window.open("/exchange/addgroup.html?ppg=1&group_id="+vendor_group_id, 'editEXgroup', 'resizable=no,scrollbars=yes,width=340,height=300');
	}

	function detach()
	{
		lay  = document.getElementById('FloatList');
		dleft = getXCoord(lay);
		dtop  = getYCoord(lay);
		lay.style.position = 'absolute';
		lay.style.top      = dtop;
		lay.style.left     = dleft;
		getFloatLayer('FloatList').initialize();
		alignFloatLayers();
	}
