function increase_size(element_name) {
  $('#sayfa_alt ' + element_name).each(function(i) {
    var font_size = $(this).css('fontSize');
    if (typeof(font_size) != undefined) {
      var unit  = font_size.indexOf('%') > 0 ? font_size.slice(-1) : font_size.slice(-2);
      var value = parseFloat(font_size, 10);
      if (value > 0) {
        switch (unit) {
          case '%': case 'em': value *= 1.1; break;
          case 'px': value += 2; break;
          case 'pt': value += 1; break;
          default: break;
        }
        $(this).data('fontSize', value + unit);
      }
    }
  });
}

function decrease_size(element_name) {
  $('#sayfa_alt ' + element_name).each(function(i) {
    var font_size = $(this).css('fontSize');
    if (typeof(font_size) != undefined) {
      var unit  = font_size.indexOf('%') > 0 ? font_size.slice(-1) : font_size.slice(-2);
      var value = parseFloat(font_size, 10);
      if (value > 0) {
        switch (unit) {
          case '%': case 'em': value /= 1.1; break;
          case 'px': value -= 2; break;
          case 'pt': value -= 1; break;
          default: break;
        }
        $(this).data('fontSize', value + unit);
      }
    }
  });
}

function update_size(element_name) {
  $('#sayfa_alt ' + element_name).each(function(i) {
    if ($(this).data('fontSize')) {
      $(this).css('fontSize', $(this).data('fontSize'));
      $(this).removeData('fontSize');
    }
  });
}

$(document).ready(function() {
  var element_array = new Array('div', 'span', 'p', 'font', 'a', 'td', 'li', 'input', 'select', 'textarea', 'h1', 'h2', 'h3');
  var cnt = 0;
  $('#font_increase').click(function() {
    if (cnt < 3) {
      cnt++;
      jQuery.each(element_array, function() {
        increase_size(this.toString());
      });

      jQuery.each(element_array, function() {
        update_size(this.toString());
      });
    }
    return false;
  });
  $('#font_decrease').click(function() {
    if (cnt > -3) {
      cnt--;
      jQuery.each(element_array, function() {
        decrease_size(this.toString());
      });

      jQuery.each(element_array, function() {
        update_size(this.toString());
      });
    }
    return false;
  });
});


