function MenuToogle()
{
	$('#FullMenu').toggle();
	$('#SmallMenu').toggle();
	$('#Arr-Down').toggle();
	$('#Arr-Up').toggle();
}
function toggleDecoration()
{
	
}

function showMainImage(Image)
{
	//document.mainimage.src = Image
	//$('#mainimage').src(Image);
	$('#mainimage').attr('src', Image);
}

var tCartDecoration = new Array();
var tCartCount = new Array();

function setDecoration(aGoodID, aDecorationID)
{
	if (tCartDecoration[aGoodID] == undefined)
	{ }
	else
	{
		$('#decorlsel' + aGoodID + '_' + tCartDecoration[aGoodID]).html("");
	}

	$('#decorlsel' + aGoodID + '_' + aDecorationID).html("цвет выбран");
	tCartDecoration[aGoodID] = aDecorationID;
}

function clearDecoration(aGoodID, aCnt)
{
	$('#decorlsel' + aGoodID + '_' + tCartDecoration[aGoodID]).html(aCnt + " добавлено");
	tCartDecoration[aGoodID] = undefined;
}
// добавляем в корзину
function addToCart(aGoodID)
{
	if (tCartDecoration[aGoodID] == undefined)
	{
		alert("Вы не указали вид отделки!");
		return ;
	}
	
	tIntCount = parseInt($('#quantity' + aGoodID).val());
	if (tIntCount == 0 || !(tIntCount))
	{
		alert("Укажите количество!");
		return ;
	}
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		if (window.attachEvent && navigator.userAgent.indexOf("Opera")==-1) {
			
		}
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(100);	
		$('#mask').fadeTo("slow",0.1);
	
	//$("#orderBTN_" + aGoodID).html("Добавлено в корзину. <a href='/cart#goods'>Перейти к оформлению</a>");
	var tUrl = '/cart/ajaxModal.php?itemID=' + aGoodID + '&decoration=' + tCartDecoration[aGoodID] + '&quant=' + $('#quantity' + aGoodID).val() + '&add';
	
	$('#Modal' + aGoodID).show(); 
	$('#mask').css("z-index", "9000");
	$('#Modal' + aGoodID).css("z-index", "9999");
	$('#Modal' + aGoodID).load(tUrl, function(){
		$('#CartCNT').load('/cart/ajaxTotal.php?cnt');
		$('#CartSum').load('/cart/ajaxTotal.php?sum');
		$('#BeforAdd').hide();
		$('#AfterAdd').show();
	});
	
	if (tCartCount[aGoodID + "-" + tCartDecoration[aGoodID]] == undefined)
		tCartCount[aGoodID + "-" + tCartDecoration[aGoodID]] = tIntCount;
	else
		tCartCount[aGoodID + "-" + tCartDecoration[aGoodID]] += tIntCount;
	
	$('#decorlsel' + aGoodID + '_' + tCartDecoration[aGoodID]).html(tCartCount[aGoodID + "-" + tCartDecoration[aGoodID]] + " добавлено");
	tCartDecoration[aGoodID] = undefined;
	
	$('#quantity' + aGoodID).val("");
	checkbrowsermask();
}

function swapCount(event, GoodID, count)
{
	tIntCount = parseInt(count);
	if (tIntCount == 0 || !(tIntCount)) return;

	$.get('/cart/index.php?basketID=' + GoodID + '&quantity=' + tIntCount, function(){
		$('#CartCNT').load('/cart/ajaxTotal.php?cnt');
		$('#CartSum').load('/cart/ajaxTotal.php?sum');
		$('#TotalSum').load('/cart/ajaxTotal.php?sum');
	});
}

function hideModal(aGoodID)
{
	$('#Modal' + aGoodID).hide()
	$('#Modal' + aGoodID).html();
	$('#mask').hide();
}

$(document).ready(function() {	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.Modal').hide();
		$('.Modal').html();
	});
});