
function popupSingleImage(x_path, x_image_src) {
    var oWindow = null;

	// get the size of the image
    var sSize = x_image_src.split("_");
    var aSize = sSize[sSize.length - 1].split("x");
    var panelwidth = 6; 

	// close-button(cross)
    var bottomheight = 45;
    var infoheight = 100;
    var infowidth = 200;
    var width = parseInt(aSize[0]);
    var height = parseInt(aSize[1].substr(0, aSize[1].length - 4));
    var format = "L";

	// unterscheiden zwischen Hochformat und Querformat
    if (width > height) {
        width = parseInt(aSize[0]) + panelwidth + panelwidth;
        height = parseInt(aSize[1].substr(0, aSize[1].length - 4)) + panelwidth + panelwidth + infoheight;
        format = "L";
    } else {
        width = parseInt(aSize[0]) + panelwidth + panelwidth + infowidth;
        height = parseInt(aSize[1].substr(0, aSize[1].length - 4)) + panelwidth + panelwidth + bottomheight;
        format = "P";
    }

    oWindow = window.open(x_path + x_image_src, "POPUP_SINGLE_IMAGE","locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height="+ height + ",width=" + width);
//    oWindow = window.open(x_path + "/piclease/image.do?doSingle=&image_id=" + x_image_id + "&format=" + format, "POPUP_IMAGE", "locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height=" + height + ",width=" + width);

    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(width, height);
    centerTopWindow(oWindow, width, height);
    oWindow.focus();
}

	

