﻿function cambiarDisplay(id, imagen)
{
  if (!document.getElementById)
    return false;
  fila = document.getElementById(id);
  
  if (fila.style.display != "none")
  {
    fila.style.display = "none"; //ocultar fila
    imagen.src="../images/intranet/mas.gif";
    imagen.alt="Show";
  }
  else
  {
    fila.style.display = ""; //mostrar fila
    imagen.src="../images/intranet/menos.gif";
    imagen.alt="Hidden";
    
  }
}

function cancelEvent(){
    if (window.event) window.event.cancelBubble = true;
    return false;
}

function ValidaDDL(source, arguments) {
    if (arguments.Value < 0) {
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }
}

function ValidaTextBox(source, arguments) {
    if (arguments.Value == '') {
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }
}


function ValidaFileUpload(source, arguments) {
    var value = arguments.Value.toString();
    if (value.length < 1 || value.length > 100) {
        arguments.IsValid = false;
    }
    else {
        arguments.IsValid = true;
    }
}


// config

	// what do we do with the toolbar when disabling the editor. Possibilities are 'disable', 'hide', 'collapse'.
	// When collapsed the toolbar can be expanded again by the user, but he'll find a disabled toolbar.
	var toolbarDisabledState = "disable";

	function toggleFCKeditor(editorInstance)
	{
		
		if ((!document.all && editorInstance.EditorDocument.designMode.toLowerCase() != "off") || (document.all && editorInstance.EditorDocument.body.disabled == false))
		{
			// disable the editArea
			if (document.all)
			{
				editorInstance.EditorDocument.body.disabled = true;
			}
			else
			{
				editorInstance.EditorDocument.designMode = "off";
			}
			// disable the toolbar
			switch (toolbarDisabledState)
			{
				case "collapse" :		editorInstance.EditorWindow.parent.FCK.ToolbarSet._ChangeVisibility(true);
				case "disable" :		editorInstance.EditorWindow.parent.FCK.ToolbarSet.Disable();
											buttonRefreshStateClone = editorInstance.EditorWindow.parent.FCKToolbarButton.prototype.RefreshState;
											specialComboRefreshStateClone = editorInstance.EditorWindow.parent.FCKToolbarSpecialCombo.prototype.RefreshState;
											editorInstance.EditorWindow.parent.FCKToolbarButton.prototype.RefreshState = function(){return false;};
											editorInstance.EditorWindow.parent.FCKToolbarSpecialCombo.prototype.RefreshState = function(){return false;};
											break;
					case "hide" :		if (editorInstance.EditorWindow.parent.document.getElementById("xExpanded").style.display != "none")
											{
												editorInstance.EditorWindow.parent.document.getElementById("xExpanded").isHidden = true;
												editorInstance.EditorWindow.parent.document.getElementById("xExpanded").style.display = "none";
											}
											else
											{
												editorInstance.EditorWindow.parent.document.getElementById("xCollapsed").style.display = "none";
											}
											break;
			}
		}
		else
		{
			// enable the editArea
			if (document.all)
			{
				editorInstance.EditorDocument.body.disabled = false;
			}
			else
			{
				editorInstance.EditorDocument.designMode = "on";
			}
			// enable the toolbar
			switch (toolbarDisabledState)
			{
				case "collapse" :		editorInstance.EditorWindow.parent.FCK.ToolbarSet._ChangeVisibility(false);
				case "disable" :		editorInstance.EditorWindow.parent.FCK.ToolbarSet.Enable();
											editorInstance.EditorWindow.parent.FCKToolbarButton.prototype.RefreshState = buttonRefreshStateClone;
											editorInstance.EditorWindow.parent.FCKToolbarSpecialCombo.prototype.RefreshState = specialComboRefreshStateClone;
											break;
					case "hide" :		if (editorInstance.EditorWindow.parent.document.getElementById("xExpanded").isHidden == true)
											{
												editorInstance.EditorWindow.parent.document.getElementById("xExpanded").isHidden = false;
												editorInstance.EditorWindow.parent.document.getElementById("xExpanded").style.display = "";
											}
											else
											{
												editorInstance.EditorWindow.parent.document.getElementById("xCollapsed").style.display = "";
											}
											break;
			}
			// set focus on editorArea
			editorInstance.EditorWindow.focus();
			// and update toolbarset
			editorInstance.EditorWindow.parent.FCK.ToolbarSet.RefreshModeState();
		}
	}
	
	//function FCKeditor_OnComplete(editorInstance){toggleFCKeditor(editorInstance);}


function VentanaCentrada(URL,ancho, alto, titulo)
{
  var width=ancho; height=alto;
  var left = (screen.width/2) - width/2;
  var top = (screen.height/2) - height/2;
  var styleStr =  'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
   var msgWindow = window.open(URL,"QueFranquicia", styleStr);
  msgWindow.focus();
 //	msgWindow.document.title = titulo;
}
