function deleteCoupon( url )
{
    if ( confirm( "Czy napewno chcesz usunąć podany kupon ze spisu? Nie będzie już żadnych okienek potwierdzających Twoją decyzję!" ))
	{
		window.location.href=url;
	}
}

function isInt(x) 
{
	var y=parseInt(x);
	if (isNaN(y)) return false;
	return x==y && x.toString()==y.toString();
} 

function updatePrice( price, wallet )
{
	count = document.getElementById( "ofertaIlosc" );
	if( !isInt(count.value) )
	{
		count.value = 1
	}
	
	countedprice =  price * count.value
	
	$("#count_value").attr( "value", count.value );
	$(".ofertaCena").html( countedprice +" PLN" );
	
	if( wallet != 'brak' )
	{
		if( wallet < countedprice )
		{
			$("#order_form_using").show();	
			$("#order_form_pay").show();
			
            $("#order_input_pay").html( " " );
			$("#order_pay_button").attr( "disabled", "disabled" );

			$("#topup_value").attr( "value", ( countedprice - wallet ) );
		}
		else
		{
			$("#order_form_using").hide();
			$("#order_form_pay").hide();	
			
            $("#order_input_pay").html( '<input type="submit" value="" id="order_form_charge" name="order_pay_button"/>' );
            
			$("#order_pay_button").attr( "disabled", "" );
			$("#order_pay_button").attr( "value", "Zapłać" );
		}
	}
}

function showTowns()
{
	$("#header_cities").show();
}

function hideTowns()
{
	$("#header_cities").hide();
}

function perform_select( id, divs )
{
	for( var i = 0; i<divs.length; i++ )
	{	
		if( divs[ i ] == id )
			$(divs[ i ]).show();
		else
			$(divs[ i ]).hide();
	}
}

function select( id )
{
	var divs=new Array("#zasilenie","#historia","#przelewkonto")
	perform_select( id, divs );
}

function select_submenu( id )
{
	var divs=new Array("#przelew","#sms")
	perform_select( id, divs );
}

function show_sms_code()
{
	var kwota = new Array(10);
	kwota[0] = 0.27;
	kwota[1] = 0.54;
	kwota[2] = "1.10";
	kwota[3] = 1.65;
	kwota[4] = "2.20";
	kwota[5] = 2.74;
	kwota[6] = "3.30";
	kwota[9] = 4.94;
	kwota[19] = 10.43;
	kwota[25] = 15.25;

	chosen = $("#smscode").val();
	cena = ( chosen == 0 ) ? 0.61 : chosen*1.22;
	
	var telefon = new Array(10);
	telefon[0] = 70068;
	telefon[1] = 71068;
	telefon[2] = 72068;
	telefon[3] = 73068;
	telefon[4] = 74068;
	telefon[5] = 75068;
	telefon[6] = 76068;
	telefon[9] = 79068;
	telefon[19] = 91968;
	telefon[25] = 92568;

	$("#sms_code_info").html( "Wyślij SMS o treści <strong>AP.Grupust</strong> na numer <strong>"+ telefon[chosen] +"</strong>. Koszt smsa: <strong>"+ cena +" PLN</strong> BRUTTO. Sms doładuje Twoje konto w serwisie o <strong>"+kwota[chosen]+"</strong> PLN.<br />" );
}
