// Declar variabilele globale
var currentProductsPrice;

var selectedInstrumentProducts_id;
var selectedInstrumentCode;
var selectedInstrumentName;

var sessionName;
var sessionId;

var instrument;

var noBowAttributesIds_option_id;
var noBowAttributesIds_attribute_id;
var noCaseAttributesIds_option_id;
var noCaseAttributesIds_attribute_id;

var linkCurrentPage;

var selected_attribute_id = new Array();

var option_id_s = new Array();
var TabelaProdus_litere_s = new Array();
var TabelaProdus_produs_s = new Array();
var TabelaProdus_produs_plural_s = new Array();

var DenumireIs = new Array();
var CodIs = new Array();
var CaleIntIs = new Array();
var NumePoza1Is = new Array();
var NumePozaPIs = new Array();
var PozaMareIs = new Array();

var attribute_id_s = new Array();
var attribute_cod_s = new Array();
var attribute_name_s = new Array();
var attribute_description_s = new Array();
var attribute_features_s = new Array();
var attribute_CaleInt_attribute_PozaMica_s = new Array();
var attribute_CaleInt_attribute_PozaMare_s = new Array();
var attribute_prefix_attribute_price_s = new Array();

var attribute_id_of_options = new Array();
var attribute_cod_of_options = new Array();
var attribute_name_of_options = new Array();
var attribute_description_of_options = new Array();
var attribute_features_of_options = new Array();
var attribute_CaleInt_attribute_PozaMica_of_options = new Array();
var attribute_CaleInt_attribute_PozaMare_of_options = new Array();
var attribute_prefix_attribute_price_of_options = new Array();
// End: Declar variabilele globale


function createCookie() // Nu e folosita nicaieri.
	{
	var expireDate  = new Date();
	expireDate.setMonth(expireDate.getMonth() + 6);
	var jsE = "yes";
	document.cookie = "jsE=" + jsE + "; path=/; expires=" + expireDate.toGMTString();
	}

function deleteCookie() // Nu e folosita nicaieri.
	{
	var expireDate  = new Date();
	expireDate.setDate(expireDate.getDate() - 1);
	var jsE = "yes";
	document.cookie = "jsE=; path=/; expires=" + expireDate.toGMTString();
	}


function redirectToAcc(redirectionLink)
	{
	document.location = "#" + redirectionLink;
	}


function setXmlFileName(fileName)
	{
	var xmlFile = 'xml/' + fileName;
	//alert(xmlFile);
	return xmlFile;
	}


function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}
// end of function CommaFormatted()

function addCommas(nStr)
	{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1))
		{
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
		}
	return x1 + x2;
	}


function setNoBowNoCase()
	{
	for(var i=0; i<option_id_s.length; i++)
		{
		for(var j=0; j<attribute_name_of_options[i].length; j++)
			{
			//if ((option_id_s[i] == '6' || option_id_s[i] == '7') && attribute_name_of_options[i][j].match("No "))
			if ((option_id_s[i] == noBowAttributesIds_option_id && attribute_id_of_options[i][j] == noBowAttributesIds_attribute_id) || (option_id_s[i] == noCaseAttributesIds_option_id && attribute_id_of_options[i][j] == noCaseAttributesIds_attribute_id))
				{
				var accSelectionName = attribute_cod_of_options[i][j];
				var accOptionId = option_id_s[i];
				var accOptionValueId = attribute_id_of_options[i][j];
				var accSelectionValue = TabelaProdus_litere_s[i];
				var accOptionName = TabelaProdus_produs_s[i];
				var accOptionValueName = (attribute_name_of_options[i][j].replace("'","")).replace('"', '&quot;');
				var accDescription = (attribute_description_of_options[i][j].replace("'","")).replace('"', '&quot;');
				var accFeatures = (attribute_features_of_options[i][j].replace("'","")).replace('"', '&quot;');
				var accPictureLink = attribute_CaleInt_attribute_PozaMica_of_options[i][j];
				var accCTEPictureLink = attribute_CaleInt_attribute_PozaMare_of_options[i][j];
				var accPriceChange = attribute_prefix_attribute_price_of_options[i][j];
	
				updateCurrentProductDetailsSelection(currentProductsPrice, accSelectionName, accOptionId, accOptionValueId, accSelectionValue, accOptionName, accOptionValueName, accDescription, accFeatures, accPictureLink, accCTEPictureLink, accPriceChange);
				}
			}
		}
	}


