init_events();

var mLocY = 0;
function mouseNS(e)
{
	mLocY = e.pageY;
	//document.getElementById('Coords').innerHTML = mLocX+","+mLocY;
}

function mouseIE()
{
	mLocY = event.y + document.body.scrollTop;
}

function init_events()
{
	if (!document.all)
		document.addEventListener("mousemove", mouseNS, false);
	else
		document.onmousemove=mouseIE;
}


function openWin(_width, _height, _img,_title,_id) 
{
_width += 16

width = "width="+_width;
height = "height="+_height;

myWin= open("", "asdsadsad", width + ',' + height + ',resizable=yes,status=no,toolbar=no,menubar=no,scrollbars=1');
myWin.document.open();
myWin._img = _img;
myWin._title= _title;
myWin.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><HTML>");
myWin.document.write("<BODY TOPMARGIN=0 LEFTMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 BGCOLOR=#FFFFFF>");
myWin.document.write("<TITLE>");
myWin.document.write(''+_title+'');
myWin.document.write("</TITLE>");
myWin.document.write("<script language=JavaScript> {");
myWin.document.write("document.write('<A HREF=# ONCLICK=window.close()><IMG SRC=' + _img + ' BORDER=0></A>')");
myWin.document.write("} </script>"); 
myWin.document.write("</BODY>");
myWin.document.write("</HTML>");
myWin.document.close();
}


var activeDiv = ''
  function showDiv(id){
     if (activeDiv!=''){
      document.getElementById(activeDiv).style.display = "none";
      activeDiv = ''
    }
    
    clearTimeout(tm) 
    document.getElementById(id).style.display = "block";
    activeDiv = id
  }
  
 
  function hideDiv(obj){
    if (activeDiv!=''){
      document.getElementById(activeDiv).style.display = "none";
      activeDiv = ''
      for (i=1;i<10;i++){
        obj = eval ("document.getElementById('a"+i+"')")
        if (obj) eval ("document.getElementById('a"+i+"').bgColor = '#5994D3'")
      }

    }
      clearTimeout(tm) 
  }
  
    tm = setTimeout("hideDiv()", 1000);
    
  function hideMenu(obj){
    tm = setTimeout("hideDiv('"+obj+"')", 500);
  }
  
  function cancelCloseMenu(){
     clearTimeout(tm) 
  }
 
  menuColor = "";
  
  
  
  function chMenuColorA(obj){
   
    eval ("document.getElementById('a1').bgColor = '#5994D3'")
    eval ("document.getElementById('a2').bgColor = '#5994D3'")
    eval ("document.getElementById('a3').bgColor = '#5994D3'")
    eval ("document.getElementById('a4').bgColor = '#5994D3'")
    
    obj.bgColor='#91B1D3'
    
    if(menuColor!=obj) menuColor.bgColor='#5994D3' 
    menuColor = obj

  }
  
  function chMenuColorP(obj){
    obj.bgColor='#5994D3'
  }
  
  
  function chSubMenuA(obj){
    obj.bgColor='#F9F9F8'
  }
  
  function chSubMenuP(obj){
    obj.bgColor='#ECEBE7'
  }
  
function showReg()
{
 if (document.getElementById("foto2")) document.getElementById("foto2").style.display = "" 
 if (document.getElementById("foto3")) document.getElementById("foto3").style.display = "" 
 document.fff.passunreg.disabled = 1
 document.fff.telunreg.disabled = 1
 document.fff.emailunreg.disabled = 1
 document.fff.reqviz.disabled = 1
 document.fff.namereg.disabled = 0
 document.fff.passreg.disabled = 0
 document.fff.zametki.disabled = 0
}

function showUnreg()
{
 if (document.getElementById("foto2")) document.getElementById("foto2").style.display = "none" 
 if (document.getElementById("foto3")) document.getElementById("foto3").style.display = "none" 
 document.fff.passunreg.disabled = 0
 document.fff.telunreg.disabled = 0
 document.fff.emailunreg.disabled = 0
 document.fff.reqviz.disabled = 0 
 document.fff.namereg.disabled = 1
 document.fff.passreg.disabled = 1
 document.fff.zametki.disabled = 1
}


