var editWindow;
var baseImg;

function openArticleEdit(contextPath, id, articleid, name, width, height, slaveLang) {
    var popupWidth = (width<288?288:width)+23;
    var popupHeight = slaveLang?(height*2+160):(height+110);
        popupHeight = popupHeight<=screen.height?(popupHeight):(screen.height-90);
    editWindow = window.open(contextPath + "/de/index.htm","editContent","width="+popupWidth+",height="+popupHeight+",resizeable=auto,scrollbars=no");
    editWindow.close();
    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 openColorEdit(contextPath, articleid, width, height) {
    editWindow = window.open(contextPath + "/admin/editColor.htm?articleid="+articleid,"editColor","width="+width+",height="+height+",resizeable=auto,scrollbars=yes");
    editWindow.resizeTo(width, height);
    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();
}

function mOver(img, val) {
    try {
        val = val.substring(val.lastIndexOf('/')+1,val.lastIndexOf('.'));
        var imgSrc = '/data/Generated/Productselection/'+val+'.jpg';
//            var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
//            xmlHttp.open("HEAD", imgSrc, false);
//            xmlHttp.send();
//            if(xmlHttp.status!='200') return;
        baseImg = document.getElementById(img).src;
        document.getElementById(img).src = imgSrc;
    } catch (e) {}
}

function mOut(img) {
    try {
        if(baseImg) document.getElementById(img).src = baseImg;
    } catch (e) {}
}

function popUp1(wintype, height)
{
  var nwl = (screen.width-520)/2;
  var nwh = (screen.height-370)/2;
  popUp=window.open(wintype, 'Popup', 'toolbar=no,locationbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=530,height='+height+',left='+nwl+',top='+nwh+'');
}	

function popUp2(wintype, width, height)
{
  var nwl = (screen.width-width)/2;
  var nwh = (screen.height-height)/2;
  popUp=window.open(wintype, 'Popup2', 'toolbar=no,locationbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',left='+nwl+',top='+nwh+'');
  popUp.focus();
}

function initDatePicker() {
    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(elementName, num) {
    document.write("<a href=\"#\" onClick=\"cal.select(document.forms[0].elements['"+elementName+"'],'anchor"+num+"','dd.MM.yyyy'); return false;\" TITLE=\"\" NAME=\"anchor"+num+"\" ID=\"anchor"+num+"\"><img src=\"/img/calendar.gif\" width=\"16\" height=\"16\" class=\"datePicker\" alt=\"\"></A>");
    document.write("<DIV ID=\"divDP\" class=\"datePickerDiv\"></DIV>");

}
