
// 	var req = new XMLHttpRequest();
// 	var row_hi = null;
// 	var row_sel = null;
// 	var acc_ext = '|bmp|doc|gif|jpeg|jpg|pct|pdf|png|ppt|rtf|tif|txt|wp|xls|zip|';
// 	
// 
// 	var KEY_UP = 38;
// 	var KEY_DOWN = 40;
// 	var KEY_LEFT = 37;
// 	var KEY_RIGHT = 39;
	
	function obj_show (obj, is_vis)
	{
		if (!obj) return;
		obj.style.visibility = (is_vis ? 'visible' : 'hidden');
	}
	
	function prevRow (cur_row)
	{
		result_row = cur_row;
		while ((result_row = result_row.previousSibling) != null)
		{
			if (result_row.nodeName == 'TR')
			{
				return result_row;
			}
		}
		return null;
	}

	function nextRow (cur_row)
	{
		result_row = cur_row;
		while ((result_row = result_row.nextSibling) != null)
		{
			if (result_row.nodeName == 'TR')
			{
				return result_row;
			}
		}
		return null;
	}
	
	function namedChild (obj, name)
	{
		childs = obj.childNodes;
		for (child_index = 0; child_index < childs.length; child_index++)
		{
			child = childs[child_index];
			if (child.getAttribute && child.getAttribute ('name') == name)
				return child;
		}
		return null;
	}
	
	function namedTagChild (obj, tag, name)
	{
		childs = obj.getElementsByTagName (tag);
		for (child_index = 0; child_index < childs.length; child_index++)
		{
			child = childs[child_index];
			if (child.getAttribute && child.getAttribute ('name') == name)
				return child;
		}
		return null;
	}
	
	function panel_switch (mode)
	{
		document.getElementById ('login_panel').style.display = (mode == 'new') ? 'none' : 'block';
		document.getElementById ('new_panel').style.display   = (mode == 'new') ? 'block': 'none' ;
	}


	function nextSpan (cur_row)
	{
		result_row = cur_row;
		while ((result_row = result_row.nextSibling) != null)
		{
			if (result_row.nodeName == 'SPAN')
			{
				return result_row;
			}
		}
		return null;
	}

	function prevCell (cur_row)
	{
		result_row = cur_row;
		while ((result_row = result_row.previousSibling) != null)
		{
			if (result_row.nodeName == 'TD')
			{
				return result_row;
			}
		}
		return null;
	}

	function fblock_prox (obj)
	{
		block = new Object()
		block.field = obj;
		block.error = nextSpan (obj);
		block.label = prevCell (obj.parentNode);
		return block;
	}

	function fblock_id (obj)
	{
		block = new Object()
		block.field = obj;
		block.error = document.getElementById (obj.id + '_error');
		block.label = document.getElementById (obj.id + '_label');
		return block;
	}
	
	function fblock_fix (field_id, error_id, label_id)
	{
		block = new Object()
		block.field = document.getElementById (field_id);
		block.error = document.getElementById (error_id);
		block.label = document.getElementById (label_id);
		return block;
	}

	function field_check (block)
	{
		check_string = block.field.name.split('#')[1];
		check_params = check_string.split (',');
		is_ok = true;
		for (check_index = 0; (check_index < check_params.length) && is_ok; check_index++)
		{
			check_param = check_params[check_index];
		
			if (check_param.indexOf('req') != -1)
			{
				is_ok = (block.field.value.length > 0)
				block.label.className  = is_ok ? 'label' : 'label_error';
				block.error.innerHTML = is_ok ? '' : 'errore: campo obbligatorio.'
			}
			else if (check_param.indexOf('email') != -1)
			{
				domains = ",a,bitnet,ac,ad,ae,af,ag,ai,al,am,an,ao,aq,ar,as,at,au,aw,az,ba,bb,bd,be,bf,bg,bh,bi,bj,bm,bn,bo,br,bs,bt,bv,bw,by,bz,ca,cc,cf,cg,ch,ci,ck,cl,cm,cn,cok,com,cr,cs,cu,cv,cx,cy,cz,de,dj,dk,dm,do,dz,ec,edu,ee,eg,eh,er,es,et,fi,fj,fk,fm,fo,fr,fx,ga,gb,gd,ge,gf,gh,gi,gl,gm,gn,gov,gp,gq,gr,gs,gt,gu,gw,gy,hk,hm,hn,hr,ht,hu,id,ie,il,in,io,iq,ir,is,it,jm,jo,jp,ke,kg,kh,ki,km,kn,kp,kr,ku,ky,kz,la,lb,lc,li,lk,lr,ls,lt,lu,lv,ly,ma,mc,md,mg,mh,mil,mk,ml,mm,mn,mo,mp,mq,mr,ms,mt,mu,mv,mw,mx,my,mz,na,nc,ne,net,nf,ng,ni,nl,no,np,nr,nt,nu,nz,om,org,pa,pe,pf,pg,ph,pk,pl,pm,pn,pr,pt,pw,py,qa,re,ro,ru,rw,sa,sb,sc,sd,se,sg,sh,si,sj,sk,sl,sm,sn,so,sr,st,su,sv,sy,sz,tc,td,tf,tg,th,tj,tk,tm,tn,to,tp,tr,tt,tv,tw,tz,ua,ug,uk,um,us,uy,uz,va,vc,ve,vg,vi,vn,vu,wf,ws,ye,yt,yu,za,zm,zr,zw,";	
				match_pat = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.([a-zA-Z]{2,6})$/;
				match_block = block.field.value.match(match_pat);
				is_ok = (match_block != null && (domains.indexOf (',' + match_block[1] + ',') != -1));
				block.label.className  = is_ok ? 'label' : 'label_error';
				block.error.innerHTML = is_ok ? '' : 'errore: indirizzo email non valido.'
			}
			else if (check_param.indexOf('min') != -1)
			{
				min_len = check_param.split (':')[1];
				is_ok = (block.field.value.length >= min_len)
				block.label.className  = is_ok ? 'label' : 'label_error';
				block.error.innerHTML = is_ok ? '' : 'errore: inserire almeno ' + min_len + ' caratteri.'
			}
			else if (check_param.indexOf('pass') != -1)
			{
				match_pat = /^[a-zA-Z0-9]{1,16}$/;
				is_ok = (block.field.value.match(match_pat) != null);
				block.label.className  = is_ok ? 'label' : 'label_error';
				block.error.innerHTML = is_ok ? '' : 'errore: puo\' contenere solo lettere e numeri.'
			}
			else if (check_param.indexOf('unique') != -1)
			{
				req.open ('GET', 'email_check_ajax.wp?email=' + block.field.value, false);
				req.send('');
				users_found = req.responseXML.documentElement.getElementsByTagName ('user');
				is_ok = (users_found.length == 0);
				block.label.className  = is_ok ? 'label' : 'label_error';
				block.error.innerHTML = is_ok ? '' : 'errore: email gia\' registrata.'
			}
			else if (check_param.indexOf('exists') != -1)
			{
				req.open ('GET', 'email_check_ajax.wp?email=' + block.field.value, false);
				req.send('');
				users_found = req.responseXML.documentElement.getElementsByTagName ('user');
				is_ok = (users_found.length == 1);
				block.label.className  = is_ok ? 'label' : 'label_error';
				block.error.innerHTML = is_ok ? '' : 'errore: email inesistente.'
			}
		}
	}

















