var state;
var event = window.event;
function prepareEvent(e) {
    if(!e)
        e = window.event;
    if(!e.target)
        e.target = e.srcElement;
    return e;
}
var plural = function(num, one, two, more, noone){
	var word;
    if(num%10==1&&(num%100>20||num%100<11)){word=one;}
    else if((num%10 >= 2 && num%10 <= 4) && (num%100>20 || num%100<11)){word = two;}
    else {word = more;}
    return word;
}

//var bg = new Image();
//bg.src = '/images/design/main/1.jpg';
//$(bg).ready(function(){
/* $('.ox-main .content').animate({
		backgroundPosition: '-1300px'
}, 180000); */
//});


var zIndex = -1;

var arrow_right = function(){
	var tips_num = $('.cheat-codes-2 ul li').length;
	for(i = 0; i < tips_num; i++){
		if( $('.cheat-codes-2 ul > :eq('+i+')').css('z-index') == zIndex ){
			if(i < tips_num - 1){
				$('.cheat-codes-2 ul > :eq('+i+')').next().css('z-index', zIndex += 1);
				break;
			} else {
				$('.cheat-codes-2 ul > :first-child').css('z-index', zIndex += 1);
				break;
			}
		}
	}
}

var arrow_left = function(){
	var tips_num = $('.cheat-codes-2 ul li').length;
	for(i = 0; i < tips_num; i++){
		if( $('.cheat-codes-2 ul > :eq('+i+')').css('z-index') == zIndex ){
			if(i > 0){
				$('.cheat-codes-2 ul > :eq('+i+')').prev().css('z-index', zIndex += 1);
				break;
			} else {
				$('.cheat-codes-2 ul > :last-child').css('z-index', zIndex += 1);
				break;
			}
		}
	}
}

$(document).ready(function(){
	/* window.onkeydown = function (e) { e = prepareEvent(e); state = e.keyCode;}
	document.body.onkeydown = function (e) { e = prepareEvent(e);  state = e.keyCode;}
	window.onkeyup   = function (e) { state = 0; }
	document.body.onkeyup   = function (e) { state = 0; } */
	
	/* $.ctrl = function(key, callback, args) { */
	var isCtrl = false;
	$(document).keydown(function(e) {
		if(e.ctrlKey) isCtrl = true;
		if(e.keyCode == 37  && isCtrl){
			arrow_left();
		} else if(e.keyCode == 39 && isCtrl) {
			arrow_right();
		}
	}).keyup(function(e) {
		if(e.ctrlKey) isCtrl = false;
	});

	/* $.ctrl('<', arrow_left);
	$.ctrl('>', arrow_right); */
	
	$('.blockOverlay, .close-popup').live('click', function(){$.unblockUI();});
	$('#position-gal').myslide({
		behavior: "fade",
		width: "600px", height: 367,
		speed: 1, delay: 5,
		auto: true
	});
	
	var div_other_news = $('<div></div>');
	
	$('.cheat-codes-2 ul li').each(function(){$(this).css('z-index', ++zIndex);});

	var arl = $('<a href="javascript:void(0)">←</a>').attr('id', 'arl').click(function(){return arrow_left();});
	var arr = $('<a href="javascript:void(0)">→</a>').attr('id', 'arr').click(function(){return arrow_right();});

	div_other_news.append(arl);
	div_other_news.append('<span>&nbsp;Ctrl&nbsp;</span>');
	div_other_news.append(arr);
	
	$('.cheat-codes-2 .other-news a.newsDetail').replaceWith(div_other_news);

	
	var bgs = [1,2];
	var rand_file = Math.floor( Math.random( ) * (0 - (bgs.length-1) + 1) ) + (bgs.length-1);
	$('.ox-main .content').css('background-image', "url(/images/design/main/"+bgs[rand_file]+".jpg)");
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
});


/*

#slider-wrap {background-image:url("/images/design/cool-bg-2.png");background-repeat:repeat-x;height:495px;margin: 0 20px 40px 0;overflow:hidden;position: relative;}
#slider-wrap i {position:absolute;background-image:url("/images/design/corners.png");background-repeat:no-repeat;width:16px; height:15px;display:block;}
#slider-wrap i.nw {background-position: 0 0; top: 0; left: 0;}
#slider-wrap i.ne {background-position: 100% 0; top: 0; right: 0;}
#slider-wrap i.sw {background-position: 0 100%; bottom: 0; left: 0;}
#slider-wrap i.se {background-position: 100% 100%; bottom: 0; right: 0;}
#slider-wrap li {height:440px;width: 100%;text-align: center;padding-top: 30px;}
#slider-wrap li a {color:#333333;font-family:Georgia;font-size:20px;font-style:italic;}
#slider-wrap li a:hover {color:#555555;font-family:Georgia;font-size:20px;font-style:italic;}
*/


