var price = 0;

var price_bank_card = 0;
var price_USD_WMZ = 0;
var price_USD_WMR = 0;
var price_USD_WME = 0;
var price_USD_WMU = 0;

var price_WMZ_pay_WMZ = 0;
var price_WMZ_pay_WMR = 0;
var price_WMZ_pay_WMU = 0;

var price_other = 0;

function order()
{
	var sel = document.getElementById('packService');

	if (sel.selectedIndex =='0')
	{
		document.getElementById('firstStyle').style.display='block';
		document.getElementById('secondStyle').style.display='none';
		document.getElementById('thirdStyle').style.display='none';
		document.getElementById('star2').style.display='block';
		document.getElementById('star3').style.display='none';
		price = Price_smart;
		document.getElementById('prod_id').value = 'smart';
	}
	if (sel.selectedIndex =='1')
	{
		document.getElementById('firstStyle').style.display='none';
		document.getElementById('secondStyle').style.display='block';
		document.getElementById('thirdStyle').style.display='none';
		document.getElementById('star2').style.display='none';
		document.getElementById('star3').style.display='none';
		price = Price_unique;
		document.getElementById('prod_id').value = 'unique';
	}
	if (sel.selectedIndex =='2')
	{
		document.getElementById('firstStyle').style.display='none';
		document.getElementById('secondStyle').style.display='none';
		document.getElementById('thirdStyle').style.display='block';
		document.getElementById('star2').style.display='none';
		document.getElementById('star3').style.display='block';
		price = Price_prestige;
		document.getElementById('prod_id').value = 'prestige';
	}

	set_prices ();
	show_prices ();
}

function set_prices ()
{
	price_bank_card = price;
	price_USD_WMZ = price;
	price_USD_WMR = parseInt(price * KursUSD_WMR * 100) / 100;
	price_USD_WME = parseInt(price * KursUSD_WME * 100) / 100;
	price_USD_WMU = parseInt(price * KursUSD_WMU * 100) / 100;

	price_WMZ_pay_WMZ = price;
	price_WMZ_pay_WMR = parseInt(price * KursUSD_WMR * 100) / 100;
	price_WMZ_pay_WMU = parseInt(price * KursUSD_WMU * 100) / 100;

	price_other = parseInt(price * KursUSD_WMR * 100) / 100;
}


function show_prices ()
{
	if ((document.getElementById('browser').getAttribute('name')) == 'ie')
	{
		document.getElementById('bank_span').innerText = price_bank_card;
		document.getElementById('yad_text_price').innerText = price_USD_WMR;
		document.getElementById('swmz').innerText = price_USD_WMZ;
		document.getElementById('swmr').innerText = price_USD_WMR;
		document.getElementById('swme').innerText = price_USD_WME;
		document.getElementById('swmu').innerText = price_USD_WMU;
		document.getElementById('swmz_z').innerText = price_WMZ_pay_WMZ;
		document.getElementById('swmz_e').innerText = price_USD_WME;
		document.getElementById('swmz_r').innerText = price_WMZ_pay_WMR;
		document.getElementById('swmz_u').innerText = price_WMZ_pay_WMU;
		document.getElementById('yad_s').innerText = price_USD_WMR;
		document.getElementById('snal').innerText = price_other;
		//document.getElementById('snal2').innerText = price_other;
	}
	else
	{
		document.getElementById('bank_span').innerHTML = price_bank_card;
		document.getElementById('yad_text_price').innerHTML = price_USD_WMR;
		document.getElementById('swmz').innerHTML = price_USD_WMZ;
		document.getElementById('swmr').innerHTML = price_USD_WMR;
		document.getElementById('swme').innerHTML = price_USD_WME;
		document.getElementById('swmu').innerHTML = price_USD_WMU;
		document.getElementById('swmz_z').innerHTML = price_WMZ_pay_WMZ;
		document.getElementById('swmz_e').innerHTML = price_USD_WME;
		document.getElementById('swmz_r').innerHTML = price_WMZ_pay_WMR;
		document.getElementById('swmz_u').innerHTML = price_WMZ_pay_WMU;
		document.getElementById('yad_s').innerHTML = price_USD_WMR;
		document.getElementById('snal').innerHTML = price_other;
		//document.getElementById('snal2').innerHTML = price_other;
	}
}