function changeSubtype(){
 //alert(document.fff.subtype_id.value) 
 
 //Меняем суп вначале
 //Если не дома, то нет жил пл и зем участков.
 if (document.fff.subtype_id.value!=6){
   if (document.getElementById('sup_jil_pl')) document.getElementById('sup_jil_pl').style.display = 'none'; 
 }else{
   if (document.getElementById('sup_jil_pl')) document.getElementById('sup_jil_pl').style.display = ''; 
 }
 

//Если дома, дачи, незавершенка
 if ((document.fff.subtype_id.value==6) || (document.fff.subtype_id.value==7) || (document.fff.subtype_id.value==8)){
//   if (document.getElementById('zem_uchastok_from')) document.getElementById('zem_uchastok_from').style.display = 'none'; 
   //if (document.getElementById('zem_uchastok_to')) document.getElementById('zem_uchastok_to').style.display = 'none';    
   if (document.getElementById('dop_udobstva')) document.getElementById('dop_udobstva').style.display = ''; 
   if (document.getElementById('zem_uchastok')) document.getElementById('zem_uchastok').style.display = '';    
   if (document.getElementById('obj_pl')) document.getElementById('obj_pl').style.display = '';
   if (document.getElementById('jil_pl')) document.getElementById('jil_pl').style.display = '';   
   if (document.getElementById('col_urovnei')) document.getElementById('col_urovnei').style.display = '';  
   if (document.getElementById('podval')) document.getElementById('podval').style.display = '';   

 }
 
  //Если Земельные участки
 if (document.fff.subtype_id.value==9){
   if (document.getElementById('dop_udobstva')) document.getElementById('dop_udobstva').style.display = ''; 
   if (document.getElementById('zem_uchastok')) document.getElementById('zem_uchastok').style.display = '';    
//   if (document.getElementById('zem_uchastok_from')) document.getElementById('zem_uchastok_from').style.display = ''; 
//   if (document.getElementById('zem_uchastok_to')) document.getElementById('zem_uchastok_to').style.display = '';       
   if (document.getElementById('obj_pl')) document.getElementById('obj_pl').style.display = 'none';
   if (document.getElementById('jil_pl')) document.getElementById('jil_pl').style.display = 'none';   
   if (document.getElementById('col_urovnei')) document.getElementById('col_urovnei').style.display = 'none';  
   if (document.getElementById('podval')) document.getElementById('podval').style.display = 'none';        
 }
 
   //Если Гаражи
 if (document.fff.subtype_id.value==10){
//   if (document.getElementById('zem_uchastok_from')) document.getElementById('zem_uchastok_from').style.display = 'none'; 
//   if (document.getElementById('zem_uchastok_to')) document.getElementById('zem_uchastok_to').style.display = 'none';       
   if (document.getElementById('obj_pl')) document.getElementById('obj_pl').style.display = '';
   if (document.getElementById('jil_pl')) document.getElementById('jil_pl').style.display = 'none';   
   if (document.getElementById('col_urovnei')) document.getElementById('col_urovnei').style.display = '';  
   if (document.getElementById('dop_udobstva')) document.getElementById('dop_udobstva').style.display = 'none'; 
   if (document.getElementById('zem_uchastok')) document.getElementById('zem_uchastok').style.display = 'none';      
   if (document.getElementById('podval')) document.getElementById('podval').style.display = '';        
 }
}


function chP22(){
   //Если незавершенка
  if ((document.podberi.subtype_id.value==6) || (document.podberi.subtype_id.value==7) || (document.podberi.subtype_id.value==8)){
    if (document.getElementById('pcur')) document.getElementById('pcur').style.display = '';
    if (document.getElementById('pobj_pl')) document.getElementById('pobj_pl').style.display = '';    
    if (document.getElementById('pzem_uchastok')) document.getElementById('pzem_uchastok').style.display = 'none';    
  } 
  
    //Если Земельные участки
  if (document.podberi.subtype_id.value==9){
    if (document.getElementById('pcur')) document.getElementById('pcur').style.display = 'none';
    if (document.getElementById('pobj_pl')) document.getElementById('pobj_pl').style.display = 'none';
    if (document.getElementById('pzem_uchastok')) document.getElementById('pzem_uchastok').style.display = '';
  }
  
  //Если гаражи
    if (document.podberi.subtype_id.value==10){
      if (document.getElementById('pcur')) document.getElementById('pcur').style.display = 'none';      
      if (document.getElementById('pzem_uchastok')) document.getElementById('pzem_uchastok').style.display = 'none';    
      if (document.getElementById('pobj_pl')) document.getElementById('pobj_pl').style.display = ''; 
      if (document.getElementById('ppodval')) document.getElementById('ppodval').style.display = ''; 
    }
}





var   inner = ""

function chDopParam(){

  if (document.getElementById('dopparam').style.display == "none"){
    document.getElementById('dopparam').style.display = "block"
    if (inner) document.getElementById('dopparam').innerHTML = inner
  }else{
    document.getElementById('dopparam').style.display = "none"
    inner = document.getElementById('dopparam').innerHTML
    document.getElementById('dopparam').innerHTML = ""
  }
}

pos = 0

//Конструктор сообщений для других языков
function showConstructor(lang1, lang2, lang3){
	//alert (pos)
    eval("document.getElementById('templates').style.display = ''")    
    eval("document.getElementById('templates').style.top = mLocY - 9")    
    eval("document.getElementById('mesLang_"+lang1+"').style.display = ''")
    eval("document.getElementById('mesLang_"+lang2+"').style.display = ''")
    eval("document.getElementById('mesLang_"+lang3+"').style.display = ''")    
}



function addTemplates(k){
  document.fff.dop_info_ru.value += t_ru[k]+". "
  document.fff.dop_info_ro.value += t_ro[k]+". "
  document.fff.dop_info_en.value += t_en[k]+". "
}

function validAddQuestion(){
  var err = 0;
  errText = "Заполните все обязательные поля"
    
  
  //Проверим поля имя и мыло на содержание
     if(document.question.name.value == '') err = 1; 
     if(document.question.body.value == '') err = 1; 
     if(document.question.short_body.value == '') err = 1; 
     if(document.question.subject_id.value == 0) err = 1; 
     if(document.question.email.value == '') err = 1; 
     if(checkmail(document.question.email.value) == 0) err = 1;
         
  if (err == 1){
    alert (errText)    
    return false;
  }
 
else{
    return true;
        //document.question.submit()        
  }
  
  return true;  
}

function checkmail(){
  if (document.question.email.value=='' ||  document.question.email.value==' ')	{
	  return true;
	}	else	{
		if (document.question.email.value.indexOf(' ',0)!=-1 ||  document.question.email.value.indexOf('.')==-1) {
			alert('e-mail неправильный!');
			return 0;
		}	else {
			if (document.question.email.value.indexOf('@')==-1)	{
				alert('e-mail неправильный!');
				return 0;
			} else {
				return 1;
			}
		}
	}
	return 0;
}





function SendEMail( domain, mailbox )
{	var sLink = 'mailto:' ;
	sLink += mailbox ;
	sLink += '@' ;
	sLink += domain ;
	window.location = sLink ;	
	return false ;
}
