﻿// JScript File

/*
Author: E.Post
Created: 7/8/08
Purpose: In product page, "Photos" buttons need different styling for on/off positions.
    This function first loops through all buttons, turning them off and then explicitly sets ony the "btnOn" button to "On" via CSS class.
*/

function changeBtnClass(btnOn, btnCount)
{
    
    //Loop through all buttons and set css to off.
    for (i=0; i<btnCount; i++)
    {
        document.getElementById('ctl00_cph_content_btn' + (i+1)).className='photosbtn_off';
    }
    
    //Set on buttons CSS class.
    document.getElementById(btnOn).className='photosbtn_on';
}

/*
Author: E.Post
Created: 7/22/08
Purpose: Used by "Step 1" selections to change "Dimensions" image.
*/

function ChangeDisplay(pmid, img, control1, control2)
{   
	document.getElementById(img).src='';
	
}

/*
Author: E.Post
Created: 7/29/08
Purpose: Used by "Step 2" color selections to change color swatch.
*/

function ChangeLabelColor(lbl, fieldName, color)
{
	document.getElementById(lbl).innerHTML = fieldName + "<span class='fieldlabel'>" + color + "</span>";
}

/*
Author: E.Post
Created: 7/29/08
Purpose: Used by "Step 2" to change the flash image
*/

function ChangeFlashColor(mColor,mHex,cName,mName)
{
     var flashMovie=getFlashMovieObject("colorConcept");
     //alert(flashMovie);
     var red, drkred, lghtred, offsetred;
     var green, drkgreen, lghtgreen, offsetgreen;
     var blue, drkblue, lghtblue, offsetblue;
     red = hextorgb(mHex,"R");
     green = hextorgb(mHex, "G");
     blue = hextorgb(mHex, "B");
     
     //now make the offset rgb for the corners etc....
     if (red - 75 > 0)
     {
		offsetred = red - 75;
     }
     else
     {
		offsetred = 0;
     }
     //green
     if (green - 75 > 0)
     {
		offsetgreen = green - 75;
     }
     else
     {
		offsetgreen = 0;
     }
     //blue
     if (blue - 75 > 0)
     {
		offsetblue = blue - 75;
     }
     else
     {
		offsetblue = 0;
     }
     //alert("name: " + mName);
     flashMovie.SetVariable("/:metalTubeColor",mColor);
     flashMovie.SetVariable("/:modelName",mName);
     flashMovie.SetVariable("/:rOffsetMetal",offsetred);
     flashMovie.SetVariable("/:gOffsetMetal",offsetgreen);
     flashMovie.SetVariable("/:bOffsetMetal",offsetblue);
}

//hex and RGB formatting and reformatting
function hextorgb(hexdec,clr) 
{
	n1 = replacevals(hexdec.charAt(0));
	n2 = replacevals(hexdec.charAt(1));
	n3 = replacevals(hexdec.charAt(2));
	n4 = replacevals(hexdec.charAt(3));
	n5 = replacevals(hexdec.charAt(4));
	n6 = replacevals(hexdec.charAt(5));

	var returnval = ((16 * n1) + (1 * n2));
	var returnval1 = 16 * n3 + n4;
	var returnval2 = 16 * n5 + n6;
	
	if (clr == "R")
	{
		return ((16 * n1) + (1 * n2))
	}
	
	if (clr == "G")
	{
		return ((16 * n3) + (1 * n4))
	}
	
	if (clr == "B")
	{
		return ((16 * n5) + (1 * n6))
	}

	//return ((16 * n1) + (1 * n2))+","+((16 * n3) + (1 * n4))+","+((16 * n5) + (1 * n6));
}

function replacevals(n) 
{
	if (n == "a" || n == "A") { n = "10"; }
	if (n == "b" || n == "B") { n = "11"; }
	if (n == "c" || n == "C") { n = "12"; }
	if (n == "d" || n == "D") { n = "13"; }
	if (n == "e" || n == "E") { n = "14"; }
	if (n == "f" || n == "F") { n = "15"; }

	return n
}

/*
Author: E.Post
Created: 1/12/09
Purpose: Used by "Step 1" to change dimension image
*/

