function viewImg(m1,m2)
{
	if(m2==0)
	{
		$("span#loading").show();
		$.post(
			   "/modules/ajax/imgview.php",
		{
			type: "test-request",
			tid: m1
		},
		function viewImgOk(xml)
		{
			$("span.imgV").empty();
			$("span.imgV").append($("#1", xml).text());
			$("span.imgV").show();
			$("span.nameV").empty();
			$("span.nameV").append($("#2", xml).text());
			$("span.nameV").show();
			$("span.titleV").empty();
			$("span.titleV").append($("#3", xml).text());
			$("span.titleV").show();
			$("span#loading").hide();
			
		}
		);
	
	}
//	if(m2==1)
	//$("span.imgP_"+m1).hide();
}




function add(m1,m2)
{
	
	$('div.addtocart').animate({opacity: "show"}, 500,function(){
	$('div.cart').animate({opacity: "hide"}, 500, function()
	{
		$("span#loading").show();
		$.post(
			   "/modules/ajax/addtocart.php",
		{
			type: "test-request",
			sid: m1,
			tid: m2
		},
		onAjaxSuccessAdd
		);
	});
   																	});

}
function onAjaxSuccessAdd(xml)
{
	$("span#loading").hide();
	
   	// или при помощи XPath
	item1 = $("#1", xml);
	$("span.tovarTotal").empty();
	$("span.tovarTotal").append(item1.text());
	
	item2= $("#2", xml);
	$("span.sumTotal").empty();
	$("span.sumTotal").append(item2.text());
	
	item3= $("#3", xml);
	$("span.Skidka").empty();
	$("span.Skidka").append(item3.text());
	
	item4= $("#4", xml);
	$("span.SumAll").empty();
	$("span.SumAll").append(item4.text());
	
	item5= $("#5", xml);
	$("span.DelAll").empty();
	$("span.DelAll").append(item5.text());
	
	item6= $("#6", xml);
	$("span.GoToCart").empty();
	$("span.GoToCart").append(item6.text());
	
	
	
	$("span.GoToCart").show();
	$("span.DelAll").show();
	$("span.sumTotal").show();
	$("span.tovarTotal").show();
	$("span.Skidka").show();
	$("span.SumAll").show();
	$('div.addtocart').animate({opacity: "hide"}, 500);
	$('div.cart').animate({opacity: "show"}, 1000);
}

function ch_size(m1,m2)
{
	$('div.size_text').hide();
	$('div.text_add').hide();
	
		$("span#loading").show();
		$.post(
			   "/modules/ajax/ch_size.php",
		{
			type: "test-request",
			tid: m1,
			sid: m2
		},
		onAjaxSuccess4
		);
	
	
}
function onAjaxSuccess4(xml)
{
	$("span#loading").hide();
	
   	// или при помощи XPath
	item1 = $("#1", xml);
	$("div.text_add").empty();
	$("div.text_add").append(item1.text());
	
	
	$('div.text_add').animate({opacity: "show"}, 500);
}
function ch_fason(m1, m2)
{
	$('div.text_add').hide();
	$('div.img').animate({height: 'hide'}, 500, function()
	{
		$("span#loading").show();
		$.post(
			   "/modules/ajax/ch_fason.php",
		{
			type: "test-request",
			sid: m1,
			fid: m2
		},
		onAjaxSuccess
		);
	});
}

