// GET X COORDINATE
function getRealLeft(id) { 
	var el = document.getElementById(id);
	if (el) { 
		xPos = el.offsetLeft;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		} 
		return xPos;
	} else {
		return 0;
	}
} 

// GET Y COORDINATE
function getRealTop(id) {
	var el = document.getElementById(id);
	if (el) { 
		yPos = el.offsetTop;
		tempEl = el.offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		return (yPos+1);
	} else {
		return 0;
	}
}

function togglediv(d) {
	var c = document.getElementById(d);
	if (c.style.display=='none') {
		c.style.display = '';
	} else {
		c.style.display = 'none';
	}
}

function showhidediv(d, state) {
	var c = document.getElementById(d);
	if (state) {
		c.style.display = 'block';
	} else {
		c.style.display = 'none';
	}
}


function pop_internal(url) {
	newwindow=window.open(url,'internal','height=900,width=840,left=200,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=yes');
	if (window.focus) {
		newwindow.focus()
	}
}


function checksidesubscribeform() {
	if (
		(document.forms['sidesubscribeform'].email.value.indexOf('@') == -1) ||
		(document.forms['sidesubscribeform'].name1.value == '') ||
		(document.forms['sidesubscribeform'].name2.value == '')
	) {
		alert('Please fill all fields.');
		return false;
	}
	
	return true;
}


function lead_zero(d) {
	if (d <= 9) return '0'+d;
	return ''+d;
}

