
var dragapproved=false
var minrestore=1
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("cframe").src=url
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
}
}

function maximizar(){
//document.getElementById("maxname").setAttribute("src","imagenes/restaurar.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
//document.getElementById("maxname").setAttribute("src","imagenes/restaurar.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
//document.getElementById("maxname").setAttribute("src","imagenes/maximizar.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){
document.getElementById("dwindow").style.display="none"
if(document.getElementById("cframe"))
	document.getElementById("cframe").src = "";
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr','span');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}
}

function showDate(){
                        var currDate = new Date();
                        var currMonDay = currDate.getDate();
                        var currMonth = currDate.getMonth() + 1;
                        var currDay = currDate.getDay();
                        var currYear = currDate.getYear();
                        var dayName;
                        var monthName;
                        if (currMonth == 1) monthName = "Enero";
                        if (currMonth == 2) monthName = "Febrero";
                        if (currMonth == 3) monthName = "Marzo";
                        if (currMonth == 4) monthName = "Abril";
                        if (currMonth == 5) monthName = "Mayo";
                        if (currMonth == 6) monthName = "Junio";
                        if (currMonth == 7) monthName = "Julio";
                        if (currMonth == 8) monthName = "Agosto";
                        if (currMonth == 9) monthName = "Septiembre";
                        if (currMonth == 10) monthName = "Octubre";
                        if (currMonth == 11) monthName = "Noviembre";
                        if (currMonth == 12) monthName = "Diciembre";
                        if (currDay == 0) dayName = "Domingo";
                        if (currDay == 1) dayName = "Lunes";
                        if (currDay == 2) dayName = "Martes";
                        if (currDay == 3) dayName = "Miércoles";
                        if (currDay == 4) dayName = "Jueves";
                        if (currDay == 5) dayName = "Viernes";
                        if (currDay == 6) dayName = "Sabado";
                        document.write(dayName + " " + currMonDay + " " + monthName + " , " 
                        + currYear);
}

function getTicker(){	
	var ajax = new Ajax.Updater('ticker','ticker.php',{method:'get',onComplete: showTicker});
}
function showTicker(req){	
	txt = req.responseText;
}

function getHTML(div,url){	
	document.getElementById(div).style.display = "none";
	var ajax = new Ajax.Updater(div,url,{method:'get',onComplete: showResponse});
}
function showResponse(req){	
	$('contenido').innerHTML = req.responseText;
	new Effect.SlideDown(document.getElementById('contenido'));
}

function getHTML2(div,url){	
	var ajax = new Ajax.Updater(div,url,{method:'get',onComplete: showResponse2});
}
function showResponse2(req){	
	$('contenido').innerHTML = req.responseText;
	new Effect.SlideDown(document.getElementById('contenido'));	
	document.getElementById("banner").style.display = "block";
	s1.write('banner');
}
function getHTML3(div,url){	
	var ajax = new Ajax.Updater(div,url,{method:'get',onComplete: showResponse3});
}
function showResponse3(req){	
	$('contenido').innerHTML = req.responseText;
	document.getElementById("banner").style.display = "block";
	s1.write('banner');
}
/*function ventana_ver(dir){
var cabecera= " ";
ventana=window.open ("",'ventana_sec','scrollbars=no,status=no,resizable=yes,toolbars=0,location=0,directories=0,menubar=0,width=750,height=600');
ventana.document.open();
ventana.creator=window;
cabecera+= "<html><head><title>ACN Press - Edición Servicio</title></head>";
cabecera+= "<frameset rows=* border=0>";
cabecera+= "<frame frameborder=0 src=" +dir +" name='doc' scrolling=yes>";
cabecera+= "</frameset></body></html>";
ventana.document.write(cabecera);
ventana.document.close();
ventana.creator=window;
ventana.focus();
}*/
function ventana_editar(dir){
                if(tipo == 4){ alert("No puede editar servicios"); return;}
        var dim = "width=750,height=600";
        window.open(dir,'Edición','resizable=yes,menubar=no,scrollbars=yes,status=no,'+dim);
}
function ventana_ver(dir){
        var dim = "width=750,height=600";
        window.open(dir,'Servicio','resizable=yes,menubar=no,scrollbars=yes,status=no,'+dim);
}
function ventana(tipo,foto){
        var dir = "";
		if(tipo == 1){		
			dir = "galeriafotos.php?foto="+foto;
			titulo = "Foto";
		}
		if(tipo == 2){
			dir = "galeriaaudios.php?fichero="+foto;
			titulo = "Audio";		
		}
		if(tipo == 3){
			dir = "galeriavideos.php?codadjunto="+foto;
			titulo = "Video";		
		}
        //window.open(dir,titulo,'resizable=no,menubar=no,scrollbars=yes,status=no,width=480,height=800');
		//if(galeria != "") galeria.cleanup();
		titulo = titulo+new Date().getTime();
		galeria = dhtmlwindow.open(titulo, "iframe", dir, "ACNPress", "width=480px,height=800px,resize=1,scrolling=1,center=1", "recal");
		/*galeria.onclose=function(){
			galeria.close();
			return true;
		}*/
		//galeria.isScrolling(true);
		//galeria.setfocus();
		//galeria.show();
		//galeria.setopacity(0);
}

function ventana_audio(tipo,foto){
        var dir = "ventana_ampliafoto.php?tipo=" + tipo + "&fichero="+foto;
        window.open(dir,'Adjunto','resizable=yes,menubar=no,scrollbars=yes,status=no,width=340,height=145');
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function printtxt(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

function textCounter(field,counter,maxlimit,linecounter) {

	// text width//

	var fieldWidth =  parseInt(field.style.width);

	var charcnt = field.value.length;        


	
	if (charcnt > maxlimit) { 

		field.value = field.value.substring(0, maxlimit);

	}

	else { 
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	setcolor(document.getElementById(counter),percentage,"background-color");
	linecounter.value = maxlimit - charcnt;
	document.getElementById(counter).innerHTML = maxlimit - charcnt;
	}

	

}

function setcolor(obj,percentage,prop){

	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";

}


function cuenta(field, countfield){
	countfield.value = field.value.length;
}

function makeBigger(direction,field) {
  var txtarea = document.getElementById(field);
  if (direction==1) {
    txtarea.cols = txtarea.cols + 10;
    txtarea.rows = txtarea.rows + 20;
  } else {
    txtarea.cols = txtarea.cols - 10;
    txtarea.rows = txtarea.rows - 20;
  }
  //document.getElementById("textarea_next_time").value=txtarea.cols+","+txtarea.rows;
}

window.defaultstatus="ACN Press 2009";
window.status="ACN Press 2009";

am = "This function is disabled!";

// do not edit below this line
// ===========================
bV  = parseInt(navigator.appVersion)
bNS = navigator.appName=="Netscape"
bIE = navigator.appName=="Microsoft Internet Explorer"

function nrc(e) {
   if (bNS && e.which > 1){
      //alert(am)
      return false
   } else if (bIE && (event.button >1)) {
     //alert(am)
     return false;
   }
}

/*document.onmousedown = nrc;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (bNS && bV<5) window.onmousedown = nrc;*/