function onAjaxSuccess(xml)
{
	$("span#loading").hide();
	
    item1 = $("#1", xml);
	$("div.m").empty();
	$("div.m").append(item1.text());
	
	item2 = $("#2", xml);
	$("div.img").empty();
	$("div.img").append(item2.text());
	
	item3 = $("#3", xml);
	$("div.dop").empty();
	$("div.dop").append(item3.text());
	
	item4 = $("#4", xml);
	$("div.size").empty();
	$("div.size").append(item4.text());
	
	item5 = $("#5", xml);
	$("div.turn").empty();
	$("div.turn").append(item5.text());
	
	item6 = $("#6", xml);
	$("span.price").empty();
	$("span.price").append(item6.text());
	
	//alert(item1.text());
  // Извлекаем текст из элемента
   
	$('div.m').animate({opacity: "show"}, 500);
	$('div.img').animate({height: 'show'}, 500);
    $('div.size').animate({opacity: "show"}, 500);
	$('div.turn').animate({opacity: "show"}, 500); 
	$('span.price').animate({opacity: "show"}, 500); 
	//$('div.dop').animate({opacity: "show"}, 500);
}
function ch_color(m1)
{
	$('div.text_add').hide();
	$('div.img').animate({height: 'hide'}, 500, function()
	{
		$("span#loading").show();
		$.post(
			   "/modules/ajax/ch_color.php",
		{
			type: "test-request",
			tid: m1
		},
		onAjaxSuccess2
		);
	});
}

function onAjaxSuccess2(xml)
{
	$("span#loading").hide();
	
   	// или при помощи XPath
	item1 = $("#1", xml);
	$("div.img").empty();
	$("div.img").append(item1.text());
	
	item2 = $("#2", xml);
	$("div.size").empty();
	$("div.size").append(item2.text());
	
	item3 = $("#3", xml);
	$("div.dop").empty();
	$("div.dop").append(item3.text());
	
	item4 = $("#4", xml);
	$("div.turn").empty();
	$("div.turn").append(item4.text());
	
	//alert(item1.text());
  // Извлекаем текст из элемента
    $('div.size').animate({opacity: "show"}, 500);
	$('div.turn').animate({opacity: "show"}, 500);
	//$('div.dop').animate({opacity: "show"}, 500);
	$('div.img').animate({height: 'show'}, 500);
}
function turn_img(m1,m2)
{
	
	$('div.img').animate({height: 'hide'}, 500, function()
	{
		$("span#loading").show();
		$.post(
			   "/modules/ajax/turn_img.php",
		{
			type: "test-request",
			tid: m1,
			images: m2
		},
		onAjaxSuccess3
		);
	});
}

function onAjaxSuccess3(xml)
{
	$("span#loading").hide();
	
	item1 = $("#1", xml);
	$("div.img").empty();
	$("div.img").append(item1.text());
	
	item2 = $("#2", xml);
	$("div.turn").empty();
	$("div.turn").append(item2.text());

	$('div.turn').animate({opacity: "show"}, 500);
	$('div.img').animate({height: 'show'}, 500);
}



// JavaScript Document
//-->
<!--
function show1()
{
//document.getElementById('q2').style.visibility='visible';
document.getElementById('L1').style.display='';
document.getElementById('L2').style.display='none';
}
function show2()
{
//document.getElementById('q2').style.visibility='hidden';
document.getElementById('L1').style.display='none';
document.getElementById('L2').style.display='';
}



function Dostavka(m1,m2)
{
		
		//$("span#loading").show();	
			$.post(
				   "/modules/ajax/dostavka.php",
			{
				type: "request",
				id: m1,
				opl: m2
			},
				SuccesD
			);
}   	
function SuccesD(xml)
{
	
	item1=$("#1", xml).text();
	$("#loading").hide();
	$("#loading2").hide();
	$("span.dostavka").empty();
	$("span.dostavka").append(item1);
	$("span.dostavka").animate({opacity: "show"}, 100);

	$("span.sumall").empty();
	$("span.sumall").append($("#2", xml).text());
	$("span.sumall").animate({opacity: "show"}, 100);
	

}

