// ie min-width
var d = document;
var winIE = (navigator.userAgent.indexOf("Opera")==-1 && (d.getElementById && d.documentElement.behaviorUrns)) ? true : false;

function bodySize(){
	if(winIE && d.documentElement.clientWidth) {
		sObj = d.getElementsByTagName("body")[0].style;
		sObj.width = (d.documentElement.clientWidth<960) ? "960px" : "100%";
	}
}

function init(){
	if(winIE) { bodySize(); }
}
onload = init;
if(winIE) { onresize = bodySize; }

 
jQuery.noConflict();
  (function($) { 
  $(document).ready(function() {
     $("#menu-announcements .menu-announcement-block").hover(
          function(){
               $("#menu-announcements .menu-announcement-block").removeClass("menu-announcement-block-current");
               $(this).addClass("menu-announcement-block-current");
               $(".header-tabs-tab").css({'display' : 'none'});
               $("." + $(this).attr("id")).show();
          },
          function(){});
     $(".header-tabs-tab1").css({'display' : 'block'});
     $("menu-announcements:first").css({'background' : '#fff'});
});
$(document).ready(function() {
if ($('.fancy').length) {$('.fancy').fancybox();}
if ($('.small-i').length){$('.small-i').jcarousel(); }
	if ($('form.l-comment').length) {$('form.l-comment').submit (function () {
		var form = this, obj = {};
		$(this).find ('input,textarea').each (function () {
			if (this.name != '') obj [this.name] = this.value;
		})
		$.post (this.action, obj, function (d) {
			if (d.substr (0, 2) == 'ok') document.location.href = form._redirect_url.value;
			else alert (d);
		});
		return false;
	});}
	
	if ($('form.fast-registration').length){$('form.fast-registration').submit (function () {
		var args = {};
		$(this).find ('input, textarea').each (function () {
			args [this.name] = this.value;
		})
		$.post (this.action, args, function (d) {
			var id = parseInt (d);
			if (!id) {
				alert (d);
			} else {
				$('#orderIdContainer').text (d);
				$('#checkoutFormContainer').hide ();
				$('#thanksTextContainer').show ();
				$(window).scrollTop (0);
			}
		});
		return false;
	});}
	if ($('form.m-order, form.properties').length){$('form.m-order, form.properties').submit (function () {
		f = this;
		$.post ('/system/php/actions.php?a=addtocart', {
			id: f.id.value,
			cnt: f.cnt.value
		}, function (d) {
			if (d ['items']) {
				$ ('.cartInfoItems').text (d.items);
				$ ('.cartInfoSum').text (d.sum);
				$(f).find ('.close').click ();
			}
		}, 'json');
		return false;
	});}

	$ ('form .increment .up').click (function () {
		var i = $(this).parent ().parent ().find ('input'), val = i.val ();
		if (val != 1) i.val ((val * 1) - 1);
		return false;
	});
	$ ('.increment .down').click (function () {
		var i = $(this).parent ().parent ().find ('input'), val = i.val ();
		i.val ((val * 1) + 1);
		return false;
	});


	$('.category .items li a.button').click(function(){
		$(this).parent().find('form').toggle();
		return false;
	});
	$('.category .items li form .close').click(function(){
		$(this).parent().parent().hide();
	});
	$(".cart-items fieldset:odd").addClass("alt");
	$(".cart-items .delete").click(function(){
		var parent = $(this).parent().parent (), a = parent.attr ('id').split ('-'), id = a [1];
		$.post ('/system/php/actions.php?a=addtocart', {
			id: id,
			cnt: 0
		}, function (d) {
			if (d ['items']) {
				$ ('.cartInfoItems').text (d.items);
				$ ('.cartInfoSum').text (d.sum);
			}
			parent.remove();
		}, 'json')
		return false;
	});
	
	if($('.photos ul').length){$('.photos ul').jqGalScroll();	}
	$('.jqGSContainer').css({'display' : 'none'});
	$('.photos #gallery1').parent().parent().css({'display' : 'block'});
	$('.gallery-foto-menu a').click(function(){
		$('.photos ul').parent().parent().css({'display' : 'none'})
		$("#" + $(this).attr('title')).parent().parent().css({'display' : 'block'});
		$(this).parent().parent().find('li').removeClass('current');
		$(this).parent().addClass('current');
		return false;
		});
	
});
})(jQuery); 

