function sfHover() {

	

	level0 = null;

	level1 = null;

	level2 = null;

	

	link_level0 = null;

	link_level1 = null;

	

	currentPromotion = null;

	currentPromotionLink = null;

	defaultPromotion = null;

	currentFlash = null;

	currentID = null;

	

	

	mySlide1 = null;

	mySlide2 = null;

	mySlide3 = null;

	aimationPlay = false;

	aimationStop = false;

	lastone;

	

	var wrapper_product = document.getElementById("wrapper_product");

	wrapper_product.className = "products";

		

	

	var heating = document.getElementById("heating");

	var heatingLIs = heating.getElementsByTagName("LI");

	

	for (var i=0; i<heatingLIs.length; i++) {

		

		if (heatingLIs[i].firstChild.nodeType == 3) {

				var aLink = document.createElement("a");

				aLink.appendChild(heatingLIs[i].firstChild);

				aLink.href="#";

				

				aLink.setAttribute("onclick", "navigate(this); return false;");

				aLink.onclick = function() {navigate(this); return false;};

				heatingLIs[i].insertBefore(aLink,heatingLIs[i].firstChild);

		}

	}

	

	var piping = document.getElementById("piping");

	var pipingLIs = piping.getElementsByTagName("LI");

	

	for (var i=0; i<pipingLIs.length; i++) {

		

		if (pipingLIs[i].firstChild.nodeType == 3) {

				var aLink = document.createElement("a");

				aLink.appendChild(pipingLIs[i].firstChild);

				aLink.href="#";

				

				aLink.setAttribute("onclick", "navigate(this); return false;");

				aLink.onclick = function() {navigate(this); return false;};

				pipingLIs[i].insertBefore(aLink,pipingLIs[i].firstChild);

		}

	}

	

	var air_conditioning = document.getElementById("air_conditioning");

	var air_conditioningLIs = air_conditioning.getElementsByTagName("LI");

	

	for (var i=0; i<air_conditioningLIs.length; i++) {

		

		if (air_conditioningLIs[i].firstChild.nodeType == 3) {

				var aLink = document.createElement("a");

				aLink.appendChild(air_conditioningLIs[i].firstChild);

				aLink.href="#";

				

				aLink.setAttribute("onclick", "navigate(this); return false;");

				aLink.onclick = function() {navigate(this); return false;};

				air_conditioningLIs[i].insertBefore(aLink,air_conditioningLIs[i].firstChild);

		}

	}

}

function navigate(o) {

	if (level1 == o.parentNode) {

		aimationStop = true;

	}

	if (level2 == o.parentNode) {

		aimationStop = true;

	}

if (!aimationPlay &&  !aimationStop) {

	if(o.parentNode.parentNode.nodeName == "UL") {

		

		if(o.parentNode.parentNode.className == "level0") {

			

			if(level1 != null) {

				level1.className = "";

				link_level0.className = "";

				if(level2 != null) {

					level2.className = "";

					link_level1.className = "";

					$(level2UL).hide();

				}

				

				$(level1UL).hide();

			}

			

			level1UL = o.parentNode.childNodes[1];

			

			level1 = o.parentNode;

			link_level0 = o;

			link_level0.className = "selected";

			

		}

		

		if(o.parentNode.parentNode.className == "level1") {



			if(level2 != null) {

				level2.className = "";

				link_level1.className = "";

				

				$(level2UL).hide();

			}

			level2UL = o.parentNode.childNodes[1];

			

			level2 = o.parentNode;

			link_level1 = o;

			link_level1.className = "selected";

		}

		

	}

	

	o.parentNode.className = "sfhover";



		aimationPlay = true;

			$(o.parentNode.childNodes[1]).slideToggle("normal", function () {

					aimationPlay = false;

			  });

	}

	aimationStop = false;

}



var level0 = null;

var level1 = null;

var level2 = null;



var link_level0 = null;

var link_level1 = null;



var currentPromotion = null;

var currentPromotionLink = null;

var defaultPromotion = null;

var currentFlash = null;

var currentID = null;





var mySlide1 = null;

var mySlide2 = null;

var mySlide3 = null;

var aimationPlay = false;

var aimationStop = false;

var lastone;



function promotions() {



	if(document.getElementById) {

		

		var promotionLinks = document.getElementById("categories").getElementsByTagName("a");

		for(var i=0; i<promotionLinks.length; i++) {

			var trigger = promotionLinks[i];

			

			trigger.setAttribute("onclick", "displayPromotion(this); return false;");

			

			trigger.onclick = function() {

					displayPromotion(this);

					return false;

				};

		}

		

		var promotions = document.getElementsByTagName("ul");

		for(var j=0; j<promotions.length; j++) {

			if(/level0/.test(promotions[j].className)) {

				var promotion = promotions[j];

				var tempID = document.getElementById(promotion.id);

					$(tempID).hide();

			}

		}

		//defaultPromotion = document.getElementById("defaultLink");

		//displayPromotion(defaultPromotion);

		

	}

}

function displayPromotionFlash(flashId) {

	var refByFlash = document.getElementById(flashId);

	displayPromotion(refByFlash);

}

