function add_cd(cd, count, button, lang)
{
	var button_ = document.getElementById(button);
	var total = document.getElementById('bucket_total_count');
	jx.load('/ajax/add_to_cart?cd='+ cd +'&count=' + count,function(data){
		var json_result =  JSON.parse(data);
		
		
		
	button_.innerHTML = json_result.cd_count;
	total.innerHTML = json_result.total_count;
});
	
};

var ship_flag = 1;

function calculate_total(total)
{
	ship_flag = !ship_flag;
	var price = document.getElementById('price');
	var ship = document.getElementById('ship');
	var amount_mb = document.getElementById('amount_mb');
	
	if(ship_flag == 1)
	{
		total=total;
		ship.innerHTML = 6;
	}
	else
	{
		total-=6;
		ship.innerHTML = 0;
	}
	
	amount_mb.innerHTML = total;
	price.innerHTML = total;
}

function update_count(cd_number, lang)
{
	var count = document.getElementById('count_'+ cd_number).value;
	var price_span = document.getElementById('price_'+ cd_number);
	var total_span = document.getElementById('total');
	var shipment_span = document.getElementById('shipment');
	var order_price_field = document.getElementById('total_field');
	var shipment_price_field = document.getElementById('shipment_field');
	
	jx.load('/ajax/update_cart?cd='+ cd_number +'&count=' + count + '&lang=' + lang, function(data){
	var json_result =  JSON.parse(data);
	price_span.innerHTML = json_result.single_price;
	total_span.innerHTML = json_result.total_price;
	shipment_span.innerHTML = json_result.shipment;
	order_price_field.value = json_result.total_price - json_result.shipment;
	shipment_price_field.value = json_result.shipment;
	});	
}

JSON.parse = JSON.parse || function (str) {  
    if (str === "") str = '""';  
    eval("var p=" + str + ";");  
    return p;  
};

function hint(lang, message_index)
{
	var messages = new Array();
	messages['ru1'] = 'Оплата заказа в момент его получения на почте.<br> Обратите внимание: при оплате наложенным платежом итоговая сумма получается на 30-40% больше.';
	
	messages['ru2'] = 'Оплата через систему Web Money. Инструкции по оплате будут показаны на следующем шаге заказа.';
	
	messages['ru3'] = 'Мы можем также принять оплату другим удобным для вас способом: банковским переводом, через терминал и т.д. Наш менеджер свяжется с вами для уточнения деталей после подтверждения заказа.';
	
	messages['en1'] = 'Skrill (Moneybookers) is the secure way to pay globally without revealing your financial details. With just your email address, you can send and spend with over 100 payment options, including all major credit and debit cards, in 200 countries.';
	
	messages['en2'] = 'To pay your order with PayPal you must made a manual payment to our address. You will receive a complete details on the next step.';
	
	messages['it1'] = 'Skrill (Moneybookers) è il metodo di pagamento sicuro in tutto il mondo, senza dover rivelare i propri dettagli finanziari. Vi basta fornire il vostro indirizzo email e potrete spedire e acquistare con più di 100 opzioni di pagamento, incluse le principali carte di credito e debito, in 200 nazioni.';
	messages['it2'] = 'PayPal, società leader a livello mondiale per i pagamenti online.';


	

	var hint_div = document.getElementById('order_hint');
	hint_div.innerHTML = messages[lang+message_index];
}

function feedback_post(lang)
{
	var name = encodeURIComponent(document.getElementById('name').value);
	var message = encodeURIComponent(document.getElementById('message').value);
	var country = encodeURIComponent(document.getElementById('country').value);
	var order_number = encodeURIComponent(document.getElementById('order_number').value);
	var disc_id = document.getElementById('disc_id').value;
	var rating = document.getElementById('rating_field').value;

	var post_string =  'lang=' + lang + '&name=' + name + '&message=' + message + '&country=' + country + '&disc_id=' + disc_id
	+ '&order_number=' + order_number + '&rating=' + rating;

	jx.load('/ajax/post_feedback?' + post_string, function(data) {
	
	var form = document.getElementById('comment_form');
	form.style.visibility='hidden';
	
	var message_div = document.getElementById('message_div');
	message_div.innerHTML = data;
	
	},'text','post');
	

}

function rate (rating)
{
	var rating_field = document.getElementById('rating_field');
	
	rating_field.value = rating;
}

function embed_player (track, mp3)
{
	var flashvars = {};
	var params = {wmode: "transparent"};
	var attributes = {styleclass: "flash_audio"};
	var param_string = '/js/audioplay/audioplay.swf?auto=false&bgcolor=0xFEBA0D&repeat=1&file=' + mp3 + '&buttondir=/js/audioplay/buttons/my&mode=listenstop&mastervol=100';
	var track_string = 'flashcontent_' + track;
	alert(param_string);
	swfobject.embedSWF(param_string, track_string, "15", "15", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

