﻿/////////////////////////////////////////////////////////////////////////////////////
/////*OBTENER UN ELEMENTO*///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function getElement(name) 
{
	if (document.all)
	{
		return document.all(name);
	}
	return document.getElementById(name);
}
/////////////////////////////////////////////////////////////////////////////////////
/////*OBTENER UBICACION DE UN ELEMENTO*//////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function getAbsoluteElementPosition(element) {
    if (typeof element == "string") element = getElement(element)
    if (!element) return { top:0,left:0 };
    var y = 0;var x = 0;
    while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;}
    return {top:y,left:x};}
/////////////////////////////////////////////////////////////////////////////////////
/////*MOSTRAR Y OCULTAR*/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function mostrarElemento(elemento){
    getElement(elemento).style.display = "";
}
function ocultarElemento(elemento){
    getElement(elemento).style.display = "none";
}
/////////////////////////////////////////////////////////////////////////////////////
/////*MOSTRAROCULTAR, MismaAcción*///////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function mostrarOcultar(elemento)
{
    if(getElement(elemento).style.display == "none")
    {
        getElement(elemento).style.display = "";
    }
    else
    {    
        getElement(elemento).style.display = "none";
    }
}
/////////////////////////////////////////////////////////////////////////////////////
/////*SWAP IMAGENES*/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function cambiarimagen(img,dir){
img.src = dir;
}
function restaurarimagen(img,dir){
img.src = dir;
} 
/////////////////////////////////////////////////////////////////////////////////////
/////*TELERIK UPLOAD*////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function addTitle(radUpload, args)
{
    //getElement(ctl00_ContentPlaceHolder1_RU_IMGAddButton).value = "Agregar";
    var curLiEl = args.get_row();
    var firstInput = curLiEl.getElementsByTagName("input")[0];
    
    //Crear un Template HTML simple.
    var table = document.createElement("table");
    table.className = 'AdditionalInputs';
    
    //Crear una nueva fila para  el titulo.
    row = table.insertRow(-1);
    cell = row.insertCell(-1);
    var label = CreateLabel("Titulo");
    cell.appendChild(label);
    var input = CreateInput("Tit", "text"); 
    input.className = "imgTitulo";
    input.id = input.name = radUpload.getID(input.name);
    cell = row.insertCell(-1);
    cell.appendChild(input);
   
    //Crear una nueva fila para el Epígrafe.
    row = table.insertRow(-1);
    cell = row.insertCell(-1);
    label = CreateLabel("Epigrafe");
    cell.appendChild(label);
    cell = row.insertCell(-1);
    input = CreateInput("Epi", "text");
    input.className = "imgEpigrafe";
    input.id = input.name = radUpload.getID(input.name);
    cell.appendChild(input);
      
    //Crear una nueva etiqueta de Archivo delante de la entrada de archivo
    var fileInputSpan = curLiEl.getElementsByTagName("span")[0];
    var firstNode = curLiEl.childNodes[0];
    label = CreateLabel("Imágen");
    label.style.innerHTML = "&nbsp;";
    curLiEl.insertBefore(label, firstNode);
    curLiEl.insertBefore(table, label);
               
 
}

function CreateLabel(text)
{
    var label = document.createElement("span");
    label.innerHTML = text;
    label.style.fontSize = 12;
    return label;
}

function CreateInput(inputName, type)
{
    var input = document.createElement("input");
    input.type = type;
    input.style.width = "380px";
    input.name = inputName; 
    return input;
}
/////////////////////////////////////////////////////////////////////////////////////
/////*Funciones Eliminar*//////////////////////??????????////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function MostrarElimar(Valor)
{
    getElement('DivEliminar').style.position="absolute";
    getElement('mask').style.position="absolute";
    getElement('TituloNoticiaElimi').innerHTML = Valor;
    getElement('ctl00_ContentPlaceHolder1_HIDEeliminar').value = Valor;
    mostrarmodal('DivEliminar');
}
function OcultarEliminar()
{
    $('#mask').hide();
	$('#DivEliminar').hide();
}
/////////////////////////////////////////////////////////////////////////////////////
/////*Funciones Aceptar Posicion*//////////////??????????////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function MostrarPosicion(Valor)
{
    getElement('DivPosicion').style.position="absolute";
    getElement('mask').style.position="absolute";
    mostrarmodal('DivPosicion');
}
function OcultarPosicion()
{
    $('#mask').hide();
	$('#DivPosicion').hide();
}
/////////////////////////////////////////////////////////////////////////////////////
/////*Funcion Popup Modificacion*////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function MostrarMod(idnoti) 
{
ventana=window.open("Adm_Noticia_Mod.aspx?Id="+idnoti,"editar","width=550 height=640,toolbar=no,scrollbars=no, resizable=yes,menubar=no top=50 left=100");
ventana.focus();
}
/////////////////////////////////////////////////////////////////////////////////////
/////*Limpia el Imput *//////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function clearForm() {
	document.myForm.myField.value = "";
}
/////////////////////////////////////////////////////////////////////////////////////
/////*Mostrar Modal *////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
function mostrarmodal(eldiv){
 //Get the A tag
	var id = '#'+ eldiv;
	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	//transition effect		
	$('#mask').fadeIn(400);	
	$('#mask').fadeTo("slow",0.8);
	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();      
	//Set the popup window to center
	$(id).css('top',  winH/2-$(id).height()/2);
	$(id).css('left', winW/2-$(id).width()/2);
	//transition effect
	$(id).fadeIn(400); 
}

 

