$(document).ready(function() {
	$(".login li.b").hover(function() {$(this).addClass("hover");}, function() {$(this).removeClass("hover");});
	$(".details ul.tabs").tabs("div.panes > div", { effect: 'fade' });
	$(document).pngFix();
	/*
	$('ul.login').hover(function(){
         $('.sub').delay(5000).fadeOut('slow');
	});
	*/
	
	$("input#firmene-udaje").click(function() {
		this.blur();
		this.focus();
	});
	$('input#firmene-udaje').change(function() {
		if ($('input#firmene-udaje').attr('checked')==true) {
			$("div.firmene-udaje").slideDown("normal");
		} else {
			$("div.firmene-udaje").slideUp("normal");
		}
	});

	$("input#ina-adresa").click(function() {
		this.blur();
		this.focus();
	});
	$('input#ina-adresa').change(function() {
		if ($('input#ina-adresa').attr('checked')==true) {
			$("div.ina-adresa").slideDown("normal");
		} else {
			$("div.ina-adresa").slideUp("normal");
		}
	});
	
	$('#NakupMinus').change(function() {
  	//alert('Handler for .change() called.');
	  	if ($('#NakupMinus').val()=="2") {
	  		//alert('Handler for .change() called.');
	  		$('#NakupMinusInfo').css({ 'display': 'block'});
	  	} else $('#NakupMinusInfo').css({ 'display': 'none'});
	});
	
	
	/*
	$( "#datum_do" ).datepicker();
	
	$( "#datum_od" ).datepicker({
		showOn: "button",
		buttonImage: "images/calendar.gif",
		buttonImageOnly: true
	});
	*/
	$("input#ou1").click(function() {
		this.blur();
		this.focus();
	});
	$('input#ou1').change(function() {
		if ($(this).attr('checked')==true) {
			$(".cartLogin .toggle").show();
		} else {
			$(".cartLogin .toggle").hide();
		}
	});
	
	$('input#sd1').change(function() {
		if ($(this).attr('checked')==true) {
			$('input#sd5').attr('disabled',true);
			$('input#sd4').attr('disabled',false);
			
			$('input#sd4').attr('checked',true);
			$('input#sd5').attr('checked',false);
		}
	});
	
	$('input#sd2').change(function() {
		if ($(this).attr('checked')==true) {
			$('input#sd4').attr('disabled',true);
			$('input#sd5').attr('disabled',false);
			
			$('input#sd4').attr('checked',false);
			$('input#sd5').attr('checked',true);
		}
	});
	
      $("#myScroll").mbScrollable({
        width:750,
        elementsInPage:1,
        elementMargin:2,
        shadow:"#999 2px 2px 2px",
        height:"auto",
        controls:"#controls",
        slideTimer:600,
        autoscroll:true,
        scrollTimer:4000,
				changePageCallback:function(){
					var positiondisplay= $('#myScroll').get(0).idx+'/'+$('#myScroll').get(0).totalPages;
					$('#controls .positiondisplay').html(positiondisplay);
				},
				loadCallback:function(){
					var positiondisplay= $('#myScroll').get(0).idx+'/'+$('#myScroll').get(0).totalPages;
					$('#controls .positiondisplay').html(positiondisplay);
				}
      });

      //setTimeout(function(){$("#bannery").fadeIn();},500);
	
});

function checkInputs(handler) {
	var fromOpacity = "0.6";
	var toOpacity = "1";
	var fromColor = $(handler).css('color');
	var toColor = "#000000";
	var animateTime = 100;
	var message = "";

	$(handler).css({ opacity: fromOpacity }, animateTime);
	$(handler).bind('click focus', function() {
		message = ($(this).attr("title"));
		$(this).css({fontStyle:"normal"});
		$(this).animate({opacity:toOpacity}, animateTime);
		$(this).animate({color:toColor}, animateTime);

		if ( $(this).val() == message ) {$(this).val('');}
	});
	$(handler).blur(function() {
		if ( $(this).val() =="" ) {$(this).val(message);}
		if ( $(this).val() == message ) {
			$(this).css({fontStyle:"italic"});
			$(this).animate({ opacity: fromOpacity }, animateTime);
			$(this).animate({color:fromColor}, animateTime);
		}
	});
}

function valideForm(handler) {
	jQuery.validator.addMethod("defaultInvalid", function(value, element) {
		return value != element.defaultValue;
	}, "");

	jQuery.validator.messages.required = "";
	$(handler).validate({
		invalidHandler: function(e, validator) {
		},
		onkeyup: false,
		submitHandler: function() {
			form.submit();
		}
	});
}
