function getClientWidth(){
	if (self.innerWidth)
		return self.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	else if (document.body)
		return document.body.clientWidth;
}

/*************************************************/

function getClientHeight(){
	if (self.innerHeight)
		return self.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	else if (document.body)
		return document.body.clientHeight;
}	

/*************************************************/
	
function ustalWysokosci(szablon){

	var szerokoscOkna = getClientWidth();
	var wysokoscOkna = getClientHeight() - 120;
	
	var MainContent = document.getElementById("MainContent");
	var mainTable = document.getElementById("mainTable"); 
	var MainMenu = document.getElementById("MainMenu"); 
	
	var finalWitdh = (getClientWidth() > 966) ? 980 : 771;
	
	MainContent.style.height = (wysokoscOkna -17) + 'px';
	MainMenu.style.height = (wysokoscOkna -31) + 'px';
	mainTable.style.width = finalWitdh + 'px';

	if(szablon == 1){
		var ImageContent = document.getElementById("ImageContent");
		if( ImageContent ){
			ImageContent.style.height = wysokoscOkna+'px';
		}
	}	

}


function zmien(id) {
	document.getElementById(id).style.display=(document.getElementById(id).style.display=='block')?'none':'block';
}


function ukryj(id) {
	document.getElementById(id).style.display='none';
}


function odkryj(id) {
	document.getElementById(id).style.display='block';
}


function pom(id) {
	document.getElementById(id).style.color='#F26633';
}


function browserVersion() {
	var agt = navigator.userAgent.toLowerCase();

	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);

	this.nav    = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1)));
	this.nav4up = this.nav && (this.major == 4);
	this.nav6 	= this.nav && (this.major >= 5);

	this.navonly = (this.nav && (agt.indexOf(";nav") != -1));

	this.ie     = (agt.indexOf("msie") != -1);
	this.ie4up  = this.ie  && (this.major >= 4);
	this.ie5up  = this.ie && (navigator.appVersion.indexOf('compatible; MSIE 5.0') != -1)

	this.opera = (agt.indexOf("opera") != -1);

	this.ver4up = (this.ie4up || this.nav4up );
}
var browserVersion = new browserVersion();



function openNonscrolledWindow(theURL,winName,myWidth, myHeight, isCenter) { 
  if(window.screen)
	if(isCenter)
		if(isCenter=="true")
		{	var myLeft = (screen.width-myWidth)/2;
    			var myTop = (screen.height-myHeight)/2;
		window.open(theURL,winName,'location=0,directories=0,scrollbars=no,toolbar=0,menubar=0,resizable=1,status=0,width='+myWidth+',height='+myHeight+',left=' + myLeft+ ',top=' + myTop)
  }																		  
}



function openscrolledWindow(theURL,winName,myWidth, myHeight, isCenter) { 
  if(window.screen)
	if(isCenter)
		if(isCenter=="true")
		{	var myLeft = (screen.width-myWidth)/2;
    			var myTop = (screen.height-myHeight)/2;
		window.open(theURL,winName,'location=0,directories=0,scrollbars=yes,toolbar=0,menubar=0,resizable=1,status=0,width='+myWidth+',height='+myHeight+',left=' + myLeft+ ',top=' + myTop)
  }																		  
}



function open_popup(address){
	var maxW = screen.width;
	var maxH = screen.height;
	var w = 10;
	var h = 10;
	var _top = Math.floor((maxH - h) / 2);
	var _left = Math.floor((maxW - w) / 2);
	
	var win = window.open(address,'doiW',"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width="+w+",height="+h+",left="+(_left-200)+",top=200");
	//win.moveTo((_left-200),(_top-200));
	win.focus();
}



function show_popup_image(obr){
	//openNonscrolledWindow('includes/foto.php?foto='+obr,'popupimg',10, 10, 'true');
	open_popup('includes/foto.php?foto='+obr);
}


function zaznAll(the_form, nazwa_pola, akcja) {
	for (var i=0; i<document.forms[the_form].elements[nazwa_pola].length; i++)  {
		document.forms[the_form].elements[nazwa_pola][i].checked = akcja;			
	}
}

function checkCheckPP(f){

	var znacznik = false;
	for (var i=0; i<f.elements['grupa_set'].length; i++)  {
		if( f.elements['grupa_set'][i].checked == true ){
			znacznik = true;	
		}
	}	

	if(f.biuletyn.checked == true){	
		if(znacznik == false){
			alert('Musisz określić jakiego rodzaju projekty interesują Cię.');
			return false;		
		}
	}

	if (f.prod.checked == false) {
		alert('Musisz wyrazić zgodę na przetważanie danych osobowych.');
		return false;
	}
	
	if(f.login.value == "")	{
		alert("Proszę wpisać login.");
		return false;
	}	
	
	if(f.password.value == "")	{
		alert("Proszę wpisać hasło.");
		return false;
	}
	
	if(f.password.value != f.password2.value)	{
		alert("Podane hasła różnią się od siebie.");
		return false;
	}	
	
	if(f.imie.value == "")	{
		alert("Proszę podać swoje imię.");
		return false;
	}
	
	if (f.email.value=='') {
		alert('Proszę wpisać adres e-mail.');
		return false;
	}

	if ( ((f.email.value.indexOf('@',1))==-1)||(f.email.value.indexOf('.',1))==-1 ) {
		alert('Format adresu e-mail jest niepoprawny.');
		return false;
	}		
	
	if (f.biuletyn.checked == false ) {
		return confirm('Czy świadomie nie została zaznaczona opcja zgłoszenia chęci otrzymywania biuletynu?');
	}	
	
}

function biuletyn_check(){
	if (document.formularz.biuletyn.checked == true ) {
		if(confirm('Czy jesteś zdecydowany zrezygnować z otrzymywania biuletynu informacyjnego?')){
			document.formularz.biuletyn.checked = false;

			zaznAll('formularz','grupa_set', false);			
			
		} 
		else{
			document.formularz.biuletyn.checked = true;
		}
	}	
}


