﻿
/// <summary> 
/// Created: 060705 
/// Function Name: setTabStatus(intConfigStep, intStepControlID, enumConfigStepStatus)
/// Author: Mikael Larsson, Gustaf Lindqvist
/// Used in: UC/UpdateConfigSteps
/// Description: This function is used to update a single tab and its status, by looping it you can set all tabs
/// </summary>

window.defaultStatus = "Porsche Sverige AB";

var arrConfigStepActive = new Array();

function setTabStatus(intConfigStep, intStepControlID, enumConfigStepStatus)
{
        intStepControlCounter = intStepControlID + 1;
           
        tabname = "tab" + intStepControlCounter;
        imgname = "img" + intStepControlCounter;
        linkname = "ctl00_ContentPlaceHolderContent_Configsteps1_repOptionTypes_ctl0" + intStepControlID  + "_lnkOptionTypes";
        //alert("tabname = " + tabname + "\nimgname = " + imgname + "\nlinkname = " + linkname);
        
        tab = document.getElementById(tabname);
        img = document.getElementById(imgname);
        link = document.getElementById(linkname);
        
        // sets the style of the tab
        if (tab && img && link)
        {
            // default
            tab.className = tabname;
            link.style.cursor = "hand";
            arrConfigStepActive[intStepControlID] = 1;

            if (intStepControlCounter == intConfigStep)
            {
                //alert("intStepControlCounter == intConfigStep");
                tab.className = tabname + " selected";
               // img.src = ImageMachine.Text2Image("ifokus","",img.alt,"","","","","","true");
                img.src = "/ImageMachine/Image2TextNew.aspx?text="  + img.alt + "&type=ifokus&anti=true"; // IFokus 
            }
            else if(enumConfigStepStatus == 0)
            {
                //alert("enumConfigStepStatus == 0");
                img.src = "/ImageMachine/Image2TextNew.aspx?text=" + img.alt +  "&type=inaktiv&anti=true"; // Inaktiv
                arrConfigStepActive[intStepControlID] = 0;
                link.style.cursor = "default";
            }
            else if(enumConfigStepStatus == 1)
            {
                //alert("enumConfigStepStatus == 1");
                img.src = "/ImageMachine/Image2TextNew.aspx?text=" + img.alt +  "&type=aktiv&anti=true"; // Aktiv_Not_Done
            }
            else if(enumConfigStepStatus == 2)
            {
                tab.className = tabname + " selected";
                //alert("enumConfigStepStatus == 2");
               // img.src = "/ImageMachine/Image2TextNew.aspx?text=" + img.alt +  "&type=aktiv&anti=true"; // Aktiv_Done             
                 img.src = "/ImageMachine/Image2TextNew.aspx?text=" + img.alt +  " &type=done&anti=true";
            }
        }
}


// Created: 070704 
// Function Name: loadUrl(url)
// Author: Gustaf Lindqvist
// Used in: UC/ConfigSteps
// Description: This function loads a Url into the IFrame that is defined as frmContent
function loadUrl(theUrl, intConfigStep)
{
    if(arrConfigStepActive[intConfigStep-1] == 0)
        return;

    var theIFrame = window.frames["frmContent"];
    if (!theIFrame)
        theIFrame = window.frmContent;

    //alert("theIFrame = " + theIFrame);
    
    var theForm = theIFrame.document.forms['aspnetForm'];
    if (!theForm)
        theForm = theIFrame.document.aspnetForm;
    
    //alert("theForm = " + theForm);
    
    var nextUrlHidden = theIFrame.document.getElementById("ctl00_ContentPlaceHolderContent_NextUrlHidden");
    //alert("nextUrlHidden = " + nextUrlHidden);
    if (nextUrlHidden)
    {
        nextUrlHidden.value = theUrl;        
        //alert("nextUrlHidden.value = " + nextUrlHidden.value);
        theIFrame.__doPostBack();
    }
    else
    {
        theIFrame.location.href = theUrl;
    }
}

// Created: 0705? 
// Function Name: swapImgInfo and restoreImgInfo(img_id)
// Author: Mikael Larsson
// Used in: When listing the Options, for example: Option.aspx
// Description: Used to display, set and change the InformationImage
function swapImgInfo(img_id)
{
    var ImgInfo = document.getElementById(img_id);
    ImgInfo.src = '/images/btn_img_info_a.gif';
}

