function resizeIFrame(frame) 
{                
    if ( frame.readyState ) {
        while(frame.readyState != "complete"){};
    }
    var the_height = frame.contentWindow.document.body.scrollHeight;             
    if ( the_height<600 ) the_height=600; else the_height += 25;
    
    frame.height = the_height;
}

function openIMG(img) {
    window.open("image.php?foto=../img/mediaonas/"+img,"choco","width=1024px,height=768px,scrollbars=yes");
}

function aktypoz() {
     if (document.body && document.body.scrollTop)
        return document.body.scrollTop;
     if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
     if (window.pageYOffset)
        return window.pageYOffset;
     return 0;
}

function obr(jaki) {
    var obj = document.getElementById('divIMG');
    obj.style.left = '0px';
	document.getElementById('powiekszenie').src = jaki;
	if (document.all&&document.documentElement.clientHeight) {
	   obj.style.height= document.documentElement.clientHeight+'px';
	}
	zapasscroll = aktypoz();
	obj.style.top = zapasscroll+'px';
}

function sprawdzemail(adres) {	
    a = adres.value.search(/@/i);
    a1 = adres.value.substring(0,a);
    a2 = a1.length;
    a = a + 1;
    b = adres.value.indexOf(".");
    b1 = adres.value.substring(a,b);
    b2 = b1.length;
    b = b + 1;
    c = adres.value.length;
    c1 = adres.value.substring(b,c);
    c2 = c1.length;
    return (adres.value.indexOf("@") != "-1" && adres.value.indexOf(".") != "-1" && a2 >= 1 && b2 >= 1 && c2 >= 1);
}            

function sprawdz_formularz_zap_ofertowego(form,msg1,msg2) {
    if(form.zapytanie.value.length == 0 || form.nazwa_firmy.value.length == 0 || form.imie.value.length == 0 || form.nazwisko.value.length == 0 || form.email.value.length == 0 || form.telefon.value.length == 0 || form.odpowiedz.value.length == 0) 
    {
        alert(msg1);
        return false;
    }
    else if(sprawdzemail(form.email) == false)
    {
      alert(msg2);
      form.email.focus();
      return false;
    }
    return true; 
}

function printingWindow(nr) {
    window.open("product.php?id="+nr,"product","width=450,height=650,scrollbars=yes");
}