function showNewCurrentLSelection(LSelectionId)
	{
	if (typeof LSelectionId == "string" && LSelectionId.length > 0)
		{
		var LSelection = document.getElementById(LSelectionId);
		if (LSelection)
			{
			//alert("Am gasit elementul cu id-ul: " + LSelectionId);
			LSelection.selected = true;
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + LSelectionId);
			return;
			}
		}
	}


function showNewCurrentRBSelection(RBSelectionId)
	{
	if (typeof RBSelectionId == "string" && RBSelectionId.length > 0)
		{
		var RBSelection = document.getElementById(RBSelectionId);
		if (RBSelection)
			{
			//alert("Am gasit elementul cu id-ul: " + RBSelectionId);
			RBSelection.checked = true;
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + RBSelectionId);
			return;
			}
		}
	}


function showNewBlock(blockId, optionValue_name)
	{
	if (typeof blockId == "string" && blockId.length > 0)
		{
		var block = document.getElementById(blockId);
		if (block)
			{
			//alert("Am gasit elementul cu id-ul: " + blockId);
			if (optionValue_name.match("No "))
				{
				block.style.display = 'none';
				}
				else
				{
				block.style.display = 'block';
				}
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + blockId);
			return;
			}
		}
	}


function showNewPictureBlock(CTEpictureId, optionValue_pictureLink)
	{
	if (typeof CTEpictureId == "string" && CTEpictureId.length > 0)
		{
		var CTEpicture = document.getElementById(CTEpictureId);
		if (CTEpicture)
			{
			//alert("Am gasit elementul cu id-ul: " + CTEpictureId);
			if (optionValue_pictureLink.match(".gif") || optionValue_pictureLink.match(".jpg"))
				{
				CTEpicture.style.display = 'block';
				}
				else
				{
				CTEpicture.style.display = 'none';
				}
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + CTEpictureId);
			return;
			}
		}
	}


function showNewCurrentPicture(pictureId, optionValue_pictureLink, CTEpictureId, optionValue_CTEpictureLink)
	{
	if (typeof pictureId == "string" && pictureId.length > 0)
		{
		var picture = document.getElementById(pictureId);
		if (picture)
			{
			//alert("Am gasit elementul cu id-ul: " + pictureId);
			picture.src = optionValue_pictureLink;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + pictureId);
			}
		var CTEpicture = document.getElementById(CTEpictureId);
		if (CTEpicture)
			{
			//alert("Am gasit elementul cu id-ul: " + CTEpictureId);
			CTEpicture.href = "picture_detail_site.php?adresa=" + optionValue_CTEpictureLink;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + CTEpictureId);
			}
		}
	}


function showNewCurrentName(nameId, optionValue_name)
	{
	if (typeof nameId == "string" && nameId.length > 0)
		{
		var name = document.getElementById(nameId);
		if (name)
			{
			//alert("Am gasit elementul cu id-ul: " + nameId);
			name.innerHTML = optionValue_name;
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + nameId);
			return;
			}
		}
	}


function showNewCurrentValue(nameId, optionValue_name)
	{
	if (typeof nameId == "string" && nameId.length > 0)
		{
		var name = document.getElementById(nameId);
		if (name)
			{
			//alert("Am gasit elementul cu id-ul: " + nameId);
			name.value = optionValue_name;
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + nameId);
			return;
			}
		}
	}


function showNewCurrentDescription(descriptionId, optionValue_description)
	{
	if (typeof descriptionId == "string" && descriptionId.length > 0)
		{
		var description = document.getElementById(descriptionId);
		if (description)
			{
			//alert("Am gasit elementul cu id-ul: " + descriptionId);
			description.innerHTML = optionValue_description;
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + descriptionId);
			return;
			}
		}
	}


