

function Ins_Html(targ,val){ //o-oey anoaaee innerHTML
	with (document) if (getElementById && ((objpole=getElementById(targ))!=null))
		with (objpole) innerHTML = unescape(val)
	} 
dodo=''; //функция затемнения при загрузке аякс
ed='';
function Lod(l){
	if(l==0){
		with (document) if (getElementById && ((objl=getElementById('load'))!=null))
		 eval("objl.style.top = '-50px'")
		 with (document) if (getElementById && ((objl=getElementById('load_fon'))!=null))
		 eval("objl.style.top = '-2500px'")
		}
		if(l==1){
		with (document) if (getElementById && ((objl=getElementById('load'))!=null))
		 eval("objl.style.top = '350px'")
		 with (document) if (getElementById && ((objl=getElementById('load_fon'))!=null))
		 eval("objl.style.top = '-5px'")
		}
		window.clearInterval(dodo)
	}

korz_str1 = '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
korz_str3='</table>';
counts=1;

function add_Korz(id_add,check_n,watdo) {
Lod(1);

korz_str2=''

JsHttpRequest.query(
  'req_korz.php',
  {
  'id_add': id_add,
  'watdo': watdo,
  'counts': counts,
  'check_n': check_n
  },
    
  function(result, errors) { 
 // document.getElementById("err").innerHTML = errors;
                  id_str = result["tov_id"];
				  id_rod = result["rod_str"];
				  name = result["name"];
				  price = result["price"];
				  kol_vo = result["kol_vo"];
				   counts = result["counts"];
				   itogi = result["itog"]+' руб.';
				   pic = result["pic"];
				   pred = result["pred"];
				 id_arr=id_str.split('|');
				 id_rod_arr=id_rod.split('|');
				 name_arr=name.split('|');
				 price_arr=price.split('|');
				 kol_vo_arr=kol_vo.split('|');
				 pic_arr=pic.split('|');
				 pred_arr=pred.split('|');
				 
				for(t=0;t<id_arr.length;t++){
		      if(watdo==1) { korz_str2+='<tr class="tov_in_rght"><td class="tov_in_rght" align="left">&nbsp;<a class="tov_in_rght" href="6-'+id_arr[t]+'-'+id_rod_arr[t]+'-0-<?php echo $sort; ?>.html">'+name_arr[t]+'</a></td><td class="tov_in_rght" width="30">'+kol_vo_arr[t]+'</td><td class="tov_in_rght" align="center" width="55">'+price_arr[t]+' p.</td></tr>';}
			  if(watdo==2||watdo==3||watdo==4) {
				  if(kol_vo_arr[t]>1){minusy='<a href="#111" onClick="add_Korz('+id_arr[t]+',<?php echo $chk; ?>,3)"><img src="images/minus.png" width="20" height="20" border="0" /></a>';}
				  else if(kol_vo_arr[t]<=1) {minusy='<img src="images/minus_no.png" width="20" height="20" border="0" />';}
				  pred_arr[t]=pred_arr[t].substring(0,200);
			korz_str2+='<tr class="tov_in"><td height="45" width="60" class="tov_in" align="center"><img class="img" src="boss/img.php?id='+pic_arr[t]+'&t=2" height="36" width="46"  border="1" /></td><td width="50%" class="tov_in" align="left"><b><a class="tov_in" href="6-'+id_arr[t]+'-'+id_rod_arr[t]+'-0-<?php echo $sort; ?>.html">'+name_arr[t]+'</a></b><br />'+pred_arr[t]+'</td><td class="tov_in" width="10%"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><a href="#111" onClick="add_Korz('+id_arr[t]+',<?php echo $chk; ?>,2)"><img src="images/plus.png" width="20" height="20" border="0" /></a></td><td>'+kol_vo_arr[t]+' шт.</td><td>'+minusy+'</td></tr></table></td><td class="tov_in" align="center" width="15%">'+price_arr[t]+' руб.</td><td class="tov_in" align="center" width="10%"><a href="#111" onClick="add_Korz('+id_arr[t]+',<?php echo $chk; ?>,4)"><img src="images/delete_tov.png" width="20" height="20" border="0" /></a></td></tr>'	  
				  }
				
				}
				if(watdo==1){oform='<a href="5-63-0-0-<?php echo $sort; ?>.html" class="tov_in_rght">Оформить заказ</a>'}
				else{oform=' '}
				 kor=korz_str1+korz_str2+korz_str3;
	if(watdo!=1) {val_tov=document.getElementById('tovary_k'); val_tov.value=id_str;
	val_price=document.getElementById('price_k'); val_price.value=price;
	val_kolv=document.getElementById('kolv_k'); val_kolv.value=kol_vo;}
	Ins_Html('korz_div',kor);
	Ins_Html('itog',itogi);
	Ins_Html('zakof',oform);
	dodo=window.setInterval('Lod(0)',10)
    },
 false
 );

		 
	counts++
}

b=0
n=new Array()
n[0]=1
n[1]=1
n[2]=1
n[3]=1
mas=new Array()
mas[0]=m[0].length
mas[1]=m[1].length
mas[2]=m[2].length
mas[3]=m[3].length

kol=new Array()
kol[0]=1
kol[1]=1
kol[2]=1
kol[3]=1

function Timer() { //ooieoee aey auaiaa iaiy?ueeony ea?oeiie
gg1 = window.setInterval("ImgChange(0)",7300);
gg2 = window.setInterval("ImgChange(1)",8500);
gg3 = window.setInterval("ImgChange(2)",6700);
gg4 = window.setInterval("ImgChange(3)",9700);
}
function ImgChange(i) {
n[i]= -(n[i])
with (document) if (getElementById && ((obj1=getElementById('pic'+i))!=null))
with (document) if (getElementById && ((obj2=getElementById('pics'+i))!=null))
if (n[i]==1){
        with (obj1) style.zIndex = '2';
		with (obj2) style.zIndex = '1';
		with (obj1) innerHTML = unescape('<a href="'+ss[i][kol[i]]+'"><img class="kar" id="pok'+i+'" src='+m[i][kol[i]]+' width="170" height="200" border="0" /></a>');
		MM_effectAppearFade(obj2, 1000, 100, 0, false);
		MM_effectAppearFade(obj1, 1000, 0, 100, false);
		kol[i]++
		if(kol[i]==mas[i]) kol[i]=1;
	}
else{
        with (obj2) style.zIndex = '2';
		with (obj1) style.zIndex = '1';
		with (obj2) innerHTML = unescape('<a href="'+ss[i][kol[i]]+'"><img class="kar" id="pok'+i+'" src='+m[i][kol[i]]+' width="170" height="200" border="0" /></a>');
		MM_effectAppearFade(obj1, 1000, 100, 0, false);
		MM_effectAppearFade(obj2, 1000, 0, 100, false);
		kol[i]++
		if(kol[i]==mas[i]) kol[i]=1;
	}	

}

function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}


function Change_Style(targ_id,styl,val){ //ooieoey eciaiaiey noeeae iauaeoa
	with (document) if (getElementById && ((obj=getElementById(targ_id))!=null))
		 eval("obj.style."+styl+" = '"+val+"'")
	}
	
