function toggle(div_id) { var el = document.getElementById(div_id); if ( el.style.display == 'none' ) { el.style.display = 'block';} else {el.style.display = 'none';} } function popup_background_size(popup_windowVar) { if (typeof window.innerWidth != 'undefined') { viewportheight = window.innerHeight; } else { viewportheight = document.documentElement.clientHeight; } if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) { popup_background_height = viewportheight; } else { if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) { popup_background_height = document.body.parentNode.clientHeight; } else { popup_background_height = document.body.parentNode.scrollHeight; } } var popup_background = document.getElementById('popup_background'); popup_background.style.height = popup_background_height + 'px'; var popup_window = document.getElementById(popup_windowVar); //popup_window_height=popup_background_height/2-250;//150 is half popup's height //popup_window.style.top = popup_window_height + 'px'; } function window_pos(popup_windowVar, popup_width) { if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerHeight; } else { viewportwidth = document.documentElement.clientHeight; } if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) { window_width = viewportwidth; } else { if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) { window_width = document.body.parentNode.clientWidth; } else { window_width = document.body.parentNode.scrollWidth; } } if(!popup_width) { popup_width = 240; } else { popup_width = popup_width / 2; } var popup_window = document.getElementById(popup_windowVar); window_width=window_width/2-popup_width; popup_window.style.left = window_width + 'px'; } function popup(windowname, popup_width) { popup_background_size(windowname); window_pos(windowname, popup_width); toggle('popup_background'); toggle(windowname); scroll(0, 0); }