function widthfix() {
  $('.widthfix_oneside').css('width',(980 - 12) + "px");
}

function fullwidthadjust() {
  
  var windowwidth=$(window).width();
    
  $('.fromleft').css('left',((windowwidth/2)-490) + 'px');
  $('.fromright').css('right',((windowwidth/2)-490) + 'px');

  $('#submenu').css('left',((windowwidth/2)-363) + 'px');
  
  $('#modeswitch a:last').css('marginRight',((windowwidth/2)-490) + 'px');
  
}

function contentheightadjust() {
  // Content height
  var yheight=$('#modeswitch').offset().top;
  yheight=parseInt(yheight);
  
  $('#content').css('height',(yheight - 12) + 'px');
  
  $('.scroll').css('height', (yheight - 50) + "px");
  
  $('.scroll').jScrollPane( { 
     scrollbarWidth: 4,
     dragMaxHeight: 57
   });
  
}

function backgroundsize() {
  
  var ratio=1.725352112676056;
  
  var newx=$(window).width();
  var newy=newx/ratio;
  var newy=Math.round(newy);
  
  //var newy=$(window).height();
  //var newx=newy*ratio;
  //newx=Math.round(newx);
  
  $('#background_img').css('width',newx + 'px','height',newy + 'px');
  
}

$(document).ready(function() {
  
  widthfix();
  
  $(window).resize(function() {
    fullwidthadjust();
    contentheightadjust();
    backgroundsize();
    leftpanelsize();
  });
  
  fullwidthadjust();
  contentheightadjust();
  backgroundsize();
  leftpanelsize();
  
  $('#eye-icon').click(function() {
    $('.eyehide').toggle(0,function() {
      
      if($(this).is(':visible')) {
        $('#eye-icon').attr('src','/templates/ecopod2/images/eye-closed.png');
      }else{
        $('#eye-icon').attr('src','/templates/ecopod2/images/eye-open.png');        
      }
      
    });
    
    
  });
  
  $('.hoverImage').each(function() {
        
    var img=$(this);
    var original=img.attr('src');
    
    var ext=original.substr(original.length - 3);

    var chk=original.substr(original.length - 7);
    var hov='';

    if(chk == ('-on.' + ext)) {
      hov=original;
    }else{
      hov=original.substr(0,(original.length - 4)) + '-on.' + ext;
    }

    $(this).hover(function() {
      img.attr('src',hov);
    },function() {
      img.attr('src',original);
    });
    
  });
  
  
  // height of menu wrapper
  
});

function leftpanelsize() {
  
  $('#mainmenu-wrapper').css('height',$('#content').height() + 'px');
  
}

