﻿/*
 * Настройки
 */
indexFrame = 0; //�������� � N �����
interval = 1; //�������� ����� �������
speedText = 250; //������� ����� ��������
speedColor = 1000; //������� ����� �����
maxFrames = -1800; //���������
resJSON = '';

function aClick(url, divIn, divOut, empty){
	var pattern = "^(([^:/\\?#]+):)?(//(([^:/\\?#]*)(?::([^/\\?#]*))?))?([^\\?#]*)(\\?([^#]*))?(#(.*))?$";
	var rx = new RegExp(pattern);
	var parts = rx.exec(url);
	if (divOut != ''){
		$('#'+divOut).fadeOut(300);
	}
	//var resultData = '';
	$.getJSON(
		url,
		{ },
		function(results) {
			if (results.result == 'success') {
				if (empty === undefined){
					$('#'+divIn).hide();
					$('#'+divIn).html(results.content);
					$('#'+divIn).fadeIn(500);
				}
			} else {
		    	alert("I'm sorry! The server was unable to process request, please try again.");
		    }
		});
}

function move (){
	setTimeout(function(){
		indexFrame = indexFrame - 5;
		if (indexFrame <= maxFrames){
			indexFrame = 0;
		}
		$('#light').css('background-position', indexFrame+'px');
		move();
	}, interval);
}

$(document).ready(function() {
	//$('#msg').hide();
	//$('#light').hide().delay(2000).fadeIn(600);
	move();
	//$('#msg').delay(3000).fadeIn(600);
	div = $('#page > *');
	
	$('a.enter').click(function(){
		var key = $('#key').val();
		aClick(this.href+'/c/'+key, 'page', div[0].id);
		return false;
	});
});
