//финкции за main screen (ms)
//Христо Марков Христов - 6 Април 2007 г.

//alert("zarejdam ms.js palen");

function scusmsexe(Form)
{
//	alert("hello=>"+Form.elem0+" 1=>"+Form.elem1);

	switch(Form.msexe)
	{
		case 1:// add
			if(Form.scusz1.add()!=scus_success)
			{
				alert("THE RECORD IS ALREADY ADDED");
			}
			return scus_error;
		break;
		case 2:// delete
			if(confirm("THE RECORD WILL BE DELETED")!=true) return;
		break;
		case 3:// copy
			if(Form.scusz1.add()!=scus_success)
			{
				alert("I CANT COPY THIS RECORD");
			}
			return scus_error;
		break;
		default: break;
	}
//изпълнявам обработка преди екран
	if(typeof(Form.scus_elem0)!="undefined") scusform.scusf(Form.scus_elem0,Form.scusz1);

	switch(Form.msexe)
	{
		case 2:// delete
			if(Form.scusz1.del()!=scus_success)
			{
				alert("I CANT DELETE THIS RECORD");
			}
			return scus_error;
		break;
		case 4:// change
			if(Form.scusz1.update()!=scus_success)
			{
				alert("I CANT CHANGE THE RECORD");
			}
			return scus_error;
		break;
		default: break;
	}
//изпълнявам обработка след екран
	if(typeof(Form.scus_elem1)!="undefined") scusform.scusf(Form.scus_elem1,Form.scusz1);


	//ако не е copy => всички полета се зануляват
	if(Form.msexe!=3)
	{
		//от записа
		Form.scusz1.clrp();

		//от полетата на екрана
		var i,f;
		for(i=0;i<document[Form.id].length;i++) 
		{
			f=document[Form.id].elements[i];
			if(typeof(f.scustype)!='undefined')
			{
				if(f.scustype<10) f.value=" ";
				if(typeof(f.scuspar_add)!='undefined') //ако има чекнати checkbox или radio бутони - махам чекнатото
				{
					if(f.scuspar_add==2||f.scuspar_add==3) f.checked=0;
				}
			}
		}
	}
}

function scusfunc(Scusf,Form_id,Scusmsexe) // при натискане на бутони ADD, DELETE, COPY, CHANGE
{
	if(Scusf==(Form_id+"_func"))
	{
//		document.getElementById(Form_id+"_func").elements[Scusmsexe].onclick();
		document[Form_id+"_func"].elements[Scusmsexe].onclick();
		return;
	}

	document[Form_id].msexe=Scusmsexe;
//	alert(Scusmsexe);

	if(typeof(document[Form_id].fmsexe)!="undefined")
	{
		document[Form_id].fmsexe.style.background=document[Form_id].fmsexe.scusbackground;
		document[Form_id].fmsexe.style.color=document[Form_id].fmsexe.scuscolor;
	}

	document[Form_id].fmsexe=Scusf;

	Scusf.style.background='green';
	Scusf.style.color='white';
	if(typeof(document[Form_id].af)!='undefined') document[Form_id].af.focus();
//	return scus_success;
}


function scussetfocus(Form,Num)
{

alert("tazi funkciq wetche na se izpolzwa. Naprawi promeni w koda!");

//	document[Form].elements[Num].focus();
	scusonfocus(document[Form].elements[Num]);


//	f=document[Form].elements[Num];
//	f.focus();
//	document[Form].af=f; //af се зарежда от функция scusonfocus()
}
