﻿// JavaScript Document

// TAB MENU
var TabGraphicStart = "<div class=\"TabGraphicStart\"><img src\"/files/nothing.gif\" width=\"1\" height=\"1\" /></div>";
var TabGraphicEnd = "<div class=\"TabGraphicEnd\"><img src\"/files/nothing.gif\" width=\"1\" height=\"1\" /></div>";
var SelectedTabContent = null;
var SelectedTab = null;
var AnyTabs = false;

function InitTabMenu() {
  var TabIdNum = 0;
  var TabElm = document.getElementById('TabMenuContentPlaceHolder').getElementsByTagName('div');
  for(elm=0;elm<TabElm.length;elm++) {
    if((TabElm[elm].className=="TabMenu")&&(TabIdNum==0)) {
      eval("Tab"+TabIdNum+" = new Tab(TabElm[elm],TabElm[elm].id,'Tab"+TabIdNum+"')");
      document.getElementById('TabMenuPlaceHolder').innerHTML += eval("Tab"+TabIdNum+".initTabOn");
      TabIdNum++;
      AnyTabs = true;
    }
    else if(TabElm[elm].className=="TabMenu") {
      eval("Tab"+TabIdNum+" = new Tab(TabElm[elm],TabElm[elm].id,'Tab"+TabIdNum+"')");
      document.getElementById('TabMenuPlaceHolder').innerHTML += eval("Tab"+TabIdNum+".initTabOff");
      TabIdNum++;
    }
  }
  if(!AnyTabs) {
    document.getElementById('TabMenuPlaceHolder').style.display = "none";
  }
  else {
    Tab0.id.style.display = "block";
    SelectedTabContent = Tab0.id;
    SelectedTab = Tab0.tabid;
  }
}

function Tab(id,name,tabid) {
  this.name=name;
  this.id=id;
  this.tabid=tabid;
  this.initTabOn="<div id=\""+tabid+"\" class=\"TabSelected\" onclick=\"ShowTab('"+name+"',this)\">"+TabGraphicStart + "<a href=\"Javascript:void(0);\">" + name + "</a>" + TabGraphicEnd +"</div>";
  this.initTabOff="<div id=\""+tabid+"\" class=\"TabNotSelected\" onclick=\"ShowTab('"+name+"',this)\"><a href=\"Javascript:void(0);\">" + name + "</a></div>";
  this.TabOn=TabGraphicStart + "<a href=\"Javascript:void(0);\">" + name + "</a>" + TabGraphicEnd;
  this.TabOff="<a href=\"Javascript:void(0);\">" + name + "</a>";
}

function ShowTab(TabContent,TabObj) {
  SelectedTabContent.style.display = "none";
  document.getElementById(TabContent).style.display = "block";
  SelectedTabContent = document.getElementById(TabContent);

  eval("document.getElementById(SelectedTab).innerHTML="+SelectedTab+".TabOff");
  document.getElementById(SelectedTab).className="TabNotSelected";

  eval("TabObj.innerHTML="+TabObj.id+".TabOn");
  TabObj.className="TabSelected";
  SelectedTab=TabObj.id;
}

// LAUNCH/CLOSE OVERLAY GALLERY
function imageNumber(imageID, galleryID) {
  document.getElementById('NZGalleryHolder').style.display = "block";
  document.getElementById('TransparentPopup').style.display = "block";
  var flashvars = 
    {
      nzURL: "http://morsoe.net.dynamicweb.dk/Default.aspx?ID=72",
      nzImageFolder: "http://morsoe.net.dynamicweb.dk/Files/Filer/NZGallery/data/",
      category: galleryID,
      imageID: imageID
    };
    
    var params = 
    {
      scale: "noScale",
      wmode: "transparent"
    };
    swfobject.embedSWF("/Files/System/Morsoe/Flash/ProductSlider/NZGallery.swf", "MorsoeGallery", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params);
};

/*2011 open nz galleri*/
function openGallery(galleryID) {
  document.getElementById('NZGalleryHolder').style.display = "block";
  document.getElementById('TransparentPopup').style.display = "block";
  var flashvars = 
    {
      nzURL: "http://morsoe.net.dynamicweb.dk/Default.aspx?ID=72",
      nzImageFolder: "http://morsoe.net.dynamicweb.dk/Files/Filer/NZGallery/data/",
      category: galleryID
    };
    
    var params = 
    {
      scale: "noScale",
      wmode: "transparent"
    };
    swfobject.embedSWF("/Files/System/Morsoe/Flash/ProductSlider/NZGallery.swf", "MorsoeGallery", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params);
};


