function regresar() {
	history.back();
	return false;
}

function WinOpen(page,w,h) {
	var ancho=((screen.width-w)/2);
	var alto=((screen.height-h)/2);
	eval("pag=open('"+page+"','','toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width="+w+",height="+h+",top="+alto+",left="+ancho+"');");
}

function WinOpenVertical(page,w,h) {
	var ancho=((screen.width-w)/2);
	var alto=((screen.height-h)/2);
	eval("pag=open('"+page+"','','toolbar=no,directories=no,menubar=no,scrollbars=1,resizable=no,width="+w+",height="+h+",top="+alto+",left="+ancho+"');");
}

function WinOpenVH(page,w,h) {
	var ancho=((screen.width-w)/2);
	var alto=((screen.height-h)/2);
	eval("pag=open('"+page+"','','toolbar=no,directories=no,menubar=no,scrollbars=2,resizable=yes,width="+w+",height="+h+",top="+alto+",left="+ancho+"');");
}

function UpdateImage(file,type,typefile){
	var correct; 

	if(typefile==2){
		correct=0;
		image=new Image();
		image.src=(file);	
		if(LimitAttach(document.all.form, document.all.form.uploadfile.value)) {		
			switch(type){
				case 0:
					if((image.width==210)&&(image.height==210)){
						document.all.nueva.width=158;
						document.all.nueva.hight=158;
						correct=1;
					}
					break;
				case 1:
					if((image.width==105)&&(image.height==60)){
						document.all.nueva.width=105;
						document.all.nueva.hight=60;
						correct=1;
					}
					break;
				case 2:
					if((image.width==106)&&(image.height==106)){
						document.all.nueva.width=106;
						document.all.nueva.hight=106;
						correct=1;
					}
					break;
				case 3:
					document.all.nueva.width=document.all.actual.width;
					document.all.nueva.hight=document.all.actual.hight;
					correct=1;
					break;
				case 4:
					document.all.nueva.width=document.all.actual.width;
					document.all.nueva.hight=document.all.actual.hight;
					correct=1;
					break;
				case 5:
					if((image.width==106)&&(image.height==106)){
						document.all.nueva.width=106;
						document.all.nueva.hight=106;
						correct=1;
					}
					break;
				case 6:
					if((image.width==550)&&(image.height==140)){
						document.all.nueva.width=275;
						document.all.nueva.hight=70;
						correct=1;
					}
					break;
				case 7:
					document.all.nueva.width=150;
					correct=1;
					break;
				case 8:
					if((image.width==40)&&(image.height==40)){
						document.all.nueva.width=40;
						document.all.nueva.hight=40;
						correct=1;
					}
					break;
			}
		}
		if(correct==1){
			document.nueva.src=file;
			return true;
		} else {
			alert("Las dimensiones del archivo gráfico, no son las correctas");
			document.all.form.uploadfile.clear();
			return false;
		}
	}else{
		return true;
	}
}		

function LimitAttach(form, file) {
	extArray = new Array(".gif", ".jpg", ".png", ".jpeg", ".swf");	

	var ancho=((screen.width - 100)/2);
	var alto=((screen.height - 100)/2);
	allowSubmit = false;
	if (!file) {
		alert ("Por favor ingrese el archivo grafico");
		return false;
	}
	while (file.indexOf("\\") != -1)
		file = file.slice(file.indexOf("\\") + 1);
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < extArray.length; i++) {
		if (extArray[i] == ext) { 
			allowSubmit = true; 
			break; 
		}
	}
	if (allowSubmit) {
		return true;
	} else {
		alert ("Usted puede utilizar unicamente archivos: " + (extArray.join("  ")) + "\nPor favor, seleccione un nuevo archivo e intentelo nuevamente");
		return false;
	}
}

function ReplaceString(string, match, replacement) {
  var result = '';
  var index = 0;
  var lastIndex = index;
  while (string.length > lastIndex) {
    index = string.indexOf(match, lastIndex);
    if (index == -1) { break }
    result += string.substring(lastIndex, index) + replacement;
    lastIndex = index + match.length;
  }
  result += string.substring(lastIndex, string.length);
  return result; 
}

/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function pausescroller(content, divId, divClass, delay){
	this.content=content //message array content
	this.tickerid=divId //ID of ticker div to display information
	this.delay=delay //Delay between msg change, in miliseconds.
	this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
	this.hiddendivpointer=1 //index of message array for hidden div
	document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
	var scrollerinstance=this
	if (window.addEventListener) //run onload in DOM2 browsers
		window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
	else if (window.attachEvent) //run onload in IE5.5+
		window.attachEvent("onload", function(){scrollerinstance.initialize()})
	else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
		setTimeout(function(){scrollerinstance.initialize()}, 500)
}

// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
	this.tickerdiv=document.getElementById(this.tickerid)
	this.visiblediv=document.getElementById(this.tickerid+"1")
	this.hiddendiv=document.getElementById(this.tickerid+"2")
	this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
	this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
	this.getinline(this.visiblediv, this.hiddendiv)
	this.hiddendiv.style.visibility="visible"
	var scrollerinstance=this
	document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
	document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
	if (window.attachEvent) //Clean up loose references in IE
		window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
	setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}


// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------

pausescroller.prototype.animateup=function(){
	var scrollerinstance=this
	if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
		this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
		this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
		setTimeout(function(){scrollerinstance.animateup()}, 50)
	}else{
		this.getinline(this.hiddendiv, this.visiblediv)
		this.swapdivs()
		setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
	}
}

// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------

pausescroller.prototype.swapdivs=function(){
	var tempcontainer=this.visiblediv
	this.visiblediv=this.hiddendiv
	this.hiddendiv=tempcontainer
}

pausescroller.prototype.getinline=function(div1, div2){
	div1.style.top=this.visibledivtop+"px"
	div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}

// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------

pausescroller.prototype.setmessage=function(){
	var scrollerinstance=this
	if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
		setTimeout(function(){scrollerinstance.setmessage()}, 100)
	else{
		var i=this.hiddendivpointer
		var ceiling=this.content.length
		this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
		this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
		this.animateup()
	}
}

pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
	if (tickerobj.currentStyle)
		return tickerobj.currentStyle["paddingTop"]
	else if (window.getComputedStyle) //if DOM2
		return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
	else
		return 0
}

// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

function MostrarVentana(url) {
 	ventana = open(url,"ventana","scrollbars=no,status=no,toolbar=no,directories=no,menubar=no,resizable=no,width=649,height=340")
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");