

function validateOpenPlayer(form){
	if (form.nickname.value == ''){
		alert(openPlayerWarn != undefined ? openPlayerWarn : 'Please type player`s nickname');
		return false;
	}
	return openPlayerWin();
}

function openPlayer(playerId, gameId){
	if (locale == undefined){
		locale = 'uk';
	}

	var url = '/'+locale+'/player/show/playerId/'+playerId+'/gameId/'+gameId;
	openPlayerWin(url);

}

function openPlayerWin(url){
	if (url == undefined){
		url = '';
	}
	var win = open(url,'playerWin','left=10,top=10,height=500,width=660,toolbar=0,scrollbars=1');
	if (typeof(win) == 'object'){
		win.focus();
		return true;
	}
	alert('Possible pop-up blocking action. Please disable the popup blocker for this site.');
	return false;
}



function goToAnchor(anc){
	var url = location.href;
	if (url.indexOf('#')!=-1){
		url = url.replace(/#[^\&]*/, '#'+anc);
	} else {
		url = url+'#'+anc;
	}
	location.href = url;
}

function fixAnchors() {
	//var time1 = new Date().getTime();
	var site = window.location.protocol+'//'+window.location.hostname;
	var aEls = document.getElementsByTagName("a");
	var len = aEls.length;
	for (var i = 0; i < len; i++) {
		if (aEls[i].href.indexOf(site+'/#') == 0 || aEls[i].href.indexOf('#') == 0) {
			aEls[i].href = window.location.href.split('#')[0] + aEls[i].href.slice(aEls[i].href.indexOf('#'), aEls[i].href.length);
		}
	}
	//alert(new Date().getTime()-time1);
}

// remove a flickering
(fixBgImageCache = function() {
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(e) {}
})();


if (window.onload) {
	old_onload = window.onload;
}
window.onload = function() {
	fixAnchors();
	if (this.old_onload) {
		this.old_onload();
	}
}
