jQuery.noConflict();

jQuery(document).ready(function(){

//for flick effect for ie60
if(jQuery.browser.msie)
	{
	try {document.execCommand('BackgroundImageCache', false, true);
	}
	catch(e) {}
	}

//top manu tank
jQuery("div.header > .centerUl > ul > li > a").hover (
function()
{
	jQuery("div.header").append("<div id='tankMenu'></div>");
	var leftPos = this.parentNode.offsetLeft+this.parentNode.parentNode.offsetLeft-40; // vichislyaem posiciyu for tank
	if(jQuery(this).text()=="Home Page") leftPos-=10;
	else if(jQuery(this).text()=="About War") leftPos-=20;
	else if(jQuery(this).text()=="Forum") leftPos-=30;
	else if(jQuery(this).text()=="About Graviteam") leftPos+=30;
	jQuery("#tankMenu").css("left",leftPos+"px").fadeIn(300);
	return false;
},
function()
{
	jQuery("#tankMenu").remove();
	return false;
});

//pokazivaem foto na glavnoy
jQuery("div.photoRamka").hover (
function()
{
	jQuery(this).addClass("zindex5");
	return false;
},
function()
{
	jQuery(this).removeClass("zindex5");
	return false;
});

//pokazivaem plus pri navedenii na foto
jQuery(".photoRamka > a").hover (
function()
{
	jQuery(this).append("<b class='plus'></b>");
	if(jQuery(this).parent().is("div")) jQuery(this).parent().addClass("zindex5");
	return false;
},
function()
{
	jQuery(this).find(".plus").remove();
	jQuery(this).parent().removeClass("zindex5");
	return false;
});

//gallery

jQuery("ul.gameScreenshots > li > a").click (
function()
{
	if(jQuery.browser.opera) return true;
	var hrefImg = jQuery(this).attr("href"); //link na big ris
	jQuery("body").append("<div id='TB_overlay'></div>");
	//plavno pokazivaem fon
	showTD(0,hrefImg);
	
	return false;
});

jQuery("div.photoRamka > a").click (
function()
{
	if(jQuery.browser.opera) return true;
	var hrefImg = jQuery(this).attr("href"); //link na big ris
	jQuery("body").append("<div id='TB_overlay'></div>");
	//plavno pokazivaem fon
	showTD(0,hrefImg);
	
	return false;
});


	});

//plavniy pokaz fona
function showTD(opacity,hrefImg) {
	 jQuery("#TB_overlay").css("filter","alpha(opacity="+opacity+")").css("-moz-opacity","0."+opacity).css("opacity","0."+opacity);
	 if(opacity<55)
	{
		opacity+=10;
		setTimeout("showTD("+opacity+",'"+hrefImg+"')",2);
	}
	else
	{
		if(hrefImg!="video") loadingPhoto(hrefImg);
		else 
		return false;
	}
}

//zagruzka photo
function loadingPhoto(hrefImg)
{
	jQuery("body").append("<div id='bigPhoto'><span>loading photo...</span><div class='progBar'></div></div>");
	jQuery("#bigPhoto").css("top",(screen.availHeight-jQuery("#bigPhoto").height())/2+(document.documentElement.scrollTop || document.body.scrollTop)-250+"px");
	jQuery("#bigPhoto").css("left",document.body.clientWidth/2-jQuery("#bigPhoto").width()/2+"px");
	jQuery("#bigPhoto").append("<img src='"+hrefImg+"' id='bigImg' />");
	loadBigImg(hrefImg);
	return false;
}
function loadBigImg(hrefImg)
{
	jQuery("#bigImg").load (
	function()
	{
		jQuery("#bigPhoto").find("span").remove();
		jQuery("#bigPhoto > .progBar").remove();
		jQuery("#bigImg").fadeIn(200);
		jQuery("#bigPhoto").css("top",(screen.availHeight-jQuery("#bigPhoto").height())/2+(document.documentElement.scrollTop || document.body.scrollTop)+"px");
		jQuery("#bigPhoto").css("left",document.body.clientWidth/2-jQuery("#bigPhoto").width()/2+"px");
		jQuery("#bigPhoto").append("<div id='closeBigImg'>Click to close</div>");
		popupEvents();
		return false;
	});
	return false;
}
function popupEvents()
{
	jQuery("#bigPhoto").mousedown (
	function()
	{
		jQuery("#bigPhoto").remove();
		jQuery("#TB_overlay").remove();
		return false;
	});
	document.onkeydown = function(e)
		{
			if(jQuery.browser.msie) { // ie
			keycode = event.keyCode;
			} else { // mozilla
			keycode = e.which;
			}
			if(keycode == 27){
			jQuery("#bigPhoto").remove();
			jQuery("#TB_overlay").remove();
			}
	}
}
