function clearForm(nodeId)
	{
	var counter=i;
	
	for(i=0; i<counter; i++)
		{
		if(a=getNode(indexForms[i]))
			{
			if(indexForms[i]!=nodeId)
				{
				if(a.value=="")
					{a.value=forms[indexForms[i]];}
				}
			else if(a.value==forms[indexForms[i]])
				{a.value="";}
			}
		}
	}

function chIdBgcolor_b(txt_gf,txt_f,txt_s,id_gf,id_f,id_s,bgColor)
	{
		if(txt_s)
		{txt_s.className='sitemap_l3_active';}	
		if(txt_f)
		{txt_f.className='sitemap_l2_active';}
		if(txt_gf)
		{txt_gf.className='sitemap_l1_active';}
		if(id_gf)
		{id_gf.style.background=bgColor;}
		if(id_f)
		{id_f.style.background=bgColor;}
		if(id_s)
		{id_s.style.background=bgColor;}		
	}
	
function chIdBgcolor_b2(txt_gf,txt_f,txt_s,id_gf,id_f,id_s,bgColor)
	{
		if(txt_s)
		{txt_s.className='sitemap_l3';}	
		if(txt_f)
		{txt_f.className='sitemap_l2';}
		if(txt_gf)
		{txt_gf.className='sitemap_l1';}
		if(id_gf)
		{id_gf.style.background=bgColor;}
		if(id_f)
		{id_f.style.background=bgColor;}
		if(id_s)
		{id_s.style.background=bgColor;}		
	}
function chIdBgcolor_a(txt_gf,txt_s,id_gf,id_f,id_s,bgColor)
	{

		txt_gf.className='sitemap_l1_active';
		txt_s.className='sitemap_l2_active';

		if(id_gf)
		{id_gf.style.background=bgColor;}
		if(id_f)
		{id_f.style.background=bgColor;}
		if(id_s)
		{id_s.style.background=bgColor;}		
	}
	
function chIdBgcolor_a2(txt_gf,txt_s,id_gf,id_f,id_s,bgColor)
	{

		txt_gf.className='sitemap_l1';
		txt_s.className='sitemap_l2';
		
		if(id_gf)
		{id_gf.style.background=bgColor;}
		if(id_f)
		{id_f.style.background=bgColor;}
		if(id_s)
		{id_s.style.background=bgColor;}		
	}	





















function overFaceContainer(nom)
	{
	chNodeBgcolor("faceCartContainer_"+nom, "#fbfbfa");
	chNodeSrc("faceCartImage_"+nom, "/img/face/magnifer.gif");
	}


function outFaceContainer(nom)
	{
	chNodeBgcolor("faceCartContainer_"+nom, "#f3f2ee");
	chNodeSrc("faceCartImage_"+nom, "/img/spacer.gif");
	}


function sitemapL0Activate(nom)
	{
	chNodeBgcolor("level0_name_container_"+nom, "#e9e7e0");

	chNodeClassName("level0_name_"+nom, "sitemapActiveL0");
	}

function sitemapL0DeActivate(nom)
	{
	chNodeBgcolor("level0_name_container_"+nom, "#ffffff");
	chNodeClassName("level0_name_"+nom, "sitemapUnActiveL0");
	}

function sitemapL1Activate(nom)
	{
	chNodeBgcolor("level1_name_container_"+nom, "#e9e7e0");
	chNodeClassName("level1_name_"+nom, "sitemapActiveL1");
	}

function sitemapL1DeActivate(nom)
	{
	chNodeBgcolor("level1_name_container_"+nom, "#ffffff");
	chNodeClassName("level1_name_"+nom, "sitemapUnActiveL1");
	}



function clearForm(nodeId)
	{
	var counter=i;
	
	for(i=0; i<counter; i++)
		{
		if(a=getNode(indexForms[i]))
			{
			if(indexForms[i]!=nodeId)
				{
				if(a.value=="")
					{a.value=forms[indexForms[i]];}
				}
			else if(a.value==forms[indexForms[i]])
				{a.value="";}
			}
		}
	}




