/********************* cart **********************/
function aj_addc(idi)
	{
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'addc',
		'idi': idi
            },
            function(result, errors) {
                if (result) {
                    $("#ncart").html(result["r"]);
		    if(result["r"]){$('div#cartok').show();scroll(0,0);}
                }
            },
            true
        );
	}
function aj_delc(idi)
	{
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'delc',
		'idi': idi
            },
            function(result, errors) {
                if (result) {
		    $("#ncart").html(result["r"]);
		    $("#r"+idi).hide();
                }
            },
            true
        );
	}

/***************** chs ************************/

function aj_chs(min,max)                                  
	{
/*	 if(x==2){$("#fromPRC option[value='50']").attr("selected", "selected");
		  $("#toPRC option[value='300']").attr("selected", "selected");}
	 if(x==3){$("#fromPRC option[value='300']").attr("selected", "selected");
		  $("#toPRC option[value='1000']").attr("selected", "selected");}
	 if(x==4){$("#fromPRC option[value='1000']").attr("selected", "selected");
		  $("#toPRC option[value='3000']").attr("selected", "selected");}
	 if(x==5){$("#fromPRC option[value='3000']").attr("selected", "selected");
		  $("#toPRC option[value='50000']").attr("selected", "selected");}

	 $("#fromPRC").trigger('click');
	 $("#toPRC").trigger('click');

	 $('#dslider').show();*/
    	 $("#ajldr").show();
	 $("#main_tbl").hide();
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'chs',
                'min': min,
                'max': max
            },
            function(result, errors) {
                if (result) {
                    $("#main_tbl").html(result["r"]);
		    $("#main_tbl").show(500);
                }
		$("#ajldr").hide();
            },
            true
        );

	}

function aj_chs2(from,to)
	{
    	 document.getElementById("ajldr").style.visibility="visible";
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'chs2',
                'from': from,
                'to': to
            },
            function(result, errors) {
                if (result) {
                    document.getElementById("main_tbl").innerHTML=result["r"];
                }
	    	document.getElementById("ajldr").style.visibility="hidden";

            },
            true
        );

	}

/********************** sbox3 ************************/
function fc(x)
	{
	 if(x.id!='sbox3')if(document.getElementById("sbox3").value=='')
		{
		 document.getElementById("sbox3").value='Наберите первые буквы...';
		 document.getElementById("sbox3").style.fontColor='grey';
		}
	}

function aj_src3()
	{
	 if(document.getElementById("sbox3").value.length<3)return;
	 $("#main_tbl").hide();
	 $("#ajldr").show();
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'src3',
		'stxt': document.getElementById("sbox3").value,
            },
            function(result, errors) {
                if (result){
                    	$("#main_tbl").html(result["r"]);
			$("#main_tbl").show(300);
                	}
    	    	$("#ajldr").hide();
            },
            false
        );
	}

function tosrc(x)
	{
	 document.getElementById("sbox3").value=x.innerHTML;
	 aj_src3();
	}

/********************* rnd2 *******************************/
function aj_rnd()
	{
	 $("#sbx").hide(200);
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'rnd'
            },
            function(result, errors) {
                if (result) {
			$("#sbx").html(result["r"]);
			$("#sbx").show(300);
                }
            },
            true
        );
	}

/***************** item ******************************/
function tool_hint1(event,id,sh)
	{
	 if(!sh)return;
	 hint=document.getElementById('hint');
	 if(id==1){hint.style.background='black';hint.style.color='red';hint.innerHTML='Доставляется в подарочном пакете!';}
	 if(id==2){hint.style.background='white';hint.style.color='green';hint.innerHTML='Бесплатная доставка по Киеву!';}
	 if(id==3){hint.style.background='black';hint.style.color='magenta';hint.innerHTML='Рекомендуем дарить прекрасному полу!';}
	 if(id==4){hint.style.background='white';hint.style.color='blue';hint.innerHTML='Этот подарок понравится мужчинам!';}
	 if(id==5){hint.style.background='black';hint.style.color='white';hint.innerHTML='Шефу понравится!';}
	 if(id==6){hint.style.background='white';hint.style.color='red';hint.innerHTML='Постоянным клиентам скидки!';}
	 if(id==10){hint.style.background='blue';hint.style.color='white';hint.innerHTML='Видеообзор подарка';}
	 hint.style.left=(event.clientX-315)+"px";
	 hint.style.top=(event.clientY-30)+"px";
	 $('#hint').show();
	}
function tool_hint(event,id,sh)
	{
	 if(!sh)return;
	 hint=document.getElementById('hint');
	 if(id==1){hint.innerHTML='Доставляется в подарочном пакете!';}
	 if(id==2){hint.innerHTML='Бесплатная доставка по Киеву!';}
	 if(id==3){hint.innerHTML='Рекомендуем дарить прекрасному полу!';}
	 if(id==4){hint.innerHTML='Этот подарок понравится мужчинам!';}
	 if(id==5){hint.innerHTML='Шефу понравится!';}
	 if(id==6){hint.innerHTML='Постоянным клиентам скидки!';}
	 if(id==10){hint.innerHTML='Видеообзор подарка';}
	 if(id==11){hint.innerHTML='Отзывы об этом подарке';}
	 hint.style.left=(event.clientX-150)+"px";
	 hint.style.top=(event.clientY-150)+"px";
	 $('#hint').show();
	}
function tool_hint_c(){$('#hint').hide();}
function sh_bimg(i)
	{
	 document.getElementById('bimg').src=document.getElementById('ism'+i).src;
	 document.getElementById('abimg').href=document.getElementById('ism'+i).src;
	}
//function sh_vid(){if($("#video").css("display")=="none")$("#video").show(300);else $("#video").hide(300);}

/********************* opinion *************************/
function aj_send_opinion(itid,itnm)
	{
	 JsHttpRequest.query(
            '/aj.php',
            {
                'act': 'send_opinion',
		'id': itid,
		'itnm': itnm,
		'nm': $("#op_in_nm").val(),
		'tx': $("#op_in_tx").val()
            },
            function(result, errors) {
                if (result) {
                    $("#res_win").html(result["r"]);
		    document.getElementById("op_in_nm").value="";
		    document.getElementById("op_in_tx").value="";
                }
            },
            true
        );
	}
	                                                                 
