﻿var previousSelect;

function switchImage(MainImage, image, storage, imageUrl, colorid)
{
    var mImg = document.getElementById(MainImage);
    var mStorage = document.getElementById(storage);
    var mImage = document.getElementById(imageUrl);
    var container = document.getElementById("item" + colorid);
    
    if(colorid != mStorage.value)
    {
        
        container.style.backgroundColor = "#dbe3ed";
        container.style.borderColor = "#b1cbed"
        
        if(previousSelect != null)
        {
            previousSelect.style.backgroundColor = "#f1f4f8";
            previousSelect.style.borderColor = "#f1f4f8"
        }
        else
        {
            var defaultItem = document.getElementById("item" + mStorage.value)
            defaultItem.style.backgroundColor = "#f1f4f8";
            defaultItem.style.borderColor = "#f1f4f8"
        }    
        mImg.src = image;
        previousSelect = container;
        
        mStorage.value = colorid;
        mImage.value = image;
   }    
}


function adjustOption(OptionID, listID)
{
    var option = document.getElementById('option' + OptionID);
    var list = document.getElementById(listID);
    
    if(list.value.length == 0)
    {
        list.value = ",";
    }    
    
    if(list.value.indexOf("," + OptionID + ",") >= 0)
    {
        option.src = "/_images/buildyourown/unchecked.gif";
        list.value = list.value.replace("," + OptionID + ",", ",");
    }
    else
    {
        option.src = "/_images/buildyourown/checked.gif";
        list.value = list.value + OptionID + ","
    }
}


function DisplayImage(picURL,picWidth,picHeight){
	newWindow=window.open(picURL,'newWin','toolbar=no,width='+picWidth+',height='+picHeight)
	newWindow.document.write('<html><head><\/head><body background="'+picURL+'"><\/body><\/html>')
	newWindow.resizeBy(picWidth-newWindow.document.body.clientWidth,picHeight-newWindow.document.body.clientHeight)
	newWindow.focus()
}


function setPageandPerformAction(hiddenID, uniqueID, page)
{
    var toPage = document.getElementById(hiddenID);    
    toPage.value = page;
    
    var theForm2 = document.forms['aspnetForm'];
    if (!theForm2) {
        theForm2 = document.aspnetForm;
    }    
    theForm2.target = "_self";
       
    __doPostBack(uniqueID, "");
}


function adjustTarget(pTarget)
{
    var theForm2 = document.forms['aspnetForm'];
    if (!theForm2) {
        theForm2 = document.aspnetForm;
    }
    
    theForm2.target = pTarget;
}

