
function trackAndGo(location) {
    //urchinTracker(location);
    window.location = location;
}

function highlightModeButton(ison, bgcolor, color) {
    var butt = getElement('row_mode');
    var sim = getElement('simplebutt');
    var exp = getElement('expertbutt');
    if (butt) {
        butt.style.backgroundColor = bgcolor;
        butt.style.color = color;
    }
    if (sim) {
        sim.style.color = color;
        if (ison) {
            sim.style.textDecoration = "underline";
        } else {
            sim.style.textDecoration = "none";
        }
    }
    if (exp) {
        exp.style.color = color;
        if (ison) {
            exp.style.textDecoration = "underline";
        } else {
            exp.style.textDecoration = "none";
        }
    }
}

function highlightMenuItem(id, ison, bgcolor, color) {
    var row_el, lnk_el;
    if (document.getElementById) {
        row_el = document.getElementById("row_" + id);
        lnk_el = document.getElementById("lnk_" + id);
    } else if (document.all) {
        row_el = eval("document.all.row_" + id);
        lnk_el = document.getElementById("lnk_" + id);
    }
    
    if (row_el) {
        row_el.style.backgroundColor = bgcolor;
        row_el.style.color = color;
    }
    if (lnk_el) {
        lnk_el.style.color = color;
        if (ison) {
            lnk_el.style.textDecoration = "underline";
        } else {
            lnk_el.style.textDecoration = "none";
        }
    }
}

function submitSearchForm() {
    if (document.searchform.sm.value == 1) { // expert search
        document.expsearchform.ps.value = document.searchform.ps.value;
        urchinTracker(getFormTargetURL(document.expsearchform));
        document.expsearchform.submit();
    } else {
        document.simsearchform.ps.value = document.searchform.ps.value;
        urchinTracker(getFormTargetURL(document.simsearchform));
        document.simsearchform.submit();
    }
}

function getFormTargetURL(f) {
    var ret = f.action;
    for (i = 0; i < f.elements.length; i++) {
        if (i == 0) {
            ret = ret + "?";
        } else {
            ret = ret + "&";
        }
        ret = ret + f.elements[i].name + "=" + f.elements[i].value;
    }
    return ret;
}

function clearSearchForm() {
    /* simple search */
    document.simsearchform.cl.value = "";
    document.simsearchform.st.value = "";
    document.simsearchform.nm.value = "";
    
    document.simsearchform.pm.value = "";
    document.simsearchform.ps.value = "20";
    
    /* expert search */
    document.expsearchform.cl.value = "";
    document.expsearchform.st.value = "";
    document.expsearchform.la.value = "";
    document.expsearchform.lo.value = "";
    document.expsearchform.ct.value = "";
    
    document.expsearchform.pm.value = "";
    document.expsearchform.ps.value = "20";
    
    /* general search */
    document.searchform.ps.value = "20";
}

function switchSearchMode() {
    if (document.searchform.sm.value == 1) { // expert search
        document.searchform.sm.value = 0;
        showdiv("simplesrch");
        showdiv("simplebutt");
        hidediv("expertsrch");
        hidediv("expertbutt");
    } else { // simple search
        document.searchform.sm.value = 1;
        hidediv("simplesrch");
        hidediv("simplebutt");
        showdiv("expertsrch");
        showdiv("expertbutt");
    }
}

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 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 getElement(id) {
    if (document.getElementById) {
        return document.getElementById(id);
    } else if (document.all) {
        return eval("document.all." + id);
    }
}

function submitCart() {
	var f = document.cartform;
	if (f.nazw.value == '' || f.email.value == '') {
		alert('Należy podać conajmniej nazwisko i imię oraz adres e-mail aby złożyć zamówienie!');
		return false;
	}
	__utmSetTrans();
	document.cartform.submit();
	return true;
}

