Location: PHPKode > scripts > Site Guide > site-guide/siteguide.php
<?PHP

$PageDescription = array(
	"index.html" => "This is a guide, who will help you to have the site tour. You can use buttons \"previous\" / \"next\" to get to other site pages. ",
	"second.html" => "It supposed the frame describes the opened site page. But nothing is to be described here. It is just Lorem Ipsum.",
	"third.html" => '<img src="me.jpg" alt="Site Guide" align="left" style="margin-right: 10px" /> You can use HTML, images or FLASH to describe your site pages. ',
);

header("Content-type: text/html; charset=UTF-8");

class SiteGuide {
	var $NavigationPanel = false;
	var $JS = false;
	var $Content = false;
	
	function SiteGuide() {
		// Get HTML-page parameters
		$url = preg_replace("/^(.*?)\?/is","", urldecode($_SERVER["HTTP_REFERER"]));
		$pairs = split("&", $url);
		if($pairs) { 
			foreach($pairs as $pair) { 
				list($var, $val) = split("=", $pair); 
				$_GET[$var] = $val;
			}
		}
		if(!isset($_GET["st_on"])) exit;
		return $this;
	}
	function createNavigation($PageDescription) {
		$URLs = array(); $i = 0;
		$Offset = (isset($_GET["st_offset"])?(int)$_GET["st_offset"]:0);
		$PageDescLength = count($PageDescription);
		if($PageDescLength==0) exit;
		foreach($PageDescription as $url => $desc) { $URLs[$i] = $url; if($Offset==$i) $this->Content = preg_replace("/[\r\n]/", "", $desc); $i++; } 

		if($PageDescLength>1) {
			if($Offset>0)
				$this->NavigationPanel .= '<input class="smf_btn" onclick="goPage(\''.$URLs[$Offset-1].'\','.($Offset-1).')" type="image" src="prev.gif" width="12 height="12" title="Previous" />';
			$this->NavigationPanel .= ($Offset+1)."/{$PageDescLength}";
			if($Offset<$PageDescLength-1)
				$this->NavigationPanel .= '<input class="smf_btn" onclick="goPage(\''.$URLs[$Offset+1].'\','.($Offset+1).')" type="image" src="next.gif" width="12 height="12" title="Next" />';
		}
	}

	function createJS() {
	$this->JS = '		
	var currentWindow = new Array();
	var currentWindowDivNamePref = false;	

	// Browser indentification
	if(document.implementation && document.implementation.createDocument) var isMozilla=true;
	else var isMozilla=false; 	
	// Short name of function
	function $(divName) {
	return document.getElementById(divName);
	}
	
	// Locate to page
	function goPage(url, offset) {
		location.href = url + "?st_on=1&st_offset="+offset+"&st_l="+$("system_message").style.left.replace("px","")+"&st_t="+$("system_message").style.top.replace("px","");
	}
	
	if (window.innerWidth) windowWidth=window.innerWidth;
		else windowWidth=window.document.body.offsetWidth;
		'.(isset($_GET["st_l"])?"Left = {$_GET["st_l"]};":'Left = windowWidth-270;').'
		'.(isset($_GET["st_t"])?"Top = {$_GET["st_t"]};":'Top = 20;').'
		
	$("system_message_content").style.top = $("system_message").style.top = Top+"px";
	$("system_message_content").style.left = $("system_message").style.left = Left+"px";
	$("system_message").style.display="block";
	$("system_message_content").style.display="block";
	';
}
	
