function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function WczytajObrazki() {
	if (document.images) {
		img_01 = newImage("img/m_01_over.jpg");
		img_02 = newImage("img/m_02_over.jpg");
		img_03 = newImage("img/m_03_over.jpg");
		img_04 = newImage("img/m_04_over.jpg");
		img_05 = newImage("img/m_05_over.jpg");
		img_06 = newImage("img/m_06_over.jpg");
		preloadFlag = true;
	}
}

function sprawdz() {
	if (document.formularz.imie.value.length == 0) 
		{
			alert("Proszę podać imię!\n");
			document.formularz.imie.focus();
			return false;
		}
	if (document.formularz.nazwisko.value.length == 0) 
		{
			alert("Proszę podać nazwisko!\n");
			document.formularz.nazwisko.focus();
			return false;
		}
	if (document.formularz.telefon.value.length == 0) 
		{
			alert("Proszę podać telefon!\n");
			document.formularz.telefon.focus();
			return false;
		}
	if (document.formularz.pytanie.value == "") 
		{
			alert("Proszę zadać pytanie!\n");
			document.formularz.pytanie.focus();
			return false;
		}
			
	return true; 

} 

var okno = null;
function powieksz_ceryfikat(width, height, url) {
	borderless=false;
	ScrWidth = 640; ScrHeight = 480;
	if (window.screen) {ScrWidth = window.screen.width; ScrHeight = window.screen.height}
	PosX = Math.round((ScrWidth - width)/2);
	PosY = Math.round((ScrHeight - height)/2);
	if (okno != null && !document.layers) {okno.close();}
	if (borderless && !document.layers) {
		okno = window.open("", "splash", "fullscreen=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
		okno.resizeTo(w, s);
		okno.moveTo(PosX, PosY);
	}
	else
		okno = window.open("", "splash", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);

	okno.document.open();
	okno.document.clear();
	okno.document.write("<html><head><title>Explo Service</title></head><body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0><div align='center'><img src='"+url+"' alt='ładuję obrazek (42 KB)' width='530' height='752' border='0'></div></body></html>");
	okno.document.close();
	okno.focus();	
}

function displayImage(image, rnd) {
	document.getElementById('productPicture').src = 'images/resize.php?image=' +image +'&width=240&height=240&rnd=' +rnd;
	return true;
}

var comparator_checked = 1;
function compreset(id) {comparator_checked = 1;}

function drawcomptable(elem) {
	if (elem.checked) comparator_checked++;
	else comparator_checked--;
	
	var handle = document.getElementsByName('compcheck');
	var url = 'products.php?spec';
	
	var j = 0;
	for (var i=0; i<handle.length; i++) {
		if (handle[i].checked) {
			j++;
			url += '&id' +j +'=' +handle[i].id;
		}
	}
	
	if (comparator_checked >= 3) {
		for (var i=0; i<handle.length; i++) {
			if (!handle[i].checked) handle[i].disabled = true;
		}
	}
	else {
		for (var i=0; i<handle.length; i++) {
			if (!handle[i].checked) handle[i].disabled = false;
		}
	}
	if (comparator_checked <= 1) {
		for (var i=0; i<handle.length; i++) {
			if (handle[i].checked) handle[i].disabled = true;
		}
	}
	else if (comparator_checked < 3) {
		for (var i=0; i<handle.length; i++) {
			handle[i].disabled = false;
		}
	}
	
	getData(url, 'comparator_main_table');
}
var bo_ns_id = 0; 
function startIeFix() { 
  if (isIE()) { 
    document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- '); 
  } 
} 
function endIeFix() { 
  if (isIE()) { 
    document.write('</div>'); 
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++); 
    var theCode = theObject.innerHTML; 
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>")); 
    document.write(theCode); 
  } 
} 
function isIE() { 
  // only for Win IE 6+ 
  // But not in Windows 98, Me, NT 4.0, 2000 
  var strBrwsr= navigator.userAgent.toLowerCase(); 
  if (strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0) { 
    if (parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6) { 
      return false; 
    } 
    if (strBrwsr.indexOf("win98") > -1 || 
       strBrwsr.indexOf("win 9x 4.90") > -1 || 
       strBrwsr.indexOf("winnt4.0") > -1 || 
       strBrwsr.indexOf("windows nt 5.0") > -1) 
    { 
      return false; 
    } 
    return true; 
  } else { 
    return false; 
  } 
} 

function sprawdz() {
	if (document.formularz.osoba_kontaktowa.value.length == 0) 
		{
			alert("Prosimy o wypełnienie pola: Imię i nazwisko.\n");
			document.formularz.osoba_kontaktowa.focus();
			return false;
		}
	if (document.formularz.email.value.length == 0) 
		{
			alert("Prosimy o wypełnienie pola: e-mail.\n");
			document.formularz.email.focus();
			return false;
		}
	if (document.formularz.telefon.value.length == 0) 
		{
			alert("Prosimy o wypełnienie pola: Telefon.\n");
			document.formularz.telefon.focus();
			return false;
		}
	if (document.formularz.pytanie.value.length == 0) 
		{
			alert("Prosimy o wypełnienie pola: pytanie.\n");
			document.formularz.pytanie.focus();
			return false;
		}
	return true; 
}