function closeWindow(){
  document.getElementById('NZGalleryHolder').style.display = "none";
  document.getElementById('TransparentPopup').style.display = "none";
}

// SKORSTENSBEREGNER
function newGr3WinPopUp(strWidth, strHeight, strUrl, strMenubar, strToolbar, strStatusbar, strLocation, strDirectories, strScrollbar, strResizable, strXPos, strYPos) {
  if (!strXPos) strXPos = (document.body.clientWidth-strWidth) >> 1;
  if (!strYPos) strYPos = (document.body.clientHeight-strHeight) >> 1;
  window.open(strUrl, "", "width="+strWidth+", height="+strHeight+", left="+strXPos+", top="+strYPos+",menubar="+strMenubar+", location="+strLocation+", toolbar="+strToolbar+", directories="+strDirectories+", status="+strStatusbar+", scrollbars="+strScrollbar+", resizable="+strResizable+"");
}

// FLAMEGIMMICK
  //// LAUNCH
  function AddIcon() {
    document.getElementById('AddFire').style.display='inline';
  }
  function AddFire() {
    $("#AddFireHolder").css("height","350px");
    //$("#AddFireGimmick").css("height","300px");
  }
  //// REMOVE
  function REMOVEFLASH() {
    $("#AddFireHolder").css("height","0px");
    //$("#AddFireGimmick").css("height","0px");
  }
  
  
$(document).ready(function () {  

$('.replaceInput').each(function(){
  var thisVal = $(this).attr('value');              
  $(this).focus(function(){
    if($(this).attr('value')==thisVal){
      $(this).attr('value','');
    }
  }).blur(function(){
    if($(this).attr('value')==''){
      $(this).attr('value',thisVal);
    }
  });                      
  
        
});

/*LIVE SEARCH DK
$('#liveSearchInput').keyup(function(){
  $('.dealerListTable').removeHighlight();
  var searchField = $(this);
  var searchInput = searchField.attr('value').toLowerCase();
  
  if(searchInput==''){
    $('.dealerInfoAddress').parent().show();  
  }
  else{//console.log(searchInput);
    $('.dealerInfoAddress').parent().hide();
    $('.dealerInfoAddress:contains('+searchInput+')').highlight(searchInput).parent().show();
    //console.log($('.dealerInfo:contains('+searchInput+')'));
    $('#output').text(searchInput);
  }
});  */


/*LIVE SEARCH 2*/
$('#liveSearchInput').keyup(function(){
  
  $('.dealerListTable').removeHighlight();
  var searchField = $(this);
  var searchInput = searchField.attr('value').toLowerCase();
  
  if(searchInput==''){
    $('.dealerInfoAddress').parent().show();  
  }
  else{
		$('.dealerInfoAddress').parent().hide();
    	$('.dealerZipCity:contains('+searchInput+')').highlight(searchInput).parent().parent().show();	
    	$('#output').text(searchInput);
  }
  
}); 



});  /* Closing document.ready function */
  
/*CUFON font replacement here*/
Cufon.replace('h1, div.oneFourthTeaser h2, div.oneHalfTeaserLeft h2, div.oneHalfTeaserRight h2, #SitemapLetter h2, #LeftMenu h3, .Product .ProductDescription h3, .ProductWide .ProductDescription h3, #RightColumn .Related h4, .h4, #RightColumn .Teaser h4,#RightColumn .Miljoe h5, .HomeContentBoxGreen h2, .HomeContentBox h2, #ProductGroups .Group h3', { 
  fontFamily: 'DinProRegular' 
}); // Det var mange. Fjernede alle med h1 - de burde nedarve. ~ nis

Cufon.replace('#MainMenu div, #XtranetMainMenu div, #ProductGroups .Group h3, #XtranetLeftMenu h3', { 
  fontFamily: 'DinProRegular',
  hover: true 
});

Cufon.replace('.btnStoreLocator', { 
  fontFamily: 'DinProRegular',
  hover: true 
});

/*Cufon.replace('.HomeContentBox h1, .HomeContentBoxGreen h1, #ProductGroups .Group h3, #HomeContent .FloatNone h1 ', { 
  fontFamily: 'DinProRegular',
  hover: true 
});
*/



  
