var timeout	= 300;
var closetimer	= 0;
var ddmenuitem	= 0;

function mopen(id){	
	mcancelclosetime();
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';
}

function mclose(){
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

function mclosetime(){
	closetimer = window.setTimeout(mclose, timeout);
}

function mcancelclosetime(){
	if(closetimer)	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
document.onclick = mclose; 

function checkContactForm(){
	re = /([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)/;
	var name, email, txt_message, vercode, dataRight = true;
	message = "";

	name = document.contactFrm.name.value;
	email = document.contactFrm.email.value;
	txt_message = document.contactFrm.message.value;
	vercode = document.contactFrm.vercode.value;

	if (email.length==0){
	   message += "\n -  Name";
	   dataRight=false;
	}
	if (email.length==0){
	   message += "\n -  E-mail";
	   dataRight=false;
	}
	if (email.length!=0 && email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your E-Mail is Incorrect";
	}
	if (txt_message.length==0){
		message += "\n -  Message";
		dataRight=false;
	}
	if (vercode.length==0){
		message += "\n -  Verification code";
		dataRight=false;
	}
	
	if (!dataRight){
		if (message != ""){
		   message ="\nYou failed to correctly fill in the form:\n" + message + "\n\nPlease re-enter and click the Send button again!";
	   }
	   alert(message);
	}
	return dataRight;
}

function checkContactFormRU(){
	re = /([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)/;
	var name, email, txt_message, vercode, dataRight = true;
	message = "";

	name = document.contactFrm.name.value;
	email = document.contactFrm.email.value;
	txt_message = document.contactFrm.message.value;
	vercode = document.contactFrm.vercode.value;

	if (email.length==0){
	   message += "\n -  Ваше Имя";
	   dataRight=false;
	}
	if (email.length==0){
	   message += "\n -  Введите свой E-mail";
	   dataRight=false;
	}
	if (email.length!=0 && email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Неправильно введенный E-mail адрес";
	}
	if (txt_message.length==0){
		message += "\n -  Сообщение";
		dataRight=false;
	}
	if (vercode.length==0){
		message += "\n -  Код для подтверждения";
		dataRight=false;
	}
	
	if (!dataRight){
		if (message != ""){
		   message ="\nФорма заполнена неверно:\n" + message + "\n\nПожалуйста заполните снова и нажмите кнопку „Бнести”!";
	   }
	   alert(message);
	}
	return dataRight;
}

function checkContactFormBG(){
	re = /([0-9a-zA-Z\.-_]+)@([0-9a-zA-Z\.-_]+)/;

	var name, email, txt_message, vercode, dataRight = true;
	message = "";

	name = document.contactFrm.name.value;
	email = document.contactFrm.email.value;
	txt_message = document.contactFrm.message.value;
	vercode = document.contactFrm.vercode.value;

	if (email.length==0){
	   message += "\n -  Име";
	   dataRight=false;
	}
	if (email.length==0){
	   message += "\n -  E-mail";
	   dataRight=false;
	}
	if (email.length!=0 && email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Въведеният E-Mail е грешен";
	}
	if (txt_message.length==0){
		message += "\n -  Относно";
		dataRight=false;
	}
	if (vercode.length==0){
		message += "\n -  Код за потвърждение";
		dataRight=false;
	}
	
	if (!dataRight){
		if (message != ""){
		   message ="\nНе сте въвели коректно всички полета от формата:\n" + message + "\n\nМоля въведете отново сгрешените полета и натиснете бутона 'Изпрати'!";
	   }
	   alert(message);
	}
	return dataRight;
}