function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// disableFrames: detecta si la pantalla se cargo en un frame, de ser asi se carga en toda la 
//				  pantalla (deshabilita los frames).
function disableFrames() {
	if (top != window)
		top.location.href = window.location.href;
}

function selectAllCheckboxes(formIndex,setToTrue) 
{
	var form = document.forms[formIndex];
	var obj;
	for (var i = 0; i < form.length; i++) 
	{
		obj = form.elements[i];
		if (obj.type == "checkbox") 
			if (setToTrue)
				obj.checked = true;			/*	TRUE = SELECCIONAR TODOS */
			else
				obj.checked = !obj.checked; /*  NOT = INVERTIR SELECCION */
	}
}

function selectAllCheckboxesName(formIndex,inputName,setToTrue) 
{
	var form = document.forms[formIndex];
	var obj;
	for (var i = 0; i < form.length; i++) 
	{
		obj = form.elements[i];
		if (obj.type == "checkbox") 
			if (obj.name == inputName)
				if (setToTrue)
					obj.checked = true;			/*	TRUE = SELECCIONAR TODOS */
				else
					obj.checked = !obj.checked; /*  NOT = INVERTIR SELECCION */
	}
}

function openPopup(url,name,features,width,height)
{

	if (features != "")
		features += ", ";

	var popup = window.open(url,name,features+" width="+width+", height="+height);
	centerPopup(popup,width,height);
	popup.focus();

	return popup;
}

function centerPopup(popup,width,height)
{
	var windowX = (screen.width-width)/2;
	var windowY = (screen.height/2)-(height/2);	

	popup.moveTo(windowX,windowY);
	
	return popup;
}

function fixSizePopup(popup,width,height)
{
	var w_resize = -20;
	var h_resize = 0;

	if (popup.document.height > height)	// VSCROLL!
		w_resize += 20;

	if (popup.document.width > width)	// HSCROLL!
		h_resize += 20;
	
	if (h_resize || w_resize)
	{
		popup.resizeBy(w_resize,h_resize);
		centerPopup(popup,width,height);
	}

	return popup;
}