function restoreImgInfo(img_id)
{
    var ImgInfo = document.getElementById(img_id);
    ImgInfo.src = '/images/btn_img_info_na.gif';
}

// Created: 070629 
// Function Name: setInfoFooter(headline, information, date, description, currentDate, parseDate)
// Author: Gustaf Lindqvist
// Used in: When listing information about options in information panel, for example: Option.aspx
// Description: Used to display information in an information panel
var strHeadline = "";
var strActivation = "";
var strActivationDate = "";
var strDescription = "";
var strCurrentDate;
var strParseDate;
function setInfoFooter(headline, information, date, description, strOnly, strNot, currentDate, parseDate)
{    
    var strRestrictions = "";

    //alert("strOnly:\n" + strOnly + "\n\nstrNot:\n" + strNot);

    if (strOnly.length > 0)
    {
        strRestrictions += "<br />Only in conjunction with ";
        var arrOnlyAll = strOnly.split(";");

        for(var i = 0; i < arrOnlyAll.length; i++)
        {
            var arrOnlyCurrent = arrOnlyAll[i].split('|');
            strRestrictions += "<span title=\"" + arrOnlyCurrent[1] + "\" style=\"cursor:url('/images/cursor/porsche.cur')\">" + arrOnlyCurrent[0] + "</span>, ";
        }
        
        strRestrictions = strRestrictions.substr(0, strRestrictions.length - 2);
    }

    if (strNot.length > 0)
    {
        strRestrictions += "<br />Not in conjunction with ";
        var arrNotAll = strNot.split(";");

        for(var i = 0; i < arrNotAll.length; i++)
        {
            var arrNotCurrent = arrNotAll[i].split('|');
            strRestrictions += "<span title=\"" + arrNotCurrent[1] + "\" style=\"cursor:url('/images/cursor/porsche.cur')\">" + arrNotCurrent[0] + "</span>, ";
        }
        
        strRestrictions = strRestrictions.substr(0, strRestrictions.length - 2);
    }
    
    //document.write(strRestrictions);
    
    // Set the INPUT to variables
    strHeadline = headline;
    strActivation = information;
    strActivationDate = date;
    strDescription = description + "<br />" + strRestrictions;
    strCurrentDate = currentDate;
    strParseDate = parseDate;
        
    /* Initiate the UC objects*/
    infoFooterHeadLine = document.getElementById("ctl00_ContentPlaceHolderContent_InfoFoot_litHeadLine");
    infoFooterDescription = document.getElementById("ctl00_ContentPlaceHolderContent_InfoFoot_litInfoDescription");
   

    // This function checks if the current date is larger than the ActivationDate, if not show the restrictions    
    // Get the values from the database
    infoFooterActivationNotification = document.getElementById("ctl00_ContentPlaceHolderContent_InfoFoot_litInfoActivationNotification");
    infoFooterActivationDate = document.getElementById("ctl00_ContentPlaceHolderContent_InfoFoot_litInfoActivationDate");   
    if(currentDate < parseDate)
    {
        // Set the values to the UC, InfoFooter
        setObjInnerText(infoFooterActivationNotification, strActivation);
        setObjInnerText(infoFooterActivationDate, strActivationDate);
    }
    else
    {
        // Blank the values
        setObjInnerText(infoFooterActivationNotification, "");
        setObjInnerText(infoFooterActivationDate, "");
    }
    

    /* Send the values to the UC */
    setObjInnerText(infoFooterHeadLine, strHeadline);
    //setObjInnerText(infoFooterActivationNotification, strActivation); //commented since used above in the if statement
    //setObjInnerText(infoFooterActivationDate, strActivationDate);//commented since used above in the if statement
    setObjInnerHtml(infoFooterDescription, strDescription);
      
}

