function showDialogBox(id, name)
{
	width = 370;
	height = 500;
	w = window.open('', 'da_' + name,'toolbar=no,scrollbars=no,status=no,resizable=yes,height=' + height + ',width=' + width);
	if (!(w.framelog)) {
		w = window.open('/dialog.php?id=' + id, 'da_' + name,'toolbar=no,scrollbars=no,status=no,resizable=yes,height=' + height + ',width=' + width);
		w.focus();
	}
}

function showDialogLog(id1, id2)
{
	width = 370;
	height = 500;
	w = window.open('', 'da_' + id1 + '_' + id2,'toolbar=no,scrollbars=auto,status=no,resizable=yes,height=' + height + ',width=' + width);
	if (!(w.framelog)) {
		w = window.open('/dialogview.php?member1_id=' + id1 + '&member2_id=' + id2, 'da_' + id1 + '_' + id2,'toolbar=no,scrollbars=auto,status=no,resizable=yes,height=' + height + ',width=' + width);
		w.focus();
	}
}

function showPopup(url, name, width, height, scrollbars)
{
	w = window.open(url, 'da_' + name,'toolbar=no,scrollbars=' + scrollbars + ',status=no,resizable=yes,height=' + height + ',width=' + width);
	//w.focus();
}

$(document).ready(function() {

$(".comment-add-link").click(function(e) {
    e.preventDefault();
    
    var params = $(this).attr('href').substring(1).split('-');
    
    var _objectId = params[0];
    var _objectType = params[1];
    var _parentId = params[2];
    
    var blockName = "#comment-add-block-" + _parentId; 
    
	if ($(blockName).length > 0)
		$(blockName).toggle('fast');
	else {
    var data = { objectId : _objectId, objectType : _objectType, parentId : _parentId};
	 $("#comment-template" ).tmpl( data ).insertAfter("#block-options-" + _parentId).toggle('fast');
	 
	 	//$(blockName).find('textarea').ckeditor();
	 
		$(blockName).keydown(function(e) {
        if (e.ctrlKey && e.keyCode == 13) {
         //alert(this.id);
         $(this).find('input[type=image]').click();
        }
		});
	 
	}
	
	$(blockName + " textarea").focus();
    
});

$(".sharing-link").click(function(e) {
    e.preventDefault();
    
    var params = $(this).attr('href').substring(1).split('-');
    
    var _workId = params[0];
    var _storagePath = params[1];
    var _fileName = params[2];
    
    var blockName = "#sharing-block-" + _workId; 
    
	if ($(blockName).length > 0)
		$(blockName).toggle('fast');
	else {
    var data = {
    	workId : _workId,
    	baseHref : BASE_HREF,
    	thumbPath : _storagePath + THUMB_IMAGE_PATH + _fileName,
    	previewPath : _storagePath + PREVIEW_IMAGE_PATH + _fileName,
    	fullPath : _storagePath + FULL_IMAGE_PATH + _fileName
    	};
	 $("#sharing-template" ).tmpl( data ).insertAfter("#context-menu-" + _workId).toggle('fast');
	}
});

$(".admin-item-delete-link").click(function(e) {
    e.preventDefault();

    var params = $(this).attr('href').substring(1).split('-');
    
    var _objectId = params[0];
    var _objectType = params[1];
    var _authorLogin = params[2];

    var blockName = "#admin-item-delete-block-" + _objectId;
    
	if ($(blockName).length > 0)
		$(blockName).toggle('fast');
	else {
    var data = {
    	objectId : _objectId,
    	objectType : _objectType,
    	backUrl : _authorLogin
    	};
	 $("#admin-item-delete-template" ).tmpl( data ).insertAfter("#context-menu-" + _objectId).toggle('fast');
	}
});

$(".sharing-block input").focus(function() {
    $(this).select();
});

$(".sharing-block textarea").focus(function() {
    $(this).select();
});

$("#form-fast-search #f-query").focus(function() {
	$(this).val("");
   $(this).removeClass("form-hint-mode");
});

$("#form-fast-search").submit(function(e) {
	if ($(this).find("#f-query").val() == "Search for...") { e.preventDefault(); return false; }
});

/*
$("#add-to-favs").click(function(e) {
    e.preventDefault();
    
    $(this).find("img").attr("src", "i/ajax-loader.gif");
    $(this).find("a").addClass("link-disabled");
});
*/

});


