$(document).ready(
   function()
   {
   	 
   	 $("#main_menu li.main_menu_item").each(
   	 	function()
   	 	{
   	 		var dif = $("a", this).width() + 30;
   	 		$(this).css("width", dif);
   	 	}
   	 );
   	
     $(".content_menu_item_text").hover(
       function()
       {
         // var hover = "uploads/img/catalog/1/" + $("img", this).attr("alt");
         // var id = $("img", this).attr("longdesc");
         // var element = "#index_" + id;
         // var icon_hover = "uploads/img/catalog/1/" + $(element).attr("alt");
         // $("img", this).attr("src", hover);
         // $(element).attr("src", icon_hover);
		 
		 $('.normal', this).css('display', 'none');
		 $('.hover', this).css('display', '');
		
		 $("#content_menu tr:has(td img[src='"+$('img', this).attr('src')+"']) td:first .normal").css('display', 'none');
		 $("#content_menu tr:has(td img[src='"+$('img', this).attr('src')+"']) td:first .hover").css('display', '');
       },

       function()
       {
         // var real = "uploads/img/catalog/1/" + $("img", this).attr("title");
         // var id = $("img", this).attr("longdesc");
         // var element = "#index_" + id;
         // var icon_hover = "uploads/img/catalog/1/" + $(element).attr("title");
         // $("img", this).attr("src", real);
         // $(element).attr("src", icon_hover);
		 
		 $('.normal', this).css('display', '');
		 $('.hover', this).css('display', 'none');
		 
		 $("#content_menu tr:has(td img[src='"+$('img', this).attr('src')+"']) td:first .normal").css('display', '');
		 $("#content_menu tr:has(td img[src='"+$('img', this).attr('src')+"']) td:first .hover").css('display', 'none');
       }
     );

     if($("#flash_trigger").attr("value") == 1)
     {
       var randomnumber=Math.floor(Math.random()*11);
       var so = new SWFObject("flash/SACtitulinis.swf", "flash", "100%", "100%", "8");
       var lang = $("#lng").attr("value");
   	   so.useExpressInstall('flash/expressinstall.swf');
	 	   so.addVariable("xmlPath", "http://" + document.domain + "/flash/xml/blocks_"+lang+".xml?idd="+randomnumber);
	 	   so.addVariable("language", $("#lng").attr("value"));
	     so.write("flash");
	     $("#header").css("background", "url(images/header_bg_white.jpg) no-repeat");
     }
     else
     {
       $("#header").css("background", "url(images/header_bg.gif) no-repeat");
     }

     $('#offer_type_name').click(
       function ()
       {
         offer_item_clicked = false;
         $("#service_items").slideToggle("slow");
       }
     );

     $('#drop_arrow').click(
       function ()
       {
         offer_item_clicked = false;
         $("#service_items").slideToggle("fast");
       }
     );


     var offer_item_clicked = false;

     $("#service_items").hover(
      function()
      {

      },
      function()
      {
        if(offer_item_clicked == false)
        {
          $(this).slideToggle(1);
        }
      }
     );


     $('#service_items li').click(
       function ()
       {
         var tmp_id   = $("#offer_type_name_id").attr("value");
         var tmp_name =  $("#offer_type_name").attr("value");

         $("#offer_type_name_id").attr("value", $(this).attr("value"));
         $("#offer_type_name").attr("value", $(this).attr("title"));
         $(this).attr("value", tmp_id);
         $(this).attr("title", tmp_name);
         $("input", this).attr("value", tmp_name);
         $("#service_items").slideToggle(1);
         offer_item_clicked = true;
       }
     );

     //$('#lang_menu li ul').hide();
     //$('#lang_menu').droppy({speed: 100});

    
    if($("#content_right").height() > ($("#content").height() + $('#content_footer').height()))
    {
      
      var ieversion=0;
      if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
      {
        var ieversion=new Number(RegExp.$1);
      }
      var top = ( $("#content_right").height() - $('#content').height() - $('#content_footer').height() );
      if(ieversion == 6)
      {
        top = top - 5;
      }
      else if(ieversion == 7)
      {
        top = top - 11;
      }
      
      $('#content_footer').css('margin-top', top);
    }

   	 /*$("#main_menu li.main_menu_item.active_main_menu_item").addClass("active_main_menu_item_real");*/
     /*$("#main_menu li.main_menu_item").hover(
	       function()
	       {
           $("#main_menu li.main_menu_item.active_main_menu_item").css("background", "url(images/menu_sep.gif) right no-repeat");
           $("#main_menu li.main_menu_item.active_main_menu_item a.main_menu_item_text").css("font-weight", "normal");
	         $("#main_menu li.main_menu_item.active_main_menu_item").removeClass("active_main_menu_item");
	         $("#main_menu li.main_menu_item_current").removeClass("main_menu_item_current");
	         $(this).addClass("main_menu_item_current");
	         $("a.main_menu_item_text", this).css("font-weight", "bold");
	       },
	       function()
	       {
	         $("#main_menu li.main_menu_item_current a.main_menu_item_text").css("font-weight", "normal");
	         $("#main_menu li.main_menu_item.active_main_menu_item_real a.main_menu_item_text").css("font-weight", "bold");
	       	 $("#main_menu li.main_menu_item.active_main_menu_item_real").addClass("active_main_menu_item");
	       	 $("#main_menu li.main_menu_item.active_main_menu_item_real").css("background", "url(images/active_menu_bg.gif) repeat-x");

	       }
       );*/

    /* $("ul.sub_menu").hover(

	       function()
	       {
	         //$("#main_menu li.main_menu_item_current a.main_menu_item_text").css("font", "bold");
	       },
	       function()
	       {
	        // $(this).parent().css("background", "url(images/menu_sep.gif) right no-repeat");
	       	 //$(this).parent().removeClass("active_main_menu_item");
	       }
       );*/

       $("#offer_form_submit").hover(

	       function()
	       {
	         var img_name = "images/submit_button_hover_" + $("#lng").attr("value").toLowerCase() + ".gif";
	        
	         $(this).attr("src", img_name);
	       },
	       function()
	       {
	         var img_name = "images/submit_button_" + $("#lng").attr("value").toLowerCase() + ".gif";
	         $(this).attr("src", img_name);
	       }
       );



       $("#offer_form_submit").click(
        function()
        {
          $("#offer_form").submit();
        }
       );

   }
 );