function ChangeDimensionImg_AnthroBench(rb1, rb2, rb3, img1, img2, hid1, hid2) 
{
    imgSrc = "";
 
    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {
            
            rb1SelValue = rb1[i].value;
        }
    }
    
      //Retrieve selected value from rb2
    rbLen = rb2.length;
    rb2SelValue = 0;

    for (i = 0; i < rbLen; i++) 
    {
        if (rb2[i].checked) 
        {
            rb2SelValue = rb2[i].value;
        }
    }
    
    prefixImg1 = "B";
    if (rb2SelValue == "28")
    {
        prefixImg1 = "S";
    }
    
    //Retrieve selected value from rb2
    rbLen = rb3.length;
    rb3SelValue = 0;

    for (i = 0; i < rbLen; i++) 
    {
        if (rb3[i].checked) 
        {
            rb3SelValue = rb3[i].value;
        }
    }

    img1.src = "images/lineart/" + prefixImg1 + rb1SelValue + rb3SelValue + ".gif";
    hid1.value = img1.src;
    img2.src = "images/lineart/SPerspective_" + rb3SelValue + ".gif";
    hid2.value = img2.src;
}

function ChangeDimensionImg_UtilityBench(rb1, img1, img2, hid1, hid2) 
{
    imgSrc = "";
 
    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {
            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/UB" + rb1SelValue + "35.gif";
    hid1.value = img1.src;    
    hid2.value = img2.src;
}

function ChangeDimensionImg_AnthroCart36(rb1, img1, img2, hid1, hid2) 
{
    imgSrc = "";
 
    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {
            
            rb1SelValue = rb1[i].value;
        }
    }
        
    appendImg1 = "";
    if (rb1SelValue == "Non Recessed")
    {
        appendImg1 = "NR";
    }
    
    img1.src = "images/lineart/GT16" + appendImg1 + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_PrinterCart(rb1, img1, hid1) 
{
    imgSrc = "";
 
    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {
            
            rb1SelValue = rb1[i].value;
        }
    }

    switch (rb1SelValue)
    {
        case "24w X 28h":
            imgSrc= "030";
            break;
        case "24w X 20h":
            imgSrc= "035";
            break;
        case "36w X 28h":
            imgSrc= "080";
            break;
        case "36w X 20h":
            imgSrc= "085";
            break;
    }

    img1.src = "images/lineart/" + imgSrc + ".gif";    
    hid1.value = img1.src;    
}

function ChangeDimensionImg_IdeaCart(rb1, img1, hid1) 
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    imgSrc = "AA02";
    if (rb1SelValue == "25-30")
    {
        imgSrc = "AA03";
    }

    img1.src = "images/lineart/" + imgSrc + ".gif";    
    hid1.value = img1.src;    
}

function ChangeDimensionImg_ElevateSingleSurface(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/ELTA1" + rb1SelValue + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_ElevateAdjusta(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/ELTAD" + rb1SelValue + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_FitSystemStandardUnit(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/F" + rb1SelValue + "29.gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_FitSystemAdjustaUnit(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/FAJ" + rb1SelValue + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_FitSystemUtilityUnit(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/FY" + rb1SelValue + "29.gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_FitSystemSideTable(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/FST" + rb1SelValue + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_USSecurityCart(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/SEC" + rb1SelValue + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

function ChangeDimensionImg_USLaptopStorageCart(rb1, img1, hid1) 
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }
    
    imgSrc = "20";
    if (rb1SelValue == "30 unit")
    {
        imgSrc = "30";
    }
    
    img1.src = "images/lineart/LTSC" + imgSrc + ".gif";    
    hid1.value = img1.src;    
}

function ChangeDimensionImg_USConvoi(rb1, rb2, img1, hid1) 
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }
    
    rbLen = rb2.length;
    rb2SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb2[i].checked) 
        {            
            rb2SelValue = rb2[i].value;
        }
    }
    
    switch (rb2SelValue)
    {
        case "30":
            rb2SelValue= "ST";
            break;
        case "36":
            rb2SelValue= "TL";
            break;
        case "42":
            rb2SelValue= "XT";
            break;
    }
    
    img1.src = "images/lineart/BU" + rb1SelValue + rb2SelValue + ".gif";  
    hid1.value = img1.src;    
}

