﻿// ie6 transparent PNG fix
$(document).ready(function() {

    var cookie = readCookie("textsizestyledaynotes");
    textsize = cookie ? cookie : 1;
    fsize(textsize, 'em', 'DayNotes');

    //$(document).pngFix();

    //$('input[title!=""]').hint();

    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        var ieversion = new Number(RegExp.$1)
        if (ieversion > 6)
            PEPS.rollover.init();
    }

//    $('input[type="radio"]').customInput();  // activate custom radio buttons
//    $('input[type="checkbox"]').customInput(); // activate custom checkboxes

//    // Activate Custom Scrollbars
//    $('#scroll1').jScrollPane({ scrollbarWidth: 15, scrollbarMargin: 4, showArrows: true });
//    $('.divContentGridView').jScrollPane({ scrollbarWidth: 15, scrollbarMargin: 4, showArrows: true }); 

});

// Roll Over Logic
PEPS = {};
PEPS.rollover =
{
    init: function() {
        this.preload();

        $(".ro").hover(
         function() { $(this).attr('src', PEPS.rollover.newimage($(this).attr('src'))); },
         function() { $(this).attr('src', PEPS.rollover.oldimage($(this).attr('src'))); }
      );
    },

    preload: function() {
        $(window).bind('load', function() {
            $('.ro').each(function(key, elm) { $('<img>').attr('src', PEPS.rollover.newimage($(this).attr('src'))); });
        });
    },

    newimage: function(src) {
        return src.substring(0, src.search(/(\.[a-z]+)$/)) + '_o' + src.match(/(\.[a-z]+)$/)[0];
    },

    oldimage: function(src) {
        return src.replace(/_o\./, '.');
    }
};

// Font Sizer
function fsize(textsize,unit,id){
  var vfontsize = document.getElementById(id);
  if(vfontsize){
    vfontsize.style.fontSize = textsize + unit;
    createCookie("textsizestyledaynotes", textsize, 365);
  }
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
 
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}