NS4 = (document.layers) ? 1 : 0; 
IE4 = (document.all) ? 1 : 0;
MAC = (navigator.appVersion.indexOf("Macintosh") > -1);
PAG = escape(window.location.href);
esconder = 0;

if (NS4) IEBR = "";
else if (IE4) IEBR = "<BR>";

PAG = Replace(PAG, "/", "%2F");
PAG = Replace(PAG, ".", "%2E");
PAG = Replace(PAG, "-", "%2D");
PAG = Replace(PAG, "_", "%5F");

function Replace(sr, sf, ss){
	a = sr.split(sf);
	return a.join(ss);
}

function O_setTimer(){
	vistimerID = setTimeout("Visualizar()", 500);
}

function Visualizar(){ 
	if (IE4) calif1.style.display = "block";
	clearTimeout(vistimerID); 
	vistimerID = null;
}

function Desplegar(){
	if (NS4){
		calif1_element = eval("document.calif1");
		calif1_element.visibility = "hide";
		calif2_element = eval("document.calif2");
		calif2_element.visibility = "show";
	}
	if (IE4){
		calif2.style.left = calif1.offsetLeft + 1;
		calif2.style.top = calif1.offsetTop - 73;
		calif1.style.display = "none";
		calif2.style.display = "block";
	}
}

function GetCookie(label){
	var labelLen = label.length;
	var cLen = document.cookie.length;
	var i = 0;
	var cEnd;
	while (i < cLen){
		var j= i + labelLen; 
		if (document.cookie.substring(i, j) == label){
			cEnd = document.cookie.indexOf(";", j);
			if (cEnd == -1) cEnd = document.cookie.length;
			return unescape(document.cookie.substring(j + 1, cEnd));
		}
		i++;
	}
	return "";
}

function SetCookie(name, value){
	newdate = new Date((new Date()).getTime() + 3600000);
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + newdate.toGMTString();
}

function ActualizarBD(cal){
	if (cal > 0 && cal < 5){
		SetCookie(PAG, 2);
		if (NS4 || MAC) window.location.href = "/application/ac_calificacion.asp?c=" + cal + "&p=" + calif1.code;
		if (IE4 && !MAC){
			if (document.frm == null) return;
			esconder = 1;
			with (document.frm.frm){
				action = "/application/ac_calificacion.asp";
				c.value = cal;
				p.value = calif1.code;
				submit();
				Esconder();
			}
		}
	}
}

function MouseOver(image_num){
	over_graphic = 1;
	s = "im" + image_num;
	document[s].src = Grafica[image_num + 5].src;
	over_graphic = 1;
}

function MouseOut(image_num) {
	layerOut();
	s = "im" + image_num;
	document[s].src = Grafica[image_num].src;
}

function layerOut() {
	over_graphic = 0; 
	setTimeout ("layerTimeout();", 50);
}

function layerTimeout() {
	if (over_graphic == 0) Esconder();
}

function Esconder(){
	over_graphic = 1;
	if (NS4){
		calif1_element = eval("document.calif1");
		calif1_element.visibility = "show";
		calif2_element = eval("document.calif2");
		calif2_element.visibility = "hide";
	}
	if (IE4){
		if (esconder) calif1.style.display = "none";
		else calif1.style.display = "block";
		calif2.style.display = "none";
	}
}

function Inicializar(){
	if (parseFloat(navigator.appVersion) < 4 || (navigator.appName != "Microsoft Internet Explorer" && navigator.appName != "Netscape")) return;
	if (MAC && IE4) return; 
	CookieData = GetCookie(PAG);
	if (CookieData == 2) st = "<DIV ID=calif2 CLASS=dos></DIV>";
	else {
		Grafica = new Array();
		for (i = 1; i < 12; i++) Grafica[i] = new Image();
		for (i = 1; i < 6; i++){
			Grafica[i].src = 'images/star' + i + 'u.gif';
			Grafica[i + 5].src = 'images/star' + i + 'd.gif';
		}
		s1 = "<A HREF='' onClick='ActualizarBD(";
		s2 = "); return false;' onMouseOver='MouseOver(";
		s3 = "); return true;' onMouseOut='MouseOut(";
		s4 = "); return true;'><IMG BORDER=0 src=images/star";
		s5 = "u.gif NAME=im";
		st = "<DIV ID=calif2 CLASS=dos STYLE='position:absolute;top:0;left:0;'><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=19><TR><TD>";
		st += s1 + "5" + s2 + "5" + s3 + "5" + s4 + "5" + s5 + "5 HEIGHT=18 WIDTH=19 ALT='Excelente'></A>" + IEBR;
		st += s1 + "4" + s2 + "4" + s3 + "4" + s4 + "4" + s5 + "4 HEIGHT=18 WIDTH=19 ALT='Buena'></A>" + IEBR;
		st += s1 + "3" + s2 + "3" + s3 + "3" + s4 + "3" + s5 + "3 HEIGHT=18 WIDTH=19 ALT='Normal'></A>" + IEBR;
		st += s1 + "2" + s2 + "2" + s3 + "2" + s4 + "2" + s5 + "2 HEIGHT=18 WIDTH=19 ALT='Mala'></A>" + IEBR;
		st += s1 + "1" + s2 + "1" + s3 + "1" + s4 + "1" + s5 + "1 HEIGHT=21 WIDTH=19 ALT='Pésima'></A></TD></TR></TABLE></DIV>";
		if (IE4 && !MAC) st += "<div id=ifrm style='position:absolute:0;left:0'><iframe name=frm src=includes/cap.htm width=0 height=0 frameborder=0 scrolling=no></iframe></div>";
	}
	document.write(st);
}
Inicializar();