function ChangeDimensionImg_USSpacePal(rb1, img1) 
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }

    img1.src = "images/lineart/SP" + rb1SelValue + ".gif";    
}

function ChangeDimensionImg_ZidoFixedHeight(rb1, rb2, img1, hid1) 
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }
    
    rbLen = rb2.length;
    rb2SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb2[i].checked) 
        {            
            rb2SelValue = rb2[i].value;
        }
    }

    img1.src = "images/lineart/ZD" + rb1SelValue + rb2SelValue + ".gif";    
    hid1.value = img1.src;    
}

function ChangeDimensionImg_ZidoAdjustableHeight(rb1, img1, img2, hid1, hid2)
{
    imgSrc = "";

    //Retrieve selected value from rb1
    rbLen = rb1.length;
    rb1SelValue = 0;
    
    for (i = 0; i < rbLen; i++) 
    {
        if (rb1[i].checked) 
        {            
            rb1SelValue = rb1[i].value;
        }
    }
   
    img1.src = "images/lineart/ZAH" + rb1SelValue + ".gif";    
    hid1.value = img1.src;
    hid2.value = img2.src;
}

/* Display Accessory window vertically and horizontally centered */
function showAccessoryWindow(divid)
{
    if (document.getElementById && !document.all)  
    {
        //FF & Safari
        var IpopTop = (window.innerHeight - document.getElementById("ctl00_cph_content_pnl_accessory").offsetHeight)/2;
        var IpopLeft = (window.innerWidth - document.getElementById("ctl00_cph_content_pnl_accessory").offsetWidth)/2;
        
        //Adjust
        IpopTop -= 20;
        IpopLeft -= 180;
        
        document.getElementById("ctl00_cph_content_pnl_accessory").style.left = IpopLeft + window.pageXOffset + "px";
        document.getElementById("ctl00_cph_content_pnl_accessory").style.top = IpopTop + window.pageYOffset + "px";
    }
    else  
    {
        //IE
        var IpopTop = (document.body.clientHeight - document.getElementById("ctl00_cph_content_pnl_accessory").offsetHeight)/2;
        var IpopLeft = (document.body.clientWidth - document.getElementById("ctl00_cph_content_pnl_accessory").offsetWidth)/2;
        
        //Adjust
        IpopTop += 360;
        IpopLeft -= 180;
        
        document.getElementById("ctl00_cph_content_pnl_accessory").style.left = IpopLeft + document.body.scrollLeft + "px";
        document.getElementById("ctl00_cph_content_pnl_accessory").style.top = IpopTop + document.body.scrollTop + "px";
    }
}

/* Display Accessory window vertically and horizontally centered */
function showConfiguratorWarning(divid)
{
    if (document.getElementById && !document.all)  
    {
        //FF & Safari
        var IpopTop = (window.innerHeight - document.getElementById("ctl00_cph_content_panel_accessorywarning").offsetHeight)/2;
        var IpopLeft = (window.innerWidth - document.getElementById("ctl00_cph_content_panel_accessorywarning").offsetWidth)/3;
        
        //Adjust
        IpopTop += 60;
        /* IpopLeft -= 300; */
        
        document.getElementById("ctl00_cph_content_panel_accessorywarning").style.left = IpopLeft + window.pageXOffset + "px";
        document.getElementById("ctl00_cph_content_panel_accessorywarning").style.top = IpopTop + window.pageYOffset + "px";
    }
    else  
    {
        //IE
        var IpopTop = (document.body.clientHeight - document.getElementById("ctl00_cph_content_panel_accessorywarning").offsetHeight)/2;
        var IpopLeft = (document.body.clientWidth - document.getElementById("ctl00_cph_content_panel_accessorywarning").offsetWidth)/3;
        
        //Adjust
        IpopTop += 60;
        /* IpopLeft -= 300; */
        
        document.getElementById("ctl00_cph_content_panel_accessorywarning").style.left = IpopLeft + document.body.scrollLeft + "px";
        document.getElementById("ctl00_cph_content_panel_accessorywarning").style.top = IpopTop + document.body.scrollTop + "px";
    }
}

