$(function() {
	$("#words").autocomplete(
		"/ajax.php",
		{
			delay:10,
			minChars:2,
			matchSubset:1,
			matchContains:1,
			cacheLength:10,
			autoFill:false
		});	
});


// send question

	function sr() {
		rq = '/ajax.php?mode=quest&name='+$('#q_name').val();
		rq = rq +'&mail='+$('#q_mail').val();
		rq = rq +'&text='+$('#q_text').val();
		rq = rq +'&tel='+$('#q_tel').val();
		rq = rq +'&url='+window.location.pathname;
		
		$.ajax({
			type: "GET",
			url: rq,
        dataType: "html",
        success: function(msg) {
           	if(parseInt(msg)!=0) {
               	$('#aj_res').text(msg);
				}
			}
		});
	}

	// send comment
	function scomm() {
		rq = '/ajax.php?mode=comment&name='+$('#c_name').val();
		rq = rq +'&mail='+$('#c_mail').val();
		rq = rq +'&text='+$('#c_text').val();
		rq = rq +'&url='+window.location.pathname;

		$.ajax({
			type: "GET",
			url: rq,
        dataType: "html",
        success: function(msg) {
           	if(parseInt(msg)!=0) {
               	$('#aj_resc').text(msg);
				}
			}
		});
	}

	// send order
	function srb() {
		rq = '/ajax.php?mode=order&name='+$('#b_name').val();
		rq = rq +'&mail='+$('#b_mail').val();
		rq = rq +'&text='+$('#b_text').val();
		rq = rq +'&tel='+$('#b_tel').val();
		rq = rq +'&url='+window.location.pathname;

		$.ajax({
			type: "GET",
			url: rq,
        dataType: "html",
        success: function(msg) {
           	if(parseInt(msg)!=0) {
               	$('#aj_resb').text(msg);
				}
			}
		});
	}
	
	function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function compare(id, cid, mf) {
	rq = '/ajax.php?mode=compare&id='+id +'&cid='+cid +'&mf='+mf;

	$.ajax({
		type: "GET",
		url: rq,
     dataType: "html",
     success: function(msg) {
        	if(parseInt(msg)!=0) {
            	$('#compare').html(msg);
			}
		}
	});
}

