var popUpWin;

function showOrderrule(id) {
    document.show_orderrule.id.value = id;
    
    document.show_orderrule.submit();
}

function bookmark(p_titel) {
    var titel = p_titel || '';
    var bookmarktitel = '';
    
    if (titel != '') {
        bookmarktitel = " - " + titel;
        bookmarklink = document.location.href;
    } else {
        bookmarklink = 'http://www.bizonprint.nl';
    }
    
    if(document.all) { //MSIE
        window.external.AddFavorite(bookmarklink, "Bizonprint" + bookmarktitel);
    } else { // firefox
        window.sidebar.addPanel("Bizonprint" + bookmarktitel, bookmarklink,"");
    }
}

function focusItem(obj) {
    obj.style.border = "1px solid #372920";
}
function blurItem(obj) {
    obj.style.border = "1px solid #cdb697";
}

function openCentered(documentSrc, windowWidth, windowHeight,scrBars,res) {
    var resizable = (res != null) ? res : 0;

    if(popUpWin){
        if(!popUpWin.closed) popUpWin.close();
    }

    windowLeft = (window.screen.width  - windowWidth)  >> 1;
    windowTop  = (window.screen.height - windowHeight) >> 1;

    popUpWin = window.open(documentSrc, '','toolbar=0,channelmode=0,location=0,menubar=0,resizable=' + resizable + ',status=0,scrollbars=' + scrBars + ',width=' + windowWidth + ',height=' + windowHeight + ',left=' + windowLeft + ',top=' + windowTop);
    //popUpWin.focus();
    
    return popUpWin;
}

function popup(documentSrc) {
    openCentered(documentSrc, 500, 400, 1, 1);
}

function isArray(obj) {
   if (obj.constructor.toString().indexOf("Array") == -1) {
      return false;
   }
   else {
      return true;
   }
}

function formatPrijsNoEuro(prijs) {
    prijs = prijs.toFixed(2);
    prijs = prijs.toString().replace(".", ",");
    return prijs;
}

function formatPrijs(prijs) {
    prijs = prijs.toFixed(2);
    prijs = "&euro;&nbsp;" + prijs.toString().replace(".", ",");
    return prijs;
}

function showDivPopup(divId) {
    var obj = document.getElementById(divId);
    var dest = document.getElementById('popupholder');
    if(obj && dest) {
        var inhoud = obj.innerHTML;
        var html = "";
        html += inhoud;
        html += "<div class=\"center\"><input type=\"button\" onclick=\"closeDivPopup();\" value=\"Sluiten\" /></div>";
        
        dest.innerHTML = html;
        dest.style.display = "";
        scroll(0, 0);
    }
}

function closeDivPopup() {
    var obj = document.getElementById('popupholder');
    obj.style.display = "none";
    obj.innerHTML = "";
}

function submitAndAddMore(returnTo) {
	elem = document.getElementById('return_to_home');
    if(elem) {
    	document.getElementById('return_to_home').value = returnTo;
        document.forms['gegevens'].submit();
        return false;
    }
    else {
        return true;
    }
}

function toFirstStep() {
	document.forms['tofirststep'].submit();
}