$(function() {
	// card page
	function view() {
		var device = $('#device');
		var img = device.find('img')
		if (img.length) {
			var list = $('#device-views .box').removeClass('active').removeClass('box-bordered');
			var current = $(this).parents('.box').eq(0).addClass('active').addClass('box-bordered');
			device.removeClass('first-active').removeClass('last-active');
			img.get(0).src = this.href;
			if (list.index(current) == 0) {
				device.addClass('first-active');
			} else if (list.index(current) +1 == 4) {
				device.addClass('last-active')
			}
			// IE 6
			if ($.browser.msie && parseInt($.browser.version) < 7) {
				$('#device-outer').css({zoom: 1});
			}
			return false;
		}
	}
	// Выбираем текущий вид
	document.location.hash && $('#device-views '+ document.location.hash +'_link a').each(view);
	// Невешиваем события всем остальным, но не 3D
	$('#device-views li:not(.photo-3d) a').click(view);

	// where2buy page
	$('.stores-list').click(function() {
		$(this).parents('.stores').addClass('stores-opened');
		return false;
	});
});
document.write(
	'<style type="text/css">'+
		// where2buy page
		'.stores ul'+
			'{display: none;}'+
	'</style>'
);

// Отключаем куфон для Opera 10-
if (!(jQuery.browser.opera && parseInt(jQuery.browser.version) < 10)) {
	//Cufon('h2')('#rightside h3:not(.box-inner)')('.page-index h3')('.page-index h4');
	Cufon('h2')('#rightside h3')('.page-index h3')('.page-index h4');
}
// SeaMonkey кладёт на сложные селекторы (это селекторы, сложнее выборки по тегу :) + IE 6
// Ему кормим список из элементов HTMLElement.
if (navigator.userAgent.match(/SeaMonkey/) || (jQuery.browser.msie && jQuery.browser.version < 7)) {
	$(function() {
		var h3 = $('#rightside h3, .page-index h3, .page-index h4').get();
		Cufon('h2')(h3);
	});
}