function AbrirVentana(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 AbrirVentanaVertical(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 UpdateImage(file,w,h){
	var correct; 

	correct=0;
	image=new Image();
  	image.src=(file);	
	if(LimitAttach(document.all.form, document.all.form.uploadfile.value)) {		
		document.all.nueva.width=w;
		document.all.nueva.hight=h;
		document.nueva.src=file;
		return true;
	}
}		

function LimitAttach(form, file) {
	extArray = new Array(".gif", ".jpg");	

	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; 
}