﻿// Product Scripts

function ChangeVariant(sBaseProdID, sTypeName)
{
	var iSizeID = $get(sizeID).value;
	Prostar_WebService.SetAttributes(sBaseProdID, sTypeName, iSizeID, "-1", ChangeVariant_Response);
}

function ChangeVariant_Response(Results)
{
	$get("ProductStockCode").innerHTML = Results[1];
	//$get("ProductStockLevel").innerHTML = Results[2];
	$get("ProductPrice").innerHTML = Results[3];
	$get(hidStockCode).value = Results[4];

	if(Results[0] == "false")
	{
		$get("BasketButton").style.visibility = "hidden";
	}
	else
	{
		$get("BasketButton").style.visibility = "visible";
	}
	
	
//	if(Results[3] != "-1" && Results[4] != "-1")
//	{
//        var iVarCount = parseInt(Results[3]);
//        var iVarNum = parseInt(Results[4]);
//        
//        for(var i = 1; i <= iVarCount; i++)
//        {
//            $get('ProductImage').style.visibility = "visible";
//            $get('ProductImage').style.position = "static";
//            $get('ProductImage').style.display = "block";
//            
//            if(i == iVarNum)
//            {
//                $get('VariantImages' + i).style.visibility = "visible";
//                $get('VariantImages' + i).style.position = "static";
//                
//                $get('NoProductImage').style.visibility = "hidden";
//                $get('NoProductImage').style.position = "absolute";
//            }
//            else
//            {
//                $get('VariantImages' + i).style.visibility = "hidden";
//                $get('VariantImages' + i).style.position = "absolute";
//            }
//        }
//    }
//    else
//    {
//        $get('NoProductImage').style.visibility = "visible";
//        $get('NoProductImage').style.position = "static";
//        $get('ProductImage').style.visibility = "hidden";
//        $get('ProductImage').style.position = "absolute";
//        $get('ProductImage').style.display = "none";
//    }
}





// change the tab for the related products /size chart etc.
function changeTab(iTab)
{
    $get('Body1').style.display = "none";
    $get('Body2').style.display = "none";
    $get('Body3').style.display = "none";
    
    $get('Body' + iTab).style.display = "inline";
    
    $get('Header1').style.color = "#979797";
    $get('Header2').style.color = "#979797";
    $get('Header3').style.color = "#979797";
    $get('Header1').style.fontWeight = "normal";
    $get('Header1').style.fontWeight = "normal";
    $get('Header1').style.fontWeight = "normal";
    
    
    $get('Header' + iTab).style.color = "#343434";
    $get('Header' + iTab).style.fontWeight = "bold";
}



function ChangeBasketItemBackground(iItemNum, sColor) {
	$get("BasketItem" + iItemNum).style.background = sColor;
}



// change the tab for the related products /size chart etc.
function changeTab(iTab)
{
    $get('Body1').style.display = "none";
    $get('Body2').style.display = "none";
    $get('Body3').style.display = "none";
    
    $get('Body' + iTab).style.display = "inline";
    
    $get('Header1').style.fontWeight = "normal";
    $get('Header2').style.fontWeight = "normal";
    $get('Header3').style.fontWeight = "normal";
    
    $get('Header1').style.color = "#bbb";
    $get('Header2').style.color = "#bbb";
    $get('Header3').style.color = "#bbb";
    
    $get('Header' + iTab).style.fontWeight = "bold";
    $get('Header' + iTab).style.color = "#fff";
}