// Created: 070630
// Function Name: setModelImageFront(ModelName, ModelInfo, ImageSrc, ImageURL)
// Author: Gustaf Lindqvist
// Used in: When showing an Image in Models.aspx
// Description: Used to display an image of a model and set a URL to the image dynamicly when moving mouse over an image or link
var strModelName = "";
var strImageSrc = "";
var strImageUrl = "";
var strInfo = "";
function setModelImageFront(ModelName, ModelInfo, ImageSrc, ImageURL)
{
    // Set the INPUT to variables
    strModelName = ModelName;
    strModelInfo = ModelInfo;
    strImageSrc = ImageSrc;
    strImageUrl = ImageURL;
 
    /* Initiate the UC objects */
    modelImageModelName = document.getElementById("ctl00_ContentPlaceHolderContent_ModelImage1_imgModelName");
    modelImageInfo = document.getElementById("ctl00_ContentPlaceHolderContent_ModelImage1_imgModelInfo");
    modelImageSrc = document.getElementById("ctl00_ContentPlaceHolderContent_ModelImage1_imgModel");
    modelImageUrl = document.getElementById("ctl00_ContentPlaceHolderContent_ModelImage1_imgModelInfoUrl");
        
    /* Send the values to the UC */
    modelImageModelName.src = strModelName;
    modelImageInfo.src = strModelInfo;
    modelImageSrc.src = strImageSrc;
    modelImageUrl.href = strImageUrl;
}



// Created: 0705? updated 070630
// Function Name: updateSum(divSummaryID, checkBoxId, optionPrice)
// Author: Mikael Larsson, Gustaf Lindqvist
// Used in: UC/PriceSum
// Description: Used to dynamicaly change price and information in "Sammanfattningsrutan"
var floatSum = 0;
var floatSumExVAT = 0;
var floatOptionSum = 0;
var floatEquipSum = 0;
var floatNetOptionSum = 0;
var floatNetEquipSum = 0; 
var floatNetSum = 0;

function updateSumOption(divSummaryID, checkBoxId, optionGrossPrice, optionNetPrice, boolChecked)
{
    // Retreive the Hiddenvalues from the hiddenfields in the application
    hidTotalPriceSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalPrice"); 
    hidTotalOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionPrice");
    hidTotalEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipPrice");
    hidTotalPriceNetSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalNetPrice"); 
    hidTotalNetOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionNetPrice"); 
    hidTotalNetEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipNetPrice"); 
   
   
  // Initiate sum with model price if 0
    if (floatSum == 0)
            floatSum = parseFloat(hidTotalPriceSaved.value);
    if (floatNetSum == 0 )
        floatNetSum = parseFloat(hidTotalPriceNetSaved.value); 
    if (floatNetOptionSum == 0 )
        floatNetOptionSum = parseFloat(hidTotalNetOptionSaved.value);
     if (floatNetEquipSum == 0 )
        floatNetEquipSum = parseFloat(hidTotalNetEquipSaved.value);
        
   // Parse the Price of the Option
    floatOptionSum = parseFloat(hidTotalOptionSaved.value);
    //source = document.getElementById(checkBoxId);
   
   // Remove white spaces from the OptionPrices so that parsefloat will work
    rExp = /\s/gi;
    optionNetPrice = optionNetPrice.replace(rExp, '');
    optionGrossPrice = optionGrossPrice.replace(rExp, '');
    floatPrice = parseFloat(optionGrossPrice);
    floatNetPrice = parseFloat(optionNetPrice); 
    
    // if not a number - return
    if (isNaN(floatPrice))
    {
       return;
    }
    
    // Add/subtract option price to/from sum
    if (boolChecked)
    {
        floatSum = floatSum + floatPrice;
        floatNetSum = floatNetSum + floatNetPrice; //TODO vill ha
        floatOptionSum = floatOptionSum + floatPrice;
        floatNetOptionSum = floatNetOptionSum + floatNetPrice;
    }    
    else
    {
        floatSum = floatSum - floatPrice;
        floatNetSum = floatNetSum - floatNetPrice; //TODO vill ha
        floatOptionSum = floatOptionSum - floatPrice;
        floatNetOptionSum = floatNetOptionSum - floatNetPrice;
    }
    
    // Save the new decimal value to the hidden fields
    hidTotalPriceSaved.value = floatSum;
    hidTotalPriceNetSaved.value = floatNetSum;
    hidTotalOptionSaved.value = floatOptionSum;
    hidTotalNetOptionSaved.value = floatNetOptionSum;
    
    // Display currency formatted value
    txtTotalPrice = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPrice");
    strSum = CurrencyFormatted(floatSum) + " kr";
    setObjInnerText(txtTotalPrice, strSum); 
    
  
    // Display currency formatted option price // GUSTAF 060628
    txtPriceOptions = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceOptions");
    strOptionSum = CurrencyFormatted(floatOptionSum) + " kr";
    setObjInnerText(txtPriceOptions, strOptionSum); 
    
}