function displayPromotion(o) {

if (!aimationPlay) {

	document.getElementById('category_icons').style.display = 'none';

	document.getElementById('products').style.display = 'block';

	var pad = document.getElementById("wrapper_product");

	

	if(currentPromotion != null) {

		

		var tempID = document.getElementById(currentID);

		$(tempID).hide();

		

		currentPromotionLink.className = "";

		

		currentPromotionLink = o;

		currentPromotionLink.className = "selected";

		tempLink = o.href.substring(o.href.lastIndexOf("#")+1, o.href.length);

		currentPromotion = document.getElementById(tempLink);

		

		//pad.className = "product_navigation " + tempLink;

		pad.className = tempLink;

		

		currentID = tempLink;



		var tempID = document.getElementById(currentID);



			aimationPlay = true;

			$(tempID).slideToggle("normal", function () {

				aimationPlay = false;

			  });

		

		if(level1 != null) {

			level1.className = "";

			level1.getElementsByTagName("ul")[0].style.display = "none";

			level1 = null;

			link_level0.className = "";

			

			if(level2 != null) {

				level2.className = "";

				level2.getElementsByTagName("ul")[0].style.display = "none";

				level2 = null;

				link_level1.className = "";

			}

		}

		

		var pheading = document.getElementById("product_category");

		//pheading.className = "product_category " + tempLink;

		pheading.className = tempLink;

		pheading.innerHTML = currentPromotionLink.firstChild.nodeValue;

		

		var pcontainer = document.getElementById("product_details_container");

		pcontainer.className = "product " + tempLink;

		

		var btn_close = document.getElementById('btn_close'); 

		btn_close.style.display = 'inline';

		

	} else {

		

		currentPromotionLink = o;

		currentPromotionLink.className = "selected";

		tempLink = o.href.substring(o.href.lastIndexOf("#")+1, o.href.length);

		currentPromotion = document.getElementById(tempLink);

		

		//pad.className = "product_navigation " + tempLink;

		pad.className = tempLink;

		

		var pheading = document.getElementById("product_category");

		//pheading.className = "product_category " + tempLink;

		pheading.className = tempLink;

		pheading.innerHTML = currentPromotionLink.firstChild.nodeValue;

		

		var pcontainer = document.getElementById("product_details_container");

		pcontainer.className = "product " + tempLink;

		

		currentID = tempLink;

		

		var btn_close = document.getElementById('btn_close'); 

		btn_close.style.display = 'inline';



		var tempID = document.getElementById(currentID);

			aimationPlay = true;

			$(tempID).slideToggle("normal", function () {

				aimationPlay = false;

			 });

	}

}

}



/* Close Button */

var btn_close = document.getElementById('btn_close');

if(btn_close) {

	btn_close.setAttribute("onclick", "closeAll(this); return false;");

	btn_close.onclick = function(){

		closeAll(this);

		return false;

	};

}



function closeAll(which) {

	document.getElementById('products').style.display = 'none';

	document.getElementById('product_details_container').style.display = 'none';

	

	if(which != undefined) {

		which.style.display = 'none';

	}

	

	var pad = document.getElementById("wrapper_product");

	pad.className = 'products';

	document.getElementById('category_icons').style.display = 'block';

	

	if(document.getElementById('selected_products')) {

		document.getElementById('selected_products').style.display = 'block';

	}

	if(document.getElementById('highlights')) {

		document.getElementById('highlights').style.display = 'block';

	}

	

	var pheading = document.getElementById("product_category");

	pheading.className = "";

	pheading.innerHTML = "Продукти";

	

	currentPromotionLink.className = "";

	

	/*

	var currentLocation = window.location.href;

	if(/#/.test(currentLocation)) {

		var newLocation = currentLocation.substring(0, currentLocation.lastIndexOf("#"));

	}

	location.href = newLocation;

	*/

	

}



function findimg() {

	var imgs,i;

	imgs=document.getElementsByTagName('img');

	for(i=0;i<imgs.length;i++) {

		if(/roll/.test(imgs[i].className)) {

			

			imgs[i].setAttribute("onmouseover", "roll(this);");

			imgs[i].setAttribute("onmouseout", "roll(this);");

			

			imgs[i].onmouseover=function(){roll(this);};

			imgs[i].onmouseout=function(){roll(this);};

		}

	}

}

function roll(o) {

	var src,ftype,newsrc;

	src = o.src;

	ftype = src.substring(src.lastIndexOf('.'), src.length);

	if(/_on/.test(src)) {

		newsrc = src.replace('_on','');

	} else {

		newsrc = src.replace(ftype, '_on'+ftype);

	}

	o.src=newsrc;

}

/* Details.js */

var defaultH2 = null;



