<!--
var XMLHttpRequestObj = false;

	if (window.XMLHttpRequest) {
		XMLHttpRequestObj = new XMLHttpRequest();
		
	}
	
	if (!XMLHttpRequestObj) {
		try {
			XMLHttpRequestObj = new ActiveXObject("Msxml2.XMLHTTP");
			
		} catch(e) {
			try {
				XMLHttpRequestObj  = new ActiveXObject("Microsoft.XMLHTTP");
				
			} catch(e) {
				XMLHttpRequestObj = false;
			
			}
		
		}
	
	}
	
/*
	else if (window.ActiveXObject) {
		XMLHttpRequestObj = new ActiveXObject("Microsoft.XMLHTTP");
		
	}
*/

var Xpos = 0;
var Ypos = 0;

var PicOrgWidth;
var PicOrgHeight;
var PicScaleWidth;
var PicScaleHeight;
var PicOrgScale;


function pobierzDane(mod, sect, par, block) {

	if (XMLHttpRequestObj) {
		
		ShowHELP('loading');
		
		styl = "";
		url = "index.php?module="+mod+"&sect="+sect+"&ajax=1";
		if (par)
			url = url+"&parent="+par;
			
		if (block) {
			url = url+"&block="+block;
			styl = "block";
			
		}
		
		XMLHttpRequestObj.open("GET", url);
		XMLHttpRequestObj.onreadystatechange = function () {
			if (XMLHttpRequestObj.readyState == 4 && XMLHttpRequestObj.status == 200) {
				wyswietlDane(XMLHttpRequestObj.responseXML.documentElement, styl);
				ShowHELP('loading');
				
			}
		}
		
		XMLHttpRequestObj.send(null);
		
	}

}

function wyswietlDane(Content, styl) {
	var locOBJ = document.getElementById("location");
	
	if (styl == "block") {
		var textOBJ = document.getElementById("content");
	
	} else {
		var pictOBJ = document.getElementById("artpic");
		var textOBJ = document.getElementById("arttext");
		var listOBJ = document.getElementById("artlist");
	
	}
	
	var pictNode = Content.getElementsByTagName("picture");
	var textNode = Content.getElementsByTagName("text");
	var listNode = Content.getElementsByTagName("right");
	var locNode = Content.getElementsByTagName("location");
	var subNode = Content.getElementsByTagName("submenu");;
	
	if (styl != "block") {
		pictSRC = GetInnerText(pictNode[0]);
		if (pictSRC) {
			pictOBJ.src = pictSRC;
		} else {
			pictOBJ.src = "";
		}
			
		listSTR = GetInnerText(listNode[0]);
		if (listSTR) {
			listOBJ.innerHTML = listSTR;
		}
	
	}
		
	locSTR = GetInnerText(locNode[0]);
	if (locSTR) {
		locOBJ.innerHTML = locSTR;
		
	}
	
	textSTR = GetInnerText(textNode[0]);
	if (textSTR) {
		textOBJ.innerHTML = textSTR;
	} else {
		textOBJ.innerHTML = "";
	}

}

function wyslijFormularz() {
	var imie = document.getElementById('imie').value;
	var nazwisko = document.getElementById('nazwisko').value;
	var miejscowosc = document.getElementById('miejscowosc').value;
	var telefon = document.getElementById('telefon').value;
	var email = document.getElementById('email').value;
	var zapytanie = document.getElementById('zapytanie').value;
	
	var div = document.getElementById('formmsg');
	
	if (imie == "") {
		alert("Proszę wypełnić pole \"Imię\"");
		document.getElementById('imie').focus();
		return false;
	}
	
	if (nazwisko == "") {
		alert("Proszę wypełnić pole \"Nazwisko\"");
		document.getElementById('nazwisko').focus();
		return false;
	}

	if (telefon == "") {
		alert("Proszę wypełnić pole \"Telefon\"");
		document.getElementById('telefon').focus();
		return false;
	}
	
	if (XMLHttpRequestObj) {
		
		ShowHELP('loading');
		
		XMLHttpRequestObj.open("POST", "index.php?module=kontakt&ajax=1");
		XMLHttpRequestObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		XMLHttpRequestObj.onreadystatechange = function () {
			if (XMLHttpRequestObj.readyState == 4 && XMLHttpRequestObj.status == 200) {
				wysylkaInfo(XMLHttpRequestObj.responseXML.documentElement)
				ShowHELP('loading');
				
			}
		
		}
		
		XMLHttpRequestObj.send('imie='+imie+'&nazwisko='+nazwisko+'&miejscowosc='+miejscowosc+'&telefon='+telefon+'&email='+email+'&zapytanie='+zapytanie);
		
	}
		
}

