$(function() {
	function insertPlusOne(url) {		/*
		var fb = document.createElement('fb:like');
		fb.setAttribute("href",'https://www.facebook.com/vehicletraders.co.za');
		fb.setAttribute("send","false");
		fb.setAttribute("width","100");
		fb.setAttribute("layout","button_count");
		fb.setAttribute("show_faces","false");
		fb.setAttribute("action","like");
		//fb.setAttribute("font","");
		fb.setAttribute("id","fb-root");
		$('#plus-one').append(fb);
		*/

		$('#plus-one').html('<iframe src="http://www.facebook.com/plugins/like.php?href=https://www.facebook.com/vehicletraders.co.za&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;send=false"  style="border-size:0px; overflow:hidden; width:103px; height:21px;" frameborder=0></iframe>');

		var gplus = document.createElement('g:plusone');
		//gplus.setAttribute("size",($('#plus-one').hasClass('main') ? "small" : 'medium'));
		gplus.setAttribute("size",'medium');
		//if (url=='')
		url = 'http://vehicletraders.co.za';
		gplus.setAttribute("href",url);
		$('#plus-one').append(gplus);

	}

	insertPlusOne('');
   $('#background_select a').click(function() {
   	changeBackground($(this).attr('class').substr(2));
   });

   $('#menu-8').click(function() {   	$('#basket_dialog').modal({   		overlayClose:true,
   		opacity:50,
   		minHeight: 400, minWidth:700,
   		autoResize:true,
   		overlayCss: {backgroundColor:'#000'},
   		onOpen: function (dialog) {
				dialog.overlay.fadeIn('slow', function () {
					dialog.data.hide();
					dialog.container.fadeIn('slow', function () {
						dialog.data.slideDown('slow');
					});
				});
			}
		});
   	$('#basket_dialog').load('/ajax/index.php?module=basket', function(){
   		$('#basket_dialog').css('width',600);
   	});   });

   $('a.remove-basket').live('click',function() {      $(this).parent().parent().fadeOut(500);
      $.cookie('basket_items',$.cookie('basket_items').replace('|' + $(this).attr('car_id'),''), {path: '/'});
      return false;
   });

   if ($.cookie("backgroundColor") == null) { changeBackground(1); }   //else alert($.cookie("backgroundColor"));
   else changeBackground($.cookie("backgroundColor"));

   $('#report_button').click(function() {
   	$('#report_dialog').modal({
   		overlayClose:true,
   		opacity:50,
   		minHeight: 200, minWidth:500,
   		autoResize:true,
   		overlayCss: {backgroundColor:'#000'}
		});
   });

   /*$('#report_text').click(function() {
   	if ($(this)[0].text=='Comments...') $(this)[0].text = '';
   });*/

	// switch betwene pages (cars list)
	/*$('.nav_pages').live('click',function() {		$('#shadow_box').show();		$('#cars_list_inner').load('/ajax/index.php?module=cars_list&url='+$(this).attr('href'), function() {			$('#shadow_box').hide();
		});
		return false;
	}); */

	$(".latestCommentsList").height( $(".reviewListBox").outerHeight() - 9 );

	$('a.refresh_code').click(function() {			var num;
			if ($('[name=security_confirm]')[0].value>1000) num = Math.round(Math.random()*899999+100000);
			else num = Math.round(Math.random()*899+100);
			$('img.captcha_img').attr('src', '/inc/captcha.php?bg=green&number='+num);
			$('[name=security_confirm]')[0].value = num;

		});

	// blink text
	//$("#request_link").hide();
	setTimeout(function(){		//$("#request_link").show();
		setInterval(function(){			$("#request_link").toggle();
		},500)
	},3000);


});


