
function $(eId) {
	var ha = document.getElementById(eId);
	return ha;
}

function elDisp(eId, eDisp) {	
	var ha = $(eId);
	ha.style.display = eDisp;
	return false;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
		return [curleft,curtop];
	}
}

// ----------- Ajax Stuff

var xmlhttp;
var responseStr;
function loadAjaxContent(url,elId) {
	xmlhttp = null;
	responseStr = null;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
  }
	else if (window.ActiveXObject) {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
	if (xmlhttp != null) {
	  xmlhttp.open("GET", url, false);
		xmlhttp.send(null);
		//document.getElementById().innerHTML = xmlhttp.status;
		//document.getElementById().innerHTML = xmlhttp.statusText;
		//alert(xmlhttp.responseText);
		if (elId != '') {
			document.getElementById(elId).innerHTML = xmlhttp.responseText;
		}
  } else {
	  alert("Sorry, your browser does not support this type of ajax request.");
  }
  return false;
}

// ------ Adverts

function loadAds() {
	try {
		//alert('ads...');
		//$('leaderBoardIframe').src = '/ajax/adverts/advert.ashx?adtag=oldhamsunday&leaguetype=junior&adsize=728x90';
		$('leaderBoardIframe').src = '/ajax/adverts/advert.ashx?leagueid=' + advertLeagueId + '&adsize=728x90';
		$('skyScraperIframe').src = '/ajax/adverts/advert.ashx?leagueid=' + advertLeagueId + '&adsize=120x600,160x600';
	} catch (ex) {
	}
	return false;
}

// ------------ Modal iframe

function setModalIframe(w,h,url) {
	var haIf = $('modalIFrame');
	haIf.width = w;
	haIf.height = h;	
	haIf.src = url;
	var vh = getViewportHeight();
	var sh = getScrollHeight();
	var haP = $('modalPopup2');
	var pt = (((vh/2) - (h/2)) + sh - 15 ) + 'px';
	//alert(pt);
	haP.style.paddingTop = pt;
	haP.style.display = '';
}

// ----------- Viewport Height

function getViewportHeight() {
	var h = 0;

	if (typeof window.innerHeight != 'undefined') {
		h = window.innerHeight;
	} else if (typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientWidth !=
		'undefined' && document.documentElement.clientWidth != 0) {
		h = document.documentElement.clientHeight;
	} else {
		h = document.getElementsByTagName('body')[0].clientHeight;
	}

	return h;
}

// ----------- Scroll Height

function getScrollHeight() {

	var h = document.body.scrollTop ? document.body.scrollTop 
					: ( window.pageYOffset ? window.pageYOffset
						: ( document.body.parentElement ? document.body.parentElement.scrollTop 
							: 0 ) );
							
	return h;
}