if (window.location.href=='http://www.mumate.com/pin') {
	window.onload = init_pin_list;
	document.onmousemove = getMousePosition;
}

function init_pin_list() {
	var div_img = document.createElement('div');
	div_img.setAttribute('id','div_img_user_list');
	document.getElementsByTagName('body')[0].appendChild(div_img);

	var e = document.getElementById('pin_users_list').getElementsByTagName('a');
	for(i=0;i<e.length;i++) {
		if (e[i].id != undefined && e[i].id != '') {
			e[i].onmouseover = function () {
				var arr = this.id.split('_');
				document.getElementById('div_img_user_list').innerHTML='<img src="/img/users/thumbs/'+arr[1]+'.'+arr[2]+'" width="50" height="50" />';
				moving_div_x_offset = 9;
				moving_div_y_offset = 16;
				moving_div_id = 'div_img_user_list';
			}
			e[i].onmouseout = function () {
				document.getElementById('div_img_user_list').innerHTML='';
				moving_div_id = false;
			}
		}
	}
}

function memo_post_new(s) {
	var arr = s.split('/');
	var c = document.createElement('div');
	c.id = 'memo_new';
	c.className = 'memo';
	c.style.top = '100px';
	c.style.left = '150px';
	document.body.appendChild(c);
	var html = '<form method="post" action="/pin/'+arr[1]+'" onsubmit="return memo_save(this,\''+arr[1]+'_'+arr[2]+'_'+arr[3]+'\')">';
	html += '<div class="memo_head" onmousedown="memo_drag(\'memo_new\')" onmouseup="memo_drop(\'memo_new\')" style="cursor:move"><a href="javascript:display_element(\'memo_new\')">x</a></div>';
	html += '<div class="memo_content">';
	html += '<textarea name="txt" id="txt_memo_new" rows="8" cols="27" style="overflow:auto">';
	html += '</textarea>';
	html += '<div style="text-align:right"><input type="submit" value="pin" class="submit"></div>';
	html += '</div>';
	html += '</form>';
	c.innerHTML = html;
	
}
function memo_delete(e) {
	var y = confirm('Memo löschen?');
	if (y == true) {
		ajx('/public/ajax.php?c1=pin&c2=1&c3=memo-update&c4='+e+'&c5=delete','memo_'+e);
	}
}
function memo_drag(e) {
	elem = document.getElementById(e);
	dragstart(elem);
	elem.className = 'memo_op';
	z_index_up(elem);
}
function memo_drop(e) {
	elem = document.getElementById(e);
	elem.className = 'memo';
}
function memo_save_pos(e) {
	ajx('/public/ajax.php?c1=pin&c2=1&c3=memo-update&c4='+e+'&c5=save-pos&c6='+document.getElementById('memo_'+e).style.left+'_'+document.getElementById('memo_'+e).style.top,0);
}
function memo_save(e,s) {
	if (e.txt.value.length > 1000) {
		alert('Das Memo darf maximal 1000 Zeichen enthalten.');
	}
	else if (e.txt.value == '') {
		alert('Ein Memo ohne Inhalt?');
	}
	else {
		var arr = s.split('_');
		ajx('/public/ajax.php?c1=pin&c2='+arr[0]+'&c3=memo-save&c4='+arr[1]+'&c5='+arr[2]+'&c6='+document.getElementById('memo_new').style.left+"_"+document.getElementById('memo_new').style.top+'&text='+e.txt.value,'memo_new');
	}
	return false;
}
function pin_confirm_it(item) {
	return confirm(item);
}

