document.onkeydown = NavigateThrough;

function NavigateThrough (event)
{
	if (!document.getElementById) return;

	if (window.event) event = window.event;

	if (event.ctrlKey)
	{
		var link = null;
		var href = null;
		switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
		{
			case 0x25:
				link = document.getElementById ('NextLink');
				break;
			case 0x27:
				link = document.getElementById ('PrevLink');
				break;
			case 0x26:
				link = document.getElementById ('UpLink');
				break;
			case 0x28:
				link = document.getElementById ('DownLink');
				break;
			case 0x24:
				href = '/';
				break;
		}

		if (link && link.href) document.location = link.href;
		if (href) document.location = href;
	}			
}



/* * * * * * * * * * * * * * * * */
function cScroller () {//states: 1 - down , -1 - up , -2 - right , 2 - left
	this.objects = {};
	this.speed = 10;

	this.init = function (objID,state) {
		var obj = {};
		obj.obj = document.getElementById(objID);
		obj.state = state;
		obj.timer = null;
		obj.maxVertScroll = parseInt(obj.obj.scrollHeight) - parseInt(obj.obj.offsetHeight);
		obj.maxHorizScroll = (parseInt(obj.obj.scrollWidth) - parseInt(obj.obj.offsetWidth));
		this.objects[objID] = obj;
	}

	this.down = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,1);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = 1;
		}

		if ((obj.maxVertScroll > obj.obj.scrollTop) && (obj.state == 1)) {
			obj.obj.scrollTop = (obj.obj.scrollTop + this.speed);
			obj.timer = setTimeout(this.down.bind(this,id,true),100);
		}

	}

	this.right = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,-2);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = -2;
		}

		if ((obj.maxHorizScroll > obj.obj.scrollLeft) && (obj.state == -2)) {
			obj.obj.scrollLeft = (parseInt(obj.obj.scrollLeft) + this.speed);
			obj.timer = setTimeout(this.right.bind(this,id,true),100);
		}

	}


	this.up = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,-1);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = -1;
		}

		if ((obj.obj.scrollTop > 0) && (obj.state == -1)) {
			obj.obj.scrollTop = (parseInt(obj.obj.scrollTop) - this.speed);
			if (obj.obj.scrollTop < 0) obj.obj.scrollTop = 0;
			obj.timer = setTimeout(this.up.bind(this,id,true),100);
		}
	}


	this.left = function (id,timer) {
		if (this.objects[id] == undefined) {
			this.init(id,2);
		}
		var obj = this.objects[id];
		if (timer == undefined) {
			obj.state = 2;
		}

		if ((obj.obj.scrollLeft > 0) && (obj.state == 2)) {
			obj.obj.scrollLeft = (parseInt(obj.obj.scrollLeft) - this.speed);
			if (obj.obj.scrollLeft < 0) obj.obj.scrollLeft = 0;
			obj.timer = setTimeout(this.left.bind(this,id,true),100);
		}
	}

	this.stop = function (id) {
		if (this.objects[id]) {
			clearTimeout(this.objects[id].timer);
			this.objects[id].state = 0;
		}
	}



}

function korz(goods_id)
	{	
		url = "/zakaz.php?action=add&id=" + goods_id + "";
		cart = window.open(url,'basket','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=600,height=400,resizable=yes'); 
		cart.focus();
	}
