function cambiar(cual) {
	document.getElementById('imagen_principal').setAttribute('src', "img/trabajos/fotos/" + cual);
}

function privacidad() {
	window.open ("privacidad.htm", "privacidad","location=0,status=1,scrollbars=0,width=600,height=500")	
}

function creditos() {
	window.open ("creditos.htm", "creditos","location=0,status=1,scrollbars=0,width=500,height=200")	
}

function borrar_imagen(pagina, id) {
    if (confirm("¿Está seguro de que desea eliminar la imagen?")) {
        self.location = 'gestion/cambiar_imagen.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';
    }
}

function borrar_imagen_trabajo(pagina, id) {
    if (confirm("¿Está seguro de que desea eliminar la imagen?")) {
        self.location = 'gestion/cambiar_imagen_trabajo.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';
    }
}

function borrar_trabajo(pagina, id) {
    if (confirm("¿Está seguro de que desea eliminar el trabajo?")) {
        self.location = 'gestion/cambiar_trabajo.php?accion=borrar&pagina=' + pagina + '&id=' + id + '\n';
    }
}

function borrar_email(pagina, id) {
    if (confirm("¿Está seguro de que desea eliminar el contacto?")) {
        self.location = 'cambiar_email.php?accion=borrar&id=' + id + '\n';
    }
}

function borrar_mailing(id) {
    if (confirm("¿Está seguro de que desea eliminar el mailing?")) {
        self.location = 'cambiar_mailing.php?accion=borrar&id=' + id + '\n';
    }
}

// pasa el texto seleccionado de un textarea a negrita => hay que diferenciar entre IEXPLORER y otro
function negrita(){
	browser = navigator.appName;
	if (browser.indexOf('Microsoft') != -1) { 
		//CÓDIGO PARA IEXPLORER
		document.getElementById('texto').focus();
		document.selection.createRange().text = "<strong>" + document.selection.createRange().text + "</strong>";
	} else {
		//CÓDIGO PARA EL FIREFOX
		texto = document.getElementById('texto').value;
		inicio = document.getElementById('texto').selectionStart;
		fin = document.getElementById('texto').selectionEnd;
		t1 = texto.substring(0, inicio);
		t2 = "<strong>" + texto.substring(inicio, fin) + "</strong>";
		t3 = texto.substring(fin);
		texto = t1 + t2 + t3;
		document.getElementById('texto').value = texto;
	}	
}

function abrir_ventana(url, x, y){
	ventana = window.open(url, null, "width=" + x + ",height=" + y + ",menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}

function insertar_enlace(){
	enlace = document.getElementById('enlace').value; // valor del enlace
	/*target = document.getElementById('target').checked; // miro si la ventana se abre en esta o en otra ventana
	titulo = document.getElementById('titulo').value;
	if (target == 1) {
		target = "target=\"blank\"";	
	} else {
		target = "";
	}
	if (titulo != "") {
		title = "title=\"" + titulo + "\"";
	} else {
		title = "";
	}*/
	target = "target=\"blank\"";
	title = "";
	padre = self.opener; //esta es la ventana donde está el formulario
	//creo el TAG "<A HREF..." con el enlace para meterlo en el formulario de la ventana padre
	tag = "<a href=\"" + enlace + "\" " + target + " " + title + ">";
	if (enlace != "") {
		browser = navigator.appName;
		if (browser.indexOf('Microsoft') != -1) { 
			//CÓDIGO PARA IEXPLORER
			padre.document.getElementById('texto').focus();
			padre.document.selection.createRange().text = tag + padre.document.selection.createRange().text + "</a>";
		} else {
			//CÓDIGO PARA EL FIREFOX
			texto = padre.document.getElementById('texto').value;
			inicio = padre.document.getElementById('texto').selectionStart;
			fin = padre.document.getElementById('texto').selectionEnd;
			t1 = texto.substring(0,inicio);
			t2 = tag + texto.substring(inicio,fin)+"</a>";
			t3 = texto.substring(fin);
			texto = t1 + t2 + t3;
			padre.document.getElementById('texto').value = texto;
		}
	}
	self.close();
}
