$.noConflict();

var focusFlag = 1;

jQuery(document).ready(function() {


    jQuery(window).bind("focus",function(event){
        focusFlag = 1;
    }).bind("blur", function(event){
        focusFlag = 0;
	   });

	jQuery(".colorbox_video").colorbox({iframe:true, innerWidth:800, innerHeight:600});	

	
	jQuery("#close").click(function () {
		jQuery(".chatpopup").slideToggle("slow");
	});
	
	  
	
	jQuery(".tilbudsbox").hover(function () {
		jQuery(this).find(".text").slideToggle("fast");	

  	});
	
	
	 
	
    //vars
    //forside top
    forsidetop_count =  jQuery(".forsidetop_item").size();

      //navknapper
      
      //navknapper
      ii=0;
      var navcontent ='<ul class="navitems">';
      while (ii < forsidetop_count) {

        if (ii == 0) {
          var isAktiv = "active";
        } else {
          var isAktiv = "";
        }

        var navcontent = navcontent + '<li class="'+isAktiv+'"><a href="javascript:void(0);" rel="'+ii+'" style="display: block;"></a></li>';
        ii++;

      }
	  
      var navcontent = navcontent + "</ul>";

      jQuery("#forsidetop_nav").html(navcontent);

		Number.prototype.formatMoney = function(c, d, t){
		var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
		   return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "jQuery1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
		 };
		 
		

	//vis skjultepriser pr hotel
	jQuery(".showoverflow").click(function() {

		if (jQuery(this).hasClass('active')) {

			jQuery("tr.overflow").hide();
			jQuery(this).html('+ Vis flere muligheder').removeClass('active');

		} else {


			jQuery("tr.overflow").hide();

			var hotelid = jQuery(this).attr('rel');
			jQuery("#priser-hotelid-"+hotelid+" tr.overflow").show('fast');
			jQuery(this).html('Skjul extra valgmuligheder').addClass('active');
		}

	});

	jQuery(".startAgain").click(function() {
		window.location.href="/bestillingny/";
		return false;
	});

	
	jQuery(".tilvalg").change(function() {
		
		var antalforsik = jQuery(".tilvalg.forsikring:checked").length;
		var antalskileje = jQuery(".tilvalg.skileje:checked").length;
	
		var grundpris = jQuery('input[name="calcpris"]').val();
	
		antalforsik = parseInt(antalforsik);
		antalskileje = parseInt(antalskileje);

		grundpris = parseInt(grundpris);
		
		var totalforsik = antalforsik * 200;
		var totalskileje = antalskileje * 200;

		var nypris = grundpris + totalforsik + totalskileje;
		var nypris = (nypris).formatMoney(0, ',', '.');
		
		jQuery("#calcpris").html(nypris);
		
	});
	
	 jQuery(".chatpopup").oneTime(90000, "chatpopup", function () {
	  	
		
		jQuery.ajax({
		   type: "GET",
		   url: "http://www.onlineski.dk/chatpopup_ajax.php",
		   cache: false,
		   success: function(data){
			   if(data.indexOf('SLIDE')>-1){
				 jQuery(".chatpopup").slideToggle("slow");
			   }
		   }
		});
	
	  });

});