function updateSumEquip(divSummaryID, checkBoxId, optionGrossPrice, optionNetPrice, boolChecked)
{
    // Retreive the Hiddenvalues from the hiddenfields in the application
    hidTotalPriceSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalPrice"); 
    hidTotalOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionPrice");
    hidTotalEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipPrice");
    hidTotalPriceNetSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalNetPrice"); 
    hidTotalNetOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionNetPrice"); 
    hidTotalNetEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipNetPrice"); 
   
   
  // Initiate sum with model price if 0
    if (floatSum == 0)
            floatSum = parseFloat(hidTotalPriceSaved.value);
    if (floatNetSum == 0 )
        floatNetSum = parseFloat(hidTotalPriceNetSaved.value); 
    if (floatNetOptionSum == 0 )
        floatNetOptionSum = parseFloat(hidTotalNetOptionSaved.value);
     if (floatNetEquipSum == 0 )
        floatNetEquipSum = parseFloat(hidTotalNetEquipSaved.value);
        
   // Parse the Price of the Option
    floatOptionSum = parseFloat(hidTotalOptionSaved.value);
    floatEquipSum = parseFloat(hidTotalEquipSaved.value);
    //source = document.getElementById(checkBoxId);
   
   // Remove white spaces from the OptionPrices so that parsefloat will work
    rExp = /\s/gi;
    optionNetPrice = optionNetPrice.replace(rExp, '');
    optionGrossPrice = optionGrossPrice.replace(rExp, '');
    floatPrice = parseFloat(optionGrossPrice);
    floatNetPrice = parseFloat(optionNetPrice); 
    
    // if not a number - return
    if (isNaN(floatPrice))
    {
       return;
    }
    
    // Add/subtract option price to/from sum
    if (boolChecked)
    {
        floatSum = floatSum + floatPrice;
        floatNetSum = floatNetSum + floatNetPrice; //TODO vill ha
        floatEquipSum = floatEquipSum + floatPrice;
        floatNetEquipSum = floatNetEquipSum + floatNetPrice;
    }    
    else
    {
        floatSum = floatSum - floatPrice;
        floatNetSum = floatNetSum - floatNetPrice; //TODO vill ha
        floatEquipSum = floatEquipSum - floatPrice;
        floatNetEquipSum = floatNetEquipSum - floatNetPrice
    }
    
    // Save the new decimal value to the hidden fields
    hidTotalPriceSaved.value = floatSum;
    hidTotalPriceNetSaved.value = floatNetSum;
    hidTotalEquipSaved.value = floatEquipSum;
    hidTotalNetEquipSaved.value = floatNetEquipSum;
    
    
    // Display currency formatted value
    txtTotalPrice = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPrice");
    strSum = CurrencyFormatted(floatSum) + " kr";
    setObjInnerText(txtTotalPrice, strSum); 
    
  
    // Display currency formatted option price // GUSTAF 060628
    txtPriceOptions = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceEquip");
    strOptionSum = CurrencyFormatted(floatEquipSum) + " kr";
    setObjInnerText(txtPriceOptions, strOptionSum); 
    
}




