        function invoice_change() {
            if (document.getElementById('PaymentInvoice1').checked == true) {
                document.getElementById('InvoiceTable').style.display = '';
            }
            else {
                document.getElementById('InvoiceTable').style.display = 'none';
            }
        }
        function same_reciever_sender() {
            if (document.getElementById('OrderSameReciever0').checked == true) {
                document.getElementById('RecieverTable').style.display = '';
            }
            else {
                document.getElementById('RecieverTable').style.display = 'none';
            }
        }
        function is_member() {
            if (document.getElementById('UserIsNotMember1').checked == true) {
                $('#IsNotMemberTable').show();
                $('#IsMemberTable').hide();
            }
            else {
                $('#IsMemberTable').show();
                $('#IsNotMemberTable').hide();
            }
        }
        function method_changed() {
            if (!document.getElementById('PaymentMethodAntikatavoli')) return true;
            if (document.getElementById('PaymentMethodAntikatavoli').checked == true) {
                document.getElementById('OrderSameReciever0').checked = false;
                document.getElementById('OrderSameReciever1').checked = true;
                document.getElementById('OrderSameReciever0').disabled = true;
                document.getElementById('RecieverTable').style.display = 'none';
            }
            else {
                document.getElementById('OrderSameReciever0').disabled = false;
            }
        }
        function country_changed() {
            if (!document.getElementById('PaymentMethodAntikatavoli')) return true;
            if (document.getElementById('SenderCountryId').value != 84) {
                if (document.getElementById('PaymentMethodAntikatavoli').checked == true) {
                    document.getElementById('PaymentMethodAntikatavoli').checked = false;
                    document.getElementById('PaymentMethodPistotiki').checked = true;
                    document.getElementById('OrderSameReciever0').disabled = false;
                }
                document.getElementById('PaymentMethodAntikatavoli').disabled = true;
            }
            else {
                document.getElementById('PaymentMethodAntikatavoli').disabled = false;
            }
        }

        
        jQuery.timer = function(time,func,callback){
        	var a = {timer:setTimeout(func,time),callback:null}
        	if(typeof(callback) == 'function'){a.callback = callback;}
        	return a;
        };

        jQuery.clearTimer = function(a){
        	clearTimeout(a.timer);
        	if(typeof(a.callback) == 'function'){a.callback();};
        	return this;
        };

        var inHeader = 0;
        var closeAll = 0;
        var fromDesc = 0;
        var currentDesc;
        
        $(document).ready(function() {

        	
        	//menu
			$('#accordion li.green').click(function () {
				if ($(this).height() == 22) {
					$('#accordion li').children('ul').slideUp('slow');
					$(this).children('ul').slideDown('slow');
					return false;
				}
				return true;
			});
			$('#accordion li.black').click(function () {
				if ($(this).height() == 22) {
					$('#accordion li').children('ul').slideUp('slow');
					$(this).children('ul').slideDown('slow');
					return false;
				}
				return true;
			});
			$('#accordion li.blackClickable').click(function () {
				return true;
			});
			$('#accordion li.greenClickable').click(function () {
				return true;
			});
			//menu end

			//contact
			$('#ContactAddForm input.reset').click(function () {
				$('#ContactName').val('');
				$('#ContactPhone').val('');
				$('#ContactEmail').val('');
				$('#ContactComments').val('');
			});
			//end contact
        	
			//product view
        	$('.product-preview-header-overall').mouseover(function() {
        		inHeader = 1;
        		if (closeAll == 1) {
        			//console.log(closeAll);
        			$('.product-preview-description').hide();
        			closeAll = 0;
        		}
        		currentDesc = $(this).parent().find('.product-preview-description');
        		if (!$(currentDesc).is(':visible')) {
        			$(currentDesc).slideDown('fast');
        		}
				//console.log('product-preview-header-overall mouseover');
        	});
        	$('.product-preview-header-overall').mouseout(function() {
        		inHeader = 0;
        		$.timer(500, function() {
        			if (inHeader == 0) {
        				$('.product-preview-description').fadeOut('slow');
        			}
        		});
				//console.log('product-preview-header-overall mouseout');
        	});
        	$('.product-preview-description').mouseover(function() {
        		inHeader = 1;
				//console.log('product-preview-description mouseover');
        	});
        	$('.product-preview-description').mouseout(function() {
        		inHeader = 0;
				//console.log('product-preview-description mouseout');
        	});
        	$('.product-preview').mouseout(function() {
    			closeAll = 1;
				//console.log('product-preview mouseout');
        	});
        	$('.product-preview-header-overall').click(function() {
        		location.href = $(this).parent().find('.product-preview-title-link').attr('href');
        	});
        	//end product view
        	
        	
        	//image preview on mouseover
			imagePreview();	

			$("a.preview").click(function(event){
				event.preventDefault();
				var id = $(this).attr('id');
				window.location = '/products/view/'+id;
			});	

        	$('a.small-preview').click(function(event) {
				event.preventDefault();
        	});
        	//end of image preview on mouseover
        	
        	//orders
			$(".InputPaymentMethod").click(function(){
				$('div.PaymentText').slideUp('fast');
				var id = $(this).attr('id');
				$('#'+id+'Text').slideDown('fast');
			});
			
			if ($('#SenderCountryId').val() != 84) {
				$('#PaymentMethodAntikatavoli').attr('disabled', true);
			}
			$('#SenderCountryId').change(function() {
				if ($('#SenderCountryId').val() != 84) {
					$('#PaymentMethodAntikatavoli').attr('disabled', true);
				}
				else {
					$('#PaymentMethodAntikatavoli').attr('disabled', false);
				}
			});
			//end of orders
			
			
        });