function wysylkaInfo(Content) {
	var msgOBJ = document.getElementById("formmsg");

	var styleNode = Content.getElementsByTagName("style");
	var textNode = Content.getElementsByTagName("text");
	
	styleSTR = GetInnerText(styleNode[0]);
	if (styleSTR) {
		msgOBJ.className = GetInnerText(styleNode[0]);
	}
		
	textSTR = GetInnerText(textNode[0]);
	if (textSTR) {
		msgOBJ.innerHTML = GetInnerText(textNode[0]);
	} else {
		textOBJ.innerHTML = "";
	}

}

function GetInnerText (node) {
	 return (node.textContent || node.innerText || node.text) ;

}

function GetImgWidth() {
	var oImage = new Image();
	oImage.src = document.images.picture.src;
	PicOrgWidth = oImage.width;
	PicOrgHeight = oImage.height;
	
	PicOrgScale = 1;
	
	ResizeImg();
	
}

function ResizeImg() {
	if (PicOrgScale == 1) {
		if (PicOrgWidth > 650) {
			PicScaleWidth = 650 / PicOrgWidth;
			document.images.picture.width = 650;
			document.images.picture.height = PicOrgHeight * PicScaleWidth;
			
			if (document.images.picture.height > 590) {
				PicScaleHeight = 590 / PicOrgHeight;
				
				document.images.picture.width = PicOrgWidth * PicScaleHeight;
				document.images.picture.height = 590;
				
			}
			
		}
		
		PicOrgScale = 0;
		
		ResizeWindow();
		
	} else {
		document.images.picture.width = PicOrgWidth;
		document.images.picture.height = PicOrgHeight;
		
		PicOrgScale = 1;
		
		ResizeWindow();
		
	}
	
}


function ShowBigPicture(strProdCode) {
	var oPopUp = window.open("index.php?module=sklep&op=pic&pid="+strProdCode,'', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,width=700,height=650,top=20,left=20');

}

function Show3DPicture(strProdCode) {
	var oPopUp = window.open("index.php?module=sklep&op=pic&pid="+strProdCode,'', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,fullscreen=no,width=250,height=250,top=20,left=20');

}

function ShowURL(strURL, strWIDTH, strHEIGHT) {
	var oPopUp = window.open(strURL,'', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,fullscreen=no,width='+strWIDTH+',height='+strHEIGHT+'');
}

function ResizeWindow() {
	var picWidth = document.images.picture.width;
	var picHeight = document.images.picture.height;
	var scrNewWidth;
	var scrNewHeight;
	
	if (picWidth >= screen.width) {
		scrNewWidth = screen.width - 100;
		
	} else {
		scrNewWidth = picWidth + 25;
		
	}
	
	if (picHeight >= screen.height) {
		//scrNewWidth = screen.height - 100;
		scrNewHeight = screen.height - 100;
	} else {
		//scrNewHeight = picHeight + 55;
		scrNewHeight = picHeight + 55;
	}
	
	window.resizeTo(scrNewWidth,scrNewHeight);
	
}

function addBookmark(title,url) {
    if (window.sidebar) { 
	window.sidebar.addPanel(title, url,""); 
    } else if( document.all ) {
	window.external.AddFavorite( url, title);
    } else if( window.opera && window.print ) {
	return true;
    }
}

function setCursor(id, name) {
   document.getElementById(id).style.cursor=name;
   return true;
}

function mouseXY(evt) {
	if (evt.pageX) Xpos = evt.pageX; //return evt.pageX;
	else if (evt.clientX)
		//return evt.clientX + (document.documentElement.scrollLeft ?
		Xpos = evt.clientX + (document.documentElement.scrollLeft ?
			document.documentElement.scrollLeft :
			document.body.scrollLeft);
	else Xpos = 0;//return null;

	if (evt.pageY) Ypos = evt.pageY; //return evt.pageY;
	else if (evt.clientY)
		//return evt.clientY + (document.documentElement.scrollTop ?
		Ypos = evt.clientY + (document.documentElement.scrollTop ?
		document.documentElement.scrollTop :
		document.body.scrollTop);
	else Ypos = 0; //return null;

}
	

function ShowHELP(id) {
	
	if (document.getElementById(id).style.display == "block") {
		document.getElementById(id).style.display = "none";
	} else {
		//document.getElementById(id).style.top = Ypos;
		//document.getElementById(id).style.left = Xpos;
		document.getElementById(id).style.display = "block";

	}
	//alert(Xpos+":"+Ypos);
}

function CheckCart() {

}

function dateToISO(date) {
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	if (month < 10) month = "0" + month;
	if (day < 10) day = "0" + day;
	return year + "-" + month + "-" + day;
}

function rand(n) {
	return (Math.floor( Math.random() * n + 1 ));

}

function BrowserOpen(field, ptype) {
	my_field = field;
	
	if (!ptype) ptype = '';
	
	window.open("include/file_manager.php?type=img&fmode=1&ptype="+ptype, "file_manager", "width=600,height=600,scrollbars=yes,resizable=yes");
	
}

function ImagePreview(pictfield, picture_src) {
	
	document.getElementById('page_'+pictfield).src = picture_src;
	document.getElementById('page_'+pictfield).style.width = 'auto';
}

-->
