function initPage() {

  $(".ajaxControl").ajaxcontrol();

  if(showSplash) {
    // Make campaign popover pane work
    var ViewportPosition = $("body").scrollTop();
    if (ViewportPosition == 0)
      ViewportPosition = $("html").scrollTop();
    var ViewportMargin = ViewportPosition + 40;

    // Calculate left margin to ensure the div is centered
    var DivMarginLeft = $("#popover").outerWidth() / 2;

    $("#popover").css({
      "top": ViewportMargin,
      "margin-left": -DivMarginLeft
    }).addClass("activehover").fadeIn("fast");


    $("#shades").fadeTo("fast",0.80);
  }

  // Make it possible to click outside hover panes to disable them
  $("#shades").click(function(){
    $(this).fadeOut("fast");
    $(".activehover").fadeOut("fast")
  });

  // Make it possible to click on close circles
  $(".closebutton").click(function(){
    $("#shades").fadeOut("fast");
    $(".activehover").fadeOut("fast");
  });

    $('#prodrow ul').jcarousel({
      setupCallback:function(){$('#prodrow ul').css("visibility","visible");}
    });

}

var nofthumb = 0;
var thumbcount;

function thumbLoaded() {
  thumbcount--;
  nfndebug(thumbcount);
}


function showArt(artid) {
  StartPage.GetArticleInfo(artid, function(r){showArt2(r, artid);});
}

function showArt2(response, artid) {
  if (response.error != null) {
    nfndebug(response.error.Message);
    return;
  }
  var name = response.value[0];

  $("#productPop .prodhl").html(name);
  $("#productPop .fabrics").html(response.value[1]);
  $("#productPop .features").html(response.value[2]);
  $("#productPop .featureslab").html(response.value[3]);
  $("#productPop .sizelab").html(response.value[4]);
  $("#productPop .size").html(response.value[5]);

  var cols = response.value[6].split('|');
  var colcodes = response.value[7].split('|');
  var imgs = response.value[8].split('|');

  var html = "";
  for (var i=0; i < cols.length; i++) {
    var img = new Image();
    img.src = imgs[i];
    html += "<div class='colthumb'><a href='javascript:setArtImgGen(\"" + imgs[i] + "\", \"" + name + "\")' onfocus='this.blur()'><img src='img/colors/" + colcodes[i] + ".gif' alt='" + cols[i] + "' title='" + cols[i] + "' width=20 height=20 border=0 /></a></div>";
  }
  $("#prodcol").html(html);
  setArtImgGen(imgs[0]);

  $("#productPop .icons").html(response.value[9]);

  $("#shades").fadeTo("fast",0.80);
  $("#shades").click(function(){
    $("#productPop").fadeOut("fast");
    $("#shades").fadeOut("fast")
  });
  $("#productPop .closebutton ").click(function(){
    $("#productPop").fadeOut("fast");
    $("#shades").fadeOut("fast")
  });
  setIconTexts("#productPop");
  $("#productPop").center().show("normal");
}

function setArtImgGen(src, name) {
  $("#productPop .prodimg").html("<img src='admin/DocumentBank/thumbnail.aspx?height=300&width=300&keepaspect=true&image=" + src + "' alt='" + name + "' title='" + name + "' />");
}


