function init () 
{
	
$('.det_content').disableTextSelect();
//$('div.main_left_brands').load("/bg/ajax/right/brands");
$('p.f_link').load("/bg/ajax/footer/links");
$('div.right_bottom').load("/bg/ajax/right/coll");
$('div.right_item_a').load("/bg/ajax/right/right_item_a");
 $('#search_post input').keypress(function(e) 
 {
 	//alert(e.which);
        if(e.which == 13) 
        {
			$("#button_search_bg").attr('src', '/images/button_search_hover_bg.gif');
            $("#search_post").submit();
        }
    });	
/*	$('div.main_left_title').click(
		function () 
		{
			if($(this).next().css('display') == 'block')
			{
				$(this).next().fadeOut("slow");
			}
			else
			{
				$(this).next().fadeIn("slow");
			}
		}
	);*/
	$('div.item div.item_img img').click(
		function()
		{
			var d;
			var href;
			d=$($(this).parent().parent().children()[2]);
			href = d.children().children().attr('href');
			$(location).attr('href',href);
		}
	
	);
	$('div.main_left_title').click(
		function()
		{
			var id;
			id=$(this).attr('id');
			var str = $(this).attr('id');
			var substr = str.split('_');
			var brand_id = substr[1];
			var type = substr[2];


			
			if($(this).next().css('display') != 'block')
			{
			$.ajax(
				{
					
					type: "POST",
				   	url: "http://www.shop2bg.com/bg/ajax/brand_id/"+brand_id+"/type/"+type,
				   	data: "",
				   	success: 
					    function(t) 
			          	{
			           		$('#left_move_'+str).empty().append(t);
			           		$('#left_move_'+str).fadeIn("slow");

			       	   	},
				   	error:
					   	function()
					   	{
					   		$('#left_move_'+str).fadeOut("slow");
					   	}
				 });
			}
			else
			{
				$(this).next().fadeOut("slow");
			}
		}
		
	);	
	$("#facebook").hover(
		function () 
		{
			$(this).attr('src', '/images/facebook_r.png');
		}, 
		function () 
		{
			$(this).attr('src', '/images/facebook.png');
		}

	);
	$("#button_order_bg").hover(
		function () 
		{
			$(this).attr('src', '/images/button_order_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_order_bg.gif');
		}

	);
	$("#uk_link").hover(
		function () 
		{
			$(this).attr('src', '/images/uk_orders_р.png');
		}, 
		function () 
		{
			$(this).attr('src', '/images/uk_orders_n.png');
		}

	);
	$("#button_order_en").hover(
		function () 
		{
			$(this).attr('src', '/images/butt1_hover_en.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/butt1_en.gif');
		}

	);
	$("#button_search_bg").hover(
		function () 
		{
			$(this).attr('src', '/images/button_search_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_search_bg.gif');
		}

	);
	$("#button_search_en").hover(
		function () 
		{
			$(this).attr('src', '/images/button_search_hover_en.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_search_en.gif');
		}

	);
	$("img.button_det_bg").hover(
		function () 
		{
			$(this).attr('src', '/images/button_det_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_det_bg.gif');
		}

	);
	$("img.button_det_en").hover(
		function () 
		{
			$(this).attr('src', '/images/button_det_hover_en.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_det_en.gif');
		}

	);
	$("img.more_bg").hover(
		function () 
		{
			$(this).attr('src', '/images/more_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/more_bg.gif');
		}

	);
	$("img.more_en").hover(
		function () 
		{
			$(this).attr('src', '/images/more_en.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/more_en.gif');
		}

	);
	$("#conf_link").hover(
		function () 
		{
			$(this).attr('src', '/images/button_cart_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_cart_bg.gif');
		}

	);
	$(".input_img_det").hover(
		function () 
		{
			$(this).attr('src', '/images/button_det_car_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_det_car_bg.gif');
		}

	);
	$(".input_img_of_det").hover(
		function () 
		{
			$(this).attr('src', '/images/button_det_car_of_hover_bg.png');
		}, 
		function () 
		{
			$(this).attr('src', '/images/button_det_car_of_bg.png');
		}

	);
	$(".of_but").hover(
		function () 
		{
			$(this).attr('src', '/images/offers_button_hover_bg.png');
		}, 
		function () 
		{
			$(this).attr('src', '/images/offers_button_bg.png');
		}

	);
	$("#enter").hover(
		function () 
		{
			$(this).attr('src', '/images/enter_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/enter_bg.gif');
		}

	);
	$("#reg").hover(
		function () 
		{
			$(this).attr('src', '/images/but2_hover_bg.gif');
		}, 
		function () 
		{
			$(this).attr('src', '/images/but2_bg.gif');
		}

	);
	$('#add_to_cart').click(
		function()
		{
			$("#cart_form").submit();
		}
	);
	$('#button_search_bg').click(
		function()
		{
			$("#search_post").submit();
		}
	);
	
	$('#button_search_price_bg').click(
		function()
		{
			$("#search_post_price").submit();
		}
	);
	
	$('#conf_link').click(
		function()
		{
			if(!$('#conf_order').is(':checked'))
			{
				alert('Не сте потвърдили съгласието си с общите условия!');
				return false;
			}
			else
			{
				//return true;
				var r_value;
  				r_value = jQuery('#radio_form input:radio:checked').val();
				//alert($('#is_login').val());
				//alert(r_value);
				if(r_value != 1 && r_value != 2 && r_value != 3 && r_value != 4)
				{
					alert('Моля, изберете начин на плащане!');
					return false;					
				}				
				if($('#is_login').val() == '1' && r_value == '3')
				{
					//alert('epay?');
						$.ajax(
							{
		   						type: "POST",
							   	url: "http://www.shop2bg.com/bg/cart/action/confirm/type/epay",
							   	data: "",
							   	success: 
								    function(t) 
						          	{
						           		$("#form_epay").append(t);
						           		$("#form_epay").submit();
						       	   	},
							   	error:
								   	function()
								   	{
								    	$("#form_epay").append("An error occured during processing");
								   	}
							 });
					return false;
				}
				else if($('#is_login').val() == '1' && r_value == '4')
				{
					//alert('epay?');
						$.ajax(
							{
		   						type: "POST",
							   	url: "http://www.shop2bg.com/bg/cart/action/confirm/type/moneybookers",
							   	data: "",
							   	success: 
								    function(t) 
						          	{
						           		$("#form_moneybookers").append(t);
						           		$("#form_moneybookers").submit();
						       	   	},
							   	error:
								   	function()
								   	{
								    	$("#form_moneybookers").append("An error occured during processing");
								   	}
							 });
					return false;
				}
				else
				{
					//alert('no ok');
					return true;
					//return false;
				}
			}
			
		}
	);	
	$('#conf_link_1').click(
		function()
		{
			if(!$('#conf_order___').is(':checked'))
			{
				alert('Не сте потвърдили съгласието си с условията!');
				return false;
			}
		}
	);
	$('#conf_link_epay').click(
		function()
		{
			if(!$('#conf_order').is(':checked'))
			{
				alert('Не сте потвърдили съгласието си с общите условия!');
				return false;
			}
			else
			{
						$.ajax(
							{
		   						type: "POST",
							   	url: "https://www.shop2bg.com/bg/cart/action/confirm/type/epay",
							   	data: "",
							   	success: 
								    function(t) 
						          	{
						           		$("#form_epay").append(t);
						           		$("#form_epay").submit();
						       	   	},
							   	error:
								   	function()
								   	{
								    	$("#form_epay").append("An error occured during processing");
								   	}
							 });
				//return true;
			}
			
		}
	);
	$('#conf_link_uk').click(
		function()
		{
			if(!$('#conf_order_uk').is(':checked'))
			{
				alert('Не сте потвърдили съгласието си с общите условия!');
				return false;
			}
		}
		);
	$('#filter_cart').change(
		function()
		{
			$("#filter_cart_form").submit();
		}
	);
}
