
var cell_count;
var cell_count_discount;

function clicker(val)
{
	var obj = document.getElementById(val); 

	try{ 
	 obj.click(); 
	} catch (MyError){ 
	 obj.click = function() { 
	   document.location.href = this.href; 
	 } 
	 obj.click(); 
	}
}


$(document).ready(function(){

cell_count = Math.round($('#pop-scroll').outerWidth() / 195);
cell_count_discount = Math.round($('#hot-scroll').outerWidth() / 195);

$('#pop-scroll .item').css('width', $('#pop-scroll').outerWidth() / cell_count);
$('#hot-scroll .item').css('width', $('#hot-scroll').outerWidth() / cell_count_discount);

$(window).resize(
	function() {
		
		cell_count = Math.round($('#pop-scroll').outerWidth() / 195);
		cell_count_discount = Math.round($('#hot-scroll').outerWidth() / 195);

		$('#pop-scroll .item').css('width', $('#pop-scroll').outerWidth() / cell_count);
		$('#hot-scroll .item').css('width', $('#hot-scroll').outerWidth() / cell_count_discount);
	
	}
)

$('.btn-show').toggle(

	function() {
	
		$('#about-txt').slideUp(400);
		$(this).addClass('collapsed')
	
	},
	
	function() {
		
		$('#about-txt').slideDown(400);
		$(this).removeClass('collapsed')
		
	}
					  
)




$('ul.list li.list_li > a').click(
	function() {

			if ( $(this).parent('li').hasClass('open')) {
				$(this).parent('li').removeClass('open');
				//$(this).children('ul.list2').slideUp(400);
			}
			else {
				$(this).parent('li').addClass('open');
				//$(this).children('ul.list2').slideDown(400);
			}
		
});


	$("div#pop-scroll").scrollable({clickable: false, size: cell_count}).circular();
	$('#pop-slider-next').click(function() {$("div#pop-scroll").scrollable().nextPage();});
	$('#pop-slider-prev').click(function() {$("div#pop-scroll").scrollable().prevPage();});
	
	
	$("div#hot-scroll").scrollable({clickable: false, size: cell_count_discount}).circular();
	$('#hot-slider-next').click(function() {$("div#hot-scroll").scrollable().nextPage();});
	$('#hot-slider-prev').click(function() {$("div#hot-scroll").scrollable().prevPage();});


$('.popup .close').click(
	function() {
		$(this).closest('.cell').removeClass('open')
	}
)



$('.catalogue-table .cell a.show-popup').click(
	
	function() {
		$('.catalogue-table .cell').removeClass('open');
		$(this).closest('.cell').toggleClass('open');
	
	}
	
)


	$("#jQueryBookmark").click(function(e){
		e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
		var bookmarkUrl = this.href;
		var bookmarkTitle = this.title;
	 
		if (window.sidebar) { // For Mozilla Firefox Bookmark
			window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
		} else if( window.external || document.all) { // For IE Favorite
			window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
		} else if(window.opera) { // For Opera Browsers
			$("a.jQueryBookmark").attr("href",bookmarkUrl);
			$("a.jQueryBookmark").attr("title",bookmarkTitle);
			$("a.jQueryBookmark").attr("rel","sidebar");
		} else { // for other browsers which does not support
			 alert('Your browser does not support this bookmark action');
			 return false;
		}
	});


		$(".radio").click(function () { 
					var output = [];
					var x = 0;
					
					$.each(pOptions[$(this).val()], function(key, value) {
						if (x == 0)
						{
							$("#payment_id_unreg").val(key);
							$("#payment_id_reg").val(key);
							x = 1;
						}
						output.push('<option value="'+ key +'">'+ value +'</option>');
					});

					$('#payment_id_sel').html(output.join(''));

					if ($(this).attr("id") == 'Y')
					{
						//avia
						$("#kur_table").hide();
						$("#post_table").show();
					}
					else
					{
						$("#post_table").hide();
						$("#kur_table").show();
						

					}
					$("#service_id_unreg").val($(this).val());
					$("#service_id_reg").val($(this).val());
			  
				});

				$("#payment_id_sel").change(function()
				{
					$("#payment_id_unreg").val($(this).val());
					$("#payment_id_reg").val($(this).val());

				});

});


