		function blur_click( elem ) {
		
			var this_value = $(elem).attr('value');		
			$(elem).blur( function() { if ( $(elem).attr('value') == '' ) { $(elem).attr('value', this_value); } } );		
			$(elem).click( function() { if ( $(elem).attr('value') == this_value ) { $(elem).attr('value', ''); } } );
		
		}
		
		
		function isValidTocart( elem ) {
			
			if ( !$(elem).length ) { return true }
			if ( $(elem).val() != 0 ) { return true }
			
			return false;
			
		}
		
	
	$(window).bind(
				'load',
				function() 
				{
					
			$('.dobavlen').css('opacity', '0');
			$('.dobavlen_favorites').css('opacity', '0');
			
			blur_click('#username');
			blur_click('#passwd');
			
			$('.bigimagelink').fancybox({ 'overlayShow' : false, 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 500, 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInBack' });	
			$('.iframe').fancybox({ 'frameWidth' : 770, 'frameHeight' : 575, 'centerOnScroll' : false });	
						
		/* Добавление в избранное */
		
		
			$('.favorites').click( function() {
				
				var itemid = $(this).attr('itemid');
				var inputstring = '#favorites' + itemid;
				var plashkahaha = $( inputstring );
			
				hax('index.php?option=com_favorites&view=addtofavorites&tmpl=component&id=' + itemid, { id:'korzinka', anticache:'true', notitle:'true', nohistory:'true', callback:function() { 
					
					$(plashkahaha).css('top', '5px');					
					$(plashkahaha).fadeTo(800, 1 );
					
					setTimeout( function() { 
					
						
										$(plashkahaha).fadeTo(800, 0, function() { 

											$(plashkahaha).css('top', '-2000px');

										} );
						

					} , 1500 );		
					
					
				} } );
			
			
			} );
		
		/* Добавление в избранное */
			
			
		/* Редактирование количаства */
		
			$('.number').blur( function() {
			
			
				hax('index.php?option=com_office&view=cart&task=changeitem&tmpl=component&ajax=1&item_id=' + $(this).attr('item_id') + '&quantity=' + $(this).attr('value'), { id:'ajaxorder', anticache:'true', notitle:'true', nohistory:'true' } );
				
			
			} );
			
			$('.delete').click( function() {
			
			
				hax('index.php?option=com_office&view=cart&task=changeitem&tmpl=component&ajax=1&item_id=' + $(this).attr('item_id') + '&quantity=0', { id:'ajaxorder', anticache:'true', notitle:'true', nohistory:'true' } );
				
			
			} );
		
		/* / Редактирование количаства */
			
			
		/* Редактирование количаства */
			
			$('.delete_from_fav').click( function() {
			
			
				hax('index.php?option=com_office&view=favorites&task=changeitem&tmpl=component&ajax=1&item_id=' + $(this).attr('item_id') + '&quantity=0', { id:'ajaxorder', anticache:'true', notitle:'true', nohistory:'true' } );
				
			
			} );
		
		/* / Редактирование количаства */
			
					
			$('.incart').click( function(){
				
				if ( 
						isValidTocart('#order-select-powers') &&
						isValidTocart('#order-select-radiuss') &&
						isValidTocart('#order-select-axiss') &&
						isValidTocart('#order-select-cylinders') &&
						isValidTocart('#order-select-colors') &&
						isValidTocart('input[name="quantity"]')
						
					)
				
					{ 

						hax('index.php?option=com_cart&view=addtocart&tmpl=component', { form:'addtocartsuperform', id:'cart', anticache:'true', notitle:'true', nohistory:'true', callback:function() { 
							
							$('.dobavlen').css('top', '-30px');					
							$('.dobavlen').fadeTo(800, 1 );
							
							setTimeout( function() { 
							
								
												$('.dobavlen').fadeTo(800, 0, function() { 

													$('.dobavlen').css('top', '-2000px');

												} );
								

							} , 1500 );		
							
							
						} } );

					} else
					
					{ alert('Пожалуйста, выберите все параметры товара.'); }
			
				
			
			} );
					
					
		
			$('.zakazat').click( function(){ 

				$('.orderdetails').slideDown("5000");
				
			} );
			
			
		
			
			
		
	});

