$.fn.xnaStrChoosePhoto = function() {
	
	$(this).each(function() {
		var $this = $(this);
		$this.click(function() {
			var psrc = $this.attr('id');
			$('#strPhotoContent').remove();
			$('body').append('<div id="strPhotoContent" title="'+l_choose_photo+'"></div>');
			$('#strPhotoContent').html('<div style="margin-bottom: 10px"><table width="100%"><tr><td>'+l_gallery+' <input type="radio" name="ctype" value="0" checked="checked" onclick="loadPage(\'str_photolist\',1,\'index.php?mod=ajax&act=choose_photo&id='+psrc+'\')" /> '+l_user_gallery+' <input type="radio" name="ctype" value="1" onclick="loadPage(\'str_photolist\',1,\'index.php?mod=ajax&act=choose_photo&id='+psrc+'&ctype=1\')" /></td><td align="right"><input type="text" id="squery" name="q" value="" size="20" maxlength="20" /> <input class="btnSearch" type="button" name="search" value="" onclick=\"goSearchPhoto(\''+psrc+'\')\"></td></tr></table></div><div id="str_photolist"><img border="0" src="images/progress_bar.gif" alt="Loading..." /><br /><br />'+l_loading_progress+'</div>');
			$.post('index.php?mod=ajax',{'act':'choose_photo','id':psrc},function(xml) {
				$('#str_photolist').html($("datatable",xml).text());
			});
			$('#strPhotoContent').dialog({
				modal: true,
				width: 640,
				position: ['center',100]
			});
		})
	});
	
};

function goSearchPhoto(psrc) {
	var ctype = $("input[name^='ctype']:checked").val();
	var query = $('#squery').val();
	loadPage('str_photolist',1,'index.php?mod=ajax&act=choose_photo&id='+psrc+'&ctype='+ctype+'&q='+query)
}