
 // Предварительная загрузка изображений
var image1 = new Image(); image1.src = "/images/dt/gray.jpg";
var image2 = new Image(); image2.src = "/images/dt/active_top_menuL.png";
var image3 = new Image(); image3.src = "/images/dt/active_top_menuR.png";


 // Замена текста
Cufon.replace('.left_title, #title_basket, #title_advice, #title_call, #title_why, #top_menu li a, #title_why, #footer_menu li a, #title_time', { fontFamily: 'HeliosCond' });
Cufon.replace('#phone .index, #phone .telephone, #footer_call, #footer_call2', { fontFamily: 'HeliosCond' });


$(document).ready(function(){

 // Углы
$("#main_content").corner("10px");/*corner for right col*/
$("#title_basket").corner("top 5px");
$("#content_basket").corner("bottom 5px");
$("#title_why").corner("5px");
$(".shipment_description").corner("5px");

 // Лайтбокс
$(".colorbox").colorbox({current: "фото {current} из {total}", previous: "назад", next: "вперед", close: "закрыть"});
$("a[rel='photo']").colorbox({transition:"none", maxWidth:"100%", maxHeight:"100%"});

});


 // Подсказки в input
/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/

(function ($) {

$.fn.hint = function (blurClass) {
  if (!blurClass) {
    blurClass = 'blur';
  }

  return this.each(function () {
    // get jQuery version of 'this'
    var $input = $(this),

    // capture the rest of the variable to allow for reuse
      title = $input.attr('title'),
      $form = $(this.form),
      $win = $(window);

    function remove() {
      if ($input.val() === title && $input.hasClass(blurClass)) {
        $input.val('').removeClass(blurClass);
      }
    }

    // only apply logic if the element has the attribute
    if (title) {
      // on blur, set value to title attr if text is blank
      $input.blur(function () {
        if (this.value === '') {
          $input.val(title).addClass(blurClass);
        }
      }).focus(remove).blur(); // now change all inputs to title

      // clear the pre-defined text when form is submitted
      $form.submit(remove);
      $win.unload(remove); // handles Firefox's autocomplete
    }
  });
};

})(jQuery);

$(function(){
			    // find all the input elements with title attributes
				$('input[title!=""]').hint();

			});




var prev_comment = 0;



// Ответ на комментарий

function cr(comment_id)

{

	if (prev_comment && prev_comment != comment_id)

	{

		document.getElementById(prev_comment).style.display = 'none';

	}



	var div = document.getElementById(comment_id);



	if (div.style.display != 'block')

	{

		div.style.display = 'block';

	}

	else

	{

		div.style.display = 'none';

	}



	prev_comment = comment_id;

}




// Функция обратного вызова для AddIntoCart
function callbackfunction_AddIntoCart(responseJS)
{
	// Результат принят
	sended_request = false;

	if (typeof responseJS != 'undefined')
	{
		// Данные.
		if (typeof responseJS.cart != 'undefined')
		{
			var little_cart = document.getElementById('little_cart');

			if (little_cart)
			{
				// Создадим скрытый SPAN для IE, в который поместим текст + скрипт.
				// Если перед <script> не будет текста, нехороший IE не увидит SCRIPT
				var span = document.createElement("span");
				span.style.display = 'none';
				span.innerHTML = "Stupid IE. " + responseJS.cart;

				runScripts(span.getElementsByTagName('SCRIPT'));

				little_cart.innerHTML = responseJS.cart;
			}
			else
			{
				alert('Ошибка! Краткая корзина не найдена');
			}
		}
	}
}

function AddIntoCart(shop_path, item_id, item_count)
{
	//location.href = shop_path + 'cart/?ajax_add_item_id=' + item_id + '&count=' + item_count;
	cmsrequest = shop_path + 'cart/?ajax_add_item_id=' + item_id + '&count=' + item_count;

	// Отправляем запрос backend-у
	sendRequest(cmsrequest, 'get', callbackfunction_AddIntoCart);

	return false;
}


 // Анимация для добавления в корзину
function addtocart(id, count) {
	AddIntoCart('/catalog/', id, count);
	var img = jQuery('#img_'+id), pos = img.offset();
	var tr = $('<div class="effect-transfer"/>').appendTo('body').append(img.clone())
		.css({ top: pos.top, left: pos.left, height: img.outerHeight(), width: img.outerWidth() });

	var cart = jQuery('#basket'), pos = cart.offset();
	tr.animate({ top: pos.top, left: pos.left, height: cart.outerHeight(), width: cart.outerWidth()	}, 1000, function() {
		jQuery.noticeAdd({
			text: '<h5>\u041A\u043E\u0440\u0437\u0438\u043D\u0430</h5>\u0422\u043E\u0432\u0430\u0440 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D \u0432 \u043A\u043E\u0440\u0437\u0438\u043D\u0443!<br /><a href="/catalog/cart"><b>\u041F\u0435\u0440\u0435\u0439\u0442\u0438</b></a>&nbsp;&nbsp;\u0434\u043B\u044F \u043E\u0444\u043E\u0440\u043C\u043B\u0435\u043D\u0438\u044F \u0437\u0430\u043A\u0430\u0437\u0430.',
			stay: false,
			inEffectDuration: 250,
			stayTime: 4000
		});
		$(this).remove();
	});
	return!1;
}