function getTagetLinks () {

	var h2s = document.getElementsByTagName('h2');

	var info_section;

	var firstOne = true;

	

	for(var i=0; i<h2s.length; i++) {

		if(/section/.test(h2s[i].className)) {

			var fakeLink = document.createElement("a");

			fakeLink.appendChild(h2s[i].firstChild);

			fakeLink.href="#";

			fakeLink.setAttribute("onclick", "displaySection(this); return false;");

					

			fakeLink.onclick = function(){

				displaySection(this);

				return false;

			};

					

			h2s[i].insertBefore(fakeLink, h2s[i].firstChild);

			

			if(firstOne) {

				defaultH2 = fakeLink;

				firstOne = false;

			}

		}

	}

	

	var alldivs = document.getElementsByTagName('div');

	for(var j=0; j<alldivs.length; j++) {

		if(/section/.test(alldivs[j].className)) {

			var sectionDiv = alldivs[j];

			sectionDiv.className += " hidden";

		}

	}

	displaySection(defaultH2);

	

}

function displaySection(o) {

	

	if(/selected/.test(o.className)) {

		o.className = "";

	} else {

		o.className = "selected";	

	}

		

	if (navigator.userAgent.indexOf('MS') != -1) {

		o = o.parentNode.nextSibling;

	} else {

		o = o.parentNode.nextSibling.nextSibling;

	}

	

	if(/hidden/.test(o.className)) {

		o.className = "section";

	} else {

		o.className += " hidden";

	}

	

}

/* Gallery.js */

var imgs = new Array();

var bigImg, cont, thep, links;



function  createGallery() {

	bigImg = document.getElementById('canvas');

	cont = document.getElementById('gallery');

	links = cont.getElementsByTagName('a');

	pics();



}

function pics() {

	for (var i = 0; i < links.length; i++) {

		imgs[i] = new Image();

		imgs[i].src = links[i].href;

		imgs[i].alt = links[i].title;

		links[i].onmouseover = function(){rollImg(this);};

		links[i].onfocus = function(){rollImg(this);};

		links[i].onclick = function(){return false;};

	}

}

function rollImg(o) {

	removeBorder();

	o.className = 'chosen';

	bigImg.src = imgs[o.rel].src;

	bigImg.alt = imgs[o.rel].alt;

}

function removeBorder() {

	for (var i = 0; i < links.length; i++) {

		links[i].className = '';

	}

}

/* Products.js */

var currentLink = null;

var currentCategory = null;



function manageProducts() {

	if(document.getElementById) {

			$("ul.level2 a").attr("onclick", "Opera(this);return false;");

			

			$("ul.level2 a").click(function () {

				$("ul.level2 a").attr("class","");

				$(this).attr("rel",$(this).attr("href").split(".htm")[0]);

				$(this).attr("class","selected");

				SWFAddress.setValue($(this).attr("rel")); 

				this.blur(); 

				

				var currentLocation = window.location.href;

				if(/#/.test(currentLocation)) {

					

					if(document.getElementById('selected_products')) {

						document.getElementById('selected_products').style.display = 'none';

					}

					if(document.getElementById('highlights')) {

						document.getElementById('highlights').style.display = 'none';

					}

					document.getElementById('product_details_container').style.display = 'block';

				}

				

				return false;

    		});

			

			$("ul#air_conditioning ul.level1 a").attr("onclick", "Opera2(this);return false;");

			$("ul#air_conditioning ul.level1 a").click(function () {

				$("ul#air_conditioning ul.level1 a").attr("class","");

				$(this).attr("rel",$(this).attr("href").split(".htm")[0]);

				$(this).attr("class","selected");

				SWFAddress.setValue($(this).attr("rel")); 

				this.blur(); 

				

				var currentLocation = window.location.href;

				if(/#/.test(currentLocation)) {

					

					if(document.getElementById('selected_products')) {

						document.getElementById('selected_products').style.display = 'none';

					}

					if(document.getElementById('highlights')) {

						document.getElementById('highlights').style.display = 'none';

					}

					document.getElementById('product_details_container').style.display = 'block';

				}

				

				return false;

    		});

			

			//Opera stuff



	}

}

function Opera(which) {

	$("ul.level2 a").attr("class","");

	$(which).attr("rel",$(which).attr("href").split(".htm")[0]);

	$(this).attr("class","selected");

	SWFAddress.setValue($(which).attr("rel")); 

	which.blur();

	

	var currentLocation = window.location.href;

	if(/#/.test(currentLocation)) {

		

		if(document.getElementById('selected_products')) {

			document.getElementById('selected_products').style.display = 'none';

		}

		if(document.getElementById('highlights')) {

			document.getElementById('highlights').style.display = 'none';

		}

		document.getElementById('product_details_container').style.display = 'block';

	}

		

}



function Opera2(which) {

	$("ul#air_conditioning ul.level1 a").attr("class","");

	$(which).attr("rel",$(which).attr("href").split(".htm")[0]);

	$(this).attr("class","selected");

	SWFAddress.setValue($(which).attr("rel")); 

	which.blur();

	

	var currentLocation = window.location.href;

	if(/#/.test(currentLocation)) {

		

		if(document.getElementById('selected_products')) {

			document.getElementById('selected_products').style.display = 'none';

		}

		if(document.getElementById('highlights')) {

			document.getElementById('highlights').style.display = 'none';

		}

		document.getElementById('product_details_container').style.display = 'block';

	}

		

}

function fixie() {

	if(document.getElementById("fix-position") != undefined) {

		document.getElementById("fix-position").style.position = "relative";

	}

}
