/*
jQuery Script for ciaopanic-typy
Date   : 2010.06.04
--------------------------------------*/


(function($) {

  //plugin dateUpdate
  $.fn.dateUpdate = function(c_update,c_new) {
    var self = $(this);
    var res = "";
    var getDate = function(){
      $.ajax({
        type: "GET",
        url  : "http://www.ciaopanic-typy.com/static/include/getdate.php" ,
        cache: true,
        dataType: "xml",
        timeout : 3000,
        error   : function() {
          return true;
        },
        success : function(data) {
          addStyle(data);
          return true;
        }
      });
    }
    var addStyle = function(data){
      var y = $("year",data).text();
      var m = $("month",data).text();
      var d = $("day",data).text();
      var res = y + "." + m + "." + d;
      self.each(function(i){
        var d = $(this).find(".date");
        var t = $(this).find(".ttl");
        var n = d.text();
        if(n == res){
          if(c_update){
            d.addClass("update");
          }
          if(c_new){
            t.addClass("new");
          }
        }
      });
    }
    getDate();
  };

})(jQuery);

