
var code = new Array(4);
 code[0]='+38 067';
 code[1]='+38 050';
 code[2]='+38 066';
 code[3]='+38 097';
 code[4]='+38 063';
 code[5]='+38 039';
 code[6]='+38 068';
 var signup = '';
 var maxleng = (160 - signup.length);
 var fulltext='';

//-------------------------------------------------------------------------------

function im(path,tit){
 window.open('http://www.bul-bul.com.ua/image.php?path='+path+'&ab='+tit,'','width=100, height=100, scrollbars=no');
 //window.open('http://bulbul/image.php?path='+path+'&ab='+tit,'','width=100, height=100, scrollbars=no');
}

//-------------------------------------------------------------------------------


 function chan(ndx){
  document.frmMain.oper.value=code[ndx];
 }

//-------------------------------------------------------------------------------

 function checkSMS(){
  txt = document.frmMain.message.value;
  txtleng = txt.length;
  if (txtleng < maxleng){
   document.frmMain.sleft.value = (maxleng - txtleng);
   document.frmMain.message.focus();
   if (txt=='') document.frmMain.sleft.value = maxleng;
   if(fulltext) { fulltext = '' }
  }else{
   if(!fulltext) fulltext = txt.substring(0,maxleng);
   document.frmMain.message.value = fulltext;
   document.frmMain.sleft.value = 0;
  }
 }

//-------------------------------------------------------------------------------

 function sendSMS(){
  if (document.frmMain.cellular.value.length!=7){
   alert('Ошибка!\r\nНеверный номер получателя!');
  }else{
   if (document.frmMain.message.value.length==0){
    alert('Ошибка!\r\nЗаполните текст сообщения!');
   }else{
    document.frmMain.message.value = document.frmMain.message.value + signup;
    document.frmMain.submit();
   }
  }
 }

//-------------------------------------------------------------------------------

 function initPage(){
  document.frmMain.oper.disabled=true;
  chan(0);
  checkSMS();
 }

//-------------------------------------------------------------------------------

function its_empty (str_value){
	return (str_value == "" || str_value == null)
}

//-------------------------------------------------------------------------------

function invalid_email(email_address){
	if (email_address.length < 5)
		return true

	at_location  = email_address.indexOf("@");
	dot_location = email_address.lastIndexOf(".");

	if((at_location == 0)||(dot_location - at_location < 2)||(email_address.length - dot_location < 2))
		return true


	return false
}

//-------------------------------------------------------------------------------

function check_form(fb_form) {
 var message = "";
 var return_code = true;

 if(its_empty(fb_form.name.value) || its_empty(fb_form.mess.value)){
 	 return_code = false;
 	 message += "Не заполнены обязательные поля формы!\n";
 }

 if(invalid_email(fb_form.email.value)){
 	 return_code = false;
 	 message += "Неверный адрес электронной почты!\n";
 }

 if(!return_code)
 	 alert(message);

 return return_code
}

//-------------------------------------------------------------------------------

function display_menu(id){

  for(i=0; i<=14; i=i+1){
    lt = 'menu'+i;
    if(id == i) continue;

    if(document.getElementById && document.getElementById(lt)){
     itema = document.getElementById(lt);
     itema.style.display = 'none';
    }
  }

  child = document.getElementById('menu'+id);

  if(child.style.display == 'none') child.style.display = 'block';
  else child.style.display = 'none';

  return false;
}

//-------------------------------------------------------------------------------

function set_default_menu(id){
  if(document.getElementById && document.getElementById(id)){
     item_menu = document.getElementById(id);
     item_menu.style.display = 'block';
    }
  }
