
// BEKREFT BESTILLING
jQuery(document).ready(function() {
    //$("#payexBekreft").attr("disabled","disabled");
    $("#bekreftinfo").click(function(){
    	if(!$(".kjopsbetingelser").attr("checked")){
    		alert('Du må akseptere kjøpsbetingelser for å gå videre.');
    		$(".kjopsbetingelser").addClass('error');
    		return false;
    	}
    	
    	return true;
    });
    
    $(".kjopsbetingelser").change(function() {
        if($(".kjopsbetingelser").attr("checked")) {
            $(".kjopsbetingelser").removeClass("error");
        }
    });
    //$("#payexBekreft").addClass("inaktiv");
    
    /*$(".kjopsbetingelser").change(function() {
        if($(".kjopsbetingelser").attr("checked")) {
            $("#payexBekreft").removeAttr("disabled");
            //$("#payexBekreft").removeClass("inaktiv");
        } else {
            $("#payexBekreft").attr("disabled","disabled");
            //$("#payexBekreft").addClass("inaktiv");
        }
    });*/
});


// SLIDESHOW
$('.slide')
.cycle({
    fx:     'fade',
    speed:   2000,
    timeout: 6000,
    pause:  '1'
});

// SLIDESHOW
$('.slide2')
.cycle({
    fx:     'fade',
    speed:   300,
    timeout: 4000,
    pause:  '1'
});

// SLIDESHOW
$('.slide3')
.cycle({
    fx:     'fade',
    speed:   300,
    timeout: 4000,
    pause:  '1'
});

$(document).ready(function() {
	$(".fancybox").fancybox();
});


// HOVER
$(document).ready(function(){
       $(".prodDynamisk").hover(
           function() { $('.rollover', this).fadeIn('fast'); },
           function() { $('.rollover', this).fadeOut('fast'); });
});



// SEARCH FIELD VALUE SWAP
$(function() {
    swapValues = [];
    $(".swap_value").each(function(i){
        swapValues[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == swapValues[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(swapValues[i]);
            }
        });
    });
});


function toggleTekstKnapp(tekstKnappStatus) {
	if (tekstKnappStatus) {
		$("a.trigger").text("Skjul handlekurv");
	} else {
		$("a.trigger").text("Vis handlekurv");
	}
}

$(document).ready(function(){

	$(".toggle_container").hide();

	$("a.trigger").toggle(function(){
		$(this).addClass("active"); 
		toggleTekstKnapp(1);
		}, function () {
		$(this).removeClass("active");
		toggleTekstKnapp(0);
	});
	
	$("a.trigger").click(function(){
		$(this).next(".toggle_container").slideToggle("slow,");
	});
	
	// $(".inputsubmit").click(function(){
	// 	$("a.trigger").next(".toggle_container").slideToggle("slow,");
	// });
});

jQuery().ready(function(){
	// highly customized accordion
	jQuery('#navigation1').accordion({
		active: ".selected",
		event: 'click',
		animated: "slide",
		header: ".head"
	}).bind("change.ui-accordion", function(event, ui) {
		jQuery('<div>' + ui.oldHeader.text() + ' hidden, ' + ui.newHeader.text() + ' shown</div>').appendTo('#log');
	});
	
	
});






















    function formatText(index, panel) {
	  return index + "";
    }

    $(function () {
    
        $('.anythingSlider').anythingSlider({
            easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
            autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
            delay: 3000,                    // How long between slide transitions in AutoPlay mode
            startStopped: false,            // If autoPlay is on, this can force it to start stopped
            animationTime: 300,             // How long the slide transition takes
            hashTags: true,                 // Should links change the hashtag in the URL?
            buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
    		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
    		startText: "Go",             // Start text
	        stopText: "Stop",               // Stop text
	        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
        });
        
        $("#slide-jump").click(function(){
            $('.anythingSlider').anythingSlider(7);
        });
    });
    var checkFields = {'epost':{'function':'isNotEmpty'}, 'navn' : {'function':'isNotEmpty'}, 'telefonnummer' : {'function':'isNotEmpty'}, 'vilkaar' : {'function' : 'isChecked'}};

    function controlFields(elem)
    {
    	return true;
    }



jQuery().ready(function(){
	// PRODUKTDETALJ
    $(".inputsubmit").click(function() {
        if ($('select.inputstr option:selected').val() == '') {
            $(".inputstr").css("background", "#c90000");
            return false; 
        } else { 
            return true;
        }
    });
    // ANTREKK
    $(".inpTbhSubmit").click(function() {
        //if ($('select.inputstr option:selected').val() == '') {
        if ($(this).parent().parent().find('select.inputstr option:selected').val() == '') {
            //$(".inputstr").css("background", "#c90000");
            $(this).parent().parent().find(".inputstr").css("background", "#c90000");
            return false; 
        } else { 
            return true;
        }
    });
});

jQuery().ready(function(){
    $(".inputsubmit").click(function() {
        if ($('input.inputantall').val() == '') {
            $(".inputantall").css("background", "#c90000");
            return false; 
        } else { 
            return true;
        }
    });
});

jQuery().ready(function(){
    $(".inputsubmit").click(function() {
        if ($('input.inputantall').val() == '0') {
            $(".inputantall").css("background", "#c90000");
            return false; 
        } else { 
            return true;
        }
    });
});


jQuery().ready(function(){
    $(".inputstr").click(function() {
            $(".inputstr").css("background", "#2f2f2c");
            return false; 
    });
});

jQuery().ready(function(){
    $(".inputantall").click(function() {
            $(".inputantall").css("background", "#2f2f2c");
            return false; 
    });
});
