$(document).ready(function() {

  // coloring items of top menu
  $("#menudiv td:not(.sel):not(.lastItem)").hover(
    function(){$(this).css("background-color","#333333");},
    function(){$(this).css("background-color","#4d4d4d");}
  );

  // opening and closing popup menu.
  $("#menudiv td:not(.sel)").hover(
    function(){$(this).children("ul").show("fast");},
    function(){$("#menudiv ul").parents('td:not(.sel)').children("ul").hide("fast");} // close all UL which are not contained in td.sel and set them z-index equal 9
  );

  // setting the woman as background
  if($("body.home").width() > 1173) $("body.home").css("background-position",($("body.home").width()/2+$("div.common").width()/2 - 41)+"px 520px");
  else $("body.home").css("background-position","-10000px -10000px");

	  // hovering for the search button.
  $(".searchFieldButton > input").hover(
    function(){$(this).addClass("hover");},
    function(){$(this).removeClass("hover");}
  );

  // hovering for the submit button.
  $("input.green_button").hover(
    function(){$(this).addClass("frmbutton_hover");},
    function(){$(this).removeClass("frmbutton_hover");}
  );

  // hovering submenu items
  $("div.submenu td:not(.lastItem)").hover(
    function(){$(this).css("background-color","#73be10")},
    function(){$(this).css("background-color","#5ca100")}
  );

  // setting href for td
  $("div.submenu td:not(.lastItem)").click(
    function(){document.location.href=$(this).children("a").attr("href");}
  );


  // The weird task from client. I was need to change a date to 5 days backward.
  $(".dateAG").each(function(){
// I thought I need to use an original date... It's incorrect. I should use a current one.
//    var datestring = $(this).text();
//    var datenewParsed = Date.parse(datestring);
    var datenew = new Date();
    datenew.setDate(datenew.getDate()-5);
    $(this).text((datenew.getMonth()+1)+"/"+(datenew.getDate()+"/"+(datenew.getFullYear())));
  });


});

// setting the woman as background while making window.resize
window.onresize = function()
{
  if($("body.home").width() > 1173) $("body.home").css("background-position",($("body.home").width()/2+$("div.common").width()/2 - 41)+"px 520px");
  else $("body.home").css("background-position","-10000px -10000px");
}

