﻿// jQuery No Conflict
var $jq = jQuery.noConflict();

// function for form validation required by DW
function validateEmail( email ){
var regExp = /^[\w\-_]+(\.[\w\-_]+)*@[\w\-_]+(\.[\w\-_]+)*\.[a-z]{2,4}$/i;
return regExp.test( email );
} 

// Newsletter Translations
// Element 0 is areaId
// Odd element thereafter (1 3 5 and so forth), are names of fields to be replaced. 
// Even elements thereafter (2 4 6 and so forth), are the localized field names
arrSubscriptionFields = new Array();
arrSubscriptionFields.push(new Array(1,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit','Submit'));                  // UK
arrSubscriptionFields.push(new Array(261,'eName','Ad','eEmail','Email','eZip','Posta Kodu','Ok','Kaydol','Submit','Submit'));                  // TR
arrSubscriptionFields.push(new Array(105,'eName','Имя','eEmail','Email','eZip','Индекс','Ok','Подписаться','Submit','Submit'));                // RU
arrSubscriptionFields.push(new Array(249,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit','Submit'));                // IN
arrSubscriptionFields.push(new Array(169,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit','Submit'));                // PH
arrSubscriptionFields.push(new Array(99,'eName','お名前','eEmail','Email','eZip','郵便番号','Ok','サインアップ','Submit','Submit'));                // JP
arrSubscriptionFields.push(new Array(92,'eName','Navn','eEmail','E-mail','eZip','Postnr.','Ok','Tilmeld','Submit','TILMELD'));                  // DK
arrSubscriptionFields.push(new Array(254,'eName','Navn','eEmail','E-post','eZip','Postnummer','Ok','Påmelding','Submit', 'Submit'));          // NO
arrSubscriptionFields.push(new Array(188,'eName','Nimi','eEmail','Sähköposti','eZip','Postinumero','Ok','Liity','Submit', 'Submit'));          // SF
arrSubscriptionFields.push(new Array(95,'eName','Nom','eEmail','E-mail','eZip','Code postal','Ok',"S'inscrire",'Submit', "S'inscrire"));            // FR
arrSubscriptionFields.push(new Array(222,'eName','Nom','eEmail','E-mail','eZip','Code postal','Ok',"S'inscrire",'Submit', 'Submit'));          // BE (FR)
arrSubscriptionFields.push(new Array(176,'eName','Nom','eEmail','E-mail','eZip','Code postal','Ok',"S'inscrire",'Submit', 'Submit'));          // LU (FR)
arrSubscriptionFields.push(new Array(96,'eName','Name','eEmail','E-Mail','eZip','PLZ','Losnummer','Losnummer','Ok','Anmelden','Submit', 'Anmelden'));                    // DE
arrSubscriptionFields.push(new Array(235,'eName','Name','eEmail','E-Mail','eZip','PLZ','Ok','Anmelden','Submit', 'Anmelden'));                    // CH
arrSubscriptionFields.push(new Array(248,'eName','Όνοματεπώνυμο','eEmail','Email','eZip','Ταχυδρομικός κώδικας','Ok','Εγγραφή','Submit', 'Submit'));            // GR
arrSubscriptionFields.push(new Array(98,'eName','Név','eEmail','Email','eZip','Irányítószám','Ok','Feliratkozás','Submit', 'Submit'));          // HU
arrSubscriptionFields.push(new Array(130,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // IE
arrSubscriptionFields.push(new Array(101,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // MT
arrSubscriptionFields.push(new Array(102,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // NZ
arrSubscriptionFields.push(new Array(109,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // UK
arrSubscriptionFields.push(new Array(168,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // UAE
arrSubscriptionFields.push(new Array(110,'eName','Name','eEmail','Email','eZip','Zip code','Ok','Sign up','Submit', 'Sign up'));                // US
arrSubscriptionFields.push(new Array(220,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Sign up'));                // CA
arrSubscriptionFields.push(new Array(108,'eName','Naam','eEmail','Email','eZip','Postcode','Ok','Schrijf in','Submit', 'Submit'));              // NL
arrSubscriptionFields.push(new Array(228,'eName','Naam','eEmail','Email','eZip','Postcode','Ok','Schrijf in','Submit', 'Submit'));              // BE (NL)
arrSubscriptionFields.push(new Array(103,'eName','Imię i nazwisko','eEmail','Mail','eZip','Kod pocztowy','Ok','Wyślij','Submit', 'Submit'));    // PL
arrSubscriptionFields.push(new Array(104,'eName','Nome','eEmail','E-mail','eZip','Código Postal','Ok','Subscrever','Submit', 'Submit'));        // PT
arrSubscriptionFields.push(new Array(215,'eName','Nume','eEmail','Adresa de e-mail','eZip','Cod poştal','Ok','Înscrieţi-vă','Submit', 'Submit'));    // RO
arrSubscriptionFields.push(new Array(106,'eName','Nombre','eEmail','Email','eZip','Código Postal','Ok','Inscribirse','Submit', 'Inscribirse'));      // ES
arrSubscriptionFields.push(new Array(241,'eName','Nombre','eEmail','Email','eZip','Código Postal','Ok','Inscribirse','Submit', 'Inscribirse'));      // MX
arrSubscriptionFields.push(new Array(204,'eName','Nombre','eEmail','Email','eZip','Código Postal','Ok','Inscribirse','Submit', 'Inscribirse'));      // VE
arrSubscriptionFields.push(new Array(212,'eName','Nombre','eEmail','Email','eZip','Código Postal','Ok','Inscribirse','Submit', 'Inscribirse'));      // CO
arrSubscriptionFields.push(new Array(107,'eName','Namn','eEmail','E-post','eZip','Postnr.','Ok','Anmäl dig','Submit', 'Anmäl dig'));              // SE
arrSubscriptionFields.push(new Array(207,'eName','Име','eEmail','електроннен адрес','eZip','Пошенски код','Ok','Запиши','Submit', 'Submit'));  // BG
arrSubscriptionFields.push(new Array(184,'eName','Nombre','eEmail','Email','eZip','Código Postal','Ok','Inscribirse','Submit', 'Submit'));      // SA
arrSubscriptionFields.push(new Array(244,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // SG
arrSubscriptionFields.push(new Array(259,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // MY
arrSubscriptionFields.push(new Array(197,'eName','Jméno','eEmail','Email','eZip','PSČ','Ok','Přihlásit se','Submit', 'Submit'));                // CZ
arrSubscriptionFields.push(new Array(94,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // CY
arrSubscriptionFields.push(new Array(226,'eName','Name','eEmail','Email','eZip','Post code','Ok','Sign up','Submit', 'Submit'));                // LB
arrSubscriptionFields.push(new Array(225,'eName','Nome','eEmail','Email','eZip','Codice postale','ePrivacy','Letta <a target="_blank" href="Default.aspx?ID=114295">l’informativa</a> accetto i termini per la tutela dei dati personali','Ok','Abbonati','Submit', 'Submit'));           // IT





// Find the right translation and return the value
function getTranslateSubscriptionFields(numArea,strChkValue){
  for(xId=0;xId<arrSubscriptionFields.length;xId++){
    if(arrSubscriptionFields[xId][0]==numArea){
      for(nId=0;nId<arrSubscriptionFields[xId].length;nId++){
        if(arrSubscriptionFields[xId][nId]==strChkValue){
          return arrSubscriptionFields[xId][nId+1];
          break;
        }
      }
    }
  }
}

function TranslateFrontpageNewsletterFields(){
  if($jq('.FrontpageTeaser').find('input').length>0){
    $jq('.FrontpageTeaser').find('input').each(function(){
      if($jq(this).attr('type')=="text"||$jq(this).attr('type')=="submit"){
        $jq(this).val(getTranslateSubscriptionFields(NZAreaID,$jq(this).val()));
      }
    });
  }
}

// Translate newsletter subscriptions fields
function TranslateNewsletterFields(){
  if($jq('.StoreFooterBoxes').length>0){
    $jq(".StoreFooterBoxes").find('input').each(function(){
      if($jq(this).attr('type')=="text"||$jq(this).attr('type')=="submit"){
        $jq(this).val(getTranslateSubscriptionFields(NZAreaID,$jq(this).val()));
      }
    });
  }
  if($jq('#SiteFooter').length>0){
    $jq("#SiteFooter").find('input').each(function(){
      if($jq(this).attr('type')=="text"||$jq(this).attr('type')=="submit"){
        $jq(this).val(getTranslateSubscriptionFields(NZAreaID,$jq(this).val()));
      }
    });
  }
  
  if($jq('#NormalNewsletterLabels').find('span').length>0){
    $jq('#NormalNewsletterLabels').find('span').each(function(){
      $jq(this).html(getTranslateSubscriptionFields(NZAreaID,$jq(this).html()));
    });
    $jq("input[name='Submit']").val(getTranslateSubscriptionFields(NZAreaID,$jq("input[name='Submit']").val()));
  }
}


// AddThis Language Customization
arrAddThisUILang = new Array();
arrAddThisUILang.push(new Array(1,'en'));        // UK
arrAddThisUILang.push(new Array(105,'ru'));        // RU
arrAddThisUILang.push(new Array(249,'en'));        // IN
arrAddThisUILang.push(new Array(169,'en'));        // PH
arrAddThisUILang.push(new Array(99,'ja'));        // JP
arrAddThisUILang.push(new Array(92,'da'));        // DK
arrAddThisUILang.push(new Array(254,'no'));        // NO
arrAddThisUILang.push(new Array(188,'sf'));        // SF
arrAddThisUILang.push(new Array(95,'fr'));        // FR
arrAddThisUILang.push(new Array(222,'fr'));        // BE (FR)
arrAddThisUILang.push(new Array(176,'fr'));        // LU (FR)
arrAddThisUILang.push(new Array(96,'de'));        // DE
arrAddThisUILang.push(new Array(235,'en'));        // CH
arrAddThisUILang.push(new Array(114,'en'));        // GR
arrAddThisUILang.push(new Array(98,'hu'));        // HU
arrAddThisUILang.push(new Array(130,'en'));        // IE
arrAddThisUILang.push(new Array(101,'en'));        // MT
arrAddThisUILang.push(new Array(102,'en'));        // NZ
arrAddThisUILang.push(new Array(109,'en'));        // UK
arrAddThisUILang.push(new Array(168,'ar'));        // UAE
arrAddThisUILang.push(new Array(110,'en'));        // US
arrAddThisUILang.push(new Array(220,'en'));        // CA
arrAddThisUILang.push(new Array(108,'nl'));        // NL
arrAddThisUILang.push(new Array(228,'nl'));        // BE (NL)
arrAddThisUILang.push(new Array(103,'pl'));        // PL
arrAddThisUILang.push(new Array(104,'pt'));        // PT
arrAddThisUILang.push(new Array(215,'ro'));        // RO
arrAddThisUILang.push(new Array(106,'es'));        // ES
arrAddThisUILang.push(new Array(241,'es'));        // MX
arrAddThisUILang.push(new Array(107,'sv'));        // SE
arrAddThisUILang.push(new Array(207,'bg'));        // BG
arrAddThisUILang.push(new Array(184,'en'));        // SA
arrAddThisUILang.push(new Array(212,'en'));        // CO
arrAddThisUILang.push(new Array(244,'en'));        // SG
arrAddThisUILang.push(new Array(262,'en'));        // TW
arrAddThisUILang.push(new Array(261,'tr'));        // TR

var strUILang = getUILang();

var addthis_config = {
          services_compact: 'email, digg, stumbleupon, delicious, twitter, facebook, linkedin, more',
          services_exclude: 'print',
          ui_header_color: "#FFFFFF",
           ui_header_background: "#000000",
          ui_language: strUILang
}
/*
Digg
StumpleUpon
Delicious
Twitter
Facebook
LinkedIn

*/
function getUILang(){
  for(x=0;x<arrAddThisUILang.length;x++){
    if(arrAddThisUILang[x][0]==NZAreaID){
      return arrAddThisUILang[x][1];
      break;
    }
  }
}

// Detect Mobile UserAgent 
var _mobileUserAgents = ['android', 'iphone', 'ipad', 'htc', 'blackberry', 'windows ce', 'symbian', 'nokia', 'samsung', 'opera mini', 'palm'];

function isMobileClient(ua) {
  if (!ua) {
    ua = navigator.userAgent;
  }

  ua = ua.toLowerCase();
  for (var i = 0; i < _mobileUserAgents.length; i++) {
    if (ua.indexOf(_mobileUserAgents[i]) > -1)
      return true;
  }
  return false;
}

//Open iPaper in new window
function showFullscreen(url){
  window.open(url);
}

/************************/
/* Frontpage Splash     */
/************************/
function showSplash(){
  if(getCookie('ShowCampaign2011')!='false'){
    var winWidth = $jq("body").width(),
        winHeight = $jq("body").height(),
        splashWidth = 945,
        splashHeight = 499;
    
    $jq("#splashLayer").css(
      {
        'left':(winWidth-splashWidth)/2+"px",
        'top':(winHeight-splashHeight)/2+"px"
      }
    );
    
    $jq(".splashContent").bind({
      mousemove: function(event){
        var cursorXpos = event.pageX - $jq(this).offset().left,
            cursorYpos = event.pageY - $jq(this).offset().top;
          
        $jq(".infoBox").show().css({
          'left':cursorXpos+8,
          'top'  :cursorYpos+8
        });
      }
    });
    $jq(".splashImage").bind({
      mouseout: function(){
        $jq(".infoBox").hide();
      }
    });
    $jq("#splashOverlay").show();
    $jq("#splashLayer").show();
  }
}

/*function closeSplash() {
  $jq('#splashLayer').hide();
  $jq('#splashOverlay').hide();
  document.getElementById("altContent").resumeTimer();
}*/

function closeSplash(){
  setCookie('ShowCampaign2011','false');
  $jq('#splashLayer').hide();
  $jq('#splashOverlay').hide();
  document.getElementById("altContent").resumeTimer();
}

function setCookie(c_name,value) {
  var date = new Date();
  date.setTime(date.getTime()+(90*24*60*60*1000));
  var expires = "; expires="+date.toGMTString();
  document.cookie=c_name+ "=" + escape(value) + expires;
}

function getCookie(c_name) {
  if (document.cookie.length>0) {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1) {
      c_start=c_start + c_name.length+1; 
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
  return "";
}


/*  *************************************************
    Mapping of My BoConcept Page Ids
    16-11-2012 - NS
*    *************************************************/  
var MyBcPage;
switch(NZAreaID){
  case 92://DK
    MyBcPage = 119806;
    break;
  case 280://DK - Training Site
    MyBcPage = 123960;
    break;
  case 109://UK
    MyBcPage = 119828;
    break;
  case 260://UK - Training Site
    MyBcPage = 119858;
    break;
  
}

/*  *************************************************
    eCom - add text to mini-basket.
    eCom - show notification when product is added.
    eCom - Update mini-basket.
    16-11-2012 - NS
*    *************************************************/  

// Texts for the mini basket in top function menu.
var ecomGUITexts = [];
ecomGUITexts.push(new Array(92,'Dit produkt er nu lagt i kurven','Køb mere','Gå til kurven','Kurv','Produkter:','Pris:','Gå til kurven for at beregne leveringstid og fragtomkostninger.','Kurven'));                // DK
ecomGUITexts.push(new Array(109,'Your product is now added to the basket','Continue shopping','Show basket','Basket','Products:','Price:','Go to basket to calculate the delivery time and cost.','Basket'));        // UK

// Insert texts into the mini-basket.
function insertEcomGUITexts(){
  for(var len = ecomGUITexts.length, x = 0; x < len; x++){
    if(ecomGUITexts[x][0] === NZAreaID){
      // Set text in product added layer.
      // NS (23-11-2011) - This layer is not yet in use, but may be activated later on. 
      $jq(".notificationText").text(ecomGUITexts[x][1]);
      $jq(".continueShop").text(ecomGUITexts[x][2]);
      $jq(".showBasket a").text(ecomGUITexts[x][3]);
      
      //Set text in mini basket
      $jq(".txtBasket").text(ecomGUITexts[x][4]);
      $jq(".miniBasketProdLabel").text(ecomGUITexts[x][5]);
      $jq(".miniBasketPriceLabel").text(ecomGUITexts[x][6]);
      $jq(".miniBasketInfoTxt").text(ecomGUITexts[x][7]);
      $jq(".miniBasketButton").text(ecomGUITexts[x][8]);
      
    }
  }
}

// NS - Updates mini-basket by calling a webservice from NetCompany.
jQuery.support.cors = true;
function updateBasket(){
  $jq.getJSON("http://mscstest.dmz1.local/WebServices/MyBCMiniBasket.asmx/GetMiniBasket?callback=?",
  //Above line is to be changed, when basket goes live. Netcompany supplies url
    {
      parenturl: location.href.slice(7,location.href.indexOf("/",9))
    },
    function(json) {
      //Set amount of products and total price for the mini basket
      var amountBasket = json.BasketItemCount,
          totalPriceBasket = json.TotalAmount;
      $jq(".price").text(totalPriceBasket);
      $jq(".amountBasket").text(amountBasket);
      
      //Set amount of products and total price for the mini basket dropdown
      $jq(".miniBasketProd").text(amountBasket);
      $jq(".miniBasketPrice").text(totalPriceBasket);
      $jq(".miniBasketButton, #productAdded a, .basketButton").attr('href',location.href.slice(0,location.href.indexOf("/",9)+1) + "default.aspx?ID=" + MyBcPage + "&page=ShowBasket");
      
      $jq(".basketButton").hover(
        function(){
          $jq("#miniBasketDropdown").clearQueue();
          $jq("#miniBasketDropdown").slideDown();
        },
        function(){
          $jq("#miniBasketDropdown").delay(500).slideUp();
        }
      );
      
      $jq("#miniBasketDropdown").hover(
        function(){
          $jq("#miniBasketDropdown").clearQueue();
        },
        function(){
          $jq("#miniBasketDropdown").delay(500).slideUp();
        }
      );

      $jq("#basket").show();
    });
}

function autoUpdateBasket(){
  setInterval("updateBasket()",2000);
}

// NS - Show layer, product has been added to the basket. Layer is visible on product creator pages
function showNotification(){
  updateBasket();
  $jq("#productAdded").fadeIn(1000);
  setTimeout("closeNotification()",10000);
}
// NS - Close notification layer
function closeNotification(){
  $jq("#productAdded").fadeOut(1000);
}



/************************/
/* PLUGINS              */
/************************/
(function( $ ){

  // Version 0.8
  // Date: 15-05-2011
  // @Woodsboe
  $.fn.multiGallery = function( options ) {  

    var settings = {
    'autoRun'      : false,
    'autoRunTimer'     : 5000,
    'idleTimer'      : 8000,
    'showNavigation'   : false,
    'showMarkers'     : true,
    'showMarkerNumbers' : false,
    'zoomButton'    : true,
    'width'       : 200,
    'height'       : 200
    };

    return this.each(function() {        
    // If options exist, lets merge them
    // with our default settings
    if ( options ) { 
      $.extend( settings, options );
    }
    
    // Init Variables
    var $this = $(this),
      numSlides = $(".slides li", this).length,
      counter = 0,
      navPosVertical = (settings.height - $(".navNextArrow").height()) / 2,
      markerNum = "";

    //Append Back and Forth Navigation
    var naviMarkup = '<div class="navNextArrow"></div>' +
             '<div class="navBackArrow"></div>';
    $this.append(naviMarkup);
    
    // Show Back and Forth Navigation
    if(settings.showNavigation){
      $(".navNextArrow").css({'display':'block', 'top':navPosVertical});
      $(".navBackArrow").css({'display':'block', 'top':navPosVertical});
    }
    
    // Navigate to Next Slide
    var $next = $(".navNextArrow",$this);
    $next.click(function(event){
      if(event.originalEvent){
        clearInterval(runningTimer);
        var idleTimer = setTimeout(function(){
          runningTimer = setInterval(function(){
            $next.click();
          },settings.autoRunTimer);  
        },settings.idleTimer);
      }
      event.stopPropagation();
      var numActiveSlide = $(".slides li[class='active']",$this).index();
      if(numActiveSlide === numSlides-1){
        counter = 0;
      }
      else
      {
        counter++;
      }
      setActiveMarker($this, counter);
      setActiveImage(counter);
    });
    
    // Navigate to Previous Slide
    var $back = $(".navBackArrow",$this);
    $back.click(function(event){
      if(event.originalEvent){
        clearInterval(runningTimer);
        setTimeout(function(){
          runningTimer = setInterval(function(){
            $next.click();
          },settings.autoRunTimer);  
        },settings.idleTimer);
      }
      event.stopPropagation();
      var numActiveSlide = $(".slides li[class='active']",$this).index();
      if(numActiveSlide === 0){
        counter = numSlides-1;
      }
      else
      {
        counter--;
      }
      setActiveMarker($this, counter);
      setActiveImage(counter);
    });
    
    // Init Gallery CSS
    $this.css({
      'width' : settings.width + 'px',
      'height' : settings.height + 'px'
    });
    
    var arrUrlParams = location.search.toLowerCase().split("&");
    function getUrlParam(param){
      for(var i in arrUrlParams){
        if(arrUrlParams[i].indexOf("?"===0)){
          arrUrlParams[i] = arrUrlParams[i].replace("?","");
        }
        if(arrUrlParams[i].indexOf(param.toLowerCase())===0){
          return arrUrlParams[i].slice(param.length+1, arrUrlParams[i].length);
          break;
        }
      }
    }
    
    // Attach Marker Navigation to $this Collection
    $this.append('<ul class="navSlider"></ul>');
    
    for(var x = 0; x < numSlides; x++){
      if(settings.showMarkerNumbers){ var markerNum = x + 1 }
      $(".navSlider",$this).append('<li>'+ markerNum +'</li>');
    }
    
    //Show Slide with imageID from the Query String and Add a Class to Matching Marker
    $(".slides li",$this).each(
      function(n){
        if($(this).data("imageData").imageID === getUrlParam("imageid")){
          $(this).addClass("active").fadeIn();
          
          // Add Class to First Marker
          $(".navSlider li:eq("+ n +")",$this).addClass("active");
          
          return false;
        }
      }
    );
    
    // Bind Click Function to All Markers
    $(".navSlider li",$this).click(function(){
      var activeIndex = $(this).index(),
        imgID = $(".slides li:eq(" + activeIndex + ")").data("imageData").imageID,
        ajaxUrl = "http://" + location.hostname + location.pathname + "?id=" + getUrlParam("id") + "&ajaxget=" + imgID;
      
      setActiveMarker($this, activeIndex);
      setActiveImage(activeIndex);
      //Load XML Data
      $.ajax({
        url:    ajaxUrl,
        dataType:  "html",
        success:  function(data){
          var data = data.replace(/margin:0 0 0 7px/g,"margin:0 0 0 15px"),
            ajaxOutput = "";
          
          $(".ProductItemContainer",data).each(function() {
            ajaxOutput += '<div class="ProductItemContainer">'+$(this).html()+'</div>'
          });
          
          $("#ProductsContainer").html(ajaxOutput);
        },
        error:  function(xhr, textStatus, errorThrown){
          alert("Error: " + errorThrown + "\ntextStatus: " + textStatus + "\nxhr: " + xhr);
        }
      });

    });
    
    // Hide Zoom Icon from image
    $(".navSlider li:not('.zoom')",$this).bind('mouseover',function(){
      $(".zoomCursor").hide();
    });
    
    if(numSlides === 1){  
      $(".navSlider li:not('.zoom')").hide();
    }
    
    // Add Zoom Button to Navigation
    if(settings.zoomButton){
      $(".navSlider",$this).append('<li class="zoom"></li>');
      $(".zoom",$this).bind({
        click: function(){
          zoom($this, $(".active",$(this).parent()).index())
        },
        mouseover: function(){
          $(".zoomCursor").hide();
        }
      });
    }
    
    // Add Home Creator Button to Navigation in Product Detail View
    if(nzTranslate.HomeCreator){
      $(".navSlider",$this).append('<li class="HomeCreator">' + nzTranslate.HomeCreator + '</li>');
      $(".HomeCreator",$this).bind({
          click: function(){
            $(".imageGallery").hide();
            $("#ProductsContainer").hide();
            $("#ParagraphContainer").css("padding","20px 0 0");
            //homeCreatorUrl = homeCreatorUrl.replace("%%imgID%%",$(".slides .active").data("imageData").imageID);
            $(".homeCreator").fadeIn().attr("src", homeCreatorUrl);
          },
          mouseover: function(){
            $(".zoomCursor").hide();
          }
        }
      );
    }
  
    
    // Add Zoom Icon to Mouse Pointer
    $(".imageGallery").append('<div class="zoomCursor"><div class="zoomIcon"></div></div>');
    $(".zoomCursor").click(function() {
      $(".zoom").click();
    });
    $(".slides li").bind({
      mousemove: function(event){
        var cursorXpos = event.pageX - $(this).offset().left,
          cursorYpos = event.pageY - $(this).offset().top,
          layerWidth = $(this).width() - 8,
          layerHeight = $(this).height() - 8;
            
        if(cursorXpos < 8){
          cursorXpos = 8;
        }
        if(cursorXpos > layerWidth){
          cursorXpos = layerWidth;
        }
        if(cursorYpos < 8){
          cursorYpos = 8;
        }
        if(cursorYpos > layerHeight){
          cursorYpos = layerHeight;
        }
        if(cursorXpos < 10 || cursorXpos > (layerWidth-10) || cursorYpos < 10 || cursorYpos > (layerHeight-10)){
          $(".zoomCursor").hide();
        }
        else
        {
          $(".zoomCursor").fadeIn().css({
            'left'  :cursorXpos,
            'top'  :cursorYpos
          });
        }
      }
    });
      
    // Reset and Set Active Marker
    var setActiveMarker = function($ParentObj,$index){
      $(".navSlider li[class='active']",$ParentObj).removeClass("active");
      $(".navSlider li:eq(" + $index + ")",$ParentObj).addClass("active");
    }
    
    // Reset and Set Active Image
    var setActiveImage = function(numIndex){
      $(".slides li[class='active']",$this).removeClass("active").fadeOut();
      $(".slides li:eq(" + numIndex + ")",$this).addClass("active").fadeIn();
    }
    
    // AutoRun
    if(settings.autoRun){
      var runningTimer = setInterval(function(){
        $next.click();
      },settings.autoRunTimer);
    }
    
    $(".zoomLayer").click(function(){
      $(this).hide();
      $(".zoomLayer .zoomImage li").removeClass("active");
      $(".zoomLayer .zoomNavMarkers li").removeClass("active");
    });
    
    $(".zoomLayer").append('<ul class="zoomNavMarkers"></ul>');
    for(var x = 0; x < numSlides; x++){
      var selector = ".slides li:eq("+x+")";

//      $(".zoomLayer .zoomImage").append('<li><img src="/admin/public/getimage.aspx?&Image=' + $(selector).data("imageData").largeImage + '&Width=' + ($("body").width() - 40) + '&Resolution=75&Compression=70"/></li>');
    //Below testing to see if it is possible to create an image with whitespace - it is not
      $(".zoomLayer .zoomImage").append('<li><img style="display: block; margin-left: auto; margin-right: auto;" src="/admin/public/getimage.aspx?&Image=' + $(selector).data("imageData").largeImage + '&Height=' + ($("body").height() - 40) + '&Width=' + ($("body").width() - 40) + '&Resolution=75&Compression=70&Crop=5" /></li>');
    //Problem is in the autosetting of img width
      if(settings.showMarkerNumbers){ var markerNum = x + 1 }
      $(".zoomNavMarkers").append('<li>'+ markerNum +'</li>');
    }
    if(numSlides === 1){  
      $(".zoomNavMarkers li").hide();
    }
    $(".zoomNavMarkers li").click(function(event){
      event.stopPropagation();
      $(".zoomNavMarkers li[class='active']").removeClass("active");
      $(this).addClass("active");
      $(".zoomLayer .zoomImage li[class='active']").fadeOut().removeClass("active");
      $(".zoomLayer .zoomImage li:eq(" + $(this).index() + ")").fadeIn().addClass("active");
    });
    $(".zoomNavMarkers").bind('mouseover',function(){
      $("zoomImageCursor").hide();
    });
    
    var zoom = function($obj, liObj){
    var imageRatio = 0;
      var layerWidth = $("body").width(),
//      var layerWidth = 300,//$("body").width(),
        imgWidth = $(".zoomLayer .zoomImage li:eq("+liObj+") img")[0].width;
        imgHeight = $(".zoomLayer .zoomImage li:eq("+liObj+") img")[0].height;
    layerHeight = $("body").height();
    imageRatio = imgHeight/imgWidth;
//    alert(imageRatio);
      
    //Looks proper, if I disable both below. Does not scale up though
    //Image height versus browser height perhaps?
    
    //Get image height/width-ratio
    //See if layerWidth - 40 * ratio > body height
    //Rescale .zoomLayer .zoomImage li img
    
    $(".zoomLayer .zoomImage li").css("width", layerWidth - 40); //Puts a width on the li, and enables the image to margin-left: auto; margin-right: auto;
    
      //Scale Image Down
      if(layerWidth < imgWidth){ //if body < image width
    //set image width: body - 40
        $(".zoomLayer .zoomImage li img").attr("width", layerWidth - 40);
      }
      //Scale Image Up
      if(layerWidth > imgWidth){ //if body > image width

    if(imageRatio*(layerWidth-40) > layerHeight){ //If (image height scaled by setting image width) will be higher than body height, set image height
      $(".zoomLayer .zoomImage li img").attr("height", layerHeight - 40);
//      alert('resize needed');
    }
    if(imageRatio*(layerWidth-40) < layerHeight){ //Otherwise, no need to resize
      $(".zoomLayer .zoomImage li img").attr("width", layerWidth - 40);
//      alert('no resize needed');
    }
    
//        $(".zoomLayer .zoomImage li img").attr("width", layerWidth - 40);
      }
      
      $(".zoomLayer .zoomNavMarkers li:eq("+liObj+")").addClass("active");
      $(".zoomLayer .zoomImage li:eq("+liObj+")").addClass("active").fadeIn();
      
      $(".zoomLayer").css({
        'position'  :'absolute',
        'display'  :'block',
        'top'    :20,
        'left'    :20,
        'width'    :(layerWidth - 40),
        //'height'  :$(".zoomLayer .zoomImage li:eq("+liObj+") img")[0].height,
        'background':'#fff',
        'border'  :'#333 1px solid',
        'z-index'  :30002
      });
      
      $(".zoomImageWrapper").css({
        'width'    :(layerWidth - 40),
//    'margin-left'    :'auto',
//    'margin-right'    :'auto',
        'height'  :$(".zoomLayer .zoomImage li:eq("+liObj+") img")[0].height
      });
      
      $(".zoomNavMarkers").css({
        'z-index'  :30020
      });

      // Add Close Icon to Overlay
      if($(".closeOverlay").length === 0){
        $(".zoomImageWrapper").append('<div class="closeOverlay"></div>');
      }
      $(".closeOverlay").bind({
        click: function(){
          $(".zoomLayer .zoomImage li").removeClass("active").css("display", "none");
          $(".zoomLayer .zoomNavMarkers li").removeClass("active");
        },
        mouseover: function(){
          $(".zoomImageCursor").hide();
        }
        ,
        mouseout: function(){
          $(".zoomImageCursor").show();
        }
      });
      
      // Add Zoom Icon to Mouse Pointer
      if($(".zoomImageCursor").length === 0){
        $(".zoomImageWrapper").append('<div class="zoomImageCursor"><div class="zoomIcon"></div></div>');
      }
      $(".zoomImageCursor").click(function() {
        $(this).hide();
        $(".zoomLayer .zoomImage li").removeClass("active").css("display", "none");
        $(".zoomLayer .zoomNavMarkers li").removeClass("active");
      });
      $(".zoomImageWrapper").bind('mousemove',
        function(event){
          var cursorXpos = event.pageX - $(this).offset().left,
            cursorYpos = event.pageY - $(this).offset().top,
            layerWidth = $(".zoomLayer").width() - 8,
            layerHeight = $(".zoomLayer").height() - 8;
            
          if(cursorXpos < 8){
            cursorXpos = 8;
          }
          if(cursorXpos > layerWidth){
            cursorXpos = layerWidth;
          }
          if(cursorYpos < 8){
            cursorYpos = 8;
          }
          if(cursorYpos > (layerHeight-50)){
            cursorYpos = (layerHeight-50);
          }
          $(".zoomImageCursor").fadeIn().css({
            'left'  :cursorXpos,
            'top'  :cursorYpos
          });
        }
      );
    }
    });
  };
})(jQuery);



/*Start GA tracking*/

//Google-analytics all countries

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25345797-1']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAllowLinker', true]);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


switch(NZAreaID){
case 274: //Austria
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029120-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;
  
case 222: //Belgium
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', '28028648-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 207: //Bulgaria
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029427-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;
  
case 220: //Canada
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029416-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;
  
case 197: //Czech Republic
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028782-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;
  
case 265: //Chile
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029613-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;
  
case 93: //China
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20721150-3']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 212: //Columbia
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28053133-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 190: //Croatia
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029237-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 94: //Cypern
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029129-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 92: //Denmark
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25745007-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 188: //Finland
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28027085-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 95: //France
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28052371-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-9166605-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
  break;

case 96: //Germany
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25743409-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 248: //Greece
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25743905-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 184: //Guatemala
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28027096-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 98: //Hungary
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28052571-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 129: //Iceland
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028853-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 249: //India
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029033-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 130: //Ireland
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028767-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 228: //Italy
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25850150-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 99: //Japan
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25850150-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 192: //Latvia
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029344-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 176: //Luxemburg
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028774-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 259: //Malaysia
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28054230-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 101: //Malta
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28053067-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 241: //Mexico
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029018-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 267: //Morocco
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029904-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 108: //Netherlands
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-18591036-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 102: //New Zealand
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029336-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 254: //Norway
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19796346-2']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 255: //Panama
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28052379-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 169: //Philippines
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029245-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 103: //Poland
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28025492-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 104: //Portugal
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029013-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 215: //Romania
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28027098-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 105: //Russia put in includes/footer.html, due to special scripts
  break;

case 247: //Saudi Arabia
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029334-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 244: //Singapore
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28054905-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 106: //Spain
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25743503-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 235: //Switzerland
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028649-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 262: //Taiwan
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029241-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 261: //Turkey
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028868-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 168: //United Arab Emirates
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029223-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 109: //United Kingdom
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-11242471-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 110: //USA
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-25877922-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 204: //Venezuela
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28028770-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

case 256: //Vietnam
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28029250-1']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  break;

}

_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


/*EndGA tracking*/
