<?php
	require_once "../bin/web/page.php";
	require_once "../registry.php";
	require_once "../currency.php";
	require_once "../dal/categoryDAL.php";
	require_once "../dal/homepageDAL.php";

	class pageBase extends page
	{
		public $registry;
		public $CategoryID;
		public $is_index=false;

		public function pageBase()
		{
			$this->registry=registry::createInstance();
			parent::__construct();
		}

		public function loadData()
		{
			//網站標題
			parent::addParameter("webTitle",$this->registry->webTitle);

			//網站關鍵字
			parent::addParameter("webKeyword",$this->registry->webKeyword);

			//網站描述
			parent::addParameter("webDescription",$this->registry->webDescription);

			//rel link
			parent::addParameter("RelLink","http://".$_SERVER['HTTP_HOST']);
			
			//Photo
			////logo
			$hg = new homepageDAL();
			$hg->type = "topLogo";
			$hg->loadRecord();
			if($hg->source != ""){
				if($hg->url != ""){
					$topLogo = "<a href=\"".$hg->url."\" title=\"".$hg->imgtitle."\"><img src=\"".$hg->source."\" height=\"52\" width=\"208\" style=\"border:0px;\" alt=\"".$hg->imgtitle."\"></a>";
				}else{
					$topLogo = "<img src=\"".$hg->source."\" height=\"52\" width=\"208\" style=\"border:0px;\" alt=\"".$hg->imgtitle."\">";
				}
			}else{
				$topLogo = "<a href=\"http://".$_SERVER['HTTP_HOST']."\" title=\"".$hg->imgtitle."\"><img src=\"/mobile/images/cis.png\" height=\"52\" width=\"208\" style=\"border:0px;\" alt=\"".$hg->imgtitle."\"></a>";
			}
			parent::addParameter("topLogo",$topLogo);
			////mobilePhoto
			$hg->type = "mobilePhoto";
			$hg->loadRecord();
			if($hg->source != ""){
				if($hg->url != ""){
					$mobilePhoto = "<a href=\"".$hg->url."\" title=\"".$hg->imgtitle."\"><img src=\"".$hg->source."\" height=\"260\" width=\"320\" style=\"border:0px;\" alt=\"".$hg->imgtitle."\"></a>";
				}else{
					$mobilePhoto = "<img src=\"".$hg->source."\" height=\"260\" width=\"320\" style=\"border:0px;\" alt=\"".$hg->imgtitle."\">";
				}
			}else{
				$mobilePhoto = "<a href=\"http://".$_SERVER['HTTP_HOST']."\" title=\"".$hg->imgtitle."\"><img src=\"/mobile/images/banner.png\" height=\"260\" width=\"320\" style=\"border:0px;\" alt=\"".$hg->imgtitle."\"></a>";
			}
			parent::addParameter("mobilePhoto",$mobilePhoto);
			
			//頁腳資訊
			parent::addParameter("webTelephone",$this->registry->webTelephone);
			parent::addParameter("webAddress",$this->registry->webAddress);
			parent::addParameter("webCopy",$this->registry->webCopy);

		}
		public function getPageParameter($name,$default)
		{
			$value="";
			if(isset($_GET[$name]) && $_GET[$name] != "")
				$value=$_GET[$name];
			else if(isset($_POST[$name]) && $_POST[$name] != "")
				$value=$_POST[$name];
			else
				$value=$default;
			return trim($value);
		}
		public function alert($msg)
		{
			echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
			echo "<script language=\"javascript\">window.alert(\"".$msg."\");history.back();</script>";
		}
		public function alert2($msg,$url)
		{
			echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
			echo "<script language=\"javascript\">window.alert(\"".$msg."\");window.location.href(\"".$url."\");</script>";
		}
	}
?>
