// JavaScript Document


function displayWindow(url, nazwa, wys, szer, proc) {

	if (proc==1) {
			 var width = window.screen.width * szer/100;
			 var height = window.screen.height * wys/100;
		} 
		else {
			 var width =  szer;
			 var height =  wys;
				
		}
		var okno = window.open(url, nazwa, 'width=' + width + 'px,height=' + height + 'px,resizable=1,scrollbars=yes,menubar=yes');
	}

function displaySimpleWindow(url, width, height) {
        var Win = window.open(url,"SimpleWindow",'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes,menubar=no' );
}

function displayModalWindow(url, nazwa, wys, szer, proc) {

	// nazwa - nazwa okna, zastêpuje poprzedni±zawarto¶æ
	// wys, szer - w pikselach
	// proc = 1 - wys, szer w % aktualnego rozmiaru
	
	if (proc==1) {
		 var width = window.screen.width * szer/100;
		 var height = window.screen.height * wys/100;
	} 
	else {
		 var width =  szer;
		 var height = wys;
			
	}
	
	 var okno = window.open(url, nazwa, 'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no');

}

function toggleNode(id) {
		
	var d = document.getElementById("dNode"+id);
	var i = document.getElementById("iNode"+id);
	
	d.style.display = (d.style.display=='none')?'':'none';
	i.src = (i.src.indexOf('plus')>0)?i.src.replace(/plus/,'minus'):i.src.replace(/minus/, 'plus');
			
}


function pageLoader(ddir, page, pagelength) {
		 

	var i;
 
	for (i=0; i<=pagelength; i++)
		document.getElementById('linkPage'+i).className= 'stopkaKontakt';

	document.getElementById('linkPage'+page).className = 'menuBox2';
	getAjax('inc_galeria_page.php?dir='+ddir+'&page='+page, 'galeria_content');
}


function getAjax(loadurl, dest) {
	advAJAX.get(
			{
    		url: loadurl,
    			
    		onLoading : function(obj) { 
    			//wys = document.getElementById(dest).style.Height;
					document.getElementById(dest).innerHTML = "<p align='center'><img src='_images/ajax-loader.gif' ></p>";
				//document.getElementById(dest).style.Height = wys;
				},
			 onComplete : function(obj) { 
					document.getElementById(dest).innerHTML = '';
				},
			onSuccess : function(obj) {
				document.getElementById(dest).innerHTML = obj.responseText;
    			}, 
				
				onError : function(obj) {
					document.getElementById(dest).innerHTML  =  obj.responseText;	
				}
			});

	
}


function validate() {
	
	var ok = true;
	var i;
	var elem = ['imienazw', 'email', 'tel'];

	for (i=0;i<3;i++) {
		el = document.getElementById(elem[i]);
		if (el.value=='')  {	
			ok = false;
			el.className='option-red';
		} else el.className='option';
	}

	if (!ok) alert ("Wypełnij wszystkie wymagane pola formularza");
	return ok;

}


