﻿// NUNES Javascript File

// Product Detail Option Switcher

function productSwitch(optionValue, groupIdx, productName, productSRC, productWIDTH, productHEIGHT, productALT, productFullSRC, productFullWIDTH, productFullHEIGHT, productFullALT)
{
	// Change product details for Cart
    document.getElementById(groupIdx).value = optionValue;
    
    // Change product image
    document.display.src = productSRC;
    document.display.width = productWIDTH;
    document.display.height = productHEIGHT;
    document.display.alt = productALT;
    
    // Change product FullSize Image
    if (productFullSRC!='')
    {
    document.detail.src = productFullSRC;
    document.detail.width = productFullWIDTH;
    document.detail.height = productFullHEIGHT;
    document.detail.alt = productFullALT;
    document.getElementById('fullSizeOptionTitle').innerHTML = productName;
    
	// Change FullSize Position so it is centered and show
	var leftMargin = (756 - productFullWIDTH)/2;
	document.getElementById('fullSizeImage').style.left = leftMargin + 'px';
	//document.getElementById('fullSizeImage').style.display = 'none';
	}
}

function showFullSize()
{
	
	document.getElementById('fullSizeImage').style.display = 'block';
}

function displayDiscountSections(group)
{
	var group_opt = group + '_opt';
    //close any other open classes
     var elems = getElementsByClassName(document, 'currentSection')
     for(var i = 0; i < elems.length; i++)
     {
        elems[i].className = 'discountSection'
     }
     var elems = getElementsByClassName(document, 'currentOpt')
     for(var i = 0; i < elems.length; i++)
     {
        elems[i].className = 'discountOpt'
     }
    //open our unit by changing class
    document.getElementById(group).className = 'currentSection';
    document.getElementById(group_opt).className = 'currentOpt';    
}
function getElementsByClassName(node, classname)
{
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))a.push(els[i]);
    return a;
}
function currencyPicker ()
{
	document.getElementById('currencyOptions').style.display = 'inline';
}