global proc AECurveNurbsTemplate( string $nodeName )
{
	editorTemplate -beginScrollLayout;
	
		// The all go into the collapsable "Parameters" section
		editorTemplate -beginLayout "Overall" -collapse false;

			// Add the default controls
			editorTemplate -addControl "segments";
			editorTemplate -addControl "lengthscale";
			editorTemplate -addControl "movescale";
			editorTemplate -addControl "softInsert";
			editorTemplate -addControl "evaluation";
			
		editorTemplate -endLayout;

		editorTemplate -beginLayout "Standard Curve Parameters" -collapse false;
					
			//Add the default controls for the CurveParameters
			string $newFuncAttrib = "curvatureCurvNewAttrib";
			string $replaceFuncAttrib = "curvatureCurvReplaceAttrib";
			editorTemplate -callCustom $newFuncAttrib $replaceFuncAttrib "";
		
		editorTemplate -endLayout;
		
		/*editorTemplate -beginLayout "Extra Curve Parameters - not yet implemented" -collapse true;
							
			//Add the default controls for the ExtraCurveParameters
			//string $newFuncAttrib = "curvatureExtraNewAttrib";
			//string $replaceFuncAttrib = "curvatureExtraReplaceAttrib";
			//editorTemplate -callCustom $newFuncAttrib $replaceFuncAttrib "";
				
		editorTemplate -endLayout;*/
		
		editorTemplate -beginLayout "Family" -collapse false;
		
			//Add the default controls for the Family-Members-Handling
			string $newFuncAttrib = "curvatureFamilyNewAttrib";
			string $replaceFuncAttrib = "curvatureFamilyReplaceAttrib";
			editorTemplate -callCustom $newFuncAttrib $replaceFuncAttrib "";	
						
		editorTemplate -endLayout;
		

		// Create an "Extras" section and also add controls for any
		// attributes we have not explicitly mentioned.
		editorTemplate -addExtraControls;
	editorTemplate -endScrollLayout;

	// Tell the attribute editor not to display the attributes we
	// don't care about.
	editorTemplate -suppress "caching";
	editorTemplate -suppress "nodeState";
}

global proc curvatureCurvNewAttrib(string $attr)
{
	curvatureCurvReplaceAttrib($attr);
}

