  var screen_size_table = new Array(800, 600,
                                    1024, 768,
                                    1152, 864,
                                    1280, 1024);
  var window_size_table = new Array(940, 605,
                                    940, 605,
                                    940, 605,
                                    940, 605);
  var default_width_percent = 90;
  var default_height_percent = 90;
  var target_window_name = "uploader"; //uploader

  function hide_help() {
  	var helpDiv = document.getElementById("getHelp");
		helpDiv.style.visibility = "hidden";
  }
	
  function hide_intro() {
		var introLeftDiv = document.getElementById("introTextLeft");
		if (introLeftDiv != null) {
			introLeftDiv.style.display = "none";
			var introRightDiv = document.getElementById("introTextRight");
			introRightDiv.style.display = "none";
		}
	}
	
	function hide_noflash() {
		var noFlashDiv = document.getElementById("alternativeContent");
		noFlashDiv.style.display = "none";
		document.has_flash = true;
	}

  function open_window(wedding_id, wedding_site_url, upload_folder, update_id, html_page)
    {
    var i;
    var window_width;
    var window_height;
    var window_top;
    var window_left;

    var target_html_page = "imageuploader/uploader.php";
	if (html_page != null) {
		target_html_page = html_page;
	}

    if (window.screen.availHeight)
      {
      window_height = window.screen.availHeight * (default_height_percent / 100);
      window_width = window.screen.availWidth * (default_width_percent / 100);
      }

    for (i = 0; i < screen_size_table.length; i += 2)
      if ((screen_size_table[i] == window.screen.width) && (screen_size_table[i + 1] == window.screen.height))
        {
        window_width = window_size_table[i];
        window_height = window_size_table[i + 1];
        break;
        }

		if (window.screen.availHeight && (window.screen.availTop == 0))
		  {
		  window_top = ((window.screen.availHeight / 2) + window.screen.availTop) - (window_height / 2);
		  window_left = ((window.screen.availWidth / 2) + window.screen.availLeft) - (window_width / 2);
		  window_top = (window_top + ((window_top / 100) * 30));
		  }
		else if (window.screen.availHeight)
		  {
		  window_top = (window.screen.availHeight / 2) - (window_height / 2);
		  window_left = (window.screen.availWidth / 2) - (window_width / 2);
		  window_top = (window_top + ((window_top / 100) * 30));
		  }
		else
		  {
		  window_top = 0;
		  window_left = 0;
		  }
		if (upload_folder == "paypal") {
			window.open(target_html_page, target_window_name, "screenX=" + window_left + ",screenY=" + window_top + ",height=" + window_height + ",width=" + window_width + ",hotkeys=no,directories=no,menubar=no,location=yes,personalbar=no,resizable=no,scrollbars=yes,status=yes,titlebar=no,toolbar=no");//.moveTo(window_left, window_top);
		} else if (upload_folder == "flashdownload") {
			window.open(target_html_page, target_window_name, "screenX=" + window_left + ",screenY=" + window_top + ",height=" + window_height + ",width=" + window_width + ",hotkeys=no,directories=no,menubar=no,location=yes,personalbar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=no,toolbar=no");
		} else if (upload_folder == "terms_and_conditions") {
			window.open(target_html_page, target_window_name, "screenX=" + window_left + ",screenY=" + window_top + ",height=" + window_height + ",width=" + window_width + ",hotkeys=no,directories=no,menubar=no,location=no,personalbar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no");
		} else {
			window.open(target_html_page + "?wedding_id=" + wedding_id + "&wedding_site_url=" + wedding_site_url + "&upload_folder=" + upload_folder + "&update_id=" + update_id, target_window_name, "screenX=" + window_left + ",screenY=" + window_top + ",height=" + window_height + ",width=" + window_width + ",hotkeys=no,directories=no,menubar=no,location=no,personalbar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no");//.moveTo(window_left, window_top);
		}
    }
	
	function reloadPictures() {
		//called from action.php when closing the window.
		document.loader.SetVariable("photosChanged", "true");
	}
	
	function dontReloadPictures() {
		//called from action.php when closing the window.
		document.loader.SetVariable("photosChanged", "nochange");
	}
	
	function checkForPayment() {
		//called from payment/success.php when closing the window after paying with paypal.
		document.loader.SetVariable("backFromPaypal", "true");
	}


