var PHOTO_COUNTER = 0;
var NUM_PHOTO = 0;
function wp_socialnetwork_addphoto(url,destination) {
	if(NUM_PHOTO >= MAXPHOTOS) {
		alert('No more photo are uploadable');
		return;
	}
	var el = '';
	
	el += '<div id="foto-container['+PHOTO_COUNTER+']" class="foto-container">';
	el += '	<input type="hidden" value="" name="photo:id['+PHOTO_COUNTER+']">';
	el += '	<table style="width: 100%;">';
	el += '		<tr>';
	el += '			<th rowspan="2"><img src="'+url+'/wp-content/plugins/wp-socialnetwork/images/nofoto.jpg" style="height: 70px;"/><br />( <a href="javascript:wp_socialnetwork_delphoto(\'files\',\''+PHOTO_COUNTER+'\')">cancella</a> )</th>';
	el += '			<td style="vertical-align:top;"><b>Descrizione:</b><br /><input type="text" name="photo:desc['+PHOTO_COUNTER+']"  id="photo:desc[<?=$counter?>]" value="" /></td>';
	el += '		</tr>';
	el += '		<tr>';
	el += '			<td style="vertical-align:top;"><b>File:</b><br /><input type="file" name="photo:file['+PHOTO_COUNTER+']"  id="photo:file['+PHOTO_COUNTER+']" /></td>';
	el += '		</tr>';
	el += '	</table>';
	el += '</div>	';

	var parse = document.createElement('div');
	parse.innerHTML = el;
	var src = parse.getElementsByTagName('foto-container['+PHOTO_COUNTER+']');
	var obj = document.getElementById(destination);
	PHOTO_COUNTER++;
	NUM_PHOTO++;
	obj.appendChild(parse.childNodes[0]); // += el;
}
function wp_socialnetwork_delphoto(destination,count) {
	var div = document.getElementById('foto-container['+count+']');
	var obj = document.getElementById(destination);
	obj.removeChild(div);
	NUM_PHOTO --;	
}