function ajaxResultProcessingIntoNode(nodeId)
	{
	if (httpRequest.readyState == 4)
		{
		if (httpRequest.status == 200)
			{
			if(a=getNode(nodeId))
				{a.innerHTML=httpRequest.responseText;}
			}
		else
			{alert(errorsXMLHTTP_Request);}
		}
	}

function ajaxResultProcessingIntoNodeAndChangePriceQuantity(nodeId)
	{
	if (httpRequest.readyState == 4)
		{
		if (httpRequest.status == 200)
			{
			if(a=getNode(nodeId))
				{a.innerHTML=httpRequest.responseText;}
// міняємо на ходу ціну та кількість
			getCartCounterAsAjax();
			}
		else
			{alert(errorsXMLHTTP_Request);}
		}
	}



function getAjax(path)
	{
	hideNode("listProdUnLinked_"+path);
	showNode("listProdWait_"+path);


	if (!httpRequest)
		{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}

	httpRequest.onreadystatechange = function() { goAjax(path); };
	httpRequest.open('GET', "/cart/add/"+path+"/index.html", true);
	httpRequest.send('');
	}

function goAjax(path)
	{
	if (httpRequest.readyState == 4)
		{
		if (httpRequest.status == 200)
			{
			if(a=getNode('bottomCartContainer'))
				{
				htmlResult=httpRequest.responseText.substring(15, httpRequest.responseText.length);
				a.innerHTML=htmlResult;
				}
			if(a=getNode('top_cart_counter'))
				{
				top_quantity=httpRequest.responseText.substring(0, 15);
				a.innerHTML=Number(top_quantity);
				}
			}
		else
			{alert(errorsXMLHTTP_Request);}

		showNode("listProdUnLinked_"+path);
		hideNode("listProdWait_"+path);
		}
	}


function restoreToCart(elementId, counter)
	{
	if (!httpRequest)
		{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}

	httpRequest.onreadystatechange = function() { ajaxResultProcessingIntoNodeAndChangePriceQuantity("cartCell_"+counter); };
	httpRequest.open('GET', "/cart/restore/"+elementId+"/index.html?item="+counter, true);
	httpRequest.send('');
	}




function deleteFromCart(groupId, counter)
	{
	if (!httpRequest)
		{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}

	httpRequest.onreadystatechange = function() {ajaxResultProcessingIntoNodeAndChangePriceQuantity("cartCell_"+counter); };
	httpRequest.open('GET', "/cart/delete/"+groupId+"/index.html?item="+counter, true);
	httpRequest.send('');
	}

function getCartCounterAsAjax()
	{
	if (!httpRequest)
		{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}

	httpRequest.onreadystatechange = function() {setNewPriceAndQuantity(); };
	httpRequest.open('GET', "/cart/price/0/index.html", true);
	httpRequest.send('');
	}

function purchase_order()
	{
	if (!httpRequest)
		{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
		}

	httpRequest.onreadystatechange = function() {ajaxResultProcessingIntoNode("cartBottomContainer"); };
	httpRequest.open('GET', "/cart/ajax_purchase_type/index.html", true);
	httpRequest.send('');
	}


function setNewPriceAndQuantity()
	{
	if (httpRequest.readyState == 4)
		{
		if (httpRequest.status == 200)
			{
			eval(httpRequest.responseText);
			if(a=getNode("cartFullPrice"))
				{a.innerHTML=price;}
			if(a=getNode("top_cart_counter"))
				{a.innerHTML=quantity;}
			if(a=getNode("cartContainerQuantity"))
				{a.innerHTML=quantity;}
			if(a=getNode("cartContainerDigitalProducts"))
				{a.innerHTML=digitalProducts;}
			}
		else
			{alert(errorsXMLHTTP_Request);}
		}
	}


