// JavaScript Document

/* tabs switcher */
$(function(){
	$('.tabs ul a').click(function(){
		$('.tabs ul a').removeClass('active');
		$(this).addClass('active');
		var $currentId = this.id;

		$('.tabsContent > div').each(function(){
			$('.tabsContent > div').removeClass('dispNone');
			if($(this).attr('class') == $currentId)
				$(this).css('display','block');
			else
				$(this).css('display','none');
		});
		return false;	
	});
})




/* carousel power on */
$(function() {
	jQuery(".carouselIndex div").jCarouselLite({
		btnNext: ".navArrowRight",
		btnPrev: ".navArrowLeft",
		speed: 700
	});
});

$(function() {
	jQuery(".carouselEntryA div").jCarouselLite({
		btnNext: ".carouselARight",
		btnPrev: ".carouselALeft",
		speed: 700
	});
});

$(function() {
	jQuery(".carouselEntryB div").jCarouselLite({
		btnNext: ".carouselBRight",
		btnPrev: ".carouselBLeft",
		speed: 700
	});
});


/* main menu */
$(function(){
	$('.mmRelativeDiv div a').click(function(){
		if($(this).hasClass('active')) {
			$(this).removeClass('active');
			$('.mmInsideUls').css('display','none');
		}
		else {
			$('.mmRelativeDiv div a').removeClass('active');
			$(this).addClass('active');
			$('.mmInsideUls').css('display','none');
			$(this).next().css('display','block');
		}
		return false;
	})
})

$(function(){
	$('body').click(function(){
		$('.mmInsideUls').css('display','none');
		$('.mmRelativeDiv div a').removeClass('active');
	})
})

function click_menu_item(m_item)
{
	window.location.href = m_item;
}

function load_p_video(id)
{
	$.ajax({
	   type: "POST",
	   url: "/load_p_video.php",
	   data: "id="+id,
	   success: function(msg){
		  if (msg == '')
			  return;
		  var p_video = $('#p_video');
		  if (p_video)
		  {
			  p_video.html(msg);
		  }
	   }
	 });
}

function load_p_character(id)
{
	$.ajax({
	   type: "POST",
	   url: "/load_p_character.php",
	   data: "id="+id,
	   success: function(msg){
		  if (msg == '')
			  return;
		  var p_video = $('#p_character');
		  if (p_video)
		  {
			  p_video.html(msg);
		  }
	   }
	 });
}

//поиск
function search(name)
{
	document.getElementById('search').value = name;
}

$(document).ready(function() {
	(function() {
		if (jQuery('#slideshow-left').length)
		{
			var show = jQuery('#slideshow-left').cycle({
				fx: 'fade',
				pause: 1,
				timeout: 4000,
				height: 150,
				next: '#slideshow-left-next',
				prev: '#slideshow-left-prev',
				pager: '#slideshow-left-nav',
				slideExpr: '.slide'
			});
			show.nav = jQuery('#slideshow-left-prev,#slideshow-left-next');
			show.mouseover(function() { show.nav.show(); });
			show.mouseout(function() { show.nav.hide(); });
		}
	})();
});

function check_email_u()
{
	var email_info = $('#email-info');
	if (email_info.length)
	{
		email_info.html('');
	}
	var email = $('#email_address');
	if (!email.length)
	{
		return;
	}
	if (email.val()=='')
	{
		return;
	}
	$.ajax({
	   type: "POST",
	   url: "/check_email_u_ajax.php",
	   data: "email="+email.val(),
	   success: function(msg){
		if (msg=='')
		{
			return;
		}
		if (email_info.length)
		{
			if (msg=='yes')
			{
				email_info.html('Ваш E-Mail был найден в нашей базе.<br />Перейдите на <a href="/login.php" title="Вход"><strong>страницу авторизации</strong></a> и введите свой логин и пароль.');
				email_info.css('color', 'green');
			}
			if (msg=='no')
			{
				email_info.html('Видимо, Вы ранее не покупали у нас ничего.<br />Продолжите заполнение полей ниже, для оформления заказа.');
				email_info.css('color', 'red');
			}
		}
	   }
	 });
} // check_email_u

function a_zoom()
{
	jQuery("a.zoom").fancybox({
			"zoomOpacity"			: true,
			"zoomSpeedIn"			: 500,
			"zoomSpeedOut"			: 500
		});	
} // a_zoom

function change_prod_color(id)
{
	var main_c = $('#p-img');
	if (!main_c)
	{
		return;
	}
	if ( typeof change_prod_color.htmlSrc == 'undefined' ) {
        change_prod_color.htmlSrc = main_c.html();
    }
	if (id==0)
	{
		main_c.html(change_prod_color.htmlSrc);
		a_zoom();
		return;
	}
	var pc = $('#p-'+id);
	if (!pc)
	{
		main_c.html(change_prod_color.htmlSrc);
		a_zoom();
		return;
	}
	main_c.html(pc.html());
	a_zoom();
} // change_prod_color
