// JavaScript Document
/*
function calc() {

	var c1 = $('#c1').text();
	var c2 = $('#c2').text();
	var x1 = $('#x1').text();

	$.ajax({
		type: 	'get',
		url: 	'modules/calculator.php',
		data:	'c1='+c1+"&c2="+c2+"&x1="+x1,
		beforeSend: function () {},
		success: function (response) {

		},
		error: function(response) {
		},
		complete:	function(response) {
		}
		
	})

}*/






window.onload = function(){


	$('a[rel=external]').attr('target', '_blank');



	var ct = new Date();
	var year = ct.getFullYear();
	if (ct.getMonth()+1 < 10) 
		var month = '0'+(ct.getMonth()+1);
	else
		var month = ct.getMonth()+1;
	if (ct.getDate() < 10)
		var day = '0'+(ct.getDate());
	else
		var day = ct.getDate();
	
	var today = "'"+year+'-'+month+'-'+day+"'";
	
	$('.date-picker').datePicker({
		startDate:	'1998-01-01',
		endDate:	today
	});
	//alert('"'+year+'-'+month+'-'+day+'"');
	
	$('.hover').fadeTo(500, 0.6).bind('mouseover', function(){
		$(this).fadeTo(200, 1).css({
			color: '#FFF',
			background: '#069'
		});
	}).bind('mouseout', function(){
		$(this).fadeTo(300, 0.6).css({
			color: '#000',
			background: '#FFF'
		});
	});
	$('.hover2').bind('mouseover', function(){
		$(this).css({
			color: '#FFF',
			background: '#069',
			cursor: 'pointer'
		});
	}).bind('mouseout', function(){
		$(this).css({
			color: '#000',
			background: '#FFF'
		});
	});
	$('#main-messages').fadeTo(500, 0.5).bind('mouseover', function(){
		$(this).fadeTo(500, 1)
	}).bind('mouseout', function(){
		$(this).fadeTo(500, 0.5)
	}).bind('click', function (){
		$(this).slideUp(500);
	}).css({
		cursor: 'pointer'
	});
	
}



function calc()
{
	if  (document.getElementById("x1").value != "" )
	{
		rez_exact = parseFloat(document.getElementById("x1").value) * parseFloat(document.getElementById("c1").value) / parseFloat(document.getElementById("c2").value);
		document.getElementById("rez").value = Math.round(rez_exact*100)/100;
		document.getElementById("tva").value = Math.round(rez_exact*100*0.19)/100;
		document.getElementById("rez_final").value = Math.round(rez_exact*100*1.19)/100;
	}
	else
	{
		document.getElementById("rez").value = "";
		document.getElementById("tva").value = "";
		document.getElementById("rez_final").value = "";
	}
}