document.onclick= onclickhandle;
function onclickhandle(e)
{
	$FormFieldsColor="#fff";

	// ------------ KERNEL
	$Browser=navigator.appName;
	if($Browser.match("Microsoft"))
	{
		$kcode=window.event.keyCode;
		$id=window.event.srcElement.id;
		$Rel=window.event.srcElement.rel;
		$Href=window.event.srcElement.href;
		$TagName=window.event.srcElement.tagName;
		$Class=window.event.srcElement.className;
		if($kcode==0) $kcode=1;
	}
	else
	{
		$kcode=e.which;
		$id=e.target.id
		$Rel=e.target.rel;
		$Href=e.target.href;
		$TagName=e.target.tagName;
		$Class=e.target.className;
	}

	if($kcode==1)
	{
		if($TagName=="TEXTAREA" | $TagName=="INPUT")
		{

				if(document.getElementById($id))
				{
					//if(document.getElementById($id).type!="button") document.getElementById($id).style.backgroundColor=$FormFieldsColor;
					//if(document.getElementById($id+"errormessage")) document.getElementById($id+"errormessage").innerHTML="";
				}

		}
		else if($TagName=="SELECT")
		{
			if(document.getElementById($id))  document.getElementById($id).style.backgroundColor=$FormFieldsColor;
		}

		if($id=="submitquestionform" && document.getElementById("submitquestionform").disabled!=true){ submitthisform("questionform","name,email,text","ajax:systemmessage",""); clearthisform("questionform");}
		if($id=="addnoticeformsubmit" && document.getElementById("addnoticeformsubmit").disabled!=true){submitthisform("addnoticeform","text","","");}
		if($id=="editenoticeformsubmit" && document.getElementById("editenoticeformsubmit").disabled!=true) submitthisform("editenoticeform","text","","");
		if($id=="addyourtopicformsubmit" && document.getElementById("addyourtopicformsubmit").disabled!=true) submitthisform("addyourtopicform","name","","");
		if($id=="addyourcommentsubmit" && document.getElementById("addcommentsubmit").disabled!=true)
		{
			submitthisform("addcommentform","name","","");


		}
		if($id=="addcomment") { openthisdiv("addcommentdiv");document.getElementById("foradvdiv").style.display="none"; return false;}
		if($id=="passwordchangeformsubmit" && document.getElementById("passwordchangeformsubmit").disabled!=true) submitthisform_msg("passwordchangeform","oldpass,pass,pass2","ajax:passwordchangeformmessage");
		//if($id=="anketachangeformsubmit") submitthisform("anketachangeform","email,phone,city,country,sname,fname","ajax:anketachangeformmessage");
		//if($id=="registerformsubmit") submitthisform_msg("registerform","name,surname,y,d,m,email,pass,pass2,country,city,phone");
		if($id=="anketachangeformsubmit" && document.getElementById("anketachangeformsubmit").disabled!=true) submitthisform_msg("anketachangeform","phone,city,country,sname,fname","ajax:anketachangeformmessage");
		// ЗАкрытия
		if($id=="addyourtopicformclose") { closethisdiv("addyourowntopicdiv"); return false;}
		if($id=="addcommentclose") { closethisdiv("addcommentdiv"); return false;}
		if($id=="photochangeformsubmit" && document.getElementById("photochangeformsubmit").disabled!=true) submitthisform_msg("photochangeform","photo","","");
		if($id=="addnotice") {add_notice("addnotice");checklenght('addnoticeformtext','addnoticeform','500','addnoticetextsize'); return false;}
		if($id=="addnoticeformclose"){clearthisform('addnoticeform'); closethisdiv("addnoticediv");  return false;}
		if($id=="editeanoticeformclose"){clearthisform('editenoticeform'); closethisdiv("editenoticediv");  return false;}
		if($Rel=="editenotice") { edite_notice($id); return false;}

		if($id=="addseminarformsubmit" && document.getElementById("addseminarformsubmit").disabled!=true) submitthisform("addseminarform","text","","");
		if($id=="editeseminarformsubmit" && document.getElementById("editeseminarformsubmit").disabled!=true) submitthisform("editeseminarform","text","","");
		if($id=="addseminarformclose"){clearthisform('addseminarform'); closethisdiv("addseminardiv");  return false;}
		if($id=="editeaseminarformclose"){clearthisform('editeseminarform'); closethisdiv("editeseminardiv");  return false;}
		if($id=="cutlink" || $id=="cutArr") { meeting_cuts(); return false;}
		if($Rel=="editeseminar" && document.getElementById("editeseminar").disabled!=true) { seminar_notice($id); return false;}
		if($id=="addseminar"  && document.getElementById("addseminar").disabled!=true) { add_notice($id); checklenght('addseminarformtext','addseminarform','500','addseminartextsize'); return false;}
		if($id=="emailchangeformsubmit" && document.getElementById("emailchangeformsubmit").disabled!=true) {submitthisform_msg("emailchangeform","email","ajax:emailchangeformemailerrormessage");}
		if($id=="foradv")
		{
			openthisdiv("foradvdiv");
			document.getElementById("addcommentdiv").style.display="none";
			return false;
		}
		if($id=="addyourowntopic")
		{

			openthisdiv("addyourowntopicdiv");
			locateit("addyourowntopicdiv","addyourowntopic",$Corner_L,$Corner_R);
		}
		if($id=="foradvdivclose")
		{
			closethisdiv("foradvdiv"); return false;
		}
		// Ловим THEME LINK -
		if($Rel=="themelink")
		{
			loadthemeinformation($id,$id);return false;
		}


		// Всякое разное

		if($id=="passwordchangeformoldpass") document.getElementById("passwordchangeformmessage").innerHTML="";
		if($id=="photochangeformphoto") document.getElementById("photochangeformmessage").innerHTML="";

		if($id=="anketachangeformcountry" || $id=="anketachangeformcountry" || $id=="anketachangeformfname" || $id=="anketachangeformsname" || $id=="anketachangeformemail" || $id=="anketachangeformphone" || $id=="anketachangeformuin" || $id=="anketachangeformskype" || $id=="anketachangeformweb") document.getElementById("anketachangeformmessage").innerHTML="";
	}


}
