$(document).ready(function(){

$("a[rel=lightbox]").fancybox({zoomOpacity: false, overlayOpacity: 0.85, hideOnContentClick: false, centerOnScroll: true});														
$("a[rel=lightbox-gallery]").fancybox({zoomOpacity: false, overlayOpacity: 0.85, hideOnContentClick: false, centerOnScroll: true});																																														
																																																$("div#customer-type a").fancybox({zoomOpacity: false, overlayOpacity: 0.85, hideOnContentClick: false, centerOnScroll: true, frameWidth: 265, frameHeight: 70});
																																																CheckAllFields();
																																																$("form.standard .value *").change(function(){ CheckField($(this)); });																																																																																																																	$("form.standard .value *").keyup(function(){ CheckField($(this)); });	
																																																$("form.standard input[name=equals-legal-address]").click(function(){ EqualAddress("real"); });																																																																																																																																																									$("form.standard input[name=equals-real-address]").click(function(){ EqualAddress("delivery"); });	
																																																$("form.standard *[name*='-paf']").change(function(){ BuildPhone($(this)); });																																																																																																																																																																																																					$("form.standard *[name*='-paf']").keyup(function(){ BuildPhone($(this)); });																																																
																																																$("form.standard").submit(function(){ OnSubmit($(this)); });	
																																																
																																																GetSearchResults();
																																																});

document.onkeydown = Navigate;

function Navigate(event)
{	
	link = null;
	direction = null;
	
	if (window.event) event = window.event;
	
	if (event.ctrlKey)
	{
		switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
		{
			case 0x25:
				link = $("a[rel=prev]").attr("href");
				direction = 1;
				break;
			case 0x27:
				link = $("a[rel=next]").attr("href");
				direction = 2;
				break;
		}
	}
	
	if (link) document.location = link;
	if (direction) ChangeBanner(direction);
}


function ChangeCustomerType()
{
	$.cookie("customer_type", $("#customer-select option:selected").val(), { expires: 365, path: "/" });
	
	$.fn.fancybox.close();
	document.location.reload();
}


function SwitchAuthForm()
{
	$("div#authorization-background").toggle();
	$("div#authorization").toggle();
}


function ShowCities(intNumCities)
{	
	objCurrentCity = $("div#contacts > div:not(.hidden) div.city .name");
	strCurrentCity = objCurrentCity.text();
	
	arrCities = Array();
	arrCitiesCodes = Array();
	
	k = 0;
	
	for (i = 0; i < intNumCities; i++)
	{
		strCity = $("div#contacts div.city:eq(" + i + ") .name").text();
		
		if (strCity != strCurrentCity)
		{
			arrCities[k] = strCity;
			arrCitiesCodes[k] = i + 1;
			k++;
		}
	}
	
	strCities = "";
	
	for (i = 0; i < arrCities.length; i++)
	{
		strCities += " <span class='link' onclick='ChangeCity(\"" + arrCitiesCodes[i] + "\")'>";
		strCities += arrCities[i];
		strCities += "</span>";
		
		if (i <= arrCities.length - 3)
		{
			strCities += ",";
		}
		
		if (i == arrCities.length - 2)
		{
			strCities += " или";
		}
	}
	
	
	$("div#contacts > div:not(.hidden) .city .city-selector span.change").hide();
	$("div#contacts > div:not(.hidden) .city .city-selector span.select").html("сменить на" + strCities);
	$("div#contacts > div:not(.hidden) .city .city-selector span.select").show();
}


function ChangeCity(intCity)
{
	$.cookie("city_selector", intCity, { expires: 365, path: "/" });
	
	$("div#contacts > div:not(.hidden)").attr("class", "hidden");
	$("div#contacts > div#city-" + intCity).attr("class", "");
	$("div#contacts > div:not(.hidden) .city .city-selector span.change").show();
	$("div#contacts > div:not(.hidden) .city .city-selector span.select").hide();
}

