﻿$(document).ready(function() {
	$('#uc_left .list a, #uc_header .menu_box a, #example_content .example_list a, #marquee a').click(function() {
		SetCookie('site_map_path', this.tag, 60 * 1000);
	});
	
	$('#uc_site_path').text(function() {
		var path = GetCookie('site_map_path');
		if (path == null) return;
		
		var str = path.split(',');
		path = "";
		for (var i = 0; i < str.length; i++) {
			path += ">>  " + str[i] + "  ";
		}
		return path;
	});
});

function SetCookie(name, value, keep) {
	var exp  = new Date();
	exp.setTime(exp.getTime() + keep);
	document.cookie = name + "=" + escape (value) + ";expires=" + exp.toGMTString();
}

function GetCookie(name) {
	var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
	if (arr != null)
		return unescape(arr[2]);
	return null;
}

function Marquee_Left(box, speed) {
	var str = box.innerHTML;
	box.innerHTML = "";
	box.style.overflow = "hidden";

	var frame = document.createElement("DIV");
	frame.style.width = "300%";
	

	var box2 = document.createElement("DIV");
	box2.style.float = "left";
	box2.innerHTML = str;

	var box3 = document.createElement("DIV");
	box3.style.float = "left";
	box3.innerHTML = str;

	frame.appendChild(box2);
	frame.appendChild(box3);
	box.appendChild(frame);
	
	/* --- sample ---
	<div id='box'>
		<div style='width:300%'>
			<div id='box2'>
				<ul>.....</ul>
			</div>
			<div id='box3'>
		</div>
	</div>";
	----------------- */

	function Marquee() {
		if (box.scrollLeft >= box3.offsetWidth)
			box.scrollLeft -= box2.offsetWidth;
		else
			box.scrollLeft++;
	}

	var MyMar = setInterval(Marquee, speed);
	box.onmouseover = function() { clearInterval(MyMar); }
	box.onmouseout = function() { MyMar = setInterval(Marquee, speed); }
}

function Marquee_Up(box, speed) {
	var str = box.innerHTML;
	box.innerHTML = "";
	box.style.overflow = "hidden";

	var frame = document.createElement("DIV");
	frame.style.height = "300%";

	var box2 = document.createElement("DIV");
	box2.innerHTML = str;

	var box3 = document.createElement("DIV");
	box3.innerHTML = str;

	frame.appendChild(box2);
	frame.appendChild(box3);
	box.appendChild(frame);

	function Marquee() {
		if (box.scrollTop >= box3.offsetHeight)
			box.scrollTop -= box2.offsetHeight;
		else
			box.scrollTop++;
	}

	var MyMar = setInterval(Marquee, speed);
	box.onmouseover = function() { clearInterval(MyMar); }
	box.onmouseout = function() { MyMar = setInterval(Marquee, speed); }
}