function showNewCurrentFeatures(featuresId, optionValue_features)
	{
	if (typeof featuresId == "string" && featuresId.length > 0)
		{
		var features = document.getElementById(featuresId);
		if (features)
			{
			//alert("Am gasit elementul cu id-ul: " + featuresId);
			if (optionValue_features == '') {
				features.innerHTML = "";
				return;
			}
			else {
				features.innerHTML = "<li>" + optionValue_features.replace(/; /g, "</li>" + "<li>") + "</li>";
				return;
			}
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + featuresId);
			return;
			}
		}
	}


function showNewCurrentAddSubtractLSelection(addSubtractId, optionValue_addSubtractLSelection, optionValue_name)
	{
	if (typeof addSubtractId == "string" && addSubtractId.length > 0)
		{
		optionValue_addSubtractLSelection = parseFloat(optionValue_addSubtractLSelection).toFixed(2);
		var addSubtract = document.getElementById(addSubtractId);
		if (addSubtract)
			{
			//alert("Am gasit elementul cu id-ul: " + addSubtractId);
			if (optionValue_addSubtractLSelection < 0)
				{
				addSubtract.innerHTML = optionValue_name + " (Subtract " + "$" + ((-1) * optionValue_addSubtractLSelection) + ") ";
				}
				else if (optionValue_addSubtractLSelection == 0)
					{
					addSubtract.innerHTML = optionValue_name + "";
					}
					else
					{
					addSubtract.innerHTML = optionValue_name + " (Add " + "$" + optionValue_addSubtractLSelection + ") ";
					}
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + addSubtractId);
			return;
			}
		}
	}


function showNewCurrentAddSubtractRBSelection(addSubtractId, optionValue_addSubtractRBSelection)
	{
	if (typeof addSubtractId == "string" && addSubtractId.length > 0)
		{
		optionValue_addSubtractRBSelection = parseFloat(optionValue_addSubtractRBSelection).toFixed(2);
		var addSubtract = document.getElementById(addSubtractId);
		if (addSubtract)
			{
			//alert("Am gasit elementul cu id-ul: " + addSubtractId);
			if (optionValue_addSubtractRBSelection < 0)
				{
				addSubtract.innerHTML = "Subtract " + "$" + ((-1) * optionValue_addSubtractRBSelection);
				}
				else if (optionValue_addSubtractRBSelection == 0)
					{
					addSubtract.innerHTML = "";
					}
					else
					{
					addSubtract.innerHTML = "Add " + "$" + optionValue_addSubtractRBSelection;
					}
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + addSubtractId);
			return;
			}
		}
	}


function showNewProductsPrice(priceId, priceValue)
	{
	priceValue+'';//alert('priceValue: ' + priceValue);
	var a = priceValue.split('$',2)
	var n = parseFloat(a[1]).toFixed(2);
	var CFpriceValue = '$' + CommaFormatted(n);
	if (priceId.length > 0)
		{
		var price = document.getElementById(priceId);
		if (price)
			{
			//alert("Am gasit elementul cu id-ul: " + priceId);
			price.innerHTML = CFpriceValue;
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + priceId);
			return;
			}
		}
	}


function updateShoppingCartAttributes(optionId, optionValueId)
	{
	if (typeof optionId == "string" && optionId.length > 0)
		{
		var option = document.getElementById("id[" + optionId + "]");
		if (option)
			{
			//alert("Am gasit elementul cu id-ul: " + "id[" + optionId + "]");
			option.value = optionValueId;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + "id[" + optionId + "]");
			}
		option = document.getElementById("IALid[" + optionId + "]");
		if (option)
			{
			//alert("Am gasit elementul cu id-ul: " + "id[" + optionId + "]");
			option.value = optionValueId;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + "id[" + optionId + "]");
			}
		}
	return;
	}


function updateCTELinks(product_id)
{
	var attributes='';
	for(var i=0; i<attribute_id_of_options.length; i++)
	{
		var dropdownIndex = document.getElementById('currentId' + option_id_s[i] + '_LSelection').selectedIndex;
		attributes += '{' + option_id_s[i] + '}' + attribute_id_of_options[i][dropdownIndex];
	}
	//alert(attributes);
	var allAs = new Array();
	allAs = document.getElementsByTagName('a');
	//alert(allAs.length);
	for (var i=0; i<allAs.length; i++)
	{
		var newLink='';
		if (allAs[i].href.match('picture_detail_site.php'))
		{
			var a = allAs[i].href.split('?',2);
			var d = a[1].split('&',1);
			newLink = a[0] + '?' + d[0] + '&rP=OutfitIn.php?products_id=' + product_id + attributes;
			allAs[i].href = newLink;
		}
	}
}


