// Fra Master page >>>>>>>>>>>

//Fancybox
$(function() {
  setupCarousel('.carousel');
  setupCarousel('.carousel7', 7);
  fancyboxInit(); // STH: 2011-11-02 Tilføjet fra .NO
});


 // STH: 2011-11-02 Tilføjet fra .NO
// Fancybox ----------------
function fancyboxInit() {
	$(".showproduct").fancybox({
		'width': '100%',
		'height': '100%',
		'autoScale': 'false',
		'transitionIn': 'none',
		'transitionOut': 'none',
		'type': 'iframe',
		'overlayColor': '#fff',
		'padding': '5',
		'margin': '0',	
		'scrolling': 'no',	
		'overlayOpacity': 0.5
  });
}

	

function showhideBg(i, action){
  if (action=="hide") {
        document.getElementById(i).style.display = "none";
   } else {
        document.getElementById(i).style.display = "block";
   }       
}

function setupCarousel(sSelector, visible) {
    var properties = {
        btnNext: ".next",
        btnPrev: ".prev"        
    };
    (typeof visible!='undefined') ? properties.visible = visible : '';
    
    $(sSelector).jCarouselLite(properties);
};




// --- Fra master page


jQuery(function() {
  fixNewsV2Links();
})


function fixNewsV2Links() {
  replaceValueInAttributesUsingSelector('a', ['href', 'onclick'], '&M=NewsV2', '');
  replaceValueInAttributesUsingSelector('div', ['href', 'onclick'], '&M=NewsV2', '');
}

// replaceValueInAttributesUsingSelector('a', ['href', 'onclick'], '&M=NewsV2', '')
function replaceValueInAttributesUsingSelector(sSelector, aAttributes, sSearchFor, sReplace) {
  for(var i=0; i<aAttributes.length; i++) {
    var $found = $(sSelector+'['+aAttributes[i]+'*="'+sSearchFor+'"]');
    // alert(sSelector+'['+aAttributes[i]+'*="'+sSearchFor+'"]'+' => '+$found.length)
    $found.each(function() {
        var $this = $(this);
        try {
          $this.attr(aAttributes[i], $this.attr(aAttributes[i]).replace(sSearchFor, sReplace))
        } catch(e) {
         // alert(e.message);
        }
    });
  };
}


// Default.aspx?ID=590&Action=1&NewsId=1&M=NewsV2&PID=2704
function gotoURL(sURL) {
  location.href = sURL.replace('&M=NewsV2', '');
}
