function changebgcolor(col, color){col.style.background = color;}
function changecolor(col, color){col.style.color = color;}


function changeKedvencekPipa(image) {
  if (document.images) {
  	if (document[image].src.indexOf("pipa1.gif") == -1) {
	 		document[image].src = "kepek/pipa1.gif";
			document.forms['kedvencek'].kedvencek.value +=  document[image].name.substr(3) + ";"
			if (document[image+'_']) {
		 		document[image+'_'].src = "kepek/pipa1.gif";
			}
		} else {
	 		document[image].src = "kepek/pipa0.gif";
			if (document[image+'_']) {
		 		document[image+'_'].src = "kepek/pipa0.gif";
			}
			a = document.forms['kedvencek'].kedvencek.value
			b = document[image].name.substr(3) + ";"
			c = a.substr(0, a.indexOf(b))
			d = a.substr(a.indexOf(b))
			e = d.substr(d.indexOf(";")+1)
			document.forms['kedvencek'].kedvencek.value =  c + e
		}
  }
}

function closechild() {
	if(window.child && !window.child.closed) { 
		window.child.close(); window.child = 0;
		}
	}

function newWindow(name, width, height, i) {
	closechild();
	window.child = window.open(name, "SSS"+i, "width="+width+",height="+height+",innerHeight=200,innerWidth=300,scrollbars=1,status=0,resizable=1,titlebar=0,toolbar=0,dependent=1,top="+((window.screen.height-height)/2).toString()+",left="+((window.screen.width-width)/2).toString())
	window.child.focus(); 
}

function newWindow2(name, width, height, i) {
	c = window.open(name, "SSSS"+i, "width="+width+",height="+height+",innerHeight=200,innerWidth=300,scrollbars=1,status=0,resizable=1,titlebar=0,toolbar=0,dependent=1,top="+((window.screen.height-height)/2).toString()+",left="+((window.screen.width-width)/2).toString())
	c.focus(); 
}

function selectedValue(s) {
	return s.options[s.selectedIndex].value;
	}

function daysOfMonth(y, m) {
	var d = 28;
	var date = new Date(y, m, d);
	do {
		date.setDate(d+1);
		if(date.getDate()!=d+1) {
			return d;
			}
		d++;
		}
	while(true);
	}

function fillDate(y, m, d) {
	var current=selectedValue(d);
	var days=daysOfMonth(selectedValue(y), selectedValue(m)-1);
	if(d.length==days) return;
	d.options[30] = null;
	d.options[29] = null;
	d.options[28] = null;
	for(var i=1;i<32;i++) {
		if(i<=days) d.options[i-1] = new Option(i, i, i==1, i==current || i==days && current>i);
		else d.options[i-1] = null; 
		}
	if(current>days) d.selectedIndex = days-1; else d.selectedIndex = current-1;
	}

function checkDate(select, prefix) {
	var form = select.form;
	var y = form[prefix+"ev"];
	var m = form[prefix+"ho"];
	var d = form[prefix+"nap"];
	fillDate(y, m, d);
	}
	
function checkDatum(form, prefix) {
	y = form[prefix+"ev"];
	m = form[prefix+"ho"];
	d = form[prefix+"nap"];
	date = new Date(selectedValue(y), selectedValue(m)-1, selectedValue(d));
	if(date.getDate()!=selectedValue(d)) { alert("Érvénytelen dátum"); return false; }
	return true;
	}

function checkRange(c, minValue, maxValue) {
	var value = parseInt(c.value);
	if(minValue<=0 && maxValue >=0 && parseInt(c.value+"0")==0) return true;
	if(isNaN(value) || value<minValue  || value>maxValue) { alert("Érvénytelen szám"); c.value=minValue; return false; }
	return true;
	}	


var submitcnt = 0;
function nodoublepost(bname) {
	var n;
	submitcnt++;
	if ((bname != "") && (n = document.getElementById(bname))) {
		//n.disabled = true;
	}
	if (submitcnt > 1) {
		alert("Kérjük várjon, amíg a szerver feldolgozza az adatokat!");
	}
	return (submitcnt <= 1);
}



// Vizsgalaphoz:
// Megvizsgálja, hogy a teljesítéstípus pipa átbillenthető-e.
// Bekapcsolni mindig lehet. (return true)
// Kikapcsolni nem lehet, ha utolsó bekapcsolt a kurzusban. 
// this: checkbox. Neve: teljtip_{../@ciklkurz_id}_{@sorrend}
function teljtip_toggle(checkbox) {
	if(checkbox.checked) return true;
	var namea = checkbox.name.split('_');
	var kurzus = namea[1];
	var form = checkbox.form;
	// Ha találunk még a kurzusban bekapcsolt teljtipet, akkor lehet
	for(var i=0; i!=form.length; i++) {
		ox = form[i];
		if(ox.name.substr(0,8)=='teljtip_') {
			var nax = ox.name.split('_');
			if(kurzus==nax[1] && ox.checked) return true;
			}
		}
	// Egyébként nem.
	return false;
	}

// Új vizsgalaphoz:
// Megvizsgálja, hogy a teljesítéstípus pipa átbillenthető-e.
// Bekapcsolni mindig lehet. (return true)
// Kikapcsolni nem lehet, ha utolsó bekapcsolt. 
// this: checkbox. Neve: teljtip_{@sorrend}
function teljtip_toggle_new(checkbox) {
	if(checkbox.checked) return true;
	var namea = checkbox.name.split('_');
	var form = checkbox.form;
	// Ha találunk még a kurzusban bekapcsolt teljtipet, akkor lehet
	for(var i=0; i!=form.length; i++) {
		var ox = form[i];
		if(ox.name.substr(0,8)=='teljtip_' && ox.checked) return true;
		}
	// Egyébként nem.
	return false;
	}
	


