function getCookie (n){
	var r=null,a=n+"=",b=a.length,c=window.decodeURIComponent(document.cookie),l=c.length,i=0,j,e;
	while(i<l){j=i+b;if(c.substring(i,j)==a){e=c.indexOf(";",j);
	if(e==-1)e=c.length;r=(c.substring(j,e));break;}i=c.indexOf(" ",i)+1;
	if(i==0)break;}
	return r;
}

function showMessage(msg) {
	var msgPlace = $('wrning');
	if (msgPlace!=null && msgPlace.innerHTML.search(msg)==-1) {
		msgPlace.innerHTML += msg + '<br />';
	}
}
function clearMessage() {
	var msgPlace = $('wrning');
	if (msgPlace!=null) {
		msgPlace.innerHTML = '';
	}
}

function changeText( id, text ) {
	if ($(id)!= null) {
		$(id).innerHTML = text;
	}
	return false;
}
function initializeSearch() {
	var elems = new Array('iGames','iGalleries','iVideos','iUsers','iGroups');
	for(var i=0;i<elems.length;i++) {
		if ($(elems[i])!=null) {
			$(elems[i]).onclick = new Function('changeSearch(\''+elems[i]+'\')');
			$(elems[i]+'B').onclick = new Function('changeSearch(\''+elems[i]+'\')');
		}
	}
	if (typeof(searchType)!= 'undefined' && searchType!='') {
		changeSearch(searchType);
	} else if (typeof(searchType)!= 'undefined') {
		changeSearch('iGames');
	}

}

//wlaczanie i wylaczanie szukania
function changeSearch(type) {

	var elems = new Array('iGames','iGalleries','iVideos','iUsers','iGroups');

	for(var i=0;i<elems.length;i++) {

		$(elems[i]).className = (i==0)?'first':'';
		$(elems[i]+'B').className = (i==0)?'first':'';
	}
	$(type).className='selected'+((type==elems[0])?' first':'');
	$(type+'B').className='selected '+((type==elems[0])?' first':'');

	var action = '/szukaj/gry';
	var text = 'szukaj gry';

	switch( type ) {
		case 'iGames' :
			action = '/szukaj/gry';
			text = 'szukaj gry';
		break;
		case 'iGalleries' :
			action = '/szukaj/galerie';
			text = 'szukaj galerii';
		break;
		case 'iVideos' :
			action = '/szukaj/video';
			text = 'szukaj video';
		break;
		case 'iUsers' :
			action = '/szukaj/uzytkownicy';
			text = 'szukaj użytkownika';
		break;
		case 'iGroups' :
			action = '/szukaj/grupy';
			text = 'szukaj grupy';
		break;
	}
	if (type == searchType) {
		$('iSearch').value = searchQ;
	} else {
		$('iSearch').value = text;
	}
	$('iSearchForm').action = action;
	$('iSearch').onfocus = function() {this.value = ''; }

}


//UPLOAD FORM

function uploadStarted(){
	document.getElementById('iVideoForm').style.display = 'block';
}

function uploadDone() {
	document.getElementById('next').disabled=false;
	document.getElementById('next').className = 'active';
	document.getElementById('next').style.opacity = 1;
}

function uploadError() {
	document.getElementById('iVideoForm').style.display = 'none';
	document.getElementById('next').disabled=true;
	document.getElementById('next').style.opacity = 0.5;
}
//UPLOAD FORM

//POPUP Z GRA
var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
	screenW = screen.width;
	screenH = screen.height;
}else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled() ) {
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 screenW = jScreenSize.width;
	 screenH = jScreenSize.height;
}
screenW = (screenW*1) - 20;
screenH = (screenH*1) - 160;

function goBig(id, width, height){
	var scrollable = 'no';
	if (width > screenW) { width = screenW; scrollable = 'yes'}
	if (height > screenH) { height = screenH; scrollable = 'yes'}
	var wnd = window.open('http://g-gameboard.pl/game.php?gid='+id+'&f=1','duze','width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,resize='+scrollable+',scrollbars='+scrollable);
	resizeInnerTo(width, height, wnd);
	return false;
}

function advGoBig(link, id, width, height){
	link.href="#";
	var scrollable = 'no';
	if (width > screenW) { width = screenW; scrollable = 'yes'}
	if (height > screenH) { height = screenH; scrollable = 'yes'}
	var wnd = window.open('http://g-gameboard.pl/game.php?gid='+id+'&f=1','duze','width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,resize='+scrollable+',scrollbars='+scrollable);
	resizeInnerTo(width, height, wnd);
	return false;
}

function resizeInnerTo(w,h,wnd) {

	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			wnd.innerWidth=w;
		    wnd.innerHeight=h;
	   	} else wnd.resizeTo(w+8,h+58);
	}
}