function ChangeBanner(intDirection)
{	
	objBanners = $("div#banners-shop > div.images");
	
	objBanners.stop();
	
	strLeft = objBanners.css("left");
	intLeft = parseFloat(strLeft.substring(0, strLeft.length - 2));
	
	intBannersNum = $("div#banners-shop div.images img").size();
	
	if (intDirection == 1)
	{
		if (intLeft + 557 > 0)
		{
			objBanners.animate({left: "0"}, 1000);	
		}
		else
		{
			objBanners.animate({left: (intLeft + 557) + "px"}, 1000);
		}
	}
	else
	{
		intWindowWidth = (window.innerWidth) ? window.innerWidth : ((document.all) ? document.body.offsetWidth : null);
		
		if (557 * intBannersNum + (intLeft - 557) <= intWindowWidth)
		{
			objBanners.animate({left: "-" + (557 * intBannersNum - intWindowWidth) + "px"}, 1000);
		}
		else
		{
			objBanners.animate({left: (intLeft - 557) + "px"}, 1000);
		}
	}
}


function SwitchSectionsList()
{	
	objPreviousSlider = $("div.sections-list > div.slider");
	objPrevious = $("div.sections-list > div.list");
	
	$("div.sections-list > div.slider-hidden").attr("class", "slider");
	$("div.sections-list > div.list-hidden").attr("class", "list");
	objPreviousSlider.attr("class", "slider-hidden");
	objPrevious.attr("class", "list-hidden");
}


function GetSearchResults()
{	
	strUrl = $("span#whole-site-search a").attr("href");
		
	if (strUrl)
	{
		$("span#whole-site-results").load(strUrl + " div#total-results span");
	}
}


function SwitchSelectionType()
{	
	objCurrentType = $("div.selection div.top span.type-selected");
	objNextType = $("div.selection div.top span.type");
	
	objNextType.attr("class", "type-selected");
	objCurrentType.attr("class", "type");
	
	$("div.selection form tr:not(.main)").toggleClass("visible");
}


function SwitchImage(intNewImage)
{
	newImage = "div#img-" + intNewImage;
	
	$("div#gallery > div.current").attr("class", "hidden");
	$(newImage).attr("class", "current");
}


function SwitchTextBlock(objTextBlock)
{
	if (objTextBlock.className == "hidden")
	{
		objTextBlock.className = "";
	}
	else
	{
		objTextBlock.className = "hidden";
	}
}


function ShowQuantityField(objCart, strId)
{
	if (objCart.className == "text")
	{
		objCart.className = "text-active";
		objCart.nextSibling.style.display = "";
	}
	else
	{
		objCart.className = "text";
		objCart.nextSibling.style.display = "none";
	}
	
	
	if ($(window).width() < 1100)
	{
		$("span#" + strId).parent().find('span.price-type').toggle();
		$("span#" + strId).parent().find('span.quantity').toggle();
		$("span#" + strId).toggleClass("cart-clear-m");
	}
}


function TryAddToCart(e, intComponent, intProduct, intProductDb)
{
	intKey = e.keyCode ? e.keyCode : e.which ? e.which : null;
	
	if (intKey == 13)
	{
		AddToCart(intComponent, intProduct, intProductDb);
	}
	
	return true;
}


