﻿// JScript File

var popUp;
function ConsultarArchivos(idname1,idname2,idname3)
{
	popUp = window.open('UploadArchivos.aspx?DirectoryFile=Imagenes&formname=' + document.forms[0].name + 
		'&id1=' + idname1 + '&id2=' + idname2  + '&id3=' + idname3, 
		'popupcal', 
		'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0px,left=5px,width=' + screen.width/1.2 + 'px,height=' + screen.height/1.2 + 'px');
}

function ConsultarEnlaces(idname1,idname2)
{
	popUp = window.open('FrmEnlaces.aspx?formname=' + document.forms[0].name + 
		'&id1=' + idname1 + '&id2=' + idname2, 
		'popupcal', 
		'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0px,left=5px,width=600px,height=500px');
}



function SetValue(formName, id, newValue)
{
	window.opener.document.getElementById(id).value=newValue;
	
	

}	

function QuitaImagen(control,control2,control3)
{
     document.getElementById(control).value='';
    document.getElementById(control2).value='';
    document.getElementById(control3).value='';
    
}
function QuitaEnlaces(control,control2)
{
   document.getElementById(control).value='';
    document.getElementById(control2).value='';
    
    
}

function enviarMensaje() {
						var enviarNoticia = document.getElementById('enviarNoticia');
						if (enviarNoticia.style.display == "none") {
							enviarNoticia.style.display = "block";
						} else {
							enviarNoticia.style.display = "none";
						}
						
					}

function Popup_Enlace_Interno(editor)
{
	var oEditor = FCKeditorAPI.GetInstance(editor) ;
	var oLink = oEditor.Selection.MoveToAncestorNode( 'A' ) ;
	if ( oLink )
	{
		if (oLink.pathname.substring(oLink.pathname.length, oLink.pathname.length - 4)=='aspx') 		
			var Popup_Enlace = window.open('FrmEnlaces.aspx?editor=editor&IdContenido='+ oLink.search.split('=')[1] + '&Destino='+ oLink.target,'popupcal', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=5px,left=5px,width=' + screen.width/2 + 'px,Height=' + screen.height/2 + 'px' );
		else
			var Popup_Enlace = window.open('FrmEnlaces.aspx?editor=' + editor,'popupcal', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=5px,left=5px,width=' + screen.width/2 + 'px,Height=' + screen.height/2 + 'px' );
	}		
	else 
	
		//var a=oEditor.EditorDocument.selection.createRange().text;
		var Popup_Enlace = window.open('FrmEnlaces.aspx?editor='+ editor,'popupcal', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=5px,left=5px,width=' + screen.width/2 + 'px,Height=' + screen.height/2 + 'px' );
	return false;
}

function asignarenlace(enlace,destino,editor)
{
	var oEditor = FCKeditorAPI.GetInstance(editor) ;
	oEditor.ExecuteNamedCommand('CreateLink',enlace);
	
	var oLink = oEditor.Selection.MoveToAncestorNode( 'A' ) ;
	if ( oLink )
		oEditor.Selection.SelectNode( oLink ) ;
	SetAttribute( oLink, 'target', destino);
	
	

	//oEditor.InsertHtml(enlace);
	//oEditor.InsertHtml(texto);
	//oEditor.InsertHtml("</a>");
}

function SetAttribute( element, attName, attValue )
{
	if ( attValue == null || attValue.length == 0 )
		element.removeAttribute( attName, 0 ) ;			// 0 : Case Insensitive
	else
		element.setAttribute( attName, attValue, 0 ) ;	// 0 : Case Insensitive
}
