
function Select_item(what, item, clicked, desc, val, empty){
   if(window["services_check_status"] == 1)
    window["services_check_status"] = 2;
   if(document.getElementById(clicked).checked == true){ window[val] = window[val] + 1;}
   else {window[val] = window[val] - 1;}

    if(empty == 'All' &&  window[val] == 0)
      document.getElementById(what).value = 'All';
    else {
      if(empty == '-' &&  window[val] == 0)
        document.getElementById(what).value = '';
      else {
        if(desc == "" && window[val] == 0)
          document.getElementById(what).value = "";
        else
        document.getElementById(what).value = window[val] + ' '+desc+' selected';
      }
    }
}

function Listbox(name1){

  if(name1 != 'services_check'){
   if(window["services_check_status"] == 1)
    window["services_check_status"] = 2;
  }

  if(document.getElementById(name1).style.visibility != "visible")
    { document.getElementById(name1).style.visibility = "visible";
      window[name1+"_status"] = 2; }
  else {document.getElementById(name1).style.visibility = "hidden";window[name1+"_status"] = 0; }

  if(document.getElementById(name1).style.display != "block")
    { document.getElementById(name1).style.display = "block"; }
  else {document.getElementById(name1).style.display = "none";}


}
 
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Mr J | http://www.huntingground.net/ */

scrollStep=10

timerLeft=""
timerRight=""
timerTop=""
timerBottom=""


function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",50)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",50)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function scrollDivBottom(id){
  clearTimeout(timerTop) 
  document.getElementById(id).scrollTop+=scrollStep
  timerRight=setTimeout("scrollDivBottom('"+id+"')",50)
}

function scrollDivTop(id){
  clearTimeout(timerTop) 
  document.getElementById(id).scrollTop-=scrollStep
  timerRight=setTimeout("scrollDivTop('"+id+"')",50)
}

function toTop(id){
  document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}
function toBottom(id){
  document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
  clearTimeout(timerBottom) 
  clearTimeout(timerTop)
}
// PRODUCT_DIVS
function ShowDiv(id){
  document.getElementById(id).style.display = 'block';
}
function HidesDiv(id){
  document.getElementById(id).style.display = 'none';
}




  var semail =  "Enter your emaill";

function make_blank(name1){

  if(document.getElementById(name1).value != window[name1]) { }
  else { document.getElementById(name1).value =""; }
}
function refill(name1){
  if(document.getElementById(name1).value != "") { }
  else { document.getElementById(name1).value = window[name1]; }
}

function PrintVersion(div_id) {
  new_window = null;
  aw = 800;
  ah = 600;

  w=800;
  h=606;

  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("", '_blank', settings);
  }
  new_window.document.open();
  new_window.document.clear();
  new_window.document.write(
  '<html><head><meta http-equiv="Content-Language" content="ru"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>woodymichleb</title></head><BODY leftMargin=0 topMargin=0 border="0" marginheight="0" marginwidth="0" bgcolor="#AFAFAE"><!-- 100% height TABLE --><!-- /100% height TABLE --><div align="center"><table border="0" style="border-collapse: collapse" width="650" cellpadding="0" id="table21" bgcolor="#FFFFFF"><tr><td rowspan="11" width="50">&nbsp;</td><td height="32" width="586" colspan="2">&nbsp;</td><td rowspan="11" width="50">&nbsp;</td></tr><tr><td valign="top" width="586" colspan="2"><img border="0" src="http://192.168.0.1/woody/images/logo_light.png"></td></tr><tr><td valign="top" height="32" width="586" colspan="2">&nbsp;</td></tr><tr><td valign="top" width="586" colspan="2"><table border="0" style="border-collapse: collapse" cellpadding="0" id="table26"><tr><td class="icon" valign="top"><a onClick="window.print(); return false;" href="#">Print</a>&nbsp;&nbsp;|&nbsp; &nbsp;<a href="javascript:window.close()">Close</a>&nbsp; </td></tr></table></td></tr><tr><td valign="top" height="32" width="586" colspan="2">&nbsp;</td></tr><tr><td valign="top" width="586" colspan="2" style="font-family:Arial, Helvetica, sans-serif;">'
  + document.getElementById(div_id).innerHTML+
'</td></tr><tr><td valign="top" height="32" width="586" colspan="2">&nbsp;</td></tr><tr><td valign="top" width="586" colspan="2"><table border="0" style="border-collapse: collapse" cellpadding="0" id="table25"><tr><td class="icon" valign="top"><span lang="en-us"><a href="http://www.woodymichleb.com/">www.woodymichleb.com</a><br /><br /></span></td></tr></table></td></tr></table></div></body></html>'  );

  new_window.document.close();
  new_window.focus();
}

function HideDivs(){

  if(window["services_check_status"] == 1){
    document.getElementById("services_check").style.visibility = "hidden";
    document.getElementById("services_check").style.display = "none";
  }
  if(window["services_check_status"] == 2){
    window["services_check_status"] = 1;
  }

}

