var editWindow;
var baseImg;

function openArticleEdit(contextPath, id, articleid, name, width, height, slaveLang) {
    var popupWidth = (width<208?208:width)+21;
    var popupHeight = slaveLang?(height*2+160):(height+110);
        popupHeight = popupHeight<=screen.height?(popupHeight):(screen.height-90);
    editWindow = window.open(contextPath + "/admin/editContent.htm?id="+id+"&articleid="+articleid+"&name="+name+"&twidth="+width+"&theight="+height+"&tpopupHeight="+popupHeight,"editContent","width="+popupWidth+",height="+popupHeight+",resizeable=auto,scrollbars=no");
    editWindow.focus();
    return false;
}

function openRecommendation(url) {
    recomWindow = window.open(url, "recommendation", "width=500,height=420,status=yes,scrollbars=no,resizable=no");
    recomWindow.focus();
}

function printPage() {
    if(navigator.userAgent.indexOf("Mac") == -1) window.print();
}

var actBoxID;
function showText(boxID){
    if(actBoxID!=null) {
        document.getElementById(actBoxID).style.display = "none";
    }
    document.getElementById(boxID).style.display = "block";
    actBoxID = boxID;
}

function hideText(boxID, authorize){
    if(!authorize){
        document.getElementById(boxID).style.display = "none";
    }
}

function initDatePicker() {
    if(document.getElementById("divDP")!=null) {
        var cal = new CalendarPopup("divDP");
        cal.setMonthNames('Januar','Februar','Mrz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
        cal.setDayHeaders('S','M','D','M','D','F','S');
        cal.setWeekStartDay(1);
        cal.setTodayText("Heute");
        return cal;
    }
}

function getDatePicker(contextPath, elementName, num) {
    document.write("<a href=\"#\" onClick=\"cal.select(document.formular.elements['"+elementName+"'],'anchor"+num+"','dd.MM.yyyy'); return false;\" TITLE=\"\" NAME=\"anchor"+num+"\" ID=\"anchor"+num+"\"><img src=\""+contextPath + "/img/calendar.gif\" width=\"16\" height=\"16\" class=\"datePicker\" alt=\"\"></A>");
    document.write("<br><DIV ID=\"divDP\" class=\"datePickerDiv\"></DIV>");
}

function showBig(img, text){
    tmplpreview = window.open("","", "width=400, height=420 resizable=No");
    tmplpreview.document.write("<html><body leftmargin='0' topmargin='0'><center><div><img src="+img+" onClick='self.close();' height='390' style='cursor:pointer;'></div><br><div style='font:12px verdana;color:#666666;position:absolute; bottom:5px;left:1px'>"+text+"</div></center></body></html>");
    return false;
}
