﻿disableTracker = true;

if(window.location.href.indexOf("?path=") != -1)
{
  if(detectFlash())
  {
      window.location.href = window.location.href.replace("?path=", "#");
  }
}


function callback(string)
{
    // Store url for later restoring
    document.getElementById("hashcontainer").value = window.location.href;
    
    Sys.WebForms.PageRequestManager.getInstance()._doPostBack(clientid(), string);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endCallback);
    
    // Override function to overcome hashmark issues
    Sys._Application.prototype._setState = function() {}

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(testThis);

    // Always do this to fix sifr headers
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(initSifrAfterPartialPostback);   
}

function endCallback()
{
    Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(endCallback);
    toggleVideoShortcut();
    document.getElementById('content').className = "hidden1.changed";
    document.getElementById('content').style.display = "";
    
    if(typeof sIFR != "undefined")
    {
        sIFR.replaceElement
        (
            named
                (
                    {
                        sSelector:"h2",
                        sFlashSrc:"/Frontend/FuturaND.swf",
                        sColor:"#111111",
                        sLinkColor:"#111111",
                        sBgColor:null,
                        sHoverColor:"#111111",
                        nPaddingTop:0,
                        nPaddingBottom:0,
                        sFlashVars:"textalign=left&amp;offsetTop=0"
                    }
                )
            );
        }
}

function getTexture(id)
{
    // Always do this to fix sifr headers
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endCallback);

    if(!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack())
    {
        Sys.WebForms.PageRequestManager.getInstance()._doPostBack(clientidthumbs(), id);
    } else
    {
        document.getElementById('hdnMaterials').value = id;
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(getTextureDelayed);
    }
}

function getTextureDelayed()
{
    Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(getTextureDelayed);
    Sys.WebForms.PageRequestManager.getInstance()._doPostBack(clientidthumbs(), document.getElementById('hdnMaterials').value);
}

// Opens printpage
function printPage(productId, cultureName)
{
    window.open(unescape("/Renderers/Print.aspx?productId=" + productId + "%26cultureName=" + cultureName));
}

// Hides "long page" content, and removes html from the DOM
function hideContent()
{
    //document.getElementById('content').className = "hidden1";
    document.getElementById('content1').innerHTML ="";
    document.getElementById('content2').innerHTML ="";
    document.getElementById('content3').innerHTML ="";
}

function testThis() {
    toggleVideoShortcut();
    if (typeof sIFR != "undefined") {
        sIFR.replaceElement
        (
            named
                (
                    {
                        sSelector: "h2",
                        sFlashSrc: "/Frontend/FuturaND.swf",
                        sColor: "#111111",
                        sLinkColor: "#111111",
                        sBgColor: null,
                        sHoverColor: "#111111",
                        nPaddingTop: 0,
                        nPaddingBottom: 0,
                        sFlashVars: "textalign=left&amp;offsetTop=0"
                    }
                )
            );
    }
}