// JavaScript Document

//Ventanas emergentes
function popWindow(URL){ 
window.open(URL,'ventana1','width=600, height=400, scrollbars=yes, menubar=no, location=no, resizable=no,toolbar=no,location=no,directories=no,top=50,left=50');
}

////PARA EVITAR EL CLICK DERECHO/////
function click(e) {
// Explorer
if (IE)
if (event.button == 2){
accion() ;
return false ;
}

// Netscape
if (NS)
if (e.which == 3) {
accion() ;
return false ;
}
}

function accion() {
window.status = '© Centro de Promoción Cultural "Trujillo"' ;
if (IE) alert('© Centro de Promoción Cultural "Trujillo"');
return ;
}

var NS = (document.layers) ;
var IE = (document.all) ;
if (NS) document.captureEvents(Event.MOUSEDOWN) ;
document.onmousedown = click ;

//otras cosas 2
/*
<script language="JavaScript1.2">
</script>
*/
//drag drop function for NS 4////
/////////////////////////////////
var dragswitch=0;
var nsx;
var nsy;
var nstemp;

function drag_dropns(name){
	temp=eval(name);
	temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
	temp.onmousedown=gons;
	temp.onmousemove=dragns;
	temp.onmouseup=stopns;
}

function gons(e){
	temp.captureEvents(Event.MOUSEMOVE);
	nsx=e.x;
	nsy=e.y;
}

function dragns(e){
	if (dragswitch==1){
		temp.moveBy(e.x-nsx,e.y-nsy);
		return false;
	}
}

function stopns(){
	temp.releaseEvents(Event.MOUSEMOVE);
}

//drag drop function for IE 4+////
/////////////////////////////////

var dragapproved=false;

function drag_dropie(){
	if (dragapproved==true){
		document.all.showimage.style.pixelLeft=tempx+event.clientX-iex;
		document.all.showimage.style.pixelTop=tempy+event.clientY-iey;
		return false;
	}
}

function initializedragie(){
	iex=event.clientX;
	iey=event.clientY;
	tempx=showimage.style.pixelLeft;
	tempy=showimage.style.pixelTop;
	dragapproved=true;
	document.onmousemove=drag_dropie;
}

if (document.all){
	document.onmouseup=new Function("dragapproved=false");
}

////drag drop functions end here//////

function hidebox(){
	if (document.all)
		showimage.style.visibility="hidden";
	else if (document.layers)
		document.showimage.visibility="hide";
}

// writelink - creates email hyper link that is invisible to webcrawlers
function writelink(emailname, classname) {
  document.write('<a href=\"mailto:'+emailname+'\@ceprocut.org\"'+'class=\"'+classname+'\">'+emailname+'@ceprocut.org</a>') ;
}

// writelink2 - creates email hyper link that is invisible to webcrawlers
function writelink2(emailname, classname, title) {
  document.write('<a href=\"mailto:'+emailname+'\@ceprocut.org\"'+'class=\"'+classname+'\">'+title+'</a>') ;
}

// writeURL - creates url hyper link that is invisible to webcrawlers
function writeURL(urlname, classname, title) {
  document.write('<a href=\"http://www.'+urlname+'\"'+' target="_blank" class=\"'+classname+'\">http://www.'+urlname+'</a>') ;
}

// writeURL - creates url hyper link that is invisible to webcrawlers
function writeURL2(urlname, classname, title) {
  document.write('<a href=\"http://www.'+urlname+'\"'+' target="_blank" class=\"'+classname+'\">'+title+'</a>') ;
}

// Funciones para mostrar imagenes en capas
function showImg(archivo,ancho,alto){
	//xInnerHtml('c1','')
	xWidth ('ampliacion',ancho + 6 )
	xHeight ('ampliacion',alto + 6 + 18)	//xHeight ('ampliacion',alto + 6 + 20 + 18)		
	xWidth ('c1',ancho)
	xHeight ('c1',alto)

	//xInnerHtml('c1','<img src="' + archivo + '" width="' + ancho + '" height="' + alto + '" border="0">')

    xInnerHtml('c1','<a href="javascript:closeWindow()"><img src="' + archivo + '" width="' + ancho + '" height="' + alto + '" alt="Cerrar Ventana" border="0">')

	pos_left = parseInt((xClientWidth()-ancho+3)/2)
	pos_left_actual=-ancho
	if (xClientHeight() < alto){
		pos_top = xScrollTop() + 10;
	}else{
		pos_top = xScrollTop() + parseInt((xClientHeight() - alto - 20) / 2)
	}

	xMoveTo('ampliacion',pos_left_actual,pos_top)

	situar()

	xShow('ampliacion')
}

function closeWindow(){
	xHide('ampliacion');

}

function situar(){
	if (pos_left_actual < pos_left){
		pos_left_actual += 20
		xMoveTo('ampliacion', pos_left_actual,pos_top);
		setTimeout ('situar()',10)
	}
}