function AddToCart(intComponent, intProduct, intProductDb)
{
	intQuantity = $("span#c-" + intComponent + "-" + intProduct + " input[type=text]").val();
	
	if (intComponent != "" && !(isNaN(intComponent)) && intProduct != "" && !(isNaN(intProduct)) && intQuantity != "" && !(isNaN(intQuantity)))
	{
		intQuantity = Math.round(intQuantity);
		
		if (intQuantity > 0)
		{			
			$.cookie("cart[" + intComponent + "/" + intProduct + "]", intComponent + "/" + intProduct, { expires: 7, path: "/" });
			$.cookie("order_quantity[" + intComponent + "/" + intProduct + "]", intQuantity, { expires: 7, path: "/" });
			
			if (intProductDb != "" && !(isNaN(intProductDb)))
			{
				$.cookie("cart_db[" + intProductDb + "]", intProductDb, { expires: 7, path: "/" });
				$.cookie("order_quantity_db[" + intProductDb + "]", intQuantity, { expires: 7, path: "/" });
			}
			else
			{
				$.cookie("cart_a[" + intComponent + "/" + intProduct + "]", intComponent + "/" + intProduct, { expires: 7, path: "/" });
				$.cookie("order_quantity_a[" + intComponent + "/" + intProduct + "]", intQuantity, { expires: 7, path: "/" });
			}
			
			$("span#c-" + intComponent + "-" + intProduct + " span.add span.text-active").text("Товар в корзине");
			$("span#c-" + intComponent + "-" + intProduct + " span.add input[type=submit]").val("Изменить");
		}
		else
		{
			$.cookie("cart[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
			$.cookie("order_quantity[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
			
			if (intProductDb != "" && !(isNaN(intProductDb)))
			{
				$.cookie("cart_db[" + intProductDb + "]", 0, { expires: 7, path: "/" });
				$.cookie("order_quantity_db[" + intProductDb + "]", 0, { expires: 7, path: "/" });
			}
			else
			{
				$.cookie("cart_a[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
				$.cookie("order_quantity_a[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
			}
			
			$("span#c-" + intComponent + "-" + intProduct + " span.add span.text-active").text("В корзину");
			$("span#c-" + intComponent + "-" + intProduct + " span.add input[type=submit]").val("Добавить");
		}
		
		$("span#c-" + intComponent + "-" + intProduct + " span.add span.text-active").attr("class", "text");
		$("span#c-" + intComponent + "-" + intProduct + " span.add span:not(.text)").hide();
		$("span#c-" + intComponent + "-" + intProduct + " span.add span.unit").show();
		
		$("span#c-" + intComponent + "-" + intProduct).parent().find('span.price-type').show();
		$("span#c-" + intComponent + "-" + intProduct).parent().find('span.quantity').show();
		$("span#c-" + intComponent + "-" + intProduct).removeClass("cart-clear-m");
		
		$("div#cart-summary").html("<img src='/themes/electron/images/loader-small.gif' alt='' />");
		$("div#cart-summary").load("/cart?_page_element=7 div#cart-summary");
	}
}


function ShowCartQuantityField(intComponent, intProduct)
{	
	if ($("span#q-" + intComponent + "-" + intProduct + " span.for span.text").attr("class") == "text")
	{
		$("span#q-" + intComponent + "-" + intProduct + " span.for span.text").text("за");
		
		$("span#q-" + intComponent + "-" + intProduct + " span.for span.text").attr("class", "text-active");
		$("span#q-" + intComponent + "-" + intProduct + " span.for span:not(.text-active)").show();
	}
	else
	{
		$("span#q-" + intComponent + "-" + intProduct + " span.for span.text-active").text("за " + $("span#q-" + intComponent + "-" + intProduct + " span.for input[name=quantity]").val() + " " + $("span#q-" + intComponent + "-" + intProduct + " span.for span:not(.text-active)").text());
		
		$("span#q-" + intComponent + "-" + intProduct + " span.for span.text-active").attr("class", "text");
		$("span#q-" + intComponent + "-" + intProduct + " span.for span:not(.text)").hide();
	}
}


function TryChangeCartPosition(e, intComponent, intProduct, intProductDb)
{
	intKey = e.keyCode ? e.keyCode : e.which ? e.which : null;
	
	if (intKey == 13)
	{
		ChangeCartPosition(intComponent, intProduct, intProductDb);
	}
	
	return true;
}


function ChangeCartPosition(intComponent, intProduct, intProductDb)
{
	intQuantity = $("span#q-" + intComponent + "-" + intProduct + " input[name=quantity]").val();
	intPrice = $("span#q-" + intComponent + "-" + intProduct + " input[name=price]").val();
	
	if (intComponent != "" && !(isNaN(intComponent)) && intProduct != "" && !(isNaN(intProduct)) && intQuantity != "" && !(isNaN(intQuantity)))
	{
		intQuantity = Math.round(intQuantity);
		
		if (intQuantity > 0)
		{			
			$.cookie("cart[" + intComponent + "/" + intProduct + "]", intComponent + "/" + intProduct, { expires: 7, path: "/" });
			$.cookie("order_quantity[" + intComponent + "/" + intProduct + "]", intQuantity, { expires: 7, path: "/" });
			
			if (intProductDb != "" && !(isNaN(intProductDb)))
			{
				$.cookie("cart_db[" + intProductDb + "]", intProductDb, { expires: 7, path: "/" });
				$.cookie("order_quantity_db[" + intProductDb + "]", intQuantity, { expires: 7, path: "/" });
			}
			else
			{
				$.cookie("cart_a[" + intComponent + "/" + intProduct + "]", intComponent + "/" + intProduct, { expires: 7, path: "/" });
				$.cookie("order_quantity_a[" + intComponent + "/" + intProduct + "]", intQuantity, { expires: 7, path: "/" });
			}
		}
		else
		{
			$.cookie("cart[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
			$.cookie("order_quantity[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
			
			if (intProductDb != "" && !(isNaN(intProductDb)))
			{
				$.cookie("cart_db[" + intProductDb + "]", 0, { expires: 7, path: "/" });
				$.cookie("order_quantity_db[" + intProductDb + "]", 0, { expires: 7, path: "/" });
			}
			else
			{
				$.cookie("cart_a[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
				$.cookie("order_quantity_a[" + intComponent + "/" + intProduct + "]", 0, { expires: 7, path: "/" });
			}
		}
		
		$("span#q-" + intComponent + "-" + intProduct + " span.for span.text-active").text("за " + intQuantity + " " + $("span#q-" + intComponent + "-" + intProduct + " span.for span:not(.text-active)").text());
		
		$("span#q-" + intComponent + "-" + intProduct + " span.for span.text-active").attr("class", "text");
		$("span#q-" + intComponent + "-" + intProduct + " span.for span:not(.text)").hide();
		
		
		intQuantity = parseFloat(intQuantity);
		intPrice = parseFloat(intPrice);
		
		intSum = intQuantity * intPrice;
		
		intSumRub = parseInt(intSum);
		intSumCop = intSum - intSumRub;	
		
		intSumRub = intSumRub.toString();
		intSumCop = intSumCop.toString();
		intSumCop = intSumCop.substring(2, 4);
		
		if (intSumRub.length > 9)
		{
			intSumRub = intSumRub.substring(0, intSumRub.length - 9) + ' ' + intSumRub.substring(intSumRub.length - 9, intSumRub.length - 6) + ' ' + intSumRub.substring(intSumRub.length - 6, intSumRub.length - 3) + ' ' + intSumRub.substring(intSumRub.length - 3, intSumRub.length);
		}
		else if (intSumRub.length > 6)
		{
			intSumRub = intSumRub.substring(0, intSumRub.length - 6) + ' ' + intSumRub.substring(intSumRub.length - 6, intSumRub.length - 3) + ' ' + intSumRub.substring(intSumRub.length - 3, intSumRub.length);
		}
		else if (intSumRub.length > 3)
		{
			intSumRub = intSumRub.substring(0, intSumRub.length - 3) + ' ' + intSumRub.substring(intSumRub.length - 3, intSumRub.length);
		}
		
		if (intSumCop.length == 0)
		{
			intSumCop = "00";
		}
		else if (intSumCop.length == 1)
		{
			intSumCop = intSumCop + "0";
		}
		
		
		$("span#p-" + intComponent + "-" + intProduct + " span.rub").text(intSumRub + ",");
		$("span#p-" + intComponent + "-" + intProduct + " sup.cop").text(intSumCop);
		
		$("div#cart-summary").html("<img src='/themes/electron/images/loader-small.gif' alt='' />");
		$("div#cart-summary").load("/cart?_page_element=7 div#cart-summary");
	}
}


function CheckAllFields()
{
	$("form.standard .value *").map(function(){ CheckField($(this)); });
}

	
function CheckField(objField)
{
	blnError = false;
	
	objParent = objField.parent();
	
	if (objParent.hasClass("required") && !(objParent.hasClass("range-integers") || objParent.hasClass("range-doubles") || objParent.hasClass("range-years") || objParent.hasClass("range-dates")))
	{
		if (objField.val() == "")
		{
			objParent.prev().addClass("error");
			
			blnError = true;
		}
		else
		{
			objParent.prev().removeClass("error");	
		}
	}
	
	if (!blnError)
	{
		if (objParent.hasClass("integer") || objParent.hasClass("multiinteger"))
		{
			if (objField.val() != "" && isNaN(objField.val()))
			{
				objParent.prev().addClass("error");
			}
			else
			{
				objParent.prev().removeClass("error");	
			}
		}
		
		if (objParent.hasClass("mail") || objParent.hasClass("multimail"))
		{
			if (objField.val() != "" && !(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-z]{2,4}|[0-9]{1,3})(\]?)$/.test(objField.val())))
			{
				objParent.prev().addClass("error");
			}
			else
			{
				objParent.prev().removeClass("error");	
			}
		}
		
		if (objParent.hasClass("phone") || objParent.hasClass("multiphone"))
		{
			if (objField.val() != "" && !(/^(\+\d{1,3}\s{1}\d{2,5}\s{1}\d{5,7})$/.test(objField.val())))
			{
				objParent.prev().addClass("error");
			}
			else
			{
				objParent.prev().removeClass("error");	
			}
		}
		
		if (objParent.hasClass("double") || objParent.hasClass("multidouble"))
		{
			if (objField.val() != "" && !(/^((\d+(\.\d*)?)|((\d*\.)?\d+))$/.test(objField.val())))
			{
				objParent.prev().addClass("error");
			}
			else
			{
				objParent.prev().removeClass("error");	
			}
		}
		
		if (objParent.hasClass("password"))
		{
			if (objField.attr("name").substring(objField.attr("name").length - 13) != "-confirmation")
			{
				strConfirmationName = objField.attr("name") + "-confirmation";
			}
			else
			{
				strConfirmationName = objField.attr("name").substring(0, objField.attr("name").length - 13);
			}
			
			objConfirmation = $("form.standard .value *[name=" + strConfirmationName + "]");
			
			if (!((objField.val() == "" && objConfirmation.val() == "") || ((/^(([a-z0-9_-]){4,20})$/.test(objField.val())) && objField.val() == objConfirmation.val())))
			{
				objParent.prev().addClass("error");
				objConfirmation.parent().prev().addClass("error");
			}
			else
			{
				objParent.prev().removeClass("error");	
				objConfirmation.parent().prev().removeClass("error");
			}
		}
	}
	
	
	strFormId = $("form.standard:has(td.value *[id=" + objField.attr("id") + "])").attr("id");
	
	if ($("form.standard[id=" + strFormId + "] td.error").size() == 0)
	{
		$("form.standard[id=" + strFormId + "] .buttons input[name^=save]").attr("disabled", "");
		$("form.standard[id=" + strFormId + "] .buttons input[name^=apply]").attr("disabled", "");
	}
	else
	{
		$("form.standard[id=" + strFormId + "] .buttons input[name^=save]").attr("disabled", "disabled");
		$("form.standard[id=" + strFormId + "] .buttons input[name^=apply]").attr("disabled", "disabled");
	}
}

function EqualAddress($strAdressType)
{
	if ($strAdressType == "real")
	{
		if ($("form.standard input[name=equals-legal-address]").attr("checked"))
		{
			$("form.standard .value *[name='real-postal-code']").val($("form.standard .value *[name='legal-postal-code']").val());
			$("form.standard .value *[name='real-region']").val($("form.standard .value *[name='legal-region']").val());
			$("form.standard .value *[name='real-place']").val($("form.standard .value *[name='legal-place']").val());
			$("form.standard .value *[name='real-street']").val($("form.standard .value *[name='legal-street']").val());
			$("form.standard .value *[name='real-house']").val($("form.standard .value *[name='legal-house']").val());
			$("form.standard .value *[name='real-building']").val($("form.standard .value *[name='legal-building']").val());
			$("form.standard .value *[name='real-office']").val($("form.standard .value *[name='legal-office']").val());
			
			$("form.standard .value *[name*='legal-']").change(function(){ OnEqualChange($(this)); });
			
			$("form.standard .value *[name*='real-']").attr("readonly", "readonly");
			$("form.standard .value *[name*='real-']").addClass("readonly");
			
			
			if ($("form.standard input[name=equals-real-address]").attr("checked"))
			{
				$("form.standard .value *[name='delivery-postal-code']").val($("form.standard .value *[name='real-postal-code']").val());
				$("form.standard .value *[name='delivery-region']").val($("form.standard .value *[name='real-region']").val());
				$("form.standard .value *[name='delivery-place']").val($("form.standard .value *[name='real-place']").val());
				$("form.standard .value *[name='delivery-street']").val($("form.standard .value *[name='real-street']").val());
				$("form.standard .value *[name='delivery-house']").val($("form.standard .value *[name='real-house']").val());
				$("form.standard .value *[name='delivery-building']").val($("form.standard .value *[name='real-building']").val());
				$("form.standard .value *[name='delivery-office']").val($("form.standard .value *[name='real-office']").val());
			}
		}
		else
		{
			$("form.standard .value *[name*='legal-']").unbind("change");		
			$("form.standard .value *[name*='real-']").attr("readonly", "");
			$("form.standard .value *[name*='real-']").removeClass("readonly");	
		}
	}
	else
	{
		if ($("form.standard input[name=equals-real-address]").attr("checked"))
		{
			$("form.standard .value *[name='delivery-postal-code']").val($("form.standard .value *[name='real-postal-code']").val());
			$("form.standard .value *[name='delivery-region']").val($("form.standard .value *[name='real-region']").val());
			$("form.standard .value *[name='delivery-place']").val($("form.standard .value *[name='real-place']").val());
			$("form.standard .value *[name='delivery-street']").val($("form.standard .value *[name='real-street']").val());
			$("form.standard .value *[name='delivery-house']").val($("form.standard .value *[name='real-house']").val());
			$("form.standard .value *[name='delivery-building']").val($("form.standard .value *[name='real-building']").val());
			$("form.standard .value *[name='delivery-office']").val($("form.standard .value *[name='real-office']").val());
			
			$("form.standard .value *[name*='real-']").change(function(){ OnEqualChange($(this)); });
			
			$("form.standard .value *[name*='delivery-']").attr("readonly", "readonly");
			$("form.standard .value *[name*='delivery-']").addClass("readonly");
		}
		else
		{
			$("form.standard .value *[name*='real-']").unbind("change");			
			$("form.standard .value *[name*='delivery-']").attr("readonly", "");
			$("form.standard .value *[name*='delivery-']").removeClass("readonly");	
		}
	}
	
	CheckAllFields();
}

function OnEqualChange(objField)
{
	strName = objField.attr("name");
	
	if (strName.substring(0, 6) == "legal-")
	{
		strName = strName.substring(6, strName.length);
		
		$("form.standard .value *[name=real-" + strName + "]").val(objField.val());
		CheckField($("form.standard .value *[name=real-" + strName + "]"));
		
		if ($("form.standard input[name=equals-legal-address]").attr("checked") && $("form.standard input[name=equals-real-address]").attr("checked"))
		{
			$("form.standard .value *[name=delivery-" + strName + "]").val(objField.val());	
			CheckField($("form.standard .value *[name=delivery-" + strName + "]"));
		}
	}
	else
	{
		strName = strName.substring(5, strName.length);
		
		$("form.standard .value *[name=delivery-" + strName + "]").val(objField.val());
		CheckField($("form.standard .value *[name=delivery-" + strName + "]"));
	}
}

function BuildPhone(objField)
{
	strName = objField.attr("id");
	strName = strName.substring(0, strName.length - 2)
	
	strPhone = "+" + $("form.standard .value *[id=" + strName + "-1]").val() + " " + $("form.standard .value *[id=" + strName + "-2]").val() + " " + $("form.standard .value *[id=" + strName + "-3]").val();
	
	if (strPhone == "+  ")
	{
		strPhone = "";
	}
	
	$("form.standard .value *[name=" + strName + "]").val(strPhone);
	
	CheckField($("form.standard .value *[name=" + strName + "]"));
}

function OnSubmit(objForm)
{
	if (!($("form.standard .value *[name=password]").parent().hasClass("required")) && !($("form.standard .value *[name=password-confirmation]").parent().hasClass("required")) && $("form.standard .value *[name=password]").val() == "")
	{		
		$("form.standard .value *[name=password]").parent().empty();
		$("form.standard .value *[name=password-confirmation]").parent().empty();
	}
}

function fixPNG(element)
{
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{		
		src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
		  
		if (src)
		{
			src = src[1];
			element.runtimeStyle.backgroundImage = "none";
		}

		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
	}
}