<?php
require_once dirname(dirname(dirname(dirname(__FILE__))))."/registry.php";
class jump{
	public $JumpHTML, $JumpStyle, $JumpScript, $JumpBody;
	public $registry;
	public $headerStyle = "";
	public $headerTop = "";
	
	//構造函數
	public function __construct(){
		//取得網站設定值
		$this->registry = registry::createInstance();
	}
	
	//覆蓋父類方法:加載控件
	public function load(){
		$jumpLink = $this->registry->webJumpLink;
		$jumpImage = $this->registry->webJumpImage;
		$jumpType = $this->registry->webJumpType;

		$this->JumpHTML = "";
		$this->JumpStyle = "";
		$this->JumpScript = "";
		$this->JumpBody = "";

		if ($jumpType != "0") {
			$this->JumpHTML = "<div id=\"jumpDiv\" style=\"width:100%;background-color:#FFF;height:8000px;text-align:center;\">";
			$this->JumpHTML .=  (!empty($jumpLink)) ? "<a href=\"$jumpLink\" target=\"_blank\"><img src=\"$jumpImage\" border=\"0\" /></a>" : "<img src=\"$jumpImage\" border=\"0\" />";
			$this->JumpHTML .= "</div>";

			if ($jumpType == "20") {
				$this->JumpHTML = "<div id=\"jumpDiv\" style=\"width:100%;background-color:#FFF;height:8000px;text-align:center;\" onmouseover=\"chgp();\"><img src=\"$jumpImage\" border=\"0\" /></div>";
				$this->JumpScript = "<script type='text/javascript'>function chgp(){location.href = '$jumpLink';}</script>";
			} elseif ($jumpType == "30") {
				$this->JumpStyle = " overflow: hidden; height: 100vh;";
			} elseif ($jumpType == "60") {
				$this->JumpHTML = "<iframe id=\"jumpIframe\" name=\"mainwindow\" src=\"$jumpLink\" frameborder=\"0\" style=\"width: 100vw; min-height: 100vh;\">您的瀏覽器不支援內置框架或目前的設定為不顯示內置框架。</iframe><div style=\"width:100%; background-color:#FFF; height:100vh;\"></div>";
				$this->JumpScript = "<script> window.onload = function(){ window.frames[0].postMessage((document.documentElement.clientWidth)+'px','$jumpLink'); window.addEventListener('message',function(e){ if(e.source == window.frames[0]){ window.frames[0].postMessage((document.documentElement.clientWidth)+'px','$jumpLink'); } },true); } </script>";
				$this->JumpBody = " style='overflow: hidden; position: relative !important;'";
			}
		}
	}
}
?>