function updateSelectWithoutBowAndCaseLinks(product_id)
{
	var attributes='';
	for(var i=0; i<attribute_id_of_options.length; i++)
	{
		var dropdownIndex = document.getElementById('currentId' + option_id_s[i] + '_LSelection').selectedIndex;
		if (option_id_s[i] != noBowAttributesIds_option_id && option_id_s[i] != noCaseAttributesIds_option_id)
		{
			attributes += '{' + option_id_s[i] + '}' + attribute_id_of_options[i][dropdownIndex];
		}
	}
	//alert(attributes);
	var allAs = new Array();
	allAs = document.getElementsByTagName('a');
	//alert(allAs.length);
	for (var i=0; i<allAs.length; i++)
	{
		var newLink='';
		if (allAs[i].id == 'current_SelectWithoutBowAndCase')
		{
			var a = allAs[i].href.split('?', 1);
			
			newLink = a[0] + '?products_id=' + product_id + '{' + noBowAttributesIds_option_id + '}' + noBowAttributesIds_attribute_id + '{' + noCaseAttributesIds_option_id + '}' + noCaseAttributesIds_attribute_id + attributes;
			allAs[i].href = newLink;
		}
	}
	
	var isNoBowAndNoCase = false;
	var isNoBow = false;
	var isNoCase = false;
	for(var i=0; i<attribute_id_of_options.length; i++)
	{
		var dropdownIndex = document.getElementById('currentId' + option_id_s[i] + '_LSelection').selectedIndex;
		//if ((option_id_s[i] == '6' || option_id_s[i] == '7') && attribute_name_of_options[i][j].match("No "))
		if (option_id_s[i] == noBowAttributesIds_option_id && attribute_id_of_options[i][dropdownIndex] == noBowAttributesIds_attribute_id)
		{
			isNoBow = true;
		}
		if (option_id_s[i] == noCaseAttributesIds_option_id && attribute_id_of_options[i][dropdownIndex] == noCaseAttributesIds_attribute_id)
		{
			isNoCase = true;
		}
	}
	if (isNoBow && isNoCase)
	{
		isNoBowAndNoCase = true;
	}
	if (isNoBowAndNoCase)
	{
		showHideBlock('clickToSeeWithoutCaseAndBow', 'hide');
	}
	else
	{
		showHideBlock('clickToSeeWithoutCaseAndBow', 'show');
	}
}


