﻿
function mm_swapimgrestore() { //v3.0
	var i,x,a=document.mm_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.osrc;i++) x.src=x.osrc;
}

function mm_findobj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
    x = mm_findobj(n,d.layers[i].document);
  if(!x && d.getelementbyid) x=d.getelementbyid(n); return x;
}

function mm_swapimage() { //v3.0
  var i,j=0,x,a=mm_swapimage.arguments; document.mm_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=mm_findobj(a[i]))!=null){document.mm_sr[j++]=x; if(!x.osrc) x.osrc=x.src; x.src=a[i+2];}
}


function openURL(url,title,options){
	okno = window.open(url,title,options);
	okno.focus();
	return false;
}

    function isValidEmail(str) {
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    }

    function checkOrder(){
        form = document.forms['order'];
        var msg = '';

        if(form.dname.value==''){
            form.dname.focus();
            alert("Wpisz imię i nazwisko");
            return false;
        }
        if(form.dstreet.value==''){
            form.dstreet.focus();
            alert("Podaj nazwę ulicy i numer domu / mieszkania");
            return false;
        }
        if(form.dzip.value==''){
            form.dzip.focus();
            alert("Podaj kod pocztowy");
            return false;
        }
        if(form.dcity.value==''){
            form.dcity.focus();
            alert("Podaj miejscowość");
            return false;
        }
        if(form.dtel.value==''){
            form.dtel.focus();
            alert("Podaj numer telefonu");
            return false;
        }

        var cf = form.checkf.checked;

        if(cf && form.iname.value==''){
            form.iname.focus();
            alert("Podaj imię i nazwisko osoby zamawiającej\nJeżeli wpiszesz nazwę firmy imię i nazwisko nie pojawi się na fakturze.");
            return false;
        }
        if(cf && form.icompany.value!='' && form.inip.value==''){
            form.inip.focus();
            alert("Podaj NIP");
            return false;
        }
        if(cf && form.istreet.value==''){
            form.istreet.focus();
            alert("Podaj nazwę ulicy");
            return false;
        }
        if(cf && form.izip.value==''){
            form.izip.focus();
            alert("Podaj kod pocztowy");
            return false;
        }
        if(cf && form.icity.value==''){
            form.icity.focus();
            alert("Podaj nazwę miejscowości");
            return false;
        }
        
		if(form.skad.value==0){
		form.skad.focus();
		alert("Wybierz skąd Pani / Pan dowiedział się o naszej firmie");
		return false;
		}
		if(form.skad.value==5 && form.skad_inny.value==''){
		form.skad_inny.focus();
		alert("Wpisz sk±d Pani / Pan dowiedział się o naszej firmie");
		return false;
		}



        return true;
    }
    
    
    function showdiv(id) {
    //safe function to show an element with a specified id
    
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'block';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
    }
    
function hidediv(id) {
    //safe function to hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById(id).style.display = 'none';
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
    }
    
    function copyinvoice(){
        var form = document.forms[6];
        form.iname.value = form.dname.value;
        form.istreet.value = form.dstreet.value;
        form.izip.value = form.dzip.value;
        form.icity.value = form.dcity.value;
        form.icompany.value = form.dcompany.value;
    }
    
    function dodo(){	//var form = document.getElementById['order'];
    var form = document.forms[6];
        var cf = form.checkf.checked;
        if(cf){
            showdiv('a2');
        }
        else{
            hidediv('a2');
        }
    //    alert('cf' + cf);
}
