	function getElementsByClass(searchClass,node,tag) {
		var classElements = new Array();
		if ( node == null )
			node = document;
		if ( tag == null )
			tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
		for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				classElements[j] = els[i];
				j++;
			}
		}
		return classElements;
	}
	function $(e) {
		return e.style? e:document.getElementById(e);
	}
	function hide(e) {
		$(e).style.display='none';
	}
	function show(e) {
		$(e).style.display='block';
	}
	function showi(e) {
		$(e).style.display='inline';
	}
	var lasttab = Array();
	lasttab[0] = 0;
	lasttab[1] = 0;
	function changetab(pos,id) {
		if (lasttab[pos] != id) {
			var e = $('p'+pos+"_"+id);
			var l = $('p'+pos+"_"+lasttab[pos]);
			hide(l);
			show(e);
			$('tab'+pos+'_'+id).className="";
			$('tab'+pos+'_'+lasttab[pos]).className="idle";
			lasttab[pos] = id;
		}
	}


	function copy(e, t) {
		e = $(e);
	    var copy = e.cloneNode(true);
	    copy.id += "-copy";
	    for(i = 0; copy.childNodes.length > i;  i++)	{
			if(copy.childNodes[i].id) {
				var node = copy.childNodes[i];
				node.id += "-copy";
			}
	    }
	    $(t).appendChild(copy);
	}
	var edit = document.createElement("div");
	edit.href="javascript:;";
	edit.style.display="none";

	edit.style.width="16px";
	edit.style.height="16px";
	edit.style.background="url(/img/page_white_edit.png) no-repeat";
	edit.style.position="absolute";
	edit.style.cursor="pointer";
	edit.style.zIndex="1000";

	edit.style.display="none";
	function showedit(e,id) {
		var width = e.offsetWidth < 450? e.offsetWidth:450;
		edit.style.left=findPos(e)[0] + width - 16 + "px";
		edit.style.top=findPos(e)[1] + "px";
		edit.style.display="block";
		edit.onclick= function() { show('content_edit_'+id); }
	}
	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			}
			while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	}


	function create_hover(id, hover_x, hover_y, hover_width, hover_height, imgsrc, img_x, img_y) {
		var hovers = $('hovers');

		var hover = document.createElement('div');

		hover.onmouseover = function() {
			var el = $(id);

			var imgs = getElementsByClass('over');
			for (var i = 0; i < imgs.length; i++) {
				imgs[i].style.display = 'none';
			}

			el.style.display = 'block';
		}

		hover.className = 'hover';

		hover.style.position = 'absolute';

		hover.style.left = hover_x + 'px';
		hover.style.top = hover_y + 'px';

		hover.style.width = hover_width + 'px';
		hover.style.height = hover_height + 'px';

		var img = document.createElement('img');
		img.className = 'over';
		img.id = id;
		img.src = imgsrc;

		img.style.position = 'absolute';

		img.style.left = img_x + 'px';
		img.style.top = img_y + 'px';

		hovers.appendChild(hover);
		hovers.appendChild(img);
	}

	window.onload = function() {
		document.body.appendChild(edit);
	}