function updateCurrentProductDetailsSelection(currentProductsPrice, accSelectionName, accOptionId, accOptionValueId, accSelectionValue, accOptionName, accOptionValueName, accDescription, accFeatures, accPictureLink, accCTEPictureLink, accPriceChange)
	{
	if (typeof accOptionId == "string" && accOptionId.length > 0)
		{
			accOptionValueName = accOptionValueName.replace(/abcde/g, '&#039;');
			accDescription = accDescription.replace(/abcde/g, '&#039;');
			accFeatures = accFeatures.replace(/abcde/g, '&#039;');
		/*alert(
			"Pretul curent: " + currentProductsPrice + "\n"
			+ "Numele selectiei in FORM: " + accSelectionName + "\n"
			+ "Valoarea selectiei in FORM: " + accSelectionValue + "\n"
			+ "Id-ul optiunii selectate: " + accOptionId + "\n"
			+ "Id-ul valorii optiunii selectate: " + accOptionValueId + "\n"
			+ "Numele optiunii selectate: " + accOptionName + "\n"
			+ "Valoarea optiunii selectate: " + accOptionValueName + "\n"
			+ "Descrierea atributului selectat: " + accDescription + "\n"
			// + "Features-urile atributului selectat: " + accFeatures + "\n"
			+ "Linkul pozei mici a atributului selectat" + accPictureLink + "\n"
			+ "Linkul pozei mari a atributului selectat" + accCTEPictureLink + "\n"
			+ "Valoarea modificarii pretului de atributul selectat: " + accPriceChange + "\n"
			);*/
		// Actualizez selectia din lista a optiunii selectate
		showNewCurrentLSelection('currentId' + accOptionId + '-' + accOptionValueId + '_LSelection');

		// Actualizez selectia radio button a optiunii selectate
		showNewCurrentRBSelection('currentId' + accOptionId + '-' + accOptionValueId + '_RBSelection');

		// Actualizez afisarea optiunii selectate (display: none or block)
		showNewBlock('currentId' + accOptionId + '_block', accOptionValueName);
		showNewBlock('IAcurrentId' + accOptionId + '_block', accOptionValueName);

		// Actualizez afisarea linkului pozei optiunii selectate (display: none or block)
		showNewPictureBlock('currentId' + accOptionId + '_CTEpicture', accPictureLink);
		showNewPictureBlock('IAcurrentId' + accOptionId + '_CTEpicture', accPictureLink);

		// Actualizez poza optiunii selectate
		showNewCurrentPicture('currentId' + accOptionId + '_picture', accPictureLink, 'currentId' + accOptionId + '_CTEpicture', accCTEPictureLink);
		showNewCurrentPicture('IAcurrentId' + accOptionId + '_picture', accPictureLink, 'IAcurrentId' + accOptionId + '_CTEpicture', accCTEPictureLink);

		// Actualizez numele optiunii selectate
		showNewCurrentName('currentId' + accOptionId + '_name', accOptionValueName);
		showNewCurrentName('IAcurrentId' + accOptionId + '_name', accOptionValueName);
		showNewCurrentName('IALcurrentId' + accOptionId + '_name', accOptionValueName);

		// Actualizez descrierea optiunii selectate
		showNewCurrentDescription('currentId' + accOptionId + '_description', accDescription);
		//showNewCurrentDescription('IAcurrentId' + accOptionId + '_description', accDescription);

		// Actualizez features optiunii selectate
		showNewCurrentFeatures('currentId' + accOptionId + '_features', accFeatures);
		showNewCurrentFeatures('IAcurrentId' + accOptionId + '_features', accFeatures);

		// Actualizez AddSubtract optiunii selectate in lista cu drop down selection
		for(var i=0; i<option_id_s.length; i++)
			{
			if (parseInt(option_id_s[i]) == parseInt(accOptionId))
				{
				for(var j=0; j<attribute_prefix_attribute_price_of_options[i].length; j++)
					{
					showNewCurrentAddSubtractLSelection('currentId' + accOptionId + '-' + attribute_id_of_options[i][j] + '_LSelection', (parseFloat(attribute_prefix_attribute_price_of_options[i][j])-parseFloat(accPriceChange)), attribute_name_of_options[i][j]);
					}
				}
			}

		// Actualizez AddSubtract optiunii selectate in lista cu radio buttons
		for(var i=0; i<option_id_s.length; i++)
			{
			if (parseInt(option_id_s[i]) == parseInt(accOptionId))
				{
				for(var j=0; j<attribute_prefix_attribute_price_of_options[i].length; j++)
					{
					showNewCurrentAddSubtractRBSelection('currentId' + accOptionId + '-' + attribute_id_of_options[i][j] + '_AddSubtractRBSelection', (parseFloat(attribute_prefix_attribute_price_of_options[i][j])-parseFloat(accPriceChange)));
					}
				}
			}


		// Actualizez pretul final al produsului (al instrumentului cu accesoriile alese)
		var newProductsPrice = parseFloat(currentProductsPrice);
		for(var i=0; i<attribute_prefix_attribute_price_of_options.length; i++)
			{
			var dropdownIndex = document.getElementById('currentId' + option_id_s[i] + '_LSelection').selectedIndex;
			newProductsPrice = parseFloat(newProductsPrice + parseFloat(attribute_prefix_attribute_price_of_options[i][dropdownIndex]));
			//var newFormattedProductsPrice = '$' + parseFloat(addCommas(newProductsPrice)).toFixed(2);
			var newFormattedProductsPrice = '$' + parseFloat(newProductsPrice).toFixed(2);
			//alert('option_id_s[' + i + ']: ' + option_id_s[i] + '\n' + 'attribute_prefix_attribute_price_of_options[' + i + ']: ' + attribute_prefix_attribute_price_of_options[i] + '\n' + 'dropdownIndex: ' + dropdownIndex + '\n' + 'currentProductsPrice: ' + currentProductsPrice + '\n' + 'newProductsPrice: ' + newFormattedProductsPrice);
			}
		//alert("Noul pret: " + newProductsPrice);
		showNewProductsPrice('productsPrice', newFormattedProductsPrice);
		showNewProductsPrice('IALproductsPrice', newFormattedProductsPrice);
			
		// Actualizez valorile pentru trimiterea in shopping cart
		updateShoppingCartAttributes(accOptionId, accOptionValueId);
		
		// Actualizez linkurile cu { } pentru intoarcerea din pagina "click to enlarge"
		updateCTELinks(selectedInstrumentProducts_id);
		
		// Actualizez linkul cu { } pentru selectarea instrumentului fara cutie si arcus
		updateSelectWithoutBowAndCaseLinks(selectedInstrumentProducts_id);
		}
	}


	//updateCurrentProductDetailsSelection_instruments(currentProductsPrice, accSelectionName, accOptionId, accOptionValueId, accSelectionValue, accOptionName, accOptionValueName, accDescription, accFeatures, accPictureLink, accCTEPictureLink, accPriceChange)
