
function ReflectCheckBox ( CheckBoxID, DependentElementID, Inverse )
{
	CBElement = document.getElementById ( CheckBoxID );
	
	if ( ! Inverse )
	{
		if ( CBElement.checked ) 
			ShowObject ( DependentElementID );
		else 
			HideObject ( DependentElementID );
	}

	if ( Inverse )
	{
		if ( ! CBElement.checked ) 
			ShowObject ( DependentElementID );
		else 
			HideObject ( DependentElementID );
	}
	
}

function ReflectCheckBoxEnable ( CheckBoxID, DependentElementID, Inverse )
{
	CBElement = document.getElementById ( CheckBoxID );
	
	if ( ! Inverse )
	{
		if ( CBElement.checked ) 
			EnableObject ( DependentElementID );
		else 
			DisableObject ( DependentElementID );
	}

	if ( Inverse )
	{
		if ( ! CBElement.checked ) 
			EnableObject ( DependentElementID );
		else 
			DisableObject ( DependentElementID );
	}
	
}


function ShowObject( ElementID )
{
	Element=document.getElementById (ElementID);
	Element.style.display = '';
}


function HideObject(ElementID)
{
	Element=document.getElementById (ElementID);
	Element.style.display = 'none';
}

function EnableObject( ElementID )
{
	Element=document.getElementById (ElementID);
	Element.disabled = false;
}

function DisableObject( ElementID )
{
	Element=document.getElementById (ElementID);
	Element.disabled = true;
}


//--------------------------------
// Konfigurace 
//----------------------------------

/* SVID = subvariant ID, PFID = product feature id */
function UpdateVCSelect ( SVID, PFID )
{
	VOptionElement = document.getElementById ( 'VOption_' + SVID + '_' + PFID );
	VOptionElement.selected=true;
	xxRecalculate();
}		


function xxRecalculate()
{
	var Price_VatEx = BasePrice_VatEx;
	var Price_VatInc = BasePrice_VatInc;  
	
	for ( ProductFeatureID in ProductFeatureIDs )
	{
		var SelectedSubVariantID = document.getElementById('SubVariants_'+ ProductFeatureID ).value;
		Price_VatEx += PriceDiff_VatEx [ ProductFeatureID ][ SelectedSubVariantID ];
		Price_VatInc += PriceDiff_VatInc [ ProductFeatureID ] [SelectedSubVariantID ];
	}
	
	InjectPriceVatInc ( FormatPrice ( Price_VatInc ) );
	InjectPriceVatEx ( FormatPrice ( Price_VatEx ) );

	
	/* TRY PHOTO SWITCHING */
	
	try {
		x_UpdatePhotos ();
	}
	catch (e) {}
		
}

function FormatPrice ( Price )
{
	Price = Math.round (Price)
	
	PriceInHalere = Math.floor ( Price * 100 );
	Koruny = Math.floor ( Price );
	KorunyInHalere = Koruny * 100;

	Halere = PriceInHalere - KorunyInHalere;
	
	HalereText = Halere;
	
	if ( Halere < 10 )
		HalereText = '0' + Halere; 
		
	if ( Halere == 0 )
		HalereText = '-' ;
	
	
	Tisicikoruny = Math.floor ( Koruny / 1000 );
	DoTisicikoruny = Koruny - (Tisicikoruny * 1000 );
	
	FormattedPrice = '';
	if ( Tisicikoruny > 0 )
	{
		FormattedPrice += Tisicikoruny + '.';
		if ( DoTisicikoruny < 10 )	FormattedPrice +='0';
		if ( DoTisicikoruny < 100 ) FormattedPrice +='0';
	}
	
	FormattedPrice += DoTisicikoruny + ',' + HalereText;
	
	return FormattedPrice;
}

function InjectPriceVatInc ( NewPriceString )
{
	PriceVatIncElement = document.getElementById ('PriceVatInc');
	PriceVatIncElement.innerHTML = NewPriceString;
}

function InjectPriceVatEx ( NewPriceString )
{
	PriceVatExElement = document.getElementById ('PriceVatEx');
	PriceVatExElement.innerHTML = NewPriceString;
}

