/* product.js */

/* Author: Daniel Guennel \*/

function onChangeCalculate(input, type) {
    try {
	    var inputValue = checkFloat(input.value, 2);
	    
	    if (!(isPositiveInteger(input.value) && input.value <= 99999)) {
	        input.value = "";
	    }
    } catch (e) {alert(e);}
}

function fillField(input, type) {
    try {
        if (input.value == "") {
            input.value = type;
        }
    } catch(e) {}
}

var urla;
function storeValues(url) {
    urla = url;
}

function doReplaceAgain() {
    window.setTimeout("doReplacePicture()",100);
}

// replaces the images for articles on the page
function doReplacePicture() {
    try {
	    var output = document.getElementById("picture");
	    var str = '<img src="'+urla+'" alt="" width="220" height="220" />';
	    output.innerHTML = str;
    } catch (e) {}
}

// we need this y() function to show a hand on empty links
function y() {}


var no;
function doStoreStarNumber(noa) {
    no = noa;
}

function doUpdateStarsAgain() {
    window.setTimeout("doUpdateStars()",100);
}

function doUpdateStars() {
    try {
        var starSpan;
        for (var i=1; i<=5; i++) {
            starSpan = document.getElementById("star"+i);
            if (i <= no) {
                starSpan.innerHTML = '<img src="img/ico_star_red.gif" />';
            } else {
                starSpan.innerHTML = '<img src="img/ico_star_gray.gif" />';
            }
        }
        var commentTitleSpan = document.getElementById("commentTitle");
        commentTitleSpan.focus();
    } catch (e) {}
}

function getSelectedRadioValue() {
    return;
    var form = document.forms[4];
    if (form != null) {
	    var formElements = form.elements;
	    for (var i=0; i<formElements.length; i++){
	        if (formElements[i].type == "radio" && formElements[i].options){
	            for (var j=0; j<formElements[i].options.length; j++){
	                if (formElements[i].options[j].selected) {
	                    return formElements[i].options[j].value;
	                }
	            }
	        }
	    }
    }
    return "";
}

function doMakeEmpty(input) {
    try {
        if (input.value == "0") {
            input.value = "";
        }
    } catch (e) {}
}
