$(function(){
  $('#topImgBox').addClass('ui-corner-bottom');
  //$('#blk_newsletter').width(parseInt($('#blk_newsletter').width()-10)).corner('5px').parent().corner('5px').css('background-color','#F00').css('padding','5px');

  roundDiv($('#blk_search'),6);
  roundDiv($('#blk_show'),6);
  roundDiv($('#blk_newsletter'),6);
  roundDiv($('.blk_min_style1'),6);
  roundDiv($('.blk_min_style2'),6);
  $('#odstep_dol div').css('background-color',$('body').css('background-color')).height(10).corner('bottom 6px');
  $('#banner_content').corner('round 6px');

  roundDiv($('.blk_icons'),6);
  $('#search_orderby').change(function(){
    $('#ff_form_changeOrderBy').submit();
  });
  $('input:checkbox[name*=showElm]','#blk_show_content').each(function(i,e){
    $(e).click(function(){
      var elmsVal = '';
      $('input:checkbox[name*=showElm]','#blk_show_content').each(function(ii,elm){
        if($(elm).attr('checked')) elmsVal +='1';
        else elmsVal +='0';
      });
      $('input:hidden','#blk_show_content').val(elmsVal);
    })
  });
  roundDiv($('.blk_style1'),6);
  //roundDiv($('tr:first td div','.reservation_blk_top'),6);
  roundDiv($('.reservation_blk_off','.reservation_blk_top'),6);
  roundDiv($('.reservation_blk_on','.reservation_blk_top'),6);

  if($('#openRegulaminDialog').length > 0){
    $("#regulaminDialog").dialog({
			autoOpen: false,
      width: 900,
      height: 500,
      minHeight: 400,
      maxHeight: 700,
      minWeight: 500,
      maxWeight: 900,
      position: ['center',10],
			show: 'fold',
			hide: "clip"
		});
    $( "#regulaminDialog" ).dialog({ maxHeight: 400 });
    $.fx.speeds._default = 1000;
		$("#openRegulaminDialog").click(function(){
			$("#regulaminDialog").dialog("open");
			return false;
		});
  }
  
  //$('.blk_icons').css('float','none').css('display','inline');

  //$('#blk_newsletter').css('text-align','center').wrapInner('<div style="padding:5px;border:solid#F00 1px;width:'+($('#blk_newsletter').width()-2)+'px"></div>');

  //$('#blk_search').corner('5px');
  //$('#blk_newsletter').corner('10px').parent().css('padding','1px').corner("10px");
  /*
  $('.btnStyle1 a,.btnStyle3 a').hover(
    function() {$(this).addClass('ui-state-hover');},
    function() {$(this).removeClass('ui-state-hover');}
  );

  $("button").button();

  $(".btnStyle2 a").hover(
    function() {$(this).removeClass('ui-state-active');$(this).addClass('ui-state-hover');},
    function() {$(this).removeClass('ui-state-hover');$(this).addClass('ui-state-active');}
  );


  $('.menuLeft li').hover(
    function() {$(this).addClass('ui-state-hover');},
    function() {$(this).removeClass('ui-state-hover');}
  );
*/

});

function roundDiv(e,cSize,borderControl){
	if($(e).length > 0){

    var borderColour = $(e).css('border-left-color');
    var cornerSize = parseInt(cSize);
    var border_left = $(e).css('border-left-width');
    var border_top = $(e).css('border-top-width');
    var border_right = $(e).css('border-right-width');
    var border_bottom = $(e).css('border-bottom-width');
    if(isNaN(cornerSize) || cornerSize < 4) cornerSize = 4;
    $(e).each(function(i,elm){
      if(borderControl == true) $(elm).width(parseInt($(elm).width()-parseInt(border_left)-parseInt(border_right))).height(parseInt($(elm).height()-parseInt(border_top)-parseInt(border_bottom)))
      $(elm)//.width(parseInt($(elm).width()-parseInt(border_left)-parseInt(border_right)))
        //.height(parseInt($(elm).height()-parseInt(border_top)-parseInt(border_bottom)))
        .parent()
          .css('background-color',borderColour)
          .css('padding',''+$(elm).css('border-left-width')+' '+$(elm).css('border-top-width')+' '+$(elm).css('border-right-width')+' '+$(elm).css('border-bottom-width')+'')
          .corner('round '+parseInt(cornerSize)+'px');//*/
      $(elm).css('border-width','0').corner('round '+parseInt(cornerSize)+'px');
    });
  }
}

