﻿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 popPrintHires(url) {
  popWin(url, "popPrintHires", 900, 600, "yes");
}

function popWin(page, name, width, height, scroll) {
  LeftPosition = (screen.width) ? (screen.width - width) / 2 : 0;
  TopPosition = (screen.height) ? (screen.height - height) / 2 : 0;
  settings = "height=" + height + ",width=" + width + ",top=" + TopPosition + ",left=" + LeftPosition + ",scrollbars=" + scroll + ",resizable";
  win = window.open(page, name, settings)
  win.focus();
}

$(document).ready(function() {
  $(".rollover").hover(function() {
    var currentImg = $(this).attr("src");
    $(this).attr("src", $(this).attr("hover"));
    $(this).attr("hover", currentImg);
  }, function() {
    var currentImg = $(this).attr("src");
    $(this).attr("src", $(this).attr("hover"));
    $(this).attr("hover", currentImg);
  });

  if ($.cookie("slidemenu") != null) {
    $('.slidemenu ul li a[href$="' + $.cookie("slidemenu") + '"]').addClass('on').next().slideDown(1);
  }


  $('.slidemenu ul ul').hide();
  //$('.slidemenu li a:first').addClass('on');
  //$('.slidemenu ul:first').show();
  $('.slidemenu ul li a').click(function() {

    var checkElement = $(this).next();
    if (checkElement.is('ul')) {
      $('.slidemenu ul li a').removeClass('on');
      $(this).addClass('on');
      $.cookie("slidemenu", $(this).attr('href'));
    }
    if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
      return false;
    }
    if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
      $('.slidemenu ul ul:visible').slideUp('normal');
      checkElement.slideDown('normal');
      return false;
    }
  }); //*/






  $('.faq .question').click(function() {
    $(this).next().slideToggle('fast');
  });

  $('.expand-all').click(function() {
    $('.hidden').slideDown('fast');
  });
  $('.collape-all').click(function() {
    $('.hidden').slideUp('fast');
  });











  // Set specific variable to represent all iframe tags.
  var iFrames = document.getElementsByTagName('iframe');

  // Resize heights.
  function iResize() {
    // Iterate through all iframes in the page.
    for (var i = 0, j = iFrames.length; i < j; i++) {
      // Set inline style to equal the body height of the iframed content.
      iFrames[i].style.height = (iFrames[i].contentWindow.document.body.offsetHeight + 500) + 'px';
    }
  }

  // Check if browser is Safari or Opera.
  if ($.browser.safari || $.browser.opera) {
    // Start timer when loaded.
    $('iframe').load(function() {
      setTimeout(iResize, 0);
    });

    // Safari and Opera need a kick-start.
    for (var i = 0, j = iFrames.length; i < j; i++) {
      var iSource = iFrames[i].src;
      iFrames[i].src = '';
      iFrames[i].src = iSource;
    }
  } else {
    // For other good browsers.
    $('iframe').load(function() {
      // Set inline style to equal the body height of the iframed content.
      this.style.height = (this.contentWindow.document.body.offsetHeight + 500) + 'px';
    });
  }


});


function MaxWords80(src, args) {
  args.IsValid = (document.getElementById(src.controltovalidate).value.split(" ").length <= 80);
}
function MaxWords150(src, args) {
  args.IsValid = (document.getElementById(src.controltovalidate).value.split(" ").length <= 150);
}
function MaxWords250(src, args) {
  args.IsValid = (document.getElementById(src.controltovalidate).value.split(" ").length <= 250);
}


function checkbox_validator(src, args) {
  args.IsValid = false;
  $('.checkboxlist').find(':checkbox').each(function() {
    if ($(this).attr('checked')) {
      args.IsValid = true;
      return;
    }
  });
}










var timeout = 1500;
var closetimer = 0;
var ddmenuitem = 0;

function sitenavi_open() {
  sitenavi_canceltimer();
  sitenavi_close();
  ddmenuitem = $(this).find("ul").css("visibility", "visible");
}

function sitenavi_close() {
  if (ddmenuitem) {
    ddmenuitem.css("visibility", "hidden");
  }
}

function sitenavi_timer() {
  closetimer = window.setTimeout(sitenavi_close, timeout);
}

function sitenavi_canceltimer() {
  if (closetimer) {
    window.clearTimeout(closetimer);
    closetimer = null;
  }
}

$(document).ready(function() {
  $(".sitenavi > li").bind("mouseover", sitenavi_open)
  $(".sitenavi > li").bind("mouseout", sitenavi_timer)
  $("li.about").hover(function() { $(this).toggleClass("about_o"); }, function() { $(this).toggleClass("about_o"); });
  $("li.capability").hover(function() { $(this).toggleClass("capability_o"); }, function() { $(this).toggleClass("capability_o"); });
  $("li.wheretobuy").hover(function() { $(this).toggleClass("wheretobuy_o"); }, function() { $(this).toggleClass("wheretobuy_o"); });
  $("li.product").hover(function() { $(this).toggleClass("product_o"); }, function() { $(this).toggleClass("product_o"); });
  $("li.support").hover(function() { $(this).toggleClass("support_o"); }, function() { $(this).toggleClass("support_o"); });
  $("li.contact").hover(function() { $(this).toggleClass("contact_o"); }, function() { $(this).toggleClass("contact_o"); });
});

document.onclick = sitenavi_close;
