var cssMarql = {
  'display' : 'block',
  'left' : '95%',
  'margin-left' : '-250px'
};
  
var cssMarq2l = {
  'left' : '95%',
  'display' : 'none',
  'margin-left' : '-250px'
};

var cssMarq = {
  'display' : 'block',
  'left' : '5%',
  'margin-left' : '+0px'
};
  
var cssMarq2 = {
  'left' : '5%',
  'display' : 'none',
  'margin-left' : '+0px'
};

var bifn = "includes/image.php?img=";

var ddd = new Date();

var hrhr = ddd.getHours();

function loadd() {
  
  var wiwi = $(window).width();
  var hihi = wiwi*0.66333333;
  var himarq = hihi*0.35;
  var wifeed = wiwi*1 - 220;
  var wiwhat = wiwi*0.288;
  var wiabou = wiwi*0.456;
  var hictp1 = hihi*0.47;
  var hictp2 = hihi*0.52;
  var hicona = $("#divcon").height()*1 - 72;
  var aifn = "&width=" + $(window).width();
	
  $("#ioverlay").attr('src',bifn+'index'+aifn);
  $("#lgo").attr('src',bifn+'logo'+aifn);
  $("#buttons").height(hihi);
  $(".marq").css("top", himarq);
  $("#bod").css("top", hihi);
  $("#blogtd").width(wiwi);
  $("#feedme").width(wifeed);
  $("#whatisjd").width(wiwhat);
  $("#abouttheauthor").width(wiabou);
  $("#whatisjd").attr('src',bifn+'whatisjd&width='+wiwhat);
  $("#abouttheauthor").attr('src',bifn+'abouttheauthor&width='+wiabou);
  $("#cloud1").css("top", hictp1);
  $("#cloud2").css("top", hictp2);
  $("#contentArea").height(hicona);
  
  dated();
}

$(function() {
  return loadd();
});

function dated() {
	
    var aifn = "&width=" + $(window).width();
  
    if (hrhr>=7 && hrhr<18) {
      $("#bgimg").attr('src',bifn+'bg_day'+aifn);
    }
    else if (hrhr>=5 && hrhr<7) {
      $("#bgimg").attr('src',bifn+'bg_evening'+aifn);
    }
    else if (hrhr>=18 && hrhr<20) {
      $("#bgimg").attr('src',bifn+'bg_evening'+aifn);
    }
        else {
          $("#bgimg").attr('src',bifn+'bg_night'+aifn);
    }
}

function marqu(dapics) {
  $(dapics).css(cssMarq);
  $(dapics).animate({
        opacity: "0"
   }, { queue: 0, duration: 1 } );
  $(dapics).animate({
        opacity: "1"
   }, { queue: 1, duration: 249 } );
  $(dapics).animate({
        left: "95%",
        marginLeft: "-250px"
   }, { queue: 250, duration: 4000 } );
  $(dapics).animate({
        opacity: "0"
   }, { queue: 4000, duration: 250 } );
  $(dapics).queue(function () {
    $(this).css(cssMarq2);
        $(this).dequeue();
  });
}

function marqul(dapics) {
  $(dapics).css(cssMarql);
  $(dapics).animate({
        opacity: "0"
   }, { queue: 0, duration: 1 } );
  $(dapics).animate({
        opacity: "1"
   }, { queue: 1, duration: 249 } );
  $(dapics).animate({
        left: "5%",
        marginLeft: "+0px"
   }, { queue: 250, duration: 4000 } );
  $(dapics).animate({
        opacity: "0"
   }, { queue: 4000, duration: 250 } );
  $(dapics).queue(function () {
    $(this).css(cssMarq2l);
        $(this).dequeue();
  });
}

function loadit(tittle,pagge) {
  $("#divcon").css("display", "block");
  $("#divtit").html(tittle);
  $("#contentArea").load(pagge);
}

function closeme() {
  $("#divcon").css("display", "none");
}

