function swapNodes(thisnode,node) {
	thisnode.style.visibility = 'hidden';
	node.style.visibility = 'hidden';
	if(thisnode.parentNode != node.parentNode) {
		var nextSibling = thisnode.nextSibling;
		var parentNode = thisnode.parentNode;
		node.parentNode.replaceChild(thisnode, node);
		parentNode.insertBefore(node, nextSibling);
	} else {
	
		var thisPos = 0;
		var nodePos = 1;
		for(var i = 0; i < thisnode.parentNode.childNodes.length; i++ ) {
			if(thisnode.parentNode.childNodes[i] == thisnode ) {
				thisPos = i;
			} else
			if(thisnode.parentNode.childNodes[i] == node ) {
				nodePos = i;
			}
		}
		if(thisPos > nodePos) {
			var nextSibling = thisnode.nextSibling;
			var parentNode = thisnode.parentNode;
			node.parentNode.replaceChild(thisnode, node);
			parentNode.insertBefore(node, nextSibling);
		} else {
			var nextSibling = node.nextSibling;
			var parentNode = node.parentNode;
			thisnode.parentNode.replaceChild(node, thisnode);
			parentNode.insertBefore(thisnode, nextSibling);
		}
	
	}
	aplinxEffectsFadeIn(thisnode);
	aplinxEffectsFadeIn(node);
}

function createEventHandler(obj,eventh,func) {
	var i;
	for (i = 0; i < obj.attributes.length; i++ ) {
		if (obj.attributes[i].name == 'on'+name) {
			obj.attributes[i].value = func;
		}
	} 
}

function removeAllElements(parent) {
	var child = parent.firstChild;
	while(child) {
		parent.removeChild(child);
		child = parent.firstChild;
	}
}

function createElement(typeStr,dlgName,dlgType,attributes) {
	var attstr = "";
	if(dlgName && dlgName != "") {
		attstr += ' name="' +dlgName+'"';
	}
	if(dlgType && dlgType != "") {
		attstr += ' type="' +dlgType+'"';
	}
	for(var keyVal in attributes) {
		if(attributes[keyVal] != "") {
			attstr += " " + keyVal + '="' +attributes[keyVal]+'"';
		}
	}
	var element;
	try {
		element = document.createElement("<" + typeStr + attstr + "/>");
		/*for(var keyVal in attributes) {
			if(attributes[keyVal] != "") {
				element.setAttribute(keyVal,attributes[keyVal]);
			}
		}*/
	} catch (e) {
		element = document.createElement(typeStr);
		if(dlgType && dlgType != "") {
			element.setAttribute("type", dlgType);
		}
		if(dlgName && dlgName != "") {
			element.setAttribute("name", dlgName);
		}
		for(var keyVal in attributes) {
			if(attributes[keyVal] != "") {
				element.setAttribute(keyVal,attributes[keyVal]);
			}
		}
	}
	return element;
}


