// scroll newer
scrollStep=3

timerLeft=""
timerRight=""

function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}


function go_umenu_url(){
  box = document.getElementById('user_nav');
  destination = box.options[box.selectedIndex].value;
  if (destination) location.href = destination;
}

function go_comnav_url(){
  box = document.getElementById('comnav');
  destination = box.options[box.selectedIndex].value;
  if (destination) location.href = destination;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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 MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function nav_form_submit(faction) {
  document.tnavform.action=faction;
  document.tnavform.submit();
}

function cng_tm_bg(menu_item, style) {
  if(style == 1) {
    menu_item.style.backgroundImage='url(images/tm_mb_sel.jpg)';
  } else {
    menu_item.style.backgroundImage='url(images/tm_mb.jpg)';
  }
}

function cng_image(item, image)
{
  item.src=image;
}

function cng_bg_col(item, color)
{
  item.style.backgroundColor=color;
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

function SwitchHide(obj) {
    if (document.getElementById) {
        var element = document.getElementById(obj);
        if (element.style.display == "none") {
            element.style.display = "block";
        } else {
            element.style.display = "none";
        }
    }
}

    function GenCheckEMail(str_email) {
        var t = str_email.indexOf("@");
        if ((str_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > str_email.length - 5) || (str_email.charAt(t - 1) == '.') || (str_email.charAt(t + 1) == '.'))  {
            return false;
        }
        return true;
    }

    function GenCheckForm(c_form, c_mandatory_fields) {
      var error = 0;
      for(i=0;i<c_mandatory_fields.length;i++) {   
 
        if($("#"+c_form+"_"+c_mandatory_fields[i]).val() == "") {
          error = 1;
          $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
        } else {
          $("#check_"+c_form+"_"+c_mandatory_fields[i]).removeClass('font_red_color');
        }
        if(c_mandatory_fields[i] == 'confirm_password') {

          if($("#"+c_form+"_confirm_password").val() != $("#"+c_form+"_password").val()) {
            error = 1;
            $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
          }
        }
        if(c_mandatory_fields[i] == 'email') {
          if(GenCheckEMail($("#"+c_form+"_email").val()) == false) {
            error = 1;
            $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
          }
        }
      }

      if(error == 1)
        return false;
      else
        return true;
    }

function doBookmark() {
 ap=navigator.appName;
 url=location.href;
 t="ОКНА МЕДИА - интернет-портал об окнах";

 if (window.sidebar) {
 window.sidebar.addPanel(t,url,'');
 } else if (window.external) {
 window.external.AddFavorite(url,t);
 } else if (window.addNet) {
 addNet(url,t);
 } else {
 alert("Your browser does not support this functionality.\nPlease add the bookmark manually.");
 }
}

  function CalcPrintNew1(text1, base_url) {
  new_window = null;
  aw = 850;
  ah = 650;

  w=850;
  h=656;

  if (new_window==null || new_window.closed) {
  settings=
  "left=" + (aw-w)/2 + ","
  +"top=" + (ah-h)/2 + ","
  +"screenX=" + (aw-w)/2 + ","
  +"screenY=" + (ah-h)/2 + ","
  +"width=" + w + ","
  +"height=" + h + ","
  +"innerWidth=" + w + ","
  +"innerHeight=" + h + ","
  +"toolbar=no,"
  +"location=no,"
  +"directories=no,"
  +"status=yes,"
  +"menubar=no,"
  +"scrollbars=yes,"
  +"resizable=no"
  new_window = window.open("", '', settings);
  }
  new_window.document.open();
  new_window.document.clear();

  new_window.document.write("<link href = \""+base_url+"style/style.css\" rel=\"stylesheet\" type=\"text/css\"><table align=center style=\"padding:10 20 10 20px;width:800px!important;\"><tr><td><img border=0  src=\"images/banner_media2.gif\"/></td><td><a onclick=\"window.print(); return false;\" title=\"Распечатать\" href=\"#\"><img border=0 width=11 height=9 src=\"images/ic_print.gif\"/>&nbsp;&nbsp;Распечатать</a>&nbsp;&nbsp;<a href=\"javascript:window.close()\"><img border=\"0\" width=\"9\" height=\"9\" src=\"images/ic_exit.gif\"/>&nbsp;&nbsp;Закрить</a></td></tr><tr><td colspan=2>"+document.getElementById(text1).innerHTML+"</td><tr></table>");
  new_window.document.close();
  new_window.focus();
  }

function SendRecommend(base_url, href_refer, htitle) {
  new_window = null;
  aw = 455;
  ah = 340;

  w=455;
  h=340;

  if (new_window==null || new_window.closed) {
    settings=
    "left=" + (aw-w)/2 + ","
    +"top=" + (ah-h)/2 + ","
    +"screenX=" + (aw-w)/2 + ","
    +"screenY=" + (ah-h)/2 + ","
    +"width=" + w + ","
    +"height=" + h + ","
    +"innerWidth=" + w + ","
    +"innerHeight=" + h + ","
    +"toolbar=no,"
    +"location=no,"
    +"directories=no,"
    +"status=yes,"
    +"menubar=no,"
    +"scrollbars=no,"
    +"resizable=no"
    new_window = window.open("", '_blank', settings);
  }
  new_window.document.open();
  new_window.document.clear();
  new_window.document.write(
  '<link href = "'+base_url+'style/style.css" rel="stylesheet" type="text/css">' 
   +'<table align=center style="padding:10 20 10 20px;width:400px!important;"><tr><td><img border=0  src="images/banner_media2.gif"/></td><td>&nbsp;&nbsp;<a href="javascript:window.close()"><img border="0" width="9" height="9" src="images/ic_exit.gif"/>&nbsp;&nbsp;Закрыть</a></td></tr><tr><td colspan=2>'
   +'<form name="letter" method="POST" action="'+base_url+'recommend.php"  OnSubmit="javascript: if (document.getElementById(\'sender\').value ==\'\' || document.getElementById(\'recipient\').value ==\'\') { alert(\'Поле отправителя и получателя не должно быть пустым!\'); return false; } else return true; ">'
   +'<table border="0" ><tr><td valign="top" width="586" colspan="2"><br><br><b>РЕКОМЕНДОВАТЬ СТРАНИЦУ</b><br><br></td></tr>'
   +'<tr><td valign="top" width="350" colspan="2" height="32" nowrap="true"><b>Отправитель (E-mail)</b> : <INPUT class=search_field2 style="WIDTH: 196; HEIGHT: 20" maxLength=130 id="sender" name="SENDER"></td></tr>'
   +'<tr><td valign="top" width="350" colspan="2" height="32" nowrap="true"><b>Получатель (E-mail)</b> :&nbsp;&nbsp; <INPUT class=search_field2 style="WIDTH: 196; HEIGHT: 20" id="recipient" maxLength=130 name="RECIPIENT"></td></tr>'
   +'<tr><td valign="top" width="350" colspan="2" height="32" nowrap="true"><br><input type="hidden" name="url_refer" id="url_refer" value="'+href_refer+'"><input type="hidden" name="title" id="title" value="'+htitle+'"><input type="submit" class="srch_button" value=" отправить " name="send"></td></tr></table></form>'
   +'</td></tr></table>'  );

  new_window.document.close();
  new_window.focus();
}



