_LH.OnLoad = function() {
  if (typeof(setup) == 'function') setup();
  _w();
};

_LH.OnBeforeUnload = function() {
  // do nothing by default. The activex uploader page redefines this function.
};

_LH.HideWidget = function(id, url) {
  get(id).style.display = 'none'; 

  if (typeof(_xmlhttp) == "undefined" || !_xmlhttp.Supported()) {
    return;
  }

  _xmlhttp.Request(url, _LH.HideWidget_Callback, "POST");
};

_LH.HideWidget_Callback = function(xml) {
  if (!xml) {
    alert("Preference not saved");
    return;
  }

  if (xml.text.indexOf("success") < 0) {
    alert("There was an error while contacting the server");
    return;
  }
};
_LH.AddPhotoCaption_OK = function() {
	var form = get("CaptionForm");
	form.submit();
};

_LH.AddPhotoCaption_Open = function() {
  get('photoCaptionForm').className='expanded';
  get('showCaption').style.display = "none";
  get('addCaption').style.display = "none";
  document.location="#photoCaptionForm";
  get('AddPhotoCaption').focus();
};

_LH.AddPhotoCaption_Cancel = function() {
  var photoCFDiv = get("photoCaptionForm");
  if (photoCFDiv) photoCFDiv.className='collapsed';
  var photoCF = get("AddPhotoCaption");
//  if (photoCF) photoCF.value = "";
  get('showCaption').style.display = "";
  get('addCaption').style.display = "";
};

_LH.MoreActions_Ok = function(form) {

	if( !form ) return;

	switch( form.mode.value ) {
		case "delete": {
			var c = confirm("Are you sure you want to remove this photo?");
			if( !c ) return;
			form.redirect.value = form.redir_delete.value;
			break;
		}

		case "banner": {
			form.redirect.value = form.redir_banner.value;
			break;
		}

		case "portrait": {
			form.redirect.value = form.redir_portrait.value;
			break;
		}

		case "moreactions":
			return;

		default: {
			alert("Invalid mode option");
			return;
		}
	}

	form.submit();
};
function LH_CreateActiveXUploader(baseref, elementid, ver) {
  var div = get(elementid);
  if (div) {
    div.innerHTML = 
      '<object id="UploadListView" ' +
      'classid="CLSID:474F00F5-3853-492C-AC3A-476512BBC336" ' +
      'codebase="' + baseref + 'uploader2.cab#version=' + ver + '" ' +
      'width="564" height="375"></OBJECT>';
  }
};