//function updateHiddenSum(divSummaryID, checkBoxId, optionGrossPrice, optionNetPrice)
function showHiddenSum(divSummaryID)
{
    //alert("optionNetPrice: " + optionNetPrice);
    // Get the two hiddenfield variables and set to local variables.
    hidTotalPriceSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalPrice"); 
    hidTotalOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionPrice");
    hidTotalEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipPrice");
    hidTotalPriceNetSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalNetPrice"); 
    hidTotalNetOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionNetPrice"); 
    hidTotalNetEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipNetPrice"); 
    
       
    
    
    // Initiate sum with model price if 0
    if (floatSum == 0)
            floatSum = parseFloat(hidTotalPriceSaved.value);
    if (floatNetSum == 0 )
        floatNetSum = parseFloat(hidTotalPriceNetSaved.value); 
    if (floatNetOptionSum == 0 )
        floatNetOptionSum = parseFloat(hidTotalNetOptionSaved.value);
     if (floatNetEquipSum == 0 )
        floatNetEquipSum = parseFloat(hidTotalNetEquipSaved.value);
  
    // Initiate the FloatOptionSum to the hidden field variable
    floatOptionSum = parseFloat(hidTotalOptionSaved.value);
    floatEquipSum = parseFloat(hidTotalEquipSaved.value);
 
    // Display currency formatted value
    txtTotalPrice = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPrice");
    strSum = CurrencyFormatted(floatSum) + " kr";
    setObjInnerText(txtTotalPrice, strSum); 
    
  
    // Display currency formatted option price 
    txtPriceOptions = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceOptions");
    strOptionSum = CurrencyFormatted(floatOptionSum) + " kr";
    setObjInnerText(txtPriceOptions, strOptionSum); 
    
    // Display currency formatted option price 
    txtPriceEquipments = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceEquip");
    strEquipSum = CurrencyFormatted(floatEquipSum) + " kr";
    setObjInnerText(txtPriceEquipments, strEquipSum); 
    
    
    
   //The hidden values!
    
    // Display currency formatted Gross Total price 
    txtGrossSummaryLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceNetLbl");
    strGrossSumLbl = "Totalt (Netto):";
    setObjInnerText(txtGrossSummaryLbl, strGrossSumLbl); 
    
    txtGrossSummary = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceNet");
    strGrossSum = CurrencyFormatted(floatNetSum) + " kr";
    setObjInnerText(txtGrossSummary, strGrossSum); 
    
    // Display currency formatted Gross Total Option price 
    txtGrossOptionLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtOptionPriceNetLbl");
    strGrossOptionSumLbl = "Tillval (Netto):";
    setObjInnerText(txtGrossOptionLbl, strGrossOptionSumLbl); 
    
    txtGrossOption = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtOptionPriceNet");
    strGrossOptionSum = CurrencyFormatted(floatNetOptionSum) + " kr";
    setObjInnerText(txtGrossOption, strGrossOptionSum); 
    
    // Display currency formatted Gross Total Equipment price 
    txtGrossEquipLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtEquipPriceNetLbl");
    strGrossEquipSumLbl = "Tillbehör (Netto):";
    setObjInnerText(txtGrossEquipLbl, strGrossEquipSumLbl); 
    
    txtGrossEquip = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtEquipPriceNet");
    strGrossEquipSum = CurrencyFormatted(floatNetEquipSum) + " kr";
    setObjInnerText(txtGrossEquip, strGrossEquipSum); 
    
    // Display currency formatted Difference price 
    txtTotalPriceDiffLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiffLbl");
    strSummaryDiffLbl = "Differens (kr):";
    setObjInnerText(txtTotalPriceDiffLbl, strSummaryDiffLbl); 
    
    txtTotalPriceDiff = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiff");
    floatSumExVAT = floatSum * 0.8;
    strDiff = CurrencyFormatted(floatSumExVAT - floatNetSum) + " kr";
    setObjInnerText(txtTotalPriceDiff, strDiff); 
      
      // Display currency formatted Difference price 
    txtTotalPriceDiffPerLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiffPerLbl");
    strSummaryDiffPerLbl = "Differens (%):";
    setObjInnerText(txtTotalPriceDiffPerLbl, strSummaryDiffPerLbl); 
      
    txtTotalPriceDiffPer = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiffPer");
    //strDiffPer = CurrencyFormatted((floatSum - floatNetSum)/floatSum * 100) + " %"; // The old inkl. VAT
    strDiffPer = CurrencyFormatted((floatSumExVAT - floatNetSum)/floatSumExVAT * 100) + " %";
    setObjInnerText(txtTotalPriceDiffPer, strDiffPer); 
}

