var images = new Array("/siteimages/icon 1a.png", "/siteimages/icon 2a.png", "/siteimages/icon 3a.png", "/siteimages/icon 4a.png", "/siteimages/icon 5a.png", "/siteimages/icon 6a.png", "/siteimages/icon 7a.png", "/siteimages/icon 8a.png", "/siteimages/icon 9a.png");
var preload = [];

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

	preload [i] = new Image();
	
	preload [i].src = images[i];

}
/*
$(document).ready(function(){
    //When Mouse rolls over ol
    $("#vnav ul").mouseover(function(){
        $(this).stop().animate({height:'100%'},{queue:false, duration:1500, easing: 'easeOutBounce'})
    });
    //When Mouse cursor removed from ol
    $("#vnav ul").mouseout(function(){
        $(this).stop().animate({height:'23px'},{queue:false, duration:1500, easing: 'easeOutBounce'})
    });
});
*/

function musicaGo(){
	var winObj = window.open('/music/musica.html', 'Musica', 'width=350,height=300,top=0,right=0,resizable=0,menubar=no,toolbar=no');
		winObj.focus();
	}

$(document).ready(function(){
    //When Mouse rolls over ol
    $(".section").mouseover(function(){
        $(this).stop().animate({height:'230px'},{queue:false, duration:1000, easing: 'easeOutBounce'})
    });
    //When Mouse cursor removed from ol
    $(".section").mouseout(function(){
        $(this).stop().animate({height:'50px'},{queue:false, duration:3000, easing: 'easeOutBounce'})
    });
	


//calc


$(".calcButton").click(function(){
	$('#calc').css('display', 'block');
	$("#calc").empty();
	$('#calc').prepend('<img src="/siteimages/loading.gif" />');
	$.post('/ajax/calc.php', function(result){
		$('#calc').empty();
		$('#calc').append(result);
	}
	);
	return false;
});

});




function addBagetBox(){
	var width = $('#width').val();
	var height = $('#height').val();
	$("#bagetbox").empty();
	$('#bagetbox').prepend('<img src="/siteimages/loading.gif" />');
	$('#bagetbox').slideDown("slow", function(){
		$.post('/ajax/bagetbox.php', {width:width, height:height}, function(result)
		{
			$('#bagetbox').empty();
			$('#bagetbox').append(result);
			$('#forfade').fadeIn(2000);
		});		
	});
	}

function removeBagetBox(){
	$('#forfade').fadeOut("slow");
	$('#bagetbox').slideUp("slow");
	}
	
function postersize(value){
var widthheight = value.split('|');
var width = widthheight[0];
var height = widthheight[1];
$('#width').val(width);
$('#height').val(height);
	if($('#bagetbox').css('display') == "block")
	{
		$('#choisebaget').attr('checked','checked');
		removeBagetBox();
		addBagetBox();
	}
postprint();
}

function postprint(){

var val = $("input[name='obrabotka']:checked").val();
var width = $('#width').val();
var height = $('#height').val();
switch (val){
	case "1":
		var cena = 4000; //Печать на холсте
		break;
	case "2":
		var cena = 4000+3000; //Печать + имитация
		break;
	case "3":
		var cena = 4000+20000; //Печать + роспись
		break;
	case "4":
		var cena = 2500; //Печать на фотобумаге
		break;
	}
if(document.getElementById("crack").checked){
			var crackPrice = width*height*12000/10000; //За кракелюр
			var ordtextcrack = " С искуственным состариванием картины художником (кракелюра)";
		}
		else {
			var crackPrice = 0;
			var ordtextcrack = "";
		}

var bagetJob = 0;		
		
$("#widthimg").empty();
$("#heightimg").empty();
$("#widthimgl").empty();
$("#widthimgd").empty();
$("#widthimg").append(width+"см.");
$("#heightimg").append(height+"см.");
$("#widthimgl").append(height+"см.");
$("#widthimgd").append(width+"см.");


	var bagetka = $("input[name='bagetrabota']:checked").val()*1;
	//alert(bagetka);
	if (bagetka > 3){
			bagetJob = bagetka;
			var ordtextbagetka = "Багет артикул "+($("input[name='bagetrabota']:checked").prev().prev().prev().prev().prev().prev().text())+" и шириной профиля "+($("input[name='bagetrabota']:checked").prev().prev().prev().prev().prev().prev().prev().prev().prev().text())+" мм.";
		} else if (bagetka != 2 && bagetka <= 3){
			var ordtextbagetka = "Без багетных работ";
			bagetJob = 0;
		}
		if (bagetka == 2){ 
			var bagetJob = (width >= height) ? ((width-30)*25 + 500).toFixed(0) : ((height-30)*25 + 500).toFixed(0); //подрмник считаем
			var ordtextbagetka = ($("input[name='bagetrabota']:checked").next().text());
			}
	var priceskidka = ((width*height*cena/10000+crackPrice*1+bagetJob*1)*1.20).toFixed(0); //20% скидка, т.е. на 20% дороже.
	if (priceskidka < 360) priceskidka=360;
	var priceonly = (width*height*cena/10000+crackPrice*1+bagetJob*1).toFixed(0);
	if (priceonly < 300) priceonly=300;
	var str = "<small style='text-decoration:line-through'>"+priceskidka+" руб.</small><br/><b style='color:green'>"+priceonly+" руб.</b>";
	$("#price").empty();
	$("#price").append(str);
	
	if ($("input[name='size']:checked").val() != 5) var ordtextsize = ($("input[name='size']:checked").next().text()); else var ordtextsize = "Свой размер ("+width+"см. х "+height+")";
	var ordtextobrabotka = ($("input[name='obrabotka']:checked").next().text());
	
	var ordertext = "<b>"+ordtextsize+"</b>\n<br/> Постпечатная обработка: <b>"+ordtextobrabotka+"</b>\n<br/>"+" Багетные работы: <b>"+ordtextbagetka+"</b>\n<br/><b>"+ordtextcrack+"</b>";
	$("#opisaniezakaza").empty();
	$("#opisaniezakaza").append(ordertext);
	$("#opisaniepole").val($("#opisaniezakaza").text());
	$("#priceonly").val(priceonly);
}
	

