var full_layout = $.cookie('full_layout');

function switchLayout() {
  if ($('link#fluid-css').length) {
    $('link#fluid-css').remove();
    $('meta[name=viewport]').remove();
    $('head').append('<meta name="viewport" content="width=974, initial-scale=1.0; maximum-scale=3.0; user-scalable=1;"/>');
    $.cookie('full_layout', 'on', { expires: 7, path: '/' });
    full_layout = 'on';
  } else {
    $('head').append('<link rel="stylesheet" id="fluid-css" href="/wp-content/themes/owetfluid/fluid.css" type="text/css" media="screen" />');
    $('meta[name=viewport]').remove();
    $('head').append('<meta name="viewport" content="width=device-width, initial-scale=1.0; maximum-scale=1.0; user-scalable=1;"/>');
    $.cookie('full_layout', 'off', { expires: 7, path: '/' });
    full_layout = 'off';
  }
}

function initSwitch() {
  $('.switch-full').click(function() {
    switchLayout();
    return false;
  });
  if (full_layout == 'on') {
    $('link#fluid-css').remove();
  }
}
$(document).ready(function() {
  initSwitch();
});