function selIndex(m1,m2)
{
		//$("span#loading").show();	

			
			$.post(
				   "/modules/ajax/sch_index.php",
			{
				type: "request",
				ind: m1
				
			},
				
				function(xml){
					$("span#loading2").hide();
					item1 = $("#1", xml);
					$("span.city").empty();
					$("span.city").append(item1.text());
					$("span.city").animate({opacity: "show"}, 0);
					if (m1.length==6 || m1.length==3)
					Dostavka(m1,m2);
				}
			);
}
function selCorp(m1)
{
		if (m1.length>0)
	$("input[@name='nocorpus']").check('off');
	else
	$("input[@name='nocorpus']").check('on');
}
jQuery.fn.check = function(mode) {
   // если mode непоределен, используем 'on' по умолчанию
   var mode = mode || 'on';
   
   // В функцию неявно передана коллекция выбранных элементов.
   // Поэтому с этой коллекцией можно работать, как с любой другой
   // коллекцией элементов в jQuery
   // В нашем случае мы воспользуемся методом each()
   return this.each(function() {
     switch(mode) {
       case 'on':
         this.checked = true;
         break;
       case 'off':
         this.checked = false;
         break;
       case 'toggle':
         this.checked = !this.checked;
         break;
     }
   });
 };
function selDom(m1)
{
	if (m1.length>0)
	$("input[@name='noflat']").check('off');
	else
	$("input[@name='noflat']").check('on');
}



function chPass()
{
	var params = {};
	$(this).find("input[@type='password']").each(function() {
		params[ this.id ] =this.value;
	});
	if (params['passwd'] == params['repasswd'] )
		$("span.password").css( "background-color", "green" );
	else $("span.password").css( "background-color", "red" );
	$("span.password").show();
}





$.fn.ajaxSubmit = function() {
			/* Change a form's submission type to ajax */
			this.submit(function(){
				var params = {};
		    $(this)
		    .find("input[@checked], input[@type='text'], input[@type='hidden'], input[@type='password'], input[@type='submit'], option[@selected], textarea")
		    .filter(":enabled")
		    .each(function() {
		      params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value;
		    });
		   		$('div.formErrors').animate({opacity: 'hide'}, 500);
				
		  		$("span#loading2").show();	
				$.post(this.getAttribute("action") + "?call=ajax", params, function(xml){
						
						$("span#loading2").hide();
						$("div.formErrors").empty();
						$("div.formErrors").append($("item[@id='formErrors']", xml).text());
						$("div.formErrors").animate({opacity: 'show'}, 500);
						
						$("div.firstname").empty();
						$("div.firstname").append($("item[@id='firstname']", xml).text());
						$('div.firstname').animate({opacity: 'show'}, 500);
						
						$("div.lastname").empty();
						$("div.lastname").append($("item[@id='lastname']", xml).text());
						$('div.lastname').animate({opacity: 'show'}, 500);
						
									
						$("div.email").empty();
						$("div.email").append($("item[@id='email']", xml).text());
						$('div.email').animate({opacity: 'show'}, 500);
						
						$("div.passwd").empty();
						$("div.passwd").append($("item[@id='passwd']", xml).text());
						$('div.passwd').animate({opacity: 'show'}, 500);

						$("div.repasswd").empty();
						$("div.repasswd").append($("item[@id='repasswd']", xml).text());
						$('div.repasswd').animate({opacity: 'show'}, 500);
						
											
						$("div.adres_d").empty();
						$("div.adres_d").append($("item[@id='adres_d']", xml).text());
						$('div.adres_d').animate({opacity: 'show'}, 500);
						
						$("div.adres_p").empty();
						$("div.adres_p").append($("item[@id='adres_p']", xml).text());
						$('div.adres_p').animate({opacity: 'show'}, 500);
						
						$("div.mobile").empty();
						$("div.mobile").append($("item[@id='mobile']", xml).text());
						$('div.mobile').animate({opacity: 'show'}, 500);
						
						$("div.phone").empty();
						$("div.phone").append($("item[@id='phone']", xml).text());
						$('div.phone').animate({opacity: 'show'}, 500);
						
						$("div.cod_phone").empty();
						$("div.cod_phone").append($("item[@id='cod_phone']", xml).text());
						$('div.cod_phone').animate({opacity: 'show'}, 500);

						item1 = $("item[@id='1']", xml).text();
						if (item1 == 1)
						
							window.location = "http://oscar.myfamily.in.ua/cart/2/";
					
					 
				});
				return false;
			});
			
			return this;
		}