$(function marqueed() {
  marqu("#m1");
  $("#m1").queue(function () {
    $(this).dequeue();
        marqul("#m2");
        $("#m2").queue(function () {
      $(this).dequeue();
      marqu("#m3");
          $("#m3").queue(function () {
        $(this).dequeue();
        marqul("#m4");
                $("#m4").queue(function () {
          $(this).dequeue();
          marqu("#m5");
                  $("#m5").queue(function () {
            $(this).dequeue();
            marqul("#m6");
                    $("#m6").queue(function () {
              $(this).dequeue();
              marqu("#m7");
                      $("#m7").queue(function () {
                $(this).dequeue();
                marqul("#m8");
                        $("#m8").queue(function () {
                  $(this).dequeue();
                  marqu("#m9");
                          $("#m9").queue(function () {
                    $(this).dequeue();
                    marqul("#m10");
                            $("#m10").queue(function () {
                      $(this).dequeue();
                      marqu("#m11");
                              $("#m11").queue(function () {
                        $(this).dequeue();
                        marqul("#m12");
                                $("#m12").queue(function () {
                          $(this).dequeue();
                          marqu("#m13");
                                  $("#m13").queue(function () {
                            $(this).dequeue();
                            marqul("#m14");
                                    $("#m14").queue(function () {
                              $(this).dequeue();
                              marqu("#m15");
                                      $("#m15").queue(function () {
                                $(this).dequeue();
                                marqul("#m16");
                                        $("#m16").queue(function () {
                                  $(this).dequeue();
                                  marqu("#m17");
                                          $("#m17").queue(function () {
                                    $(this).dequeue();
                                    marqul("#m18");
                                            $("#m18").queue(function () {
                                      $(this).dequeue();
                                      marqu("#m19");
                                              $("#m19").queue(function () {
                                        $(this).dequeue();
                                        marqueed();
                                              });
                                            });
                                          });
                                        });
                                      });
                                    });
                                  });
                                });
                              });
                            });
                          });
                        });
                      });
                    });
                  });
                });
          });
      });
  });
});

$(function cld1() {
  $("#cloud1").animate({"left": "60%"}, {duration: 40000, queue: 0} )
  $("#cloud1").animate({"left": "20%"}, {duration: 40000, queue: 40000} );
  $("#cloud1").queue(function () {
		$(this).dequeue();
		cld1();
  });
});

$(function cld2() {
  $("#cloud2").animate({"left": "30%"}, {duration: 50000, queue: 0} )
  $("#cloud2").animate({"left": "70%"}, {duration: 50000, queue: 50000} );
  $("#cloud2").queue(function () {
		$(this).dequeue();
		cld2();
  });
});

$(function moon() {
  $("#pic1").animate({
    left: "90%"
   }, { queue: 0, duration: 10000, specialEasing: {
      left: "swing"
    } } );
  $("#moon").animate({
        top: "+100px",
        width: "+120px"
   }, { queue: 0, duration: 5000, specialEasing: {
      width: "swing",
          top: "swing"
    } } );
   $("#moon").animate({
        top: "+0px",
        width: "+90px"
   }, { queue: 5000, duration: 5000, specialEasing: {
      width: "swing",
          top: "swing"
    } } );
  $("#pic1").queue(function () {
    $(this).css("z-index","3");
        $(this).dequeue();
  });
  $("#pic1").animate({
    left: "15%"
   }, { queue: 10000, duration: 10000, specialEasing: {
      left: "swing"
    } } );
  $("#moon").animate({
        top: "-10px",
        width: "+60px"
   }, { queue: 10000, duration: 5000, specialEasing: {
      width: "swing",
          top: "swing"
    } } );
   $("#moon").animate({
        top: "+0px",
        width: "+90px"
   }, { queue: 15000, duration: 5000, specialEasing: {
      width: "swing",
          top: "swing"
    } } );
  $("#pic1").queue(function () {
    $(this).css("z-index","4");
        $(this).dequeue();
  });
        moon();
});

$(window).resize(function() {
  return loadd();
});

$(window).load(function() {
  return loadd();
});