function openSitemap(x_path, x_sitemap) {
    var oWindow = null;
    var iWidth = 220;
    var iHeight = 500;
    oWindow = window.open(x_path + x_sitemap, "POPUP_SITEMAP", "dependent=yes,locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    var posX = 0;
    var posY = 0;

//	oWindow.resizeTo( iWidth, iHeight);
    oWindow.moveTo(posX, posY);
    oWindow.focus();
}
function setCountry() {
    for (i = 0; i < document.countries.country.length; i++) {
        if (document.countries.country[i].checked) {
//			alert(document.countries.country[i].value);
            parent.opener.form1.country.value = document.countries.country[i].value;
        }
    }
    window.close();
}
function popupCountryList() {
    var oWindow = null;
    var iWidth = 220;
    var iHeight = 180;
    oWindow = window.open("countryList.html", "POPUP_COUNTRYLIST", "dependent=yes,locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    var posX = (screen.availWidth - iWidth) / 2;
    var posY = (screen.availHeight - iHeight) / 2;

//	oWindow.resizeTo( iWidth, iHeight);
    oWindow.moveTo(posX, posY);
    oWindow.focus();
}
function popupMap(x_html) {
    var oWindow = null;
    var iWidth = 800;
    var iHeight = 700;
    oWindow = window.open(x_html + ".html", "POPUP_MAP", "dependent=yes,locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    var posX = (screen.availWidth - iWidth) / 2;
    var posY = (screen.availHeight - iHeight) / 2;

//	oWindow.resizeTo( iWidth, iHeight);
    oWindow.moveTo(posX, posY);
    oWindow.focus();
}
function popupQuiz() {
    var oWindow = null;
    var iWidth = 950;
    var iHeight = 660;
    oWindow = window.open("http://www.science4you.org/servlets/s2yougames/Quiz", "POPUP_QUIZ", "dependent=yes,locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }

//	centerWindow( oWindow, iWidth, iHeight);
}
function popupInfo(path, x_html) {
    var oWindow = null;
    var iWidth = 500;
    var iHeight = 500;
    oWindow = window.open(path + "help/info." + x_html + ".html", "POPUP_INFO", "dependent=yes,locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    var posX = (screen.availWidth - iWidth) / 2;
    var posY = (screen.availHeight - iHeight) / 2;
    oWindow.resizeTo(iWidth, iHeight);
    oWindow.moveTo(posX, posY);
    oWindow.focus();
}

// 
function popupInfoText(x_path, iWidth, iHeight) {
    var oWindow = null;
    oWindow = window.open(x_path, "POPUP_INFOTEXT", "locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(iWidth, iHeight);
    centerTopWindow(oWindow, iWidth, iHeight);
}

// leitet auf jsp's weiter (basiert auf sitemesh und wird popupInfo ersetzen)
function popupInfoSite(path, x_html, x_registerProject) {
    var oWindow = null;
    var iWidth = 500;
    var iHeight = 500;
    oWindow = window.open(path + "/help/info." + x_html + ".jsp?registerProject=" + x_registerProject, "POPUP_INFO", "dependent=yes,locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + iHeight + ",width=" + iWidth);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    centerWindow(oWindow, iWidth, iHeight);
}
function changeTwoFrames(x_html1, x_frame1, x_html2, x_frame2) {
    window.top.frames[x_frame1].location.href = x_html1 + ".html";
    window.top.frames[x_frame2].location.href = x_html2 + ".html";
}
function getIsNN() {
    var isNN;
    if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
        isNN = (navigator.appName == "Netscape") ? 1 : 0;
    }
    return isNN;
}
function getIsIE() {
    var isIE;
    if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
        isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
    }
    return isIE;
}
function reSizeToImage(x_obj) {
    var isNN = getIsNN();
    var isIE = getIsIE();
    if (isIE) {
        x_obj.resizeTo(100, 100);
        width = 100 - (x_obj.document.body.clientWidth - x_obj.document.images[0].width);
        height = 100 - (x_obj.document.body.clientHeight - x_obj.document.images[0].height);
        x_obj.resizeTo(width, height);
    }
    if (isNN) {
        x_obj.innerWidth = x_obj.document.images["imageBig"].width;
        x_obj.innerHeight = x_obj.document.images["imageBig"].height;
        width = x_obj.innerWidth;
        height = x_obj.innerHeight;
    }
    centerWindow(x_obj, width, height);
}
function doTitle(x_title) {
    document.title = x_title;
}
function centerWindow(x_obj, x_width, x_height) {
    var posX = (screen.availWidth - x_width) / 2;
    var posY = (screen.availHeight - x_height) / 2;
    x_obj.moveTo(posX, posY);
    x_obj.focus();
}
function centerTopWindow(x_obj, x_width, x_height) {
    var posX = (screen.availWidth - x_width) / 2;
    x_obj.moveTo(posX, 0);
    x_obj.focus();
}
function WriteHtml(HtmlString, DocObj) {
    DocObj.close();
    DocObj.open();
    DocObj.write(HtmlString);
    DocObj.close();
}

// Plates ---------------------------------------------------------------------------------------------
function getWidthPlate(x_cols) {
    return (x_cols * 175) + 60;
}
function getHeightPlate(x_rows, x_control) {
    var rowHeight = 195 + (x_control > 0 ? 15 : 0);
    return (x_rows * rowHeight) + 120;
}
function popupPlateSimple(x_path, x_imageIds, x_rows, x_cols, x_knoten_id, x_project_id, x_control, x_topics_id) {
    var oWindow = null;
    var width = getWidthPlate(x_cols);
    var height = getHeightPlate(x_rows, x_control);
    oWindow = window.open(x_path + "/plates/plate.do?doSimple=&project_id=" + x_project_id + "&imageIds=" + x_imageIds + "&knoten_id=" + x_knoten_id + "&cols=" + x_cols + "&control=" + x_control + "&topics_id=" + x_topics_id, "POPUP_PLATE", "locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + height + ",width=" + width);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(width, height);
    centerWindow(oWindow, width, height);
    oWindow.focus();
}
function popupPlateThread(x_path, x_ThreadId) {
    var oWindow = null;
    oWindow = window.open(x_path + "/plates/plate.do?doPlateThread=&threadId=" + x_ThreadId, "POPUP_PLATETHREAD", "locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=500,width=550");
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.focus();
}
function popupPlateSimpleS4(x_path, x_imageIds, x_rows, x_cols, x_control) {
    var oWindow = null;
    var width = getWidthPlate(x_cols);
    var height = getHeightPlate(x_rows, x_control);
    oWindow = window.open(x_path + "/plates/plate.do?doSimpleS4=&&imageIds=" + x_imageIds + "&cols=" + x_cols + "&control=" + x_control, "POPUP_PLATE", "locationbar=no,menubar=no,scrollbars=yes,resizable=yes,status=no,screenX=0,screenY=0,height=" + height + ",width=" + width);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(width, height);
    centerWindow(oWindow, width, height);
    oWindow.focus();
}
function popupPlateSingle(x_path, x_image_src, x_image_id) {
    var oWindow = null;

	// get the size of the image
    var sSize = x_image_src.split("_");
    var aSize = sSize[sSize.length - 1].split("x");
    var width = parseInt(aSize[0]) + 30;
    var height = parseInt(aSize[1].substr(0, aSize[1].length - 4)) + 120;
    oWindow = window.open(x_path + "/plates/plate.do?doSingle=&image_id=" + x_image_id, "POPUP_IMAGE", "locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height=" + height + ",width=" + width);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(width, height);
    centerTopWindow(oWindow, width, height);
    oWindow.focus();
}
function popupPlateSingleImage(x_path, x_image_src, x_image_id) {
    var oWindow = null;

	// get the size of the image
    var sSize = x_image_src.split("_");
    var aSize = sSize[sSize.length - 1].split("x");
    var width = parseInt(aSize[0]);
    var height = parseInt(aSize[1].substr(0, aSize[1].length - 4));
    if (width>height) {
    	width = width + 20;
    	height = height + 60;
    } else {
    	width = width + 120;
    	height = height + 20;
    }
    // get the size of the screen
    var screenMaxX = screen.availWidth-10;
    var screenMaxY = screen.availHeight-20;
    if (screenMaxX<width) width = screenMaxX;
    if (screenMaxY<height) height = screenMaxY;
    oWindow = window.open(x_path + "/plates/plate.do?doSingleImage=&image_id=" + x_image_id, "POPUP_IMAGE", "locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height=" + height + ",width=" + width);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(width, height);
    centerTopWindow(oWindow, width, height);
    oWindow.focus();
}
function popupPlateSingleS4(x_path, x_image_src, x_image_id) {
    var oWindow = null;

	// get the size of the image
    var sSize = x_image_src.split("_");
    var aSize = sSize[sSize.length - 1].split("x");
    var width = parseInt(aSize[0]) + 30;
    var height = parseInt(aSize[1].substr(0, aSize[1].length - 4)) + 120;
    oWindow = window.open(x_path + "/plates/plate.do?doSingleS4=&image_id=" + x_image_id, "POPUP_IMAGE", "locationbar=no,menubar=no,scrollbars=no,resizable=no,status=no,screenX=0,screenY=0,height=" + height + ",width=" + width);
    if (top.window.opener) {
        oWindow.opener = top.window.opener;
    }
    oWindow.resizeTo(width, height);
    centerTopWindow(oWindow, width, height);
    oWindow.focus();
}
function gotoSpeciessheet(x_path, x_knoten_id) {
//	alert(top.window.opener.parent.location);
    top.window.opener.parent.topFrame.location.href = x_path + "/encyclopedia/molluscs/pageheading.do?flap1=species";
    top.window.opener.parent.leftFrame.location.href = x_path + "/encyclopedia/molluscs/species/speciessheets/speciesdispatch.do?doSpeciesList&knoten_id=" + x_knoten_id + "#jump" + x_knoten_id;
    top.window.opener.parent.mainFrame.location.href = x_path + "/encyclopedia/molluscs/species/speciessheets/speciesdispatch.do?doSpeciesSheet&knoten_id=" + x_knoten_id;
    top.window.opener.focus();
}
function pagecontrolListDetail(x_path, x_id, x_forward, x_treeselectedgif ) {
    window.top.mainFrame.location.href = x_path + x_forward + x_id;
    if (document.pagecontrol != null) {
        document.pagecontrol["selected" + document.pagecontrol.lastVar.value].src = x_path + "/common/images/layoutelements/onepixel.gif";
        document.pagecontrol["selected" + x_id].src = x_path + x_treeselectedgif;
        document.pagecontrol.lastVar.value = x_id;
    }
}


function openGoogleMap() {
    document.commonMapsMapForm.mapTyp.value = 1;
    document.commonMapsMapForm.submit();
}
