function MM_swapImgRestore()
{ //v3.0
	var i, x, a;
	
	a = document.MM_sr;
	for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++)
		x.src = x.oSrc;
	return;
}

function MM_preloadImages()
{ //v3.0
	var i, j, a, d;
	
	d = document;
	if (d.images) {
		if (!d.MM_p)
			d.MM_p = new Array();
		j = d.MM_p.length;
		a = MM_preloadImages.arguments;
		for (i=0; i<a.length; i++) {
			//if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			//}
		}
	}
	return;
}

function MM_swapImage()
{ //v3.0
	var i, j, x, a;
	
	j = 0;
	a = MM_swapImage.arguments;
	document.MM_sr = new Array;
	for (i=0; i<(a.length-2); i+=3) {
		if ((x=MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc)
				x.oSrc = x.src;
			x.src = a[i+2];
		}
	}
	return;
}

function MM_findObj(n, d)
{ //v4.0
	var p, i, x;
	
	if (!d)
		d = document;
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if (!(x=d[n]) && d.all)
		x = d.all[n];
	for (i=0; !x && i<d.forms.length; i++)
		x = d.forms[i][n];
	for (i=0; !x && d.layers && i<d.layers.length; i++)
		x = MM_findObj(n,d.layers[i].document);
	if (!x && document.getElementById)
		x = document.getElementById(n);
	return x;
}

function MM_reloadPage(init)
{ //reloads the window if Nav4 resized
	if (init != false) { 
		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();
	return;
}

//Functiones extra
function IsValidEMail(s)
{
	var i, l, lastwasdot, atfound, atpos;
	
	l = s.length;
	if (l < 1)
		return false;
	lastwasdot = true;
	atfound = false;
	atpos = -1;
	for (i=0; i<l; i++) {
		if (s.charCodeAt(i) < 33)
	  		return false;
		if (s.charAt(i) == '.') {
			if (lastwasdot != false)
				return false;
			if (atfound!=false && atpos==i-1)
				return false;
			lastwasdot = true;
		}
		else if (s.charAt(i) == '@') {
			if (i==0 || lastwasdot!=false || atfound!=false)
				return false;
			atfound = true;
			atpos = i;
		}
		else
			lastwasdot = false;
	}
	if (lastwasdot!=false || atfound==false || atpos==l-1)
		return false;
	return true;
}

function IsJavaAvailable()
{
	if (navigator.appName=='Microsoft Internet Explorer' && navigator.appVersionindexOf('MSIE 3'))
		return false;
	return (navigator.javaEnabled && navigator.javaEnabled());
}

function MyGetElementPosition(elem, relativeWindow)
{
	var pos = {x:0, y:0};
	var oWindow = relativeWindow || window;

	while (elem) {
		pos.x += elem.offsetLeft;
		pos.y += elem.offsetTop;
		if (elem.offsetParent == null) {
			var oDocument = elem.ownerDocument || elem.document;
			var oOwnerWindow = oDocument.parentWindow || oDocument.defaultView;
			if (oOwnerWindow != oWindow)
				elem = oOwnerWindow.frameElement;
			else
				break;
		}
		else
			elem = elem.offsetParent;
	}
	return pos;
}

function MyScrollToElement(n)
{
	var pos;
	
	if ((elem=MM_findObj(n)) == null)
		return;
	pos = MyGetElementPosition(elem);
	if (pos.y > 200)
		pos.y -= 20;
	window.scrollTo(pos.x, pos.y);
	return;
}

function MyResizeToObject(s)
{
	var x, w, h, w2, h2, pw, ph, d, b;

	if ((x=MM_findObj(s)) == null)
		return;
	window.resizeTo(screen.availWidth, screen.availHeight);
	w = x.clip ? x.clip.width : x.offsetWidth;
	h = x.clip ? x.clip.height : x.offsetHeight;
	if (!h)
		return;
	window.resizeTo(w+200, h+200);
	pw = 0;	ph = 0;
	d = window.document.documentElement;
	b = window.document.body;
	if (window.innerWidth) {
		pw = window.innerWidth;
		ph = window.innerHeight;
	}
	else if (d && d.clientWidth) {
		pw = d.clientWidth;
		ph = d.clientHeight;
	}
	else if (b && b.clientWidth) {
		pw = b.clientWidth;
		ph = b.clientHeight;
	}
	if (window.opera && !document.childNodes)
		pw += 16;
	x = MM_findObj(s);
	w2 = x.clip ? x.clip.width : x.offsetWidth;
	h2 = x.clip ? x.clip.height : x.offsetHeight;
	w2 = w2+((w+200)-pw);
	h2 = h2+((h+200)-ph);
	if (w2 > screen.availWidth)
		w2 = screen.availWidth;
	if (h2 > screen.availHeight)
		h2 = screen.availHeight;
	window.resizeTo(w2, h2);
	w2 = (screen.width-w2) / 2;
	h2 = (screen.height-h2) / 2;
	window.moveTo(w2, h2);
	return;
}