global proc curvatureCurvReplaceAttrib(string $attr)
{
	$type = `nodeType ($attr+"curvRotaX")`;
	int $end   = `size($attr)`-1;
	$node = `substring $attr 1 $end`;
	
	if(!`layout -exists ($type+"_curveParam_layout")`) columnLayout ($type+"_curveParam_layout");
	
	setParent ($type+"_curveParam_layout");
	if(!`layout -exists ($type+"_rotX_layout")`) rowLayout -nc 3 ($type+"_rotX_layout"); //rotX
	if(!`text -exists ($type+"_rotX_text")`){
		setParent ($type+"_rotX_layout");
		text -label ("X-Rotation") ($type+"_rotX_text");
	}
	if(!`textField -exists ($type+"_rotX_tf")`){
		setParent ($type+"_rotX_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_rotX_tf");
	}
	if(!`symbolButton -exists ($type+"_rotX_button")`){
			setParent ($type+"_rotX_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_rotX_button");
	}
	setParent ($type+"_curveParam_layout");
	if(!`layout -exists ($type+"_rotY_layout")`) rowLayout -nc 3 ($type+"_rotY_layout"); //rotY
	if(!`text -exists ($type+"_rotY_text")`){
		setParent ($type+"_rotY_layout");
		text -label ("Y-Rotation") ($type+"_rotY_text");
	}
	if(!`textField -exists ($type+"_rotY_tf")`){
		setParent ($type+"_rotY_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_rotY_tf");
	}
	if(!`symbolButton -exists ($type+"_rotY_button")`){
			setParent ($type+"_rotY_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_rotY_button");
	}
	setParent ($type+"_curveParam_layout");
	if(!`layout -exists ($type+"_rotZ_layout")`) rowLayout -nc 3 ($type+"_rotZ_layout"); //rotZ
	if(!`text -exists ($type+"_rotZ_text")`){
		setParent ($type+"_rotZ_layout");
		text -label ("Z-Rotation") ($type+"_rotZ_text");
	}
	if(!`textField -exists ($type+"_rotZ_tf")`){
		setParent ($type+"_rotZ_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_rotZ_tf");
	}
	if(!`symbolButton -exists ($type+"_rotZ_button")`){
			setParent ($type+"_rotZ_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_rotZ_button");
	}
	setParent ($type+"_curveParam_layout");
	if(!`layout -exists ($type+"_traX_layout")`) rowLayout -nc 3 ($type+"_traX_layout"); //traX
	if(!`text -exists ($type+"_traX_text")`){
		setParent ($type+"_traX_layout");
		text -label ("X-Translation") ($type+"_traX_text");
	}
	if(!`textField -exists ($type+"_traX_tf")`){
		setParent ($type+"_traX_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_traX_tf");
	}
	if(!`symbolButton -exists ($type+"_traX_button")`){
			setParent ($type+"_traX_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_traX_button");
	}
	setParent ($type+"_curveParam_layout");
	if(!`layout -exists ($type+"_traY_layout")`) rowLayout -nc 3 ($type+"_traY_layout"); //traY
	if(!`text -exists ($type+"_traY_text")`){
		setParent ($type+"_traY_layout");
		text -label ("Y-Translation") ($type+"_traY_text");
	}
	if(!`textField -exists ($type+"_traY_tf")`){
		setParent ($type+"_traY_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_traY_tf");
	}
	if(!`symbolButton -exists ($type+"_traY_button")`){
			setParent ($type+"_traY_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_traY_button");
	}
	setParent ($type+"_curveParam_layout");
	if(!`layout -exists ($type+"_traZ_layout")`) rowLayout -nc 3 ($type+"_traZ_layout"); //traZ
	if(!`text -exists ($type+"_traZ_text")`){
		setParent ($type+"_traZ_layout");
		text -label ("Z-Translation") ($type+"_traZ_text");
	}
	if(!`textField -exists ($type+"_traZ_tf")`){
		setParent ($type+"_traZ_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_traZ_tf");
	}
	if(!`symbolButton -exists ($type+"_traZ_button")`){
			setParent ($type+"_traZ_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_traZ_button");
	}
	
	
	string $params = `connectionInfo -sfd ($attr+"curvRotaX")`;			//rotX
	if(`size($params)`!=0 && `nodeType $params`=="curveEmulation"){
		string $conInput[];
		tokenize($params, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_rotX_tf");
		symbolButton -e -i "inArrow.xpm" -h 20 -command ("select "+$conInput[0]+";") ($type+"_rotX_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_rotX_tf");
		$actionCommand  = "string $XFtempStringCurveEmulationName = `XFCreateCurveEmulation`; 								\n";
		$actionCommand += "string $XFtempStringCurveEmulationResult = `XFConnectCurveAttr $XFtempStringCurveEmulationName "+$node+" curvRotaX`;		\n";
		$actionCommand += "textField -e -tx $XFtempStringCurveEmulationResult (\""+$type+"_rotX_tf\");						\n";
		$actionCommand += "symbolButton -e -i \"inArrow.xpm\" -h 20 -command (\"select \"+$XFtempStringCurveEmulationResult+\";\") "+$type+"_rotX_button;	\n";
		symbolButton -e -i "addy.xpm" -h 20 -command $actionCommand ($type+"_rotX_button");
	}
	$params = `connectionInfo -sfd ($attr+"curvRotaY")`;				//rotY
	if(`size($params)`!=0 && `nodeType $params`=="curveEmulation"){
		string $conInput[];
		tokenize($params, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_rotY_tf");
		symbolButton -e -i "inArrow.xpm" -h 20 -command ("select "+$conInput[0]+";") ($type+"_rotY_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_rotY_tf");
		$actionCommand  = "string $XFtempStringCurveEmulationName = `XFCreateCurveEmulation`; 								\n";
		$actionCommand += "string $XFtempStringCurveEmulationResult = `XFConnectCurveAttr $XFtempStringCurveEmulationName "+$node+" curvRotaY`;		\n";
		$actionCommand += "textField -e -tx $XFtempStringCurveEmulationResult (\""+$type+"_rotY_tf\");						\n";
		$actionCommand += "symbolButton -e -i \"inArrow.xpm\" -h 20 -command (\"select \"+$XFtempStringCurveEmulationResult+\";\") "+$type+"_rotY_button;	\n";
		symbolButton -e -i "addy.xpm" -h 20 -command $actionCommand ($type+"_rotY_button");
	}
	$params = `connectionInfo -sfd ($attr+"curvRotaZ")`;				//rotZ
	if(`size($params)`!=0 && `nodeType $params`=="curveEmulation"){
		string $conInput[];
		tokenize($params, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_rotZ_tf");
		symbolButton -e -i "inArrow.xpm" -h 20 -command ("select "+$conInput[0]+";") ($type+"_rotZ_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_rotZ_tf");
		$actionCommand  = "string $XFtempStringCurveEmulationName = `XFCreateCurveEmulation`; 								\n";
		$actionCommand += "string $XFtempStringCurveEmulationResult = `XFConnectCurveAttr $XFtempStringCurveEmulationName "+$node+" curvRotaZ`;		\n";
		$actionCommand += "textField -e -tx $XFtempStringCurveEmulationResult (\""+$type+"_rotZ_tf\");						\n";
		$actionCommand += "symbolButton -e -i \"inArrow.xpm\" -h 20 -command (\"select \"+$XFtempStringCurveEmulationResult+\";\") "+$type+"_rotZ_button;	\n";
		symbolButton -e -i "addy.xpm" -h 20 -command $actionCommand ($type+"_rotZ_button");
	}
	$params = `connectionInfo -sfd ($attr+"curvTranX")`;				//traX
	if(`size($params)`!=0 && `nodeType $params`=="curveEmulation"){
		string $conInput[];
		tokenize($params, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_traX_tf");
		symbolButton -e -i "inArrow.xpm" -h 20 -command ("select "+$conInput[0]+";") ($type+"_traX_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_traX_tf");
		$actionCommand  = "string $XFtempStringCurveEmulationName = `XFCreateCurveEmulation`; 								\n";
		$actionCommand += "string $XFtempStringCurveEmulationResult = `XFConnectCurveAttr $XFtempStringCurveEmulationName "+$node+" curvTranX`;		\n";
		$actionCommand += "textField -e -tx $XFtempStringCurveEmulationResult (\""+$type+"_traX_tf\");						\n";
		$actionCommand += "symbolButton -e -i \"inArrow.xpm\" -h 20 -command (\"select \"+$XFtempStringCurveEmulationResult+\";\") "+$type+"_traX_button;	\n";
		symbolButton -e -i "addy.xpm" -h 20 -command $actionCommand ($type+"_traX_button");
	}
	$params = `connectionInfo -sfd ($attr+"curvTranY")`;				//traY
	if(`size($params)`!=0 && `nodeType $params`=="curveEmulation"){
		string $conInput[];
		tokenize($params, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_traY_tf");
		symbolButton -e -i "inArrow.xpm" -h 20 -command ("select "+$conInput[0]+";") ($type+"_traY_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_traY_tf");
		$actionCommand  = "string $XFtempStringCurveEmulationName = `XFCreateCurveEmulation`; 								\n";
		$actionCommand += "string $XFtempStringCurveEmulationResult = `XFConnectCurveAttr $XFtempStringCurveEmulationName "+$node+" curvTranY`;		\n";
		$actionCommand += "textField -e -tx $XFtempStringCurveEmulationResult (\""+$type+"_traY_tf\");						\n";
		$actionCommand += "symbolButton -e -i \"inArrow.xpm\" -h 20 -command (\"select \"+$XFtempStringCurveEmulationResult+\";\") "+$type+"_traY_button;	\n";
		symbolButton -e -i "addy.xpm" -h 20 -command $actionCommand ($type+"_traY_button");
	}
	$params = `connectionInfo -sfd ($attr+"curvTranZ")`;				//traZ
	if(`size($params)`!=0 && `nodeType $params`=="curveEmulation"){
		string $conInput[];
		tokenize($params, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_traZ_tf");
		symbolButton -e -i "inArrow.xpm" -h 20 -command ("select "+$conInput[0]+";") ($type+"_traZ_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_traZ_tf");
		$actionCommand  = "string $XFtempStringCurveEmulationName = `XFCreateCurveEmulation`; 								\n";
		$actionCommand += "string $XFtempStringCurveEmulationResult = `XFConnectCurveAttr $XFtempStringCurveEmulationName "+$node+" curvTranZ`;		\n";
		$actionCommand += "textField -e -tx $XFtempStringCurveEmulationResult (\""+$type+"_traZ_tf\");						\n";
		$actionCommand += "symbolButton -e -i \"inArrow.xpm\" -h 20 -command (\"select \"+$XFtempStringCurveEmulationResult+\";\") "+$type+"_traZ_button;	\n";
		symbolButton -e -i "addy.xpm" -h 20 -command $actionCommand ($type+"_traZ_button");
	}	
}

global proc curvatureFamilyNewAttrib(string $attr)
{
	curvatureFamilyReplaceAttrib($attr);
}

global proc curvatureFamilyReplaceAttrib(string $attr)	//still needs change for non-XFrogObject-childs
{
	$type = `nodeType ($attr+"inParameters")`;

	if(!`layout -exists ($type+"_children_layout")`) columnLayout ($type+"_children_layout");

	setParent ($type+"_children_layout");
	if(!`layout -exists ($type+"_parent_layout")`) rowLayout -nc 3 ($type+"_parent_layout"); //parent
	if(!`text -exists ($type+"_parent_text")`){
		setParent ($type+"_parent_layout");
		text -label ("Parent") ($type+"_parent_text");
	}
	if(!`textField -exists ($type+"_parent_tf")`){
		setParent ($type+"_parent_layout");
		textField  -ed 0 -tx "<no connection>" ($type+"_parent_tf");
	}
	if(!`symbolButton -exists ($type+"_parent_button")`){
			setParent ($type+"_parent_layout");
			symbolButton -i "inArrow.xpm" -h 20 ($type+"_parent_button");
	}
	
		
	if( catchQuiet ($pParams = `connectionInfo -sfd ($attr+"inParameters")`)) $pParams="";			//parent
	if(`size($pParams)`!=0){
		string $conInput[];
		tokenize($pParams, ".", $conInput);
		textField -e -tx $conInput[0] ($type+"_parent_tf");
		symbolButton -e -en 1 -command ("select "+$conInput[0]+";") ($type+"_parent_button");
	} else {
		textField -e -tx "<no connection>" ($type+"_parent_tf");
		symbolButton -e -en 0 ($type+"_parent_button");
	}
}