/* Remove IE 6 Background Flicker */
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function ajax_call (formfield, action, span_id, params) {
	if (formfield) value_id = document.getElementById(formfield).value;
	new ajax('ajax.php', {postBody: 'action=' + action + '&id=' + value_id + '&params=' + params, update: $(span_id)});
}

function default_page (page_url) {
	new ajax('ajax.php', {postBody: 'action=default_page&page='+page_url, update: $('default-page')});
}

function validationResponse(field,fieldName,message) {	
	if (message == "") {
		message = "The " + fieldName + " field is required";
	}
	alert(message);
 	eval("document.getElementById('" + field + "').focus()");
	return false;
}

var home_url = 'http://bignerve.baskettcase.com/';

function setup_page(url) {
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = '_blank['+i+']';
	}
	if (window.opener) homeurl = window.opener.document.location.href;
	if ((document.body ? window.innerWidth : document.scrollWidth) < 975) {
		window.resizeTo(975, window.outerHeight);
	}
}

function go_home() {
	if (window.opener && window.opener.close) {
		window.opener.focus();
	} else {
		go_url(home_url);
	}
	return true;
}

function go_url(the_url) {
	if (window.location) window.location.href = home_url;
	else if (document.location) document.location.href = home_url
}

function goToQuarter() {
  if (document.getElementById('yr').value != '' && document.getElementById('qtr').value != '') {
    var url = 'show_quarter.php?yr=' + document.getElementById('yr').value + '&qtr=' + document.getElementById('qtr').value;
  	if (window.location) window.location.href = url;
  	else if (document.location) document.location.href = url;
  }
}

function goToLesson() {
  if (document.getElementById('lid').value != '') {
    var url = 'show_lesson.php?qid=' + document.getElementById('qid').value + '&lid=' + document.getElementById('lid').value;
  	if (window.location) window.location.href = url;
  	else if (document.location) document.location.href = url;
  }
}

function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  }
}