
/*
 * Words like to be typed by typewriter and the point looks like rolling
 * Embed these codes in head of file: <script src="rollingTyping.js" type="text/javascript"></script>
 * Then invoke the function rollingTyping(obj, str1, str2) in which element you want
 * @adapter Gene Christian
 */
if (document.all) {
	var line = new Array();
	var object;
	/*
 * Designate the element and the words
 * @param obj Which element you want to insert the lines
 * @param str Words in lines
 */
	function rollingTyping(obj, str1, str2) {
		object = obj;
		line[1] = str1;
		line[2] = str2;
		animate();
	}
	lines = 2;
	temp = "";
	nextChar = -1;
	nextLine = 1;
	cursor = "-";
	function animate() {
		if (temp == line[nextLine] & temp.length == line[nextLine].length & nextLine != lines) {
			nextLine++;
			nextChar = -1;
			object.innerText = temp;
			temp = "";
			setTimeout("nextstep()", 5000);
		} else {
			if (nextLine == lines & temp == line[nextLine] & temp.length == line[nextLine].length) {
				nextLine = 1;
				nextChar = -1;
				object.innerText = temp;
				temp = "";
				setTimeout("nextstep()", 5000);
			} else {
				nextstep();
			}
		}
	}
	function nextstep() {
		if (cursor == "\\") {
			cursor = "|";
		} else {
			if (cursor == "|") {
				cursor = "/";
			} else {
				if (cursor == "/") {
					cursor = "-";
				} else {
					if (cursor == "-") {
						cursor = "\\";
					}
				}
			}
		}
		nextChar++;
		temp += line[nextLine].charAt(nextChar);
		object.innerText = temp + cursor;
		setTimeout("animate()", 200);
	}
}

