﻿jQuery(document).ready(function () {

  jQuery(".DatePickerTextBox").datepicker({ monthNames: ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'], dayNamesMin: ['Sø', 'Ma', 'Ti', 'On', 'To', 'Fr', 'Lø'], dateFormat: 'dd-mm-yy', showOtherMonths: true, duration: 'fast', firstDay: 1 });
  jQuery(".DatePickerCalendarTextBox").datepicker({ showOn: "button", buttonImage: "/images/calendar2.gif", buttonImageOnly: true, monthNames: ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'], dayNamesMin: ['Sø', 'Ma', 'Ti', 'On', 'To', 'Fr', 'Lø'], dateFormat: 'dd-mm-yy', showOtherMonths: true, duration: 'fast', firstDay: 1, constrainInput: false });
  jQuery(".DatePickerYearTextBox").datepicker({ yearRange: "-100:+0", changeMonth: true, changeYear: true, monthNames: ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'], dayNamesMin: ['Sø', 'Ma', 'Ti', 'On', 'To', 'Fr', 'Lø'], dateFormat: 'dd-mm-yy', showOtherMonths: true, duration: 'fast', firstDay: 1 });
  jQuery(".DatePickerYearCalendarTextBox").datepicker({ showOn: "button", buttonImage: "/images/calendar2.gif", buttonImageOnly: true, yearRange: "-100:+0", changeMonth: true, changeYear: true, monthNames: ['Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December'], dayNamesMin: ['Sø', 'Ma', 'Ti', 'On', 'To', 'Fr', 'Lø'], dateFormat: 'dd-mm-yy', showOtherMonths: true, duration: 'fast', firstDay: 1, constrainInput: false });
  jQuery(".DateWatermark").watermark('dd-mm-yyyy');
  jQuery(".MaskedDate").mask('99-99-9999');

  jQuery("#ctl00_imgInfo1 img").hover(
      function () {
        jQuery("#ctl00_imgInfo1 #infoDetailsPopup1").addClass('overMe');
        jQuery(this).css({ cursor: 'help' });
      },
      function () {
        jQuery("#ctl00_imgInfo1 #infoDetailsPopup1").removeClass('overMe');
        jQuery(this).css({ cursor: 'pointer' });
      }
    );
  jQuery("#ctl00_imgInfo2 img").hover(
      function () {
        jQuery("#ctl00_imgInfo2 #infoDetailsPopup2").addClass('overMe');
        jQuery(this).css({ cursor: 'help' });
      },
      function () {
        jQuery("#ctl00_imgInfo2 #infoDetailsPopup2").removeClass('overMe');
        jQuery(this).css({ cursor: 'pointer' });
      }
    );


  jQuery("input.txPostNrF").blur(
	function () {
	  var zip = jQuery("input.txPostNrF");
	  var value = "";
	  if (zip.length > 0) {
	    value = zip.val();
	    if (value.length > 3) {
	      jQuery("#cityF").load("?feed=rss&action=setvalue&value=" + value);

	    }
	  }
	}
	);



  /* SOME FIXES */
  jQuery(".button-right-big-corner, .linck-box li, .linck-box li span ").hover(function () {
    jQuery(this).addClass("hover");
  }, function () {
    jQuery(this).removeClass("hover");
  })

  jQuery(".linck-box").prev(".min-text-box").css("margin", "-1px 0 0 0").prev(".hor-line").remove();


  jQuery("#greenBoxRadio > table > tbody > tr > td > span > input").click(function () {
    if (jQuery(this).attr("checked")) {
      jQuery("#greenBoxPic").children("span").children("span").css("display", "none");

      var el = jQuery(this).parent().attr("id").replace("ch", "#pic");
      jQuery(el).css("display", "block");
    }
  }
    );


  //for roskildeFormular

  jQuery("div.roskildeHidenBoxes").css("display", "none");

  jQuery('select.roskildeSelect').change(
		  function () {
		    var value = jQuery(this).val();
		    var thisSelect = jQuery("div.roskildeHidenBoxes");
		    if (value == "Anden") {
		      thisSelect.css("display", "inline");
		    } else {
		      thisSelect.css("display", "none");
		    }
		  });

  jQuery('input.roskildeSend').click(
		  function () {
		    var cond = true;
		    if (jQuery("div.roskildeHidenBoxes").css("display") != "none") {
		      if ((jQuery("#ctl00_TextBoxLeverandor").val() == "") || (jQuery("#ctl00_TextBoxLeverandor").val() == " ")) {
		        jQuery("#ctl00_rfLeverandor").css("display", "inline");
		        cond = false;
		      }
		      if ((jQuery("#ctl00_TextBoxAftalen").val() == "") || (jQuery("#ctl00_TextBoxAftalen").val() == " ")) {
		        jQuery("#ctl00_rfAftalen").css("display", "inline");
		        cond = false;
		      }
		      if (jQuery("#ctl00_CheckBoxMedminbestilling").attr("checked") == false) {
		        jQuery("#ctl00_rfMed").css("display", "inline");
		        cond = false;
		      }
		    }
		    if (cond == true) {
		      jQuery("#ctl00_rfLeverandor").css("display", "none");
		      jQuery("#ctl00_rfAftalen").css("display", "none");
		      jQuery("#ctl00_rfMed").css("display", "none");
		    }

		    return cond;

		  });

  function prepareContent() {
    loginswitch('.register', '.login');
    loginswitch('.login', '.register');
  }

  jQuery('a.modal-register').click(function () {
    loginswitch('.register', '.login');
    return false;
  });

  jQuery('#modal_close').click(function () {
    jQuery('#modal_outer').toggle();
  });


  jQuery.fn.fixPNG = function () {
    return this.each(function () {
      var image = jQuery(this).css('backgroundImage');

      if (image.match(/^url\(["']?(.*\.png)["']?\)jQuery/i)) {
        image = RegExp.jQuery1;
        jQuery(this).css({
          'backgroundImage': 'none',
          'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=" + (jQuery(this).css('backgroundRepeat') == 'no-repeat' ? 'crop' : 'scale') + ", src='" + image + "')"
        }).each(function () {
          var position = jQuery(this).css('position');
          if (position != 'absolute' && position != 'relative')
            jQuery(this).css('position', 'relative');
        });
      }
    });
  };

  jQuery('a.login-w').click(function () {
    if (jQuery.browser.msie) {
      jQuery(".modal_bg").fixPNG();
      jQuery("#modal_close").fixPNG();
    }

    prepareContent();
    jQuery('#modal_outer').toggle();
  });
});

function loginswitch(showing, hiding) {
	jQuery(showing).css({'display' : 'block'})
	jQuery(hiding).css({'display' : 'none'})
}

/*)  Do not remove this, as web forms for marketers will stop working correctly - Jimmi */