var textarea_rowheight = new Array(); //висота рядка, вираховується після першого збільшення кількості рядків; масив на випадок - а раптом будуть кастомні текстареа з відмінною від інших на цій же сторінці висотою рядка
function check_textarea(id, minRows, maxRows){
	var area = getNode(id);
	var curHeight = area.clientHeight;
//		alert("area.rows="+area.rows+", area.scrollHeight="+area.scrollHeight+", \narea.clientHeight"+area.clientHeight+", mmn/mx:"+minRows+"/"+maxRows+" lh:"+area.fontSize);
	if(area.scrollHeight > area.clientHeight && area.rows != -1 && area.rows < maxRows){	//якщо текст вже не вміщається і кількість рядків менша максимуму - додаємо один рядок
		area.rows = area.rows+1;
		textarea_rowheight[id]=area.clientHeight-curHeight;	//вираховуємо і записуємо висоту рядка
//			getNode('log').innerHTML=getNode('log').innerHTML+"area.rows="+area.rows+", area.scrollHeight="+area.scrollHeight+", area.clientHeight="+area.clientHeight+", mmn/mx:"+minRows+"/"+maxRows+", TextArea rowHeight="+textarea_rowheight[id]+"<br>";
		check_textarea(id, minRows, maxRows);	//рекурсивно викликаємо себе про всяк випадок
	};
	if(area.scrollHeight > area.clientHeight && area.rows != -1 && area.rows == maxRows){	//якщо к-сть рядків максимум і текст не вміщається - вмикаємо прокрутку
		area.style.overflow = "scroll";
//			getNode('log').innerHTML=getNode('log').innerHTML+"area.rows="+area.rows+", area.scrollHeight="+area.scrollHeight+", area.clientHeight="+area.clientHeight+", mmn/mx:"+minRows+"/"+maxRows+", TextArea rowHeight="+textarea_rowheight[id]+"<br>";
	};
	if (typeof(textarea_rowheight[id])!='undefined' && textarea_rowheight[id]!==null) {	//якщо кількість рядків більша мінімума і є можливість зменшити розмір - зменшуємо і вимикаємо прокрутку
		if(area.scrollHeight+textarea_rowheight[id] < area.clientHeight && area.rows > minRows && area.rows <= maxRows ){
			area.rows = area.rows-1;
//				getNode('log').innerHTML=getNode('log').innerHTML+"area.rows="+area.rows+", area.scrollHeight="+area.scrollHeight+", area.clientHeight="+area.clientHeight+", mmn/mx:"+minRows+"/"+maxRows+"<br>";
			area.style.overflow = "hidden";
			check_textarea(id, minRows, maxRows);	//рекурсивно викликаємо себе про всяк випадок
		};
	};
	if(area.scrollHeight <= area.clientHeight && area.rows != -1 && area.rows == maxRows){	//якщо к-сть рядків максимум але текст вміщається - вимикаємо прокрутку
		area.style.overflow = "hidden";
//			getNode('log').innerHTML=getNode('log').innerHTML+"area.rows="+area.rows+", area.scrollHeight="+area.scrollHeight+", area.clientHeight="+area.clientHeight+", mmn/mx:"+minRows+"/"+maxRows+", TextArea rowHeight="+textarea_rowheight[id]+"<br>";
	};


};

function multimediaUnset(nodeId)
	{
	hideNode('multimedia_image_active_'+nodeId);
	showNode('multimedia_image_unactive_'+nodeId);
	}

function multimediaSet(nodeId)
	{
	hideNode('multimedia_image_active_'+nodeId);
	showNode('multimedia_image_unactive_'+nodeId);
	}


function showResponses(type)
	{
	hideNode("showCompany"+type);
	showNode("hideCompany"+type+"Top");
	showNode("company"+type);
	showNode("hideCompany"+type+"Bottom");
	}
function hideResponses(type)
	{
	showNode("showCompany"+type);
	hideNode("hideCompany"+type+"Top");
	hideNode("company"+type);
	hideNode("hideCompany"+type+"Bottom");
	}