function updateCurrentProductDetailsSelection_instruments(currentProductsPrice, insSelectionName, insProductId, insSelectionValue, insOptionName, insName, insPictureLink, insCTEPictureLink, insPriceChange)
	{
	if (typeof insProductId == "string" && insProductId.length > 0)
		{
		/*alert(
			"Pretul curent: " + currentProductsPrice + "\n"
			+ "Numele selectiei in FORM: " + insSelectionName + "\n"
			+ "Valoarea selectiei in FORM: " + insSelectionValue + "\n"
			+ "Id-ul instrumentului selectat: " + insProductId + "\n"
			+ "Numele optiunii selectate: " + insOptionName + "\n"
			+ "Valoarea optiunii selectate: " + insName + "\n"
			+ "Descrierea instrumentului selectat: " + insDescription + "\n"
			// + "Caracteristicile instrumentului selectat: " + insCharacteristics + "\n"
			// + "Features-urile instrumentului selectat: " + insFeatures + "\n"
			+ "Linkul pozei mici a instrumentului selectat" + insPictureLink + "\n"
			+ "Linkul pozei mari a instrumentului selectat" + insCTEPictureLink + "\n"
			+ "Valoarea modificarii pretului instrumentul selectat: " + insPriceChange + "\n"
			);*/
		// Actualizez selectia din lista a instrumentului selectat
		showNewCurrentLSelection('currentId' + insProductId + '_LSelection_instruments');

		// Actualizez selectia radio button a instrumentului selectat
		showNewCurrentRBSelection('currentId' + insProductId + '_RBSelection_instruments');

		// Actualizez poza instrumentului selectat
		showNewCurrentPicture('current_picture_instrument', insPictureLink, 'current_CTEpicture_instrument', insCTEPictureLink);

		// Actualizez codul instrumentului selectat
		showNewCurrentName('current_code_instrument', insSelectionValue);
		showNewCurrentName('IALcurrent_code_instrument', insSelectionValue);

		// Actualizez numele instrumentului selectat
		showNewCurrentName('current_name_instrument', insName);
		showNewCurrentName('IALcurrent_name_instrument', insName);

		// Actualizez products_id-ul instrumentului selectat in butonul de Add To Cart
		showNewCurrentValue('current_productId_addToCart', insProductId);
		showNewCurrentValue('IALcurrent_productId_addToCart', insProductId);


		// Actualizez linkurile cu { } pentru intoarcerea din pagina "click to enlarge"
		updateCTELinks(insProductId);
		
		// Actualizez linkul cu { } pentru selectarea instrumentului fara cutie si arcus
		selectedInstrumentProducts_id = insProductId;
		updateSelectWithoutBowAndCaseLinks(insProductId);
		}
	}