function switch_divs(div_to_hide, div_to_show) {
  $('#'+div_to_hide).BlindUp(500);
  $('#'+div_to_hide).hide();
  $('#'+div_to_show).BlindDown(500, null, 'easeout');
  $('#'+div_to_show).show();
}

function GetOptions(this_id, change_next, sections){
  $.ajax({
      url: _base_url + "get_select.php?id="+$(this_id).val()+"&section="+sections,
      cache: false,
      success: function(html){
      $(change_next).empty();
    $(change_next).html(html);
    }
});
}


//solutiob ajax content
function GET_SOL_DATA(get_vals) {
  $('#content').DropOutRight(500);
  GetContent(get_vals);
  return false;
}

function Reinit_Thikbox() {
  tb_init('a.thickbox, area.thickbox, input.thickbox');
    imgLoader = new Image();// preload image
    imgLoader.src = tb_pathToImage;
}

function GetContent(get_vals) {
  $.ajax({
      url: _base_url + "get_content.php"+get_vals,
      cache: false,
      success: function(html){
        $("#content").empty();
        $("#content").append(html);
        $("#breadcrumb").empty();
        $("#breadcrumb").append($("#breadcrumb_backup").html());
        $('#content').DropInRight(500, null, 'easeout');
    Reinit_Thikbox();
    $(function() {
        $('a[@rel*=gallery]').lightBox();
        $('a.gallery').lightBox();
    });

    }
  });
}




 function isInteger (s)
   {
      var i;

      if (isEmpty(s)) return false;

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }

   function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }

   function isDigit (c)
   {
      return ((c >= 0) && (c <= 9))
   }



//     function CustomCheckForm(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(class);
//         } else {
//           $("#check_"+c_form+"_"+c_mandatory_fields[i]).removeClass(class);
//         }
//         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(class);
//           }
//         }
//         if(c_mandatory_fields[i] == 'email') {
//           if(CheckEMail($("#"+c_form+"_email").val()) == false) {
//             error = 1;
//             $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass(class);
//           }
//         }
//         if(c_mandatory_fields[i] == 'mail') {
//           if(CheckEMail($("#"+c_form+"_mail").val()) == false) {
//             error = 1;
//             $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass(class);
//           }
//         }
//       }      
//       if(error == 1) {
//         return false;
//      } else  {
// 
//         return true;
//       }
//     }

function CheckEMail(str_email) {
          
        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) == '.'))  {
        alert('Enter Valid Email Adress!');
        return false;
        }
        return true;
    }

function CheckEMail2(str_email) {
          
        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) == '.'))  {
//         alert('Enter Valid Email Adress!');
        return false;
        }
        return true;
    }

//Main page effects
 /*   $(function() {
        $('a[@rel*=gallery]').lightBox();
    });

    $(function() {
        $('a.gallery').lightBox();
    }); */

//Form Functions
//     function CheckForm(style) {
//       if (style == undefined) {style = class;}
//       var error = 0;
//       for(i=0;i<mandatory_fields.length;i++) {
//         if($("#"+mandatory_fields[i]).val() == "") {
//           error = 1
//           $("#check_"+mandatory_fields[i]).addClass(style);
//         } else {
//           $("#check_"+mandatory_fields[i]).removeClass(style);
//         }
//       }
// 
//       if(error == 1) {
//         if (style != undefined)
//            alert("Fill all marked fields");
//         return false;
//       }
//       else
//         return true;
//     }

    function CheckFormInput(ref) {

      var _error = 0;
      var _message = "Please fill in:\n";
      var _add = "";
      var _class = "";
      if(ref == 1){
        _add = "#";
        _class = "font_red_color";
      }
      else{
        if(ref == 2){
          _add = "#check_";
          _class = "font_red_color_file";
        }
        else{
          _add = "#check_";
          _class = "font_red_color";
        }
      }

      for(i=0;i<mandatory_fields.length;i++) {
        if($("#"+mandatory_fields[i]).val() == ""
           && mandatory_fields[i] != 'email'
           && mandatory_fields[i] != 'smail'
           && mandatory_fields[i] != 'd_phone_a'
           && mandatory_fields[i] != 'd_phone'
           && mandatory_fields[i] != 'e_phone_a'
           && mandatory_fields[i] != 'e_phone'
           && mandatory_fields[i] != 'mail' ) {

          _error = 1
          $(_add+mandatory_fields[i]).addClass('font_red_color');
            _message += ' - '+window[mandatory_fields[i]]+'\n';

        } else {
            $(_add+mandatory_fields[i]).removeClass('font_red_color');
        }

        if(mandatory_fields[i] == 'email' || mandatory_fields[i] == 'smail' || mandatory_fields[i] == 'mail') {

          if(CheckEMail2($("#"+"email").val()) == false) {
            _error = 1;

            _message += ' - '+window[mandatory_fields[i]]+'\n';

            $(_add+mandatory_fields[i]).addClass(_class);
          } else {
            $(_add+mandatory_fields[i]).removeClass(_class);
          }
        }

      }

 
      if(_error == 1) {
            alert(_message+"field(s)!");
        if(ref == 1)
          RefillAll();

        return false;
      } else
        return true;

    }