	function generateWindow($PageDescription) {
		$this->createNavigation($PageDescription);
		$this->createJS();
	$out = '
	<style>
		.smf_system_message_div {  display: none; position: absolute;  z-index: 25000; filter: alpha(opacity=70);	-moz-opacity:.7; width: 250px; height: 130px; background: url(swindow_bg.gif) no-repeat; }
		.smf_system_message TD  {font-family : Arial, Helvetica, sans-serif; color: #000000; font-size: 11px;}
		.smf_body {font-family : Arial, Helvetica, sans-serif; color: #000000; font-size: 12px;}
		.smf_system_message { display: none; position: absolute;  z-index: 25002; width: 250px; height: 130px;  }
		.smf_system_message TABLE { cursor: pointer; }
		.smf_system_message .smf_title { z-index: 25003; width: 184px; padding: 7px 5px 6px 10px; vertical-align: top; font-size: 11px; font-weight: bold; color: white; }
		.smf_system_message .smf_body { z-index: 25004; margin: 0px 0px 0px 8px; padding: 5px 5px 5px 5px; background-color: #EEEEEE; width: 224px; height: 84px; }
		.smf_system_message .smf_con_body { z-index: 25004; margin: 0px; padding: 0px; background-color: #EEEEEE; width: 224px; height: 70px; overflow : auto; }
		.smf_system_message .smf_con_footer { z-index: 25005; margin: 0px 0px 0px 8px; text-align: right; padding: 0px 5px 4px 5px; width: 224px; height: 18px; background-color: #EEEEEE;  }
		.smf_btn { cursor: pointer;   }
		.smf_copyright { color: #888888; padding-top: 3px; } 
		.smf_copyright a, a:hover, a:visited { color: #888888; } 
	
	</style>
	<div id="system_message" class="smf_system_message_div">
	</div>	
	<div id="system_message_content" class="smf_system_message">
	 <table border="0" cellpadding="0" cellspacing="0" onmousedown="windowMouseDown(\'system_message\', event)" onmouseup="windowMouseUp(\'system_message\')">
		<tr>
				<td class="smf_title">Site Guide</td>
			  <td><a href="#" onclick="return hideSystemMessage();"><img src="swindow_exit_btn.gif" width="45" height="19" border="0" /></a></td>
		 </tr>
	 </table>
	 <div class="smf_body">
	 	<div id="system_message_text" class="smf_con_body">
	 	'.$this->Content.'
		</div>
			<div class="smf_copyright">
			'.$this->NavigationPanel.' Powered by <a href="http://www.phpclasses.org/browse/package/3922.html">Site Guide</a>
			</div>
	 	</div>
	</div>
	';
	$lines = split("\n", preg_replace("/\r/","", $out));
	foreach($lines as $line) { print 'document.writeln(\''.preg_replace("/\'/", "\'", $line).'\');'."\n"; }
	print $this->JS;
	}
	
}
$obj = new SiteGuide();
$obj->generateWindow($PageDescription);

?>


// Catch the object to move and its coordinateres
function windowMouseDown(divNamePref, ev) { 
	if (isMozilla) { event=ev; }
	currentWindowDivNamePref = divNamePref; 
	// Save offset
	currentWindow[divNamePref] = {
	"x" : event.clientX + document.body.scrollLeft - $(divNamePref).style.left.replace("px",""),
	"y" : event.clientY + document.body.scrollTop - $(divNamePref).style.top.replace("px","")
	};
}
// Move the object
function windowMouseMove(ev)  {
	if(!currentWindowDivNamePref) return false;
	if(!currentWindow[currentWindowDivNamePref]) return false;
	if (isMozilla) { event=ev; }
	$(currentWindowDivNamePref).style.left =
	$(currentWindowDivNamePref+"_content").style.left = (event.clientX + document.body.scrollLeft - currentWindow[currentWindowDivNamePref].x) + "px";
	$(currentWindowDivNamePref).style.top = 
	$(currentWindowDivNamePref+"_content").style.top = (event.clientY + document.body.scrollTop - currentWindow[currentWindowDivNamePref].y) + "px";
	return false;
}
// Release the object
function windowMouseUp(divNamePref) { currentWindow[divNamePref] = null; currentWindowDivNamePref = false; } 

if (isMozilla) {  document.captureEvents(Event.MOUSEMOVE); }
document.onmousemove = windowMouseMove; 
	
// Hide system message window
function hideSystemMessage(){
	$("system_message").style.display="none";
	$("system_message_content").style.display="none";
	return false;
}
Return current item: Site Guide