function updateCurrentProductDetailsListSelection(accOptionId)
	{
	if (typeof accOptionId == "string" && accOptionId.length > 0)
		{
		//alert("Option Id: " + parseInt(accOptionId));
		var dropdownIndex = document.getElementById('currentId' + accOptionId + '_LSelection').selectedIndex;
		var dropdownValue = document.getElementById('currentId' + accOptionId + '_LSelection')[dropdownIndex].value;
		//alert("dropdownIndex: " + dropdownIndex + "\n" + "dropdownValue: " + dropdownValue);
		}
	// var option_id_sIndex = option_id_s.indexOf(accOptionId); Nu merge in IE. Merge doar in Mozilla
	for(var i=0; i<option_id_s.length; i++)
		{
		if (option_id_s[i] == accOptionId)
			{
			var option_id_sIndex = i;
			}
		}

	var accSelectionName = attribute_cod_of_options[option_id_sIndex][dropdownIndex];
	var accOptionValueId = attribute_id_of_options[option_id_sIndex][dropdownIndex];
	var accSelectionValue = TabelaProdus_litere_s[option_id_sIndex];
	var accOptionName = TabelaProdus_produs_s[option_id_sIndex];
	var accOptionValueName = (attribute_name_of_options[option_id_sIndex][dropdownIndex].replace("'","")).replace('"', '&quot;');
	var accDescription = (attribute_description_of_options[option_id_sIndex][dropdownIndex].replace("'","")).replace('"', '&quot;');
	var accFeatures = (attribute_features_of_options[option_id_sIndex][dropdownIndex].replace("'","")).replace('"', '&quot;');
	var accPictureLink = attribute_CaleInt_attribute_PozaMica_of_options[option_id_sIndex][dropdownIndex];
	var accCTEPictureLink = attribute_CaleInt_attribute_PozaMare_of_options[option_id_sIndex][dropdownIndex];
	var accPriceChange = attribute_prefix_attribute_price_of_options[option_id_sIndex][dropdownIndex];
	
	updateCurrentProductDetailsSelection(currentProductsPrice, accSelectionName, accOptionId, accOptionValueId, accSelectionValue, accOptionName, accOptionValueName, accDescription, accFeatures, accPictureLink, accCTEPictureLink, accPriceChange);
	
	}


function updateCurrentProductDetailsRadioSelection(accSelectionName, accOptionId, accOptionValueId, accSelectionValue, accOptionName, accOptionValueName, accDescription, accFeatures, accPictureLink, accCTEPictureLink, accPriceChange)
	{
	updateCurrentProductDetailsSelection(currentProductsPrice, accSelectionName, accOptionId, accOptionValueId, accSelectionValue, accOptionName, accOptionValueName, accDescription, accFeatures, accPictureLink, accCTEPictureLink, accPriceChange);
		
	for(var i=0; i<option_id_s.length; i++)
		{
		if (option_id_s[i] == accOptionId)
			{
			var option_id_sIndex = i;
			}
		}
	redirectToAcc((TabelaProdus_produs_plural_s[option_id_sIndex].toLowerCase()).replace("-", ""));
	}


function updateCurrentProductDetailsRadioSelection_instruments(insSelectionName, insProductId, insSelectionValue, insOptionName, insName, insPictureLink, insCTEPictureLink, insPriceChange)
	{
	updateCurrentProductDetailsSelection_instruments(currentProductsPrice, insSelectionName, insProductId, insSelectionValue, insOptionName, insName, insPictureLink, insCTEPictureLink, insPriceChange);
		
	redirectToAcc('instruments');
	}


function lookForElementById(iElementId)
	{
	if (typeof iElementId == "string" && iElementId.length > 0)
		{
		var element = document.getElementById(iElementId);
		if (element)
			{
			alert("name=" + element.name + " - id=" + element.id);
			document.getElementById(iElementId).innerHTML = 'Status: Could find the requested element.';
			return;
			}
			else
			{
			alert("name=" + element.name + " - id=" + element.id);
			document.getElementById(iElementId).innerHTML = 'Status: Could not find the requested element.';
			return;
			}
		}
	}


function showHideBlock(blockId, showHide)
	{
	if (typeof blockId == "string" && blockId.length > 0)
		{
		var block = document.getElementById(blockId);
		if (block)
			{
			//alert("Am gasit elementul cu id-ul: " + blockId);
			if (showHide == 'show')
				{
				block.style.display = 'block';
				}
				else
				{
				block.style.display = 'none';
				}
			return;
			}
			else
			{
			//alert("Nu am gasit elementul cu id-ul: " + blockId);
			return;
			}
		}
	}