0) {
$(othertabs[othertabs.length-1]).parents('tr').after(datos);
} else {
$(ParentTab).find('tr:first').after(datos);
}
}
});
}
function SaveLastTab(TabGroupID, TabName) {
var value = 'SaveTab='+TabName;
var x =$(TabGroupID+' > table > tbody > tr > td > div.Tab').filter(':visible:last');
if(x.length == 0) {
alert('Debes primero abrir un estudio.');
return false;
}
x.find('input[@type!=radio], select, textarea, button, input[@type=radio]:checked').each(function(){
if($(this)[0].type == "checkbox") {
if($(this)[0].checked == true) {
value += '&'+$(this).attr('name')+"="+escape($(this).val());
}
} else {
value += '&'+$(this).attr('name')+"="+escape($(this).val());
}
});
//alert(value);
$.ajax({
type: "POST",
url: document.URL,
data: value,
success: function(data) {
eval(unescape(data));
}
});
}
function DeleteLastTab(TabGroupID, message) {
var x =$(TabGroupID+' > table > tbody > tr > td > div.Tab').filter(':visible:last');
if(x.length == 0) {
alert('Debes primero abrir un estudio.');
return false;
}
if(confirm(message) == false) {
return;
}
var value='DeleteTab='+TabGroupID.replace('#', '')+'&';
x.find('input[@type!=radio], select, textarea, button, input[@type=radio]:checked').each(function(){
if($(this)[0].type == "checkbox") {
if($(this)[0].checked == true) {
value += '&'+$(this).attr('name')+"="+escape($(this).val());
}
} else {
value += '&'+$(this).attr('name')+"="+escape($(this).val());
}
});
//alert(value);
$.ajax({
type: "POST",
url: document.URL,
data: value,
success: function(data) {
eval(unescape(data));
}
});
}
var DeleteTabById = function(TabGroupID, message, id) {
var x =$('div.Tab#'+id).filter(':visible');
if(x.length == 0) {
alert('Debes primero abrir un estudio.');
return false;
}
if(confirm(message) == false) {
return;
}
var value='DeleteTab='+TabGroupID.replace('#', '')+'&';
x.find('input[@type!=radio], select, textarea, button, input[@type=radio]:checked').each(function(){
if($(this)[0].type == "checkbox") {
if($(this)[0].checked == true) {
value += '&'+$(this).attr('name')+"="+escape($(this).val());
}
} else {
value += '&'+$(this).attr('name')+"="+escape($(this).val());
}
});
//alert(value);
$.ajax({
type: "POST",
url: document.URL,
data: value,
success: function(data) {
eval(unescape(data));
}
});
};
function SaveTab(TabID) {
var datos = 'SaveTab='+TabID.replace("#Tab", '');
$(TabID).find("input[@type!=radio], select, textarea, button, input[@type=radio]:checked").each(function() {
if($(this)[0].type == "checkbox") {
if($(this)[0].checked == true) {
datos += '&'+$(this).attr('name')+"="+escape($(this).val());
}
} else {
datos += '&'+$(this).attr('name')+"="+escape($(this).val());
}
});
$.ajax({
type: "POST",
url: document.URL,
data: datos,
success: function(data) {
eval(unescape(data));
}
});
}
$(function(){$('.buttons').css('opacity', 0.5); $("p.buttons, div.buttons").hover(function(){
$(this).fadeTo("fast", 1.0);
},function(){
$(this).fadeTo("fast", 0.5);
}); });
function getMonth(i) {
var Months = new Array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
return Months[i-1];
}
timeouts = Object;
clearTimeouts = function(o) {
if(typeof timeouts[o] != 'undefined') {
for(var i = 0;i<=timeouts[o].length;i++) {
window.clearTimeout(timeouts[o][i]);
}
}
timeouts[o] = [];
}
setObjectTimeout = function(o, code, interval) {
if(typeof timeouts[o] == 'undefined') { timeouts[o] = new Array; }
timeouts[o].push(window.setTimeout(code, interval));
}
function Validator() {
this.timeout = 2000;
this.objects = new Array;
this.addValidator = function(obj, event, effect, message, target) {
if(typeof target == 'undefined') {
target = obj;
}
if(document.getElementById(obj) == null) {
obj = document.getElementsByName(obj)[0];
} else {
obj = document.getElementById(obj);
}
if(obj.className.match(/(HiddenField|Uneditable)/g)) { return false; }
if(!this.objects[obj.id]) { this.objects[obj.id] = new Array; }
if(!this.objects[obj.id][event]) { this.objects[obj.id][event] = new Array; }
this.objects[obj.id][event].push(new Array(effect, message, target));
return 1;
}
this.refreshValidators = function() {
for(o in this.objects) {
for(e in this.objects[o]) {
for(f in this.objects[o][e]) {
(this.objects[o][e][f][0])();
}
}
}
return 1;
}
this.checkAllValidators = function(form, nographics) {
errors = {};
errors.length = 0;
if(form == 'undefined') {
for(o in this.objects) {
for(e in this.objects[o]) {
for(f in this.objects[o][e]) {
if((this.objects[o][e][f][0])() != true) {
errors[o] = this.objects[o][e][f][1];
errors.length++;
break; // paramos ante el primer error
}
}
}
if(errors.length != 0) {
this.showSpinnerImage(o);
clearTimeouts(o);
if(errors[o]) {
this.showError(o, errors[o]);
} else {
this.clearError(o).showTickImage(o);
}
}
}
} else {
for(o in this.objects) {
if($("#"+o).parents('div.Tab').attr("id") == form) {
for(e in this.objects[o]) {
for( f in this.objects[o][e]) {
if((this.objects[o][e][f][0])() != true) {
errors[o] = this.objects[o][e][f][1];
errors.length++;
break; //paramos ante el primer error
}
}
}
if(errors.length != 0) {
this.showSpinnerImage(o);
clearTimeouts(o);
if(errors[o]) {
this.showError(o, errors[o]);
} else {
this.showTickImage(o);
}
}
}
}
}
return (errors.length==0);
}
this.eventRaised = function(obj, ev) {
// se usa "Validator", y no "this", porque estamos llamando a este metodo
// estaticamente cuando se dispara el evento ev
return function() {
Validator.showSpinnerImage(obj);
var i = 0;
var errorobject = undefined;
var errormsg = undefined;
var errortarget = undefined;
for(;i").fadeTo(50, 100);
return this;
}
this.showTickImage = function(objid/*, parentid, eventexception, functionexception*/) {
//alert("showTickImage("+objid+", "+parentid+", "+eventexception+", "+functionexception+")");
var p =$("#error_"+objid);
var m = $("#"+objid);
var pass = true;
var self = this;
clearTimeouts(objid);
setObjectTimeout(objid, function() {
$("#"+objid).removeClass('ErroredField').attr('title', '').attr('alt', ' ');
m.unbind('mouseover').unbind('mousemove').unbind('mouseout').attr('title', ' ').attr('alt', ' ');
p.unbind('mouseover').unbind('mousemove').unbind('mouseout').attr('title', ' ').attr('alt', ' ');
p.css('cursor', 'auto');
p.html("
").fadeIn('fast');
hideToolTip(m[0]);
}, this.timeout);
setObjectTimeout(objid, function() { p.fadeTo(1500, 0.01).css('cursor', 'auto'); }, 2*this.timeout);
return this;
}
this.showError = function(object, message, parentid) {
clearTimeouts(object);
if(object != parentid) {
clearTimeouts(parentid);
}
var p = $("#"+object).parents('tr:first');
var m = $("#error_"+object);
var self = this;
setObjectTimeout(object, function() {
p.attr('title', message);
m.attr('title', message);
p.attr('alt', message);
m.attr('alt', message);
m.html(makeImage(message)).fadeIn('slow');
if(jQuery.browser.msie && (jQuery.browser.version <= 6)) {
IE6Tooltip(m[0], message, object);
} else {
showToolTip(m[0], message, object);
}
$("#"+object).bind('click', function(){$("#tooltip"+object).fadeOut().remove();/*hideToolTip(this);*/});
$("#tooltip"+object).bind('click', function(){$("#tooltip"+object).fadeOut().remove();/*hideToolTip(this);*/});
// window.setTimeout(function() { $("#tooltip"+object).fadeOut('slow').end().remove(); }, 8000);
// LO DE ABAJO ES UN HORRIBLE HACK PARA QUE TITILE LA CRUZ!!!
str = "m";
var funcs = new Array('fadeTo(1000, 100)', 'fadeTo(500, 0)');
for(var i=1; i<=6; i++) {
str += "."+funcs[i%2];
}
eval(str);
//console.log(str);
//m.glow(6);
$("#"+object).addClass('ErroredField');
}, this.timeout);
return this;
}
this.clearError = function(object) {
$("#error_"+object).fadeTo(1500, 0.01);
return this;
}
this.clearValidators = function(obj, ev) {
Validator.objects[obj][ev] = new Array;
}
}
// instanciamos (bah, mal dicho porque JS <= 2.0 no tiene clases) a Validator.
Validator = new Validator();
// preloadeamos (si, acabo de inventar esa palabra) las imagenes de la validación, asi no cargan solo cuando el flaco tiene un error de validacion.
u = new Image(); u.src ="../images/balloon_bottom.gif";
v = new Image(); v.src = "../images/balloon_top.gif";
w = new Image(); w.src = "images/transparent.gif";
x = new Image(); x.src="images/spinner.gif";
y = new Image(); y.src="images/checkbullet.gif";
z = new Image(); z.src="images/cross.gif";
u = v = w = x = y = z = undefined;
function checkUsername(username) {
// Si este control es una label, ni me fijo!!
if($("#Username")[0].className.match(/HiddenField/)) {
return true;
}
var response = $.ajax({
type: "POST",
url: document.URL,
async: false,
data: 'checkUsername='+username
});
if(response.responseText.match(/OK/)) {
return true;
} else {
return false;
}
}
function showToggle(DropDown, TextBox, ID) {
if($("#"+DropDown+""+ID).val() == 0) {
$("#TR"+TextBox+""+ID).removeClass('hidden');
} else {
$("#TR"+TextBox+""+ID).addClass('hidden');
}
}
function toggleAdicionales(Valor, ID) {
EnCurso = new Array(27 /*corta*/, 30 /*uni*/, 33 /*posgrado*/, 36 /*master*/, 39 /*doctorado*/, 43 /*terciario*/,
46,49, 52,55,63,80,110, 150, 169, 171 /*repetidos*/);
Campos = new Array('MateriasAprobadas', 'FFinEstimada', 'AnioCursando');
if(array_search(parseInt(Valor), EnCurso) == -1) { // no es un estudio en curso, se le ocultan los campos
for(ele in Campos) {
if(!($("#TR"+Campos[ele]+ID).hasClass('hidden'))) {
$("#TR"+Campos[ele]+ID).addClass('hidden');
}
}
} else {
for(ele in Campos) {
if($("#TR"+Campos[ele]+ID).hasClass('hidden')) {
$("#TR"+Campos[ele]+ID).removeClass('hidden');
}
}
}
}
function showToolTip(obj, message, tooltipid) {
tooltip = $("");
// iframe = "";
//tooltip.bgIframe();
tooltip.css('left', absolutePosition(_(tooltipid)).x+_(tooltipid).clientWidth-13).css('top', absolutePosition(_(tooltipid)).y-45-(parseInt(message.length / 50)));
/* iframe = $("");
iframe.css('height', $("#tooltip"+tooltipid).css('offsetHeight')+"px");
iframe.css('width', '241px');
iframe.css('left', $("#tooltip"+tooltipid).css('offsetLeft')+"px");
iframe.css('top', $("#tooltip"+tooltipid).css('offsetTop')+"px");*/
$(obj)./*after(document.createElement(iframe)).*/after(tooltip);
// $tooltip.insertBefore(iframe, tooltip.firstChild);
}
function moveToolTip(obj, coords) {
tooltip = document.getElementById('tooltip'+obj.id);
tooltip.style.left = coords.clientX+10+'px';
tooltip.style.top = window.scrollY+coords.clientY+10+'px';
}
function hideToolTip(obj) {
e = document.getElementById("tooltip"+obj.id);
if(e != null) {
$(e).fadeOut().remove();
}
}
function absolutePosition(obj) {
pos = {x: 0, y: 0};
do {
pos.x += obj.offsetLeft;
pos.y += obj.offsetTop;
} while((obj = obj.offsetParent) != document.getElementsByTagName('body')[0]);
return pos;
}
var AbrirDatosPersonales = false;
var AbrirResto = false;
// Esto se encarga que al apretar "enter" no se submitee la form...
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text"||node.type=="password")) {return false;}
}
$(document).ready(function(){
$("body").bind('keypress', stopRKey);
$("div.TabTitle").bind('click', function() {
// estan absolutamente posicionadas, si se les mueve el piso las pierdo!
$(".tooltip_container, .tooltip_element").fadeOut().remove();
});
// idem
window.onresize = function () {
$(".tooltip_container, .tooltip_element").fadeOut().remove();
};
}
);
function IE6Tooltip(obj, message, tooltipid) {
// para posicionar a la div a la izquierda de toda la tabla, usa (absolutePosition(document.getElementById("header2")).x+document.getElementById("header2").clientWidth)
tooltip = $(""+message+"
");
$(obj).after(tooltip);
}
jQuery.fn.glow = function(amount) {
return this.each(function(){
var ev = ['fadeTo(1000, 100)', 'fadeOut(500, 0)'];
var me = jQuery(this);
var str = 'me';
for(var i = 0; i <= amount;i++) {
str += '.'+ev[i%2];
}
eval(str);
return me;
});
};