function checkEmail(){
        sEmail1 = document.EmailForm.sEmail1.value
        sEmail2 = document.EmailForm.sEmail2.value
        sEmailAddress = sEmail1 + "@" + sEmail2
        if(sEmail1 == "" || sEmail2 == ""){
                alert("Необходимо заполнить обе части email адреса!")
                return
        }
        if(!isEmail(sEmailAddress)){
                alert("Введённый адрес неправильный!")
                document.EmailForm.sEmail1.select()
                return
        }
        document.all.hiddenIframe.src="subscribe.php?sEmailAddress="+sEmailAddress
        document.EmailForm.sEmail1.value=""
        document.EmailForm.sEmail2.value=""
}
function wE(sEmail2,sEmail1,sEmail3,sClass){
	document.write("<a href='mailto:"+ sEmail1 + "@" + sEmail2 +"."+sEmail3 + "' class='content' >"+ sEmail1 + "@" + sEmail2 +"."+sEmail3 +"</a>");
}
function wE_w(sEmail2,sEmail1,sEmail3){
        document.write("<a class='mainMenuPhoneMail' href='mailto:"+ sEmail1 + "@" + sEmail2 +"."+sEmail3 + "' class='content'>"+ sEmail1 + "@" + sEmail2 +"."+sEmail3 +"</a>");
}

function isEmail(string) {
        if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
                return true;
        else
                return false;
}

function showNews(IDNews){
        windowOpen("news.php?IDNews="+IDNews,'',300,400,'yes','yes')
}

function windowOpen(sURL,sName,iWidth,iHeight,resizable,scrollbars){
        window.open(sURL,sName,'toolbar=no,location=no,directories=no,width='+iWidth+',height='+iHeight+',scrollbars='+scrollbars+',resizable='+resizable+',status=no')
}

function resizeWindow(){
        newWidth=document.all.picNews.width+60
        if(newWidth>screen.width)newWidth=screen.width
        newHeight=400
        window.resizeTo(newWidth,newHeight)
}

function showTr(sTrId, oLink){
        var oTr = eval("document.all."+sTrId);
        var sStyleDisplay = oTr.style.display;
        var sStyleBold = oLink.style.fontWeight;
        
        // Hiding all   
        for(i=0;i<document.all.table_menu.rows.length;i++){
                obj=document.all.table_menu.rows(i);
                if(obj.tagName=="TR" && obj.id!=""){
                        obj.style.display="none";
                }
        }
        // Removing bold
        for(i=0;i<document.links.length;i++){
                obj=document.links(i);
                if(obj.className=="textMenu"){
                        obj.style.fontWeight="";
                }
        }       

        // Showing right tr     
        if(sStyleDisplay=="none")
                oTr.style.display="";
        else
                oTr.style.display="none";
        // Bolding
        if(sStyleBold=="bold")
                oLink.style.fontWeight="";
        else
                oLink.style.fontWeight="bold";
}

function doSearch(oField, oForm){
        if(oField.value.length<=1){
                alert('Строка поиска должна содержать минимум 2 символа!');
                return;
        }else{
                oForm.submit();
        }
}

function picItemResize(){
        oImage=document.getElementById('picItem')
        if(oImage!=null){
                if(oImage.width>200)oImage.width=200
        }
}

function showMap(){
        oMap=document.getElementById('map')
        oWin = window.open('','Map','toolbar=no,location=no,directories=no,menubar=yes,width=562,height=451,scrollbars=no,resizable=yes,status=no')
        oWin.document.write("<html><head><title>Подробная карта</title></head><body leftmargin='0' topmargin='0' rightmargin='0' bottommargin='0' marginwidth='0' marginheight='0'><img src="+oMap.src+"></body></html>")
}

function sendEmail(oForm){
        if(oForm.sEmail.value==""){
                alert('Вы не заполнили поле \"Email адрес\"!')
                oForm.sEmail.select()
                return
        }
        else if(!isEmail(oForm.sEmail.value)){
                alert('Введите правильный email адрес!')
                oForm.sEmail.select()
                return  
        }
        if(oForm.tText.innerText==""){
                alert('Вы не заполнили поле \"Текст\"!')
                oForm.tText.innerText.select()
                return
        }
        sQuery="sendmail.php?sEmail="+oForm.sEmail.value+"&sSubject="+oForm.sSubject.value+"&tText="+oForm.tText.innerText
        document.all.hiddenSendEmail.src=sQuery
        oForm.sEmail.value=""
        oForm.sSubject.value=""
        oForm.tText.innerText=""
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function banner(msg1st,msg,ctrlwidth) {
  msg = "  "+msg
  newmsg = msg
  while (newmsg.length < ctrlwidth) {newmsg += msg}
  document.write ('<FORM NAME="Banner"><td><INPUT NAME="banner" VALUE= "'+msg1st+'" SIZE= '+ctrlwidth+' ID=banner><INPUT TYPE="HIDDEN" NAME="banner_start" VALUE= "0"></td></FORM>')
  document.Banner.banner.value=msg1st
  bannerid=setTimeout("rollmsg(newmsg)",7000)
}
function rollmsg(str) {
  if (str!='') {
    document.Banner.banner.value=str
  }
  NowMsg=document.Banner.banner.value
  NowMsg=NowMsg.substring(1,NowMsg.length)+NowMsg.substring(0,1)
  document.Banner.banner.value = NowMsg
  bannerid=setTimeout("rollmsg('')",150)
}
