
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function bkmToggle(cur, id, isClose) {
	closeDialogs();
	var c = document.getElementById(cur);
	var e = document.getElementById(id);
	if (!isClose) {
		e.style.position = 'absolute';
		e.style.display = 'block';
		e.style.visibility = 'visible';
		var pos = findPos(document.getElementById('rCol'));
		if (pos[0] > e.offsetWidth) {
			var lp = pos[0] - e.offsetWidth;
			e.style.left = lp + 'px';
		}
		pos = findPos(document.getElementById('rIconTable'));
		e.style.top = pos[1] + 'px';
		document.getElementById('tagWith').focus();
		} else {
		e.style.position = '';
		e.style.display = 'none';
		e.style.visibility = 'hidden';
		c.focus();
	}
}

function clickA (id) {
	var e = document.getElementById(id);
	e.click();
}

function recXmlhttpRequest(sMethod, sUrlBase, sUrlArguments, bIsAsync, sBody) {
	var url = sUrlBase;
	if (sUrlArguments != '') {
		var varArray = sUrlArguments.split('&');
		var urlVars;
		for (i = 0; i < varArray.length; i++) {
			urlVars = varArray[i].split('=');
			urlVars[1] = encodeURIComponent(urlVars[1]);
			varArray[i] = urlVars.join('=');
		}
		sUrlArguments = varArray.join('&');
		url = url + '?' + sUrlArguments;
	}
	frames['recommendFrm'].location.href = url;
	recWhenLoading();
}

function recWhenLoading() {
	document.getElementById('recResult').innerHTML = "<span style='color:#800000;'>Please wait...</span><br><br>";
}

function recWhenCompleted() {
	document.getElementById('recResult').innerHTML = recResult;
	document.getElementById('fName').value = '';
	document.getElementById('fEmail').value = '';
	document.getElementById('msg').innerHTML = '';
	var rd = setTimeout(function () {
			document.getElementById('recResult').focus();
	}, 500);
}

function recToggle(cur, id, isClose) {
	closeDialogs();
	var c = document.getElementById(cur);
	var e = document.getElementById(id);
	if (!isClose) {
		e.style.position = 'absolute';
		e.style.display = 'block';
		e.style.visibility = 'visible';
		var pos = findPos(document.getElementById('rCol'));
		if (pos[0] > e.offsetWidth) {
			var lp = pos[0] - e.offsetWidth;
			e.style.left = lp + 'px';
		}
		pos = findPos(document.getElementById('rIconTable'));
		e.style.top = pos[1] + 'px';
		document.getElementById('yName').focus();
		} else {
		e.style.position = '';
		e.style.display = 'none';
		e.style.visibility = 'hidden';
		c.focus();
	}
}

function recSubmit() {
	var msg = document.getElementById('msg').innerHTML;
	var rd;
	var isError = false;
	if (document.getElementById('yName').value == '') {
		document.getElementById('recResult').innerHTML = "<span style='color:red;'>Error: Your Full Name is required...</span><br><br>";
		isError = true;
		} else if (document.getElementById('yEmail').value == '') {
		document.getElementById('recResult').innerHTML = "<span style='color:red;'>Error: Your Email Address is required...</span><br><br>";
		isError = true;
		} else if (document.getElementById('fName').value == '') {
		document.getElementById('recResult').innerHTML = "<span style='color:red;'>Error: The To Name is required...</span><br><br>";
		isError = true;
		} else if (document.getElementById('fEmail').value == '') {
		document.getElementById('recResult').innerHTML = "<span style='color:red;'>Error: The To Email address is required...</span><br><br>";
		isError = true;
		} else if (msg == '') {
		msg = "(None)";
	}
	if (isError) {
		rd = setTimeout(function () {
				document.getElementById('recResult').focus();
		}, 500);
		return;
	}
	var d = new Date();
	recXmlhttpRequest('GET', 'http://gutterstar.net/recommend_.php', 'yName=' + document.getElementById('yName').value + '&yEmail=' + document.getElementById('yEmail').value + '&fName=' + document.getElementById('fName').value + '&fEmail=' + document.getElementById('fEmail').value + '&msg=' + msg + '&pTitle=' + document.title + '&href=' + encodeURIComponent(top.location.href) + '&ts=' + d.getTime(), true, '');
}

function updateFriend(n) {
	if (n) document.getElementById('friendsName').innerHTML = n;
}

function gsToggle(cur, id, isClose) {
	closeDialogs();
	var c = document.getElementById(cur);
	var e =document.getElementById(id);
	if (!isClose) {
		e.style.position = 'absolute';
		e.style.display = 'block';
		e.style.visibility = 'visible';
		var pos = findPos(document.getElementById('rCol'));
		if (pos[0] > e.offsetWidth) {
			var lp = pos[0] - e.offsetWidth;
			e.style.left = lp + 'px';
		}
		pos = findPos(document.getElementById('gsSearchH3'));
		e.style.top = pos[1] + 'px';
		var f = e.getElementsByTagName('form');
		if (f[0].q) {
			f[0].q.title = 'Search';
			f[0].q.focus();
		}
		} else {
		e.style.position = '';
		e.style.display = 'none';
		e.style.visibility = 'hidden';
		c.focus();
	}
}

function setupPage() {
	document.body.focus();
	var x = document.getElementsByTagName("a")
	for(i = 0; i < x.length; i++) {
		x[i].title = '';
	}
	for(i = 1; i <= 6; i++) {
		eval('var i1 = document.getElementById("ti' + i + '");');
		eval('var i2 = document.getElementById("tt' + i + '");');
		i2.style.width = i1.offsetWidth + 'px';
		i2.style.position = 'absolute';
		i2.style.zIndex = '9';
		i2.style.fontSize = '12pt';
		var pos = findPos(i1);
		i2.style.left = pos[0] + 'px';
		i2.style.top = pos[1] + i1.offsetHeight + 'px';
	}
	for(i = 1; i <= 2; i++) {
		eval('var i1 = document.getElementById("ri' + i + '");');
		eval('var i2 = document.getElementById("rt' + i + '");');
		i2.style.position = 'absolute';
		i2.style.zIndex = '9';
		i2.style.width = i1.offsetWidth + 'px';
		i2.style.fontSize = '12pt';
		var pos = findPos(i1);
		i2.style.left = pos[0] + 'px';
		i2.style.top = pos[1] + i1.offsetHeight + 'px';
	}
	var x = document.getElementsByTagName("h2")
	if (x[0]) {
		x[0].style.clear = 'left';
	}
}

function closeDialogs() {
	var gs = document.getElementById("gsm");
	var bk = document.getElementById("bkm");
	var sm = document.getElementById("recForm");
	if (gs.style.position == 'absolute') {
		gs.style.position = '';
		gs.style.display = 'none';
		gs.style.visibility = 'hidden';
	}
	if (bk.style.position == 'absolute') {
		bk.style.position = '';
		bk.style.display = 'none';
		bk.style.visibility = 'hidden';
	}
	if (sm.style.position == 'absolute') {
		sm.style.position = '';
		sm.style.display = 'none';
		sm.style.visibility = 'hidden';
	}
}

if (TlxPgNm != 'amazon') {
	window.onload = setupPage;
}
