﻿// filesystem based script resource
//function identityFunction(arg) {
//    return arg;
//}
//if(typeof('Sys') !== 'undefined') Sys.Application.notifyScriptLoaded();

/**
 * Validator lato client per l'editor di immagini
 */
function imageEditorCheck(source, arguments) {
  var td = $(source).parent(td);
  var img = td.find("img");
  var upl = td.find("input[@type=file]");
  var chk = td.find("input[@type=checkbox]");
  
  arguments.IsValid = upl.val() || (!chk.get(0).checked && img.attr("src")) ? true : false;
}

/**
 * Validator lato client per l'editor di file
 */
function fileEditorCheck(source, arguments) {
  var td = $(source).parent(td);
  var hid = td.find("input[@type=hidden]");
  var upl = td.find("input[@type=file]");
  var chk = td.find("input[@type=checkbox]");
  
  arguments.IsValid = upl.val() || (!chk.get(0).checked && hid.val()) ? true : false;
}

/**
 * Sposta gli elementi da una lista all'altra
 */
function spostaelementi(src, dest) {

//  var src = document.getElementById(id_src);
//  var dest = document.getElementById(id_dest);
  var len_dest = dest.length;
  var len_src = src.length;
  for (var i = len_src-1; i >= 0; i--){
	if (src.options[i].selected == true) {
			dest.options[len_dest] = new Option(src.options[i].text, src.options[i].value);
			src.options[i] = null;
			len_dest++;
	}//end if
  } // end for
  return false;
  
}

function arsFileBrowser(field_name, url, type, win) {
  mcefld = win.document.getElementById(field_name);
  
  // alert("Field_Name: " + field_name + "\nURL: " + url + "\nType: " + type + "\nWin: " + win); // debug/testing

  /* var cmsURL = window.location.pathname;      // script URL
  var searchString = window.location.search;  // possible parameters
  if (searchString.length < 1) {
      // add "?" to the URL to include parameters (in other words: create a search string because there wasn't one before)
      searchString = "?";
  } */

  // newer writing style of the TinyMCE developers for tinyMCE.openWindow

  tinyMCE.openWindow({
      // file : cmsURL + searchString + "&type=" + type, // PHP session ID is now included if there is one at all
      file : "../../../../filebrowser.aspx?caller=mce&filter="+type,
      title : "File Browser",
      width : 660,
      height : 520,
      close_previous : "no"
  }, {
      window : win,
      input : field_name,
      resizable : "yes",
      inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
      editor_id : tinyMCE.getWindowArg("editor_id")
  });

  return false;
}

   
function onOverLi(elemento) {
	
 $(elemento).addClass("over")
}
function onOutLi(elemento) {
 $(elemento).removeClass("over")
}
