//gets ChildNode Index to direkt parent
//returns index
//needs testElementV1000
//1n: DOM-Element
//2n: (#Id,.Class,Nodename,DOM-Element)
function getChildPosV1000(child,allowedElements)
{
  var pn;
	if(child==false) return false;
  pn=child.parentNode.childNodes;
	var a=-1;
	for(var i=0;i<pn.length;i++) 
	{
  	if(testElementV1000(pn[i],allowedElements)===false) continue;
		a++;
  	if(pn[i]==child) return a;
	}
  return false;
}

//gets a "non-direct" perent, identified by:
//1n: DOM-Element
//2n: (#Id,.Class,Nodename,DOM-Element)
//3o: how Deep to search
function searchRelativeParentV1000(el,pIdentifier,depth)
{
  if(pIdentifier==null) return false;
	if(depth==null) depth=20; 
	var ptest=false;
	while(ptest==false && depth>0)
	{
  	oldEl=el;
		el=el.parentNode;
		ptest=testElementV1000(el,pIdentifier)
		depth--;
	}
	if(ptest===true) return el;
	else return false;
}

//test if element belongs to a given el
//el: DOM-Element
//2n: (#Id,.Class,Nodename,DOM-Element)
function testElementV1000(el,classID)
{
  var ptest=false;
	//if classId == ClassName
	if(classID.indexOf(".")===0 
  	&& el.className==classID.substr(1)) ptest=true;
	
	//if classId == IdName
	if(classID.indexOf("#")===0 
  	&& el.id==classID.substr(1)) ptest=true;
	
	//else (!IdName && !ClassName)
	if(classID.indexOf(".")===false 
  	&& classID.indexOf("#")===false)
		{
  		//if classId == nodeName
			if(el.nodeName==classID) ptest=true;
			//if classId == Element
			if(el==classID) ptest=true
		}
	return ptest;	
}

function moveThisInRowV1000(el,offsetTop,to)
{
  //get the DOM-Parent of el
	var p=searchRelativeParentV1000(el,offsetTop);
	if(p===false) return false;
	
	//get the x in p.parent.childNodes[x]
	var pos=getChildPosV1000(p,offsetTop);
	p=p.parentNode;
	
	//is no offsetParent found?
	if(pos===false) return false;
	
	//if is first or last Element
	if($$(offsetTop).length>=(pos+to+1) && pos+to>=0)
	{
  	if($$(offsetTop).length==(pos+to+1)) 
  		p.appendChild(p.removeChild($$(offsetTop)[pos]),$$(offsetTop)[pos+to]);
		else 
			p.insertBefore(p.removeChild($$(offsetTop)[pos]),$$(offsetTop)[pos+to]); 
	}
}

function mootoolsEffectFxMorphStart(elid,duration,fromOpacity,toOpacity)
{
  var myEffect1 = new Fx.Morph(elid, 
    {
      'duration': duration, 
      transition: Fx.Transitions.Sine.easeOut
    }
  );
	myEffect1.start({'opacity': [fromOpacity,toOpacity]});
}