//function updateHiddenSum(divSummaryID, checkBoxId, optionGrossPrice, optionNetPrice)
function removeHiddenSum(divSummaryID)
{
  
    //alert("optionNetPrice: " + optionNetPrice);
    // Get the two hiddenfield variables and set to local variables.
    hidTotalPriceSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalPrice"); 
    hidTotalOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionPrice");
    hidTotalEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipPrice");
    hidTotalPriceNetSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalNetPrice"); 
    hidTotalNetOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionNetPrice"); 
    hidTotalNetEquipSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenEquipNetPrice"); 
    
       
    
    
    // Initiate sum with model price if 0
    if (floatSum == 0)
            floatSum = parseFloat(hidTotalPriceSaved.value);
    if (floatNetSum == 0 )
        floatNetSum = parseFloat(hidTotalPriceNetSaved.value); 
    if (floatNetOptionSum == 0 )
        floatNetOptionSum = parseFloat(hidTotalNetOptionSaved.value);
     if (floatNetEquipSum == 0 )
        floatNetEquipSum = parseFloat(hidTotalNetEquipSaved.value);
  
    // Initiate the FloatOptionSum to the hidden field variable
    floatOptionSum = parseFloat(hidTotalOptionSaved.value);
    floatEquipSum = parseFloat(hidTotalEquipSaved.value);
 
    // Display currency formatted value
    txtTotalPrice = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPrice");
    strSum = CurrencyFormatted(floatSum) + " kr";
    setObjInnerText(txtTotalPrice, strSum); 
    
  
    // Display currency formatted option price 
    txtPriceOptions = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceOptions");
    strOptionSum = CurrencyFormatted(floatOptionSum) + " kr";
    setObjInnerText(txtPriceOptions, strOptionSum); 
    
    // Display currency formatted option price 
    txtPriceEquipments = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceEquip");
    strEquipSum = CurrencyFormatted(floatEquipSum) + " kr";
    setObjInnerText(txtPriceEquipments, strEquipSum); 
    
    
    
   //The hidden values!
    
    // Display currency formatted Gross Total price 
    txtGrossSummaryLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceNetLbl");
    strGrossSumLbl = "";
    setObjInnerText(txtGrossSummaryLbl, strGrossSumLbl); 
    
    txtGrossSummary = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceNet");
    strGrossSum = "";
    setObjInnerText(txtGrossSummary, strGrossSum); 
    
    // Display currency formatted Gross Total Option price 
    txtGrossOptionLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtOptionPriceNetLbl");
    strGrossOptionSumLbl = "";
    setObjInnerText(txtGrossOptionLbl, strGrossOptionSumLbl); 
    
    txtGrossOption = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtOptionPriceNet");
    strGrossOptionSum = "";
    setObjInnerText(txtGrossOption, strGrossOptionSum); 
    
    // Display currency formatted Gross Total Equipment price 
    txtGrossEquipLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtEquipPriceNetLbl");
    strGrossEquipSumLbl = "";
    setObjInnerText(txtGrossEquipLbl, strGrossEquipSumLbl); 
    
    txtGrossEquip = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtEquipPriceNet");
    strGrossEquipSum ="";
    setObjInnerText(txtGrossEquip, strGrossEquipSum); 
    
    // Display currency formatted Difference price 
    txtTotalPriceDiffLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiffLbl");
    strSummaryDiffLbl = "";
    setObjInnerText(txtTotalPriceDiffLbl, strSummaryDiffLbl); 
    
    txtTotalPriceDiff = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiff");
    strDiff = "";
    setObjInnerText(txtTotalPriceDiff, strDiff); 
      
      // Display currency formatted Difference price 
    txtTotalPriceDiffPerLbl = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiffPerLbl");
    strSummaryDiffPerLbl = "";
    setObjInnerText(txtTotalPriceDiffPerLbl, strSummaryDiffPerLbl); 
      
    txtTotalPriceDiffPer = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPriceDiffPer");
    strDiffPer = "";
    setObjInnerText(txtTotalPriceDiffPer, strDiffPer); 
}



