var PriceCalculator = new Object();
	PriceCalculator.priceTv = 0;
	PriceCalculator.priceInet = 0;
	PriceCalculator.plus18 = 0;
	PriceCalculator.totalPrice = 0;
	PriceCalculator.discountPrice = 0;

	$(document).ready(function () {


	    if ($("div.sub.chanels").length) {
	        $("#price-list > ul > li > .sub").slideToggle(0);

	        $("#price-list > ul > li > div > .price > a").click(function (e) {
	            e.preventDefault();
	            $(this).parent().parent().parent().children(".sub.order").slideToggle(150);
	            $(this).parent().parent().parent().children(".sub.chanels").slideUp(150);
	        });
	        $("#price-list > ul > li > div > .chanels > a").click(function (e) {
	            e.preventDefault();
	            $(this).parent().parent().parent().children(".sub.chanels").slideToggle(150);
	            $(this).parent().parent().parent().children(".sub.order").slideUp(150);
	        });
	    }
	    else if ($("#chanel-list").length) {
	        //$("#chanel-list").slideUp(0);
	        //$("#plus18 ul").slideUp(200);
	        /*$("#price-list.compare-chanels > a.compare").click(function (e) {
	            e.preventDefault();
	            $("#chanel-list").slideToggle(200);
	            $("#plus18 ul").slideToggle(200);
	        });*/
	        $("#price-list > ul > li > .sub").slideToggle(0);
	        $("#price-list > ul > li > div > .price > a").click(function (e) {
	            e.preventDefault();
	            if (!$(this).parent().parent().parent().children(".sub.order").hasClass("on")) {
	                $("#price-list > ul > li > .sub").each(function (e) {
	                    if ($(this).hasClass("on")) {
	                        $(this).removeClass("on");
	                        $(this).slideUp(0);
	                    }
	                });
	            }
	            
	            $(this).parent().parent().parent().children(".sub.order").addClass("on");
	            $(this).parent().parent().parent().children(".sub.order").slideToggle(150);

	        });
	    }
	    else if ($("#double-calc").length) {
	        PriceCalculator.populateArray();

	        $("#double-calc .total > div.sub").slideToggle(0);
	        $("div.sub.central").slideToggle(0);
	        $("#double-calc .total > div.block > a").click(function (e) {
	            e.preventDefault();
	            $("#double-calc .total > div.sub").slideToggle(150);
	        });
	        $("#special-offer a").click(function (e) {
	            e.preventDefault();
	            $("div.sub.central").slideToggle(150);
	        });
	        PriceCalculator.calculate();
	        $("#price-list.double > ul > li").click(function () {
	            $(this).parent("ul").children("li").removeClass("active");
	            $(this).addClass("active");




	            if ($(this).parent().hasClass("tv")) {
	                $("#double-calc .calc .tv").fadeOut(0);
	                $("#double-calc .total > .block > .tv").fadeOut(0);
	                PriceCalculator.calculate();
	                $("#double-calc .calc .tv").fadeIn(250);
	                $("#double-calc .total > .block > .tv").fadeIn(250);
	            }
	            else {
	                $("#double-calc .calc .inet").fadeOut(0);
	                $("#double-calc .total > .block > .inet").fadeOut(0);
	                PriceCalculator.calculate();
	                $("#double-calc .calc .inet").fadeIn(250);
	                $("#double-calc .total > .block > .inet").fadeIn(250);
	            }
	        });
	        $("#plus18 input").click(PriceCalculator.calculate);
	    }
	    else if ($("#price-list > ul > li > .sub").length) {
	        $("#price-list > ul > li > .sub").slideToggle(0);

	        $("#price-list > ul > li > div > .price > a").click(function (e) {
	            e.preventDefault();
	            $(this).parent().parent().parent().children(".sub").slideToggle(150);
	        });
	    }
	    else if ($("#new-year-backet").length) {
	        $(".check-menu > .check-block > input").click(function (e) {
	            //	($(this).attr("class"));
	            $("#new-year-backet ul li > *").fadeTo(150, .2);

	            $("#new-year-backet ul ." + $(this).attr("class") + " > *").fadeTo(250, 1);

	        });
	    }
	});

	PriceCalculator.populateArray = function () {

	    PriceCalculator.discountArray = [35, 45, 50, 60, 38, 48, 55, 63, 44, 54, 65, 69, 48, 58, 70, 73, 61, 71, 85, 86];
	    PriceCalculator.arrIndex = 0;

	    PriceCalculator.discountCalculator;


	    discountCalculator = new Array();
	    $("#price-list.double > ul.inet > li").each(function (i) {
	        discountCalculator.push(new Array());
	        $(this).children("div").attr("class",i);
	        $("#price-list.double > ul.tv > li").each(function (d) {
	            $(this).children("div").attr("class", d);
	            discountCalculator[i][d] = PriceCalculator.discountArray[PriceCalculator.arrIndex];
	            PriceCalculator.arrIndex++;
	        });


	    });
	    //console.log(discountCalculator);
	}

	PriceCalculator.calculate = function () {
	    //alert($("#plus18 input").removeAttr("checked");
	    //$("#plus18 input").attr("checked",false);
	    $("#calc-sum p").fadeOut(0);
	    $("#calc-formula-sum p").fadeOut(0);
	    if ($("#plus18 input").attr("checked") == "checked") {
	        PriceCalculator.plus18 = Number($("#plus18 .price .tag p").html());
	    }
	    else {
	        PriceCalculator.plus18 = 0;
	    }

	    $("#double-calc .calc .tv .tech").attr("class", $("#price-list.double ul.tv > li.active .tech").attr("class"));
	    $("#double-calc .calc .tv .speed").html($("#price-list.double ul.tv > li.active .speed p").html());
	    $("#double-calc .calc .inet .tech").attr("class", $("#price-list.double ul.inet > li.active .tech").attr("class"));
	    $("#double-calc .calc .inet .speed").html($("#price-list.double ul.inet > li.active .speed p").html());


	    $("#double-calc .total > .block > .inet").html($("#price-list.double ul.inet > li.active .type h2").html());
	    $("#double-calc .total > .block > .tv").html($("#price-list.double ul.tv > li.active .type h2").html());

	    PriceCalculator.priceTv = Number($("#price-list.double ul.tv > li.active .price .tag p").html());
	    PriceCalculator.priceInet = Number($("#price-list.double ul.inet > li.active .price .tag p").html());

	    PriceCalculator.totalPrice = PriceCalculator.priceTv + PriceCalculator.priceInet + PriceCalculator.plus18;
	    PriceCalculator.discountPrice = discountCalculator[Number($("#price-list.double ul.inet > li.active > div").attr("class"))][Number($("#price-list.double ul.tv > li.active > div").attr("class"))] + PriceCalculator.plus18;
	    $("#calc-sum p").html((PriceCalculator.totalPrice) + "<b> ლარი</b>");

	    if (PriceCalculator.totalPrice == PriceCalculator.discountPrice) {
	        $("#calc-sum p").css("text-decoration", "none");
	    }
	    else {
	        $("#calc-sum p").css("text-decoration", "line-through");
	    }




	    $("#calc-formula-sum p").html(PriceCalculator.discountPrice + "<b> ლარი</b>");
	    $("#calc-sum p").fadeIn(250);
	    $("#calc-formula-sum p").fadeIn(250);

	}

