(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)  
  
  $(document).ready(function() {
    // This is more like it!
     jQuery.preLoadImages("/images/button-features-on-" + lang_img + ".gif",     
                          "/images/button-features-off-" + lang_img + ".gif",
                          "/images/button-specs-on-" + lang_img + ".gif",
                          "/images/button-specs-off-" + lang_img + ".gif"
                          );
    
     // Expand only the active menu, which is determined by the class name
     $("#menu > li > a[class=expanded] ").find("+ ul").slideToggle("medium");

     // Toggle the selected menu's class and expand or collapse the menu
     $("#menu > li > a").click(function() {
          $(this).toggleClass("expanded").toggleClass("collapsed").find("+ ul").slideToggle("medium");
     });
               
       //cookie set tc
       $(".language-tc").change(function(){
          $.cookie('LANGUAGE','tc', { path: '/', expires: 10000, domain: 'searchable-pdf.com' });
       });
       //cookie set sc
       $(".language-sc").change(function(){
          $.cookie('LANGUAGE','sc', { path: '/', expires: 10000, domain: 'searchable-pdf.com' });
       });
       //cookie set en
       $(".language-en").change(function(){
          $.cookie('LANGUAGE','en', { path: '/', expires: 10000, domain: 'searchable-pdf.com' });
       });
       
       
       var section = new Array('.content-resizeable'); 
       section = section.join(',');

       // Large Font Size
       $(".largeFont").click(function(){
         $('h5').css('font-size', '19px');
         $('h4').css('font-size', '19px');
         $('h3').css('font-size', '16px');
         $('h2').css('font-size', '19px');
         $('.content-resizeable').css('font-size', '17px');
         $('.content-resizeable').css('line-height', '24px');
         $.cookie('TEXT_SIZE','large', { path: '/', expires: 10000, domain: 'searchable-pdf.com' });

         return false;
       });

       // Normal Font Size
       $(".normalFont").click(function(){
         $('h5').css('font-size', '15px');
         $('h4').css('font-size', '15px');
         $('h3').css('font-size', '12px');
         $('h2').css('font-size', '15px');
         $('.content-resizeable').css('font-size', '13px');
         $('.content-resizeable').css('line-height', '20px');
         $.cookie('TEXT_SIZE','normal', { path: '/', expires: 10000, domain: 'searchable-pdf.com' });

         return false;
       });
       
       // Small Font Size
       $(".smallFont").click(function(){
         $('h5').css('font-size', '17px');
         $('h4').css('font-size', '17px');
         $('h3').css('font-size', '14px');
         $('h2').css('font-size', '17px');
         $('.content-resizeable').css('font-size', '15px');
         $('.content-resizeable').css('line-height', '22px');
         $.cookie('TEXT_SIZE','small', { path: '/', expires: 10000, domain: 'searchable-pdf.com' });

         return false;
       });
       
     //text size load
     if($.cookie('TEXT_SIZE')) {
          var $textSize = $.cookie('TEXT_SIZE');
          
          if( $textSize == "large" ){
               $('.largeFont').click();
          }else if( $textSize == "normal" ){
               $('.normalFont').click();
          }else if( $textSize == "small" ){
               $('.smallFont').click();
          }
          
     }

     //Hide (Collapse) the toggle containers on load
     $(".toggle_container").hide(); 

     //Switch the "Open" and "Close" state per click
     $("h6.trigger").toggle(function(){
          $(this).addClass("active");
          }, function () {
          $(this).removeClass("active");
     });

     //Slide up and down on click
     $("h6.trigger").click(function(){
          $(this).next(".toggle_container").slideToggle("slow");
     });
       
     });
     
var textsize = 13;

function fsize(size,unit,id){
  var vfontsize = document.getElementById(id);
  if(vfontsize){
   vfontsize.style.fontSize = size + unit;
  
  }
}

//visibility toggle
function toggle_visibility(id) {

  var intro = document.getElementById('intro');
  var spec = document.getElementById('spec');
  var features_img = document.getElementById('features_img');
  var specs_img = document.getElementById('specs_img');
  
       if( id == 'intro' ){
               intro.style.display = 'block';
               spec.style.display = 'none';
               features_img.src = '/images/button-features-on-' + lang_img +'.gif';
               specs_img.src = '/images/button-specs-off-' + lang_img +'.gif';
          }
       else{
               intro.style.display = 'none';
               spec.style.display = 'block';
               features_img.src = '/images/button-features-off-' + lang_img +'.gif';
               specs_img.src = '/images/button-specs-on-' + lang_img +'.gif';
          }
    
}

