function showConfiguration(product_element_id, product_variant_id, product_variant_element_material_id, product_variant_element_material_color_id) {
  document.getElementById('product-configuration-' + product_variant_id).style.display = ''; // pokaz kontener na konfigurator
  showLoadingAnimationOnSpecificLocation('product-configuration-' + product_variant_id, '<br />Trwa ładowanie konfiguracji&hellip;<br />'); // pokaz w kontenerze animacje 

  new Ajax.Updater(
        'product-configuration-' + product_variant_id,
    		'/index.php/product/showConfigurationForProductVariantElement'
    		+ '/product_variant_id/' + product_variant_id
    		+ '/product_element_id/' + product_element_id
    		+ '/product_variant_element_material_id/' + product_variant_element_material_id
    		+ '/product_variant_element_material_color_id/' + product_variant_element_material_color_id,
    		{asynchronous:true, evalScripts:false}
  );
  
  
}

function updateConfigurationColors(element_material_id, product_variant_id, element_material_color_id, show_animation) {
	
	if(show_animation == true) {
		showLoadingAnimationOnSpecificLocation('product-configuration-' + product_variant_id + ' colors', 'Trwa ładowanie kolorów dla materiału&hellip;<br />'); // pokaz w kontenerze animacje
	}
			
	new Ajax.Updater(
			'product-configuration-' + product_variant_id + ' colors',
			'/index.php/product/updateConfigurationColors' 
			+ '/element_material_id/' + element_material_id 
			+ '/product_variant_id/' + product_variant_id 
			+ '/element_material_color_id/' + element_material_color_id, 
			{asynchronous:true, evalScripts:false}
	);	
}

function updateConfigurationMaterials(product_element_id, product_variant_id, element_material_id) {
	new Ajax.Updater(
			'product-configuration-' + product_variant_id + ' materials',
			'/index.php/product/updateConfigurationMaterials/product_element_id/' + product_element_id  
			+ '/product_variant_id/' + product_variant_id
			+ '/element_material_id/' + element_material_id, 
			{asynchronous:true, evalScripts:false}
	);	
}

function disableEnableMaterialTabs(product_variant_id, material_id) {
	var materials = document.getElementById('product-configuration-' + product_variant_id + ' materials').childNodes;
	var materials_length = materials.length; 
	
	for(i = 1 ; i < materials_length ; i++) {
		if(materials[i].nodeType == 1) {
			console.log(materials[i].innerHTML);
		}
		
	}
}

function disableEnableElementsTabs(element_name, element_parent, element_counter) {
	var elements = document.getElementsByPartialClassName(element_name, element_parent); // pobierz elementy z nazwa w klasie element
		
	for(var i = 1 ; i < elements.length ; i++) {
		if(i == element_counter) {
			elements[i].className = 'element' + element_counter + ' active';
		} else {
			elements[i].className = 'element' + i;
		}	
	}
	
	
}

function updateConfigurationMaterialColorPreview(product_variant_id, material_id, color_id) {
	showLoadingAnimationOnSpecificLocation('variant-id-' + product_variant_id + '-texture-preview', 'Trwa ładowanie podglądu&hellip;<br />'); // pokaz w kontenerze animacje
	
    new Ajax.Updater(
    		'variant-id-' + product_variant_id + '-texture-preview', 
    		'/index.php/product/updateConfigurationMaterialColorPreview'
    		+ '/product_variant_id/' + product_variant_id
    		+ '/material_id/' + material_id
    		+ '/color_id/' + color_id,
    		{asynchronous:true, evalScripts:false}
    );
}

function updateVariant(product_variant_id, product_variant_element_id, product_element_id, new_material_id, new_color_id) {	
    new Ajax.Updater(
    		'update-variant-' + product_variant_id, 
    		'/index.php/product/updateVariantConfiguration'
    		+ '/product_variant_id/' + product_variant_id
    		+ '/product_variant_element_id/' + product_variant_element_id
    		+ '/product_element_id/' + product_element_id
    		+ '/new_material_id/' + new_material_id
    		+ '/new_color_id/' + new_color_id,
    		{asynchronous:true, evalScripts:false}
    );
}

function showLoadingAnimationOnSpecificLocation(location, notify) {
	document.getElementById(location).innerHTML = notify + "<img src='/images/loadingAnimation.gif' />";
}

document.getElementsByPartialClassName = function(value, parentElement) {
    var children = ($(parentElement) || document.body).getElementsByTagName('*');
    var elements = [], child;
    regexp = new RegExp('(?:^|\s)('+value+'.*?)(?:\s|$)');
    for (var i = 0, length = children.length; i < length; i++) {
      child = children[i];
      if (matches = Element.classNames(child).toString().match(regexp)) {
        elements.push(Element.extend(child));
      }
    }
    return elements;
};