// TODO: Ännu inte färdig, skall implementeras till rabatt sidan!
function calculateOnDiscountSum(divSummaryID, modelProc, utrustningProc, tillbeProc, modellPrice, utrustningPris, tillbehPris)
{
    // Get the hiddenfield variables and set to local variables.
    hidTotalPriceSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalPrice"); 
    hidTotalOptionSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenOptionPrice");
    hidTotalPriceNetSaved = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_decHiddenTotalNetPrice"); 
    
    // Initiate sum with model price if 0
    if (floatSum == 0)
            floatSum = parseFloat(hidTotalPriceSaved.value);
    if (floatNetSum == 0 )
        floatNetSum = parseFloat(hidTotalPriceNetSaved.value); //bör vara: hidGrossSummarySave.value
        
    // Initiate the FloatOptionSum to the hidden field variable
    floatOptionSum = parseFloat(hidTotalOptionSaved.value);

    // Enable parsfloat by removing spaces in the numbers    
    rExp = /\s/gi;
    utrustningProc = utrustningProc.replace(rExp, '');
    floatPrice = parseFloat(utrustningProc);
    floatNetPrice = parseFloat(utrustningProc); // VIllha TODO: bör vara optionGrossPrice
    alert(floatPrice);
      // if not a number - return
    if (isNaN(floatPrice))
    {
       return;
    }
    
     // Save the new decimal value
    hidTotalPriceSaved.value = floatSum;
    hidTotalPriceNetSaved.value = floatNetSum;
    
    // Save Option value ADDED BY GUSTAF 060628
    hidTotalOptionSaved.value = floatOptionSum;
    
    // Display currency formatted value
    txtTotalPrice = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtTotalPrice");
    strSum = CurrencyFormatted(floatSum) + " kr";
    setObjInnerText(txtTotalPrice, strSum); 
    
    // Display currency formatted option price // GUSTAF 060628
    txtPriceOptions = document.getElementById("ctl00_ContentPlaceHolderContent_PriceSum1_txtPriceOptions");
    strOptionSum = CurrencyFormatted(floatOptionSum) + " kr";
    setObjInnerText(txtPriceOptions, strOptionSum); 
}


function CurrencyFormatted(amount)
{
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;

	s = new String(i);

    // Gör treställigt med mellanrum efter varje tresiffer-serie
    arrS = s.split("");
    for (var index = s.length - 4; index >= 0; index = index - 3)
    {
        arrS[index] = arrS[index] + " ";
    }
    s = arrS.join("");

    // Lägg till decimaler
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;

    // Byt ut punkt mot kommatecken	
	s = s.replace(/\./, ",");
	
	return s;
}

function getObjInnerText(obj)
{
    if (document.all) // IE;
        return obj.innerText;
    else if (obj.textContent != undefined)
        return obj.textContent;
    else
        alert("Error: This application does not support your browser. Try again using IE or Firefox.");
} 

function setObjInnerText(obj, strText)
{
    if (document.all) // IE;
        obj.innerText = strText;
    else if (obj.textContent != undefined)
        obj.textContent = strText;
    else
        alert("Error: This application does not support your browser. Try again using IE or Firefox.");
}

function setObjInnerHtml(obj, strText)
{
    if (document.all) // IE;
        obj.innerHTML = strText;
    else if (obj.innerHTML != undefined)
        obj.innerHTML = strText;
    else
        alert("Error: This application does not support your browser. Try again using IE or Firefox.");
} 

 function popUp(URL, id, width, height) 
 {
    //day = new Date();
    //id = day.getTime();
    //eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=200,left = 540,top = 462');");
    return window.open(URL, id, 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height='+ height +',left = 490,top = 390');
    
 }
 
// Sets which page to redirect to after postback on options.aspx
// Invokes when an optiongroup is clicked
function setNextUrl(theUrl)
{
    var nextUrlHidden = document.getElementById("ctl00_ContentPlaceHolderContent_NextUrlHidden");
    nextUrlHidden.value = theUrl;
    //alert("nextUrlHidden.value efter = " + nextUrlHidden.value);
}

function openMovie(intFlashID, intflashWidth, intflashHeight)
{
    var strURL = "media/article/?FlashID=" + intFlashID +"&w="+intflashWidth+"&h="+intflashHeight;
    var strFeatures = "width="+intflashWidth+", height="+intflashHeight;
    var movieHandel = window.open(strURL, 'FlashMovie', strFeatures);
}
