/**
* Toggles the check state of a group of boxes
*
* Checkboxes must have an id attribute in the form cb0, cb1...
* @param The number of box to 'check'
* @param An alternative field name
*/

function checkAll( n, fldName ) {
  if (!fldName) {
     fldName = 'cb';
  }
	
	var f = document.adminForm;
	var n2 = 0;
	toggle='toggle_'+fldName;
	tgl=eval('f.' + toggle);
	if (fldName=='cb') c = f.toggle.checked; else c = tgl.checked;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}



function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}

/**
* Default function.  Usually would be overriden by the component
*/
function submitbutton(pressbutton) {
	submitform(pressbutton);
}

/**
* Submit the admin form
*/
function submitform(pressbutton){
	document.adminForm.task.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

function submitbutton_user(pressbutton) {
	submitform_user(pressbutton);
}

/**
* Submit the admin form
*/
function submitform_user(pressbutton){
	document.urlap.task.value=pressbutton;
	try {
		document.urlap.onsubmit();
		}
	catch(e){}
	document.urlap.submit();
}

function checked_alert(submiting)
{
	if (document.adminForm.boxchecked.value == 0) 
	{
		alert('Jelöljön ki egy elemet!'); 
	}
	else 
	{
		submitbutton(submiting);
	}
}

function checked_alert_confirm(submiting)
{
	if (document.adminForm.boxchecked.value == 0) 
	{
		alert('Jelöljön ki egy elemet!'); 
	}
	else 
	{
		if (confirm('Biztos, hogy törli?')) submitbutton(submiting);
		else return false;
	}
}

function listItemTask( id, task ) {
    var f = document.adminForm;
    cb = eval( 'f.' + id );
    if (cb) {
        for (i = 0; true; i++) {
            cbx = eval('f.cb'+i);
            if (!cbx) break;
            cbx.checked = false;
        } // for
        cb.checked = true;
        f.boxchecked.value = 1;
        submitbutton(task);
    }
    return false;
}

function checkclick(id) {
var elem = document.getElementById(id);
if (elem.checked == '') elem.checked='checked'; else elem.checked='';
}

function txt_num_suffix() {
	if (document.getElementById('type_sel').value == 'text_num')
	document.getElementById('suffix').style.display ='';
	else 
	document.getElementById('suffix').style.display ='none';

}


function open_window_img(what,pwidth,pheight) {

	myleft=(screen.width)?(screen.width-pwidth)/2:100;
	mytop=(screen.height)?(screen.height-pheight)/2:100;
	
	f_popup = open("","cartridge_popup","width="+pwidth+",height="+pheight+",left="+myleft+", top="+mytop+",status=no,toolbar=no,menubar=no,resizable=no");
	f_popup.document.open();
	f_popup.document.write("<HTML><HEAD><TITLE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TITLE></HEAD>");
	f_popup.document.write("<BODY style='margin: 0px 0px 0px 0px; padding: 0px;' bgcolor='#000000'>");
	f_popup.document.write("<a href='javascript:;' onClick='javascript:window.close();'><img src='"+what+"' title='Bezáráshoz kattintson a képre!' border='0'></a>");
	f_popup.document.write("</BODY></HTML>");
	f_popup.document.close();
}



function anim_span(span_name, color, dir)
{
	
	var colors = new String('0123456789ABCDEF');
	var step_wait = 20;
	
	color = (dir?color-1:color+1);
	if(dir && color<0)
		{
			dir = false;
			color = 0;
		}
	if(!dir && color>15)
		{
			dir = true;
			color = 15;
		}

	// piros-fekete
	szin='#'+colors.charAt(color)+'0'+'0000';
	document.getElementById(span_name).style.color = szin;
	setTimeout('anim_span("'+span_name+'", '+color+', '+(dir?'true':'false')+')', step_wait);
}


