function setCaretTo(obj, pos) {
    if(obj.createTextRange) {
        /* Create a TextRange, set the internal pointer to
           a specified position and show the cursor at this
           position
        */
        var range = obj.createTextRange();
        range.move("character", pos);
        range.select();
    } else if(obj.selectionStart) {
        /* Gecko is a little bit shorter on that. Simply
           focus the element and set the selection to a
           specified position
        */
        obj.focus();
        obj.setSelectionRange(pos, pos);
    }
}

var selectDirectory = function(_li){

  _galleryId = $("u",_li).text();

	$("#selectedGalleryId").attr("rel",_galleryId);
	$("#inpSelectedGalleryId").val(_galleryId);
	$("#inpSelectedGalleryParent").val(allParents[_galleryId]);

	$("#modifyGallery").removeClass('offscreen');

	//$("#adminNewGallery").addClass('offscreen');



	$("#nameGallery").val(allGalleries[_galleryId]['name']);

  $("#descgallery").val(allGalleries[_galleryId]['description']);

}


var deselectDirectory = function(){

	$('.dirtree li.c').removeClass('selected');

	$("#selectedGalleryId").attr("rel",'');
	$("#inpSelectedGalleryId").val('');
	//$("#inpSelectedGalleryParent").val('');

	$("#modifyGallery").addClass('offscreen');

	//$("#adminNewGallery").addClass('offscreen');



	$("#nameGallery").val('');

  $("#descgallery").val('');

}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}
 function _NN(o){
  return o.get(0).nodeName;
}