function show_path()
{
	var zpath = window.document.location + '';
	var zproduct = zpath.substr(zpath.lastIndexOf('=')+1, zpath.length);

	switch (zproduct) {
	case 'smart':
		document.getElementById('packService').selectedIndex = '0';
		order();
		break;
	case 'unique':
		document.getElementById('packService').selectedIndex = '1';
		order();
		break;
	case 'prestige':
		document.getElementById('packService').selectedIndex = '2';
		order();
		break;
	default:
		document.getElementById('packService').selectedIndex = '0';
		order();
		break;
	}
}

function show_ym (type)
{
	document.getElementById('zform1').action = '/cgi-bin/formmail/formmail.cgi';

	// cash
	if ( type == 'cash' ) {
		document.getElementById('your_method').style.display = 'none';
		document.getElementById('cash_method').style.display = 'block';
		change_form_id ('cash_new');

	// other methods
	} else {
		document.getElementById('cash_method').style.display = 'none';
		document.getElementById('your_method').style.display = 'block';
		change_form_id ('other');
	}
	
}

function hide_ym ()
{
	document.getElementById('your_method').style.display = 'none';
	document.getElementById('cash_method').style.display = 'none';
	document.getElementById('yad_text').style.display = 'none';
	document.getElementById('formid_id').value = 'otherpay';
	document.getElementById('zform1').action = '/cgi-bin/pay.cgi';

	change_form_id ('cash');
}

function show_yad ()
{
	document.getElementById('your_method').style.display = 'none';
	document.getElementById('cash_method').style.display = 'none';
	document.getElementById('yad_text').style.display = 'block';
	document.getElementById('formid_id').value = 'yandexpay';
	document.getElementById('zform1').action = '/cgi-bin/formmail/formmail.cgi';

	change_form_id ('yandex');
}

function change_form_id (val)
{
	var res = '';
	var form_type = document.getElementById('form_type').value;
	if (form_type == 'order')
	{
		switch (val)
		{
			case 'cash':
				res = 'ordercash';
				break;
			case 'cash_new':
				res = 'cash';
				break;
			case 'yandex':
				res = 'yandexpay';
				break;
			case 'other':
				res = 'otherpay';
		}
	}
	else
	{
		switch (val)
		{
			case 'cash':
				res = 'giftcash';
				break;
			case 'cash_new':
				res = 'cash_gift';
				break;
			case 'yandex':
				res = 'yandexpay_gift';
				break;
			case 'other':
				res = 'otherpay_gift';
		}
	}
	
	document.getElementById('formid_id').value = res;
}


function show_pop2 ()
{
	var scroll_left = 268;
	var scroll_top = getBodyScrollTop();
	if (scroll_top >= 300)
	{
		scroll_top = (scroll_top + 10);
	}
	else
	{
		scroll_top = 370;
	}

	/*
	var cl_width = getClientWidth();
	if (cl_width >= 665)
	{
		scroll_left = parseInt ( (cl_width - 665)/2 );
	}
	else
	{
		scroll_left = 10;
	}
	*/

	document.getElementById('prpop3').innerHTML = price_USD_WMR;

	document.getElementById('pop_wnd2').style.left = scroll_left + 'px';
	document.getElementById('pop_wnd2').style.top = scroll_top + 'px';
	document.getElementById('pop_wnd2').style.display = 'block';
}

function getBodyScrollTop()
{
  return self.pageYOffset || 
    (document.documentElement && document.documentElement.scrollTop) || 
    (document.body && document.body.scrollTop);
}

function getClientWidth()
{  
 return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;  
}

function close_pop ()
{
	document.getElementById('pop_wnd').style.display = 'none';
}

function close_pop2 ()
{
	document.getElementById('pop_wnd2').style.display = 'none';
}


// fill date
function fill_date ()
{
	var cur_date = new Date();
	var day = cur_date.getDate();
	document.getElementById('cm_day').value = day < 10 ? '0'+day : day;
	document.getElementById('cm_year').value = cur_date.getFullYear();
	document.getElementById('cm_hours').value = cur_date.getHours();
	document.getElementById('cm_minutes').value = cur_date.getMinutes();

	var month = cur_date.getMonth() + 1;
	if ( month < 10 ) {
		month = '0' + month;
	}

	var month_sel = document.getElementById('cm_month');
	for (var i=0; i<month_sel.options.length; i++) {
		if ( month_sel.options[i].value == month ) {
			month_sel.options[i].selected = true;
		}
	}
}
