// JavaScript Document

function viewReceipt(toggle){
	
	if(toggle == 'open'){
		 document.getElementById('viewReceipt').style.display = 'block';
		 document.getElementById('contenttbl').className = "fade";	
	} else {
		 document.getElementById('viewReceipt').style.display = 'none';	
		 document.getElementById('contenttbl').className = "none";	
	}
	
}

function promptUser(msg){
	var x = confirm(msg);	
}

function submitForm(formName, action){
	
	var oForm = document.getElementById(formName);
	
	oForm.action = action;
	
	oForm.submit();
	
}



function ajaxObject(url, callbackFunction) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod,containerID,istype) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {         
	
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML, containerID);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date(); 
	  
	  //add id for switch 
	  passData += '&cid='+containerID;
	  
	  //display progress bar
	  if(istype != 'field'){
	  	showProgress(containerID);
	  }
      if (/post/i.test(postMethod)) {
		  
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}

function processData(responseText, responseStatus, responseXML, containerID) {
  if (responseStatus==200) {
    document.getElementById(containerID).innerHTML = responseText;
  } else {
    document.getElementById(containerID).innerHTML = responseStatus + ' -- Error Processing Request';
  }
}

function processField(responseText, responseStatus, responseXML, containerID) {
  if (responseStatus==200) {
    document.getElementById(containerID).value = responseText;
  } else {
    document.getElementById(containerID).value = responseStatus + ' -- Error Processing Request';
  }
}

function showProgress(containerID) {
  if( document.getElementById(containerID)){
    document.getElementById(containerID).innerHTML = "<div style=\"width:100%; text-align:center\"><img src=\"/images/progbar.gif\" /></div>";
  }
}


function quickSearch(yearPlayed, section, term, choice, exported){
	
	var process = new ajaxObject('/jmmadmin/dataSearch.asp',processData);
  	process.update(encodeURI('sy='+yearPlayed+'&section='+section+'&term='+term+'&c='+choice+'&e='+exported), 'POST', section);
	
}

function loadImages(yearPlayed, section){
	
	var process = new ajaxObject('loadImages.asp',processData);
  	process.update(encodeURI('yr='+yearPlayed+'&section='+section), 'POST', section);
	
}

function lookupData(yearPlayed, section, selected, istype){
	
	if(istype == 'field'){
		var process = new ajaxObject('/jmmadmin/dataLookup.asp',processField);
	} else {
		var process = new ajaxObject('/jmmadmin/dataLookup.asp',processData);
	}
	
	process.update(encodeURI('sy='+yearPlayed+'&section='+section+'&selected='+selected), 'POST', section, istype);
	
}


function dataExport(yearPlayed, section, processPage, choice){
	
	
	var process = new ajaxObject(processPage,processData);

  	process.update(encodeURI('sy='+yearPlayed+'&section='+section+'&c='+choice+'&exportData=true'), 'POST', section);
	
}



function addFBLike(){
	
	//document.getElementById('fbLike').innerHTML = "<fb:like href=\"http://www.joemanzigolf.com\" layout=\"button_count\" show_faces=\"false\" width=\"90\" font=\"arial\"></fb:like>"	
	
}

function highlightAnchor(){
	
	var anchorValue;
	var url = document.location;
	var strippedUrl = url.toString().split("#");
	if(strippedUrl.length > 1)
		document.getElementById(strippedUrl[1]).className = document.getElementById(strippedUrl[1]).className + " yellow";
	
}
function onUpload() {
    var formDOMObj = document.frmSend;
    if (formDOMObj.photo.value == "")
        alert("Please press the Browse button and pick a file.")
    else
        return true;
    return false;
}



function rand(l,u) // lower bound and upper bound
 {
     return Math.floor((Math.random() * (u-l+1))+l);
 }


function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}


function selPymt(value){
	
	if (value == 1){
		document.getElementById('paymentMsg1').style.display="block";
		document.getElementById('paymentMsg0').style.display="none";
		
	} else {
		document.getElementById('paymentMsg1').style.display="none";
		document.getElementById('paymentMsg0').style.display="block";
	}
	
	document.getElementById("custom").value = value;
	
}

<!-- ************************************************ -->	
<!-- Functions to Control Display of Homepage Modules -->
<!-- ************************************************ -->
	matchHeight=function(){

     var divs,contDivs,maxHeight,divHeight,d;

     // get all <div> elements in the document

     divs=document.getElementsByTagName('div');

     contDivs=[];

     // initialize maximum height value

     maxHeight=0;

     // iterate over all <div> elements in the document

     for(var i=0;i<divs.length;i++){

          // make collection with <div> elements with class attribute 'container'

          if(divs[i].className=='xbox'){

                d=divs[i];

                contDivs[contDivs.length]=d;

                // determine height for <div> element

                if(d.offsetHeight){

                     divHeight=d.offsetHeight;
					// alert('offset height '+i+': '+divHeight);

                }

                else if(d.style.pixelHeight){

                     divHeight=d.style.pixelHeight;
					// alert('pixel height '+i+': '+divHeight);

                }

                // calculate maximum height
				
                maxHeight=Math.max(maxHeight,divHeight);
				
          }

     }

     // assign maximum height value to all of container <div> elements

     for(var i=0;i<contDivs.length;i++){

          contDivs[i].style.height=maxHeight+"px";
		  //alert('new height '+i+': '+maxHeight);

     }

} 


function NOajaxReq(choice, dataid, qstring) {
	
	document.location='/jmmadmin/default.asp?c=' + choice + '&' + qstring;
	
}

//main AJAX functionality
function ajaxReq(choice, dataid, qstring){
	var ajaxRequest;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  ajaxRequest=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		ajaxRequest=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		try
		  {
		  ajaxRequest=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		catch (e)
		  {
		  alert("Your browser does not support AJAX!");
		  return false;
		  }
		}
	  }
	  
	
				
	ajaxRequest.onreadystatechange = function(){
		
			
		if(ajaxRequest.readyState == 4){
			if (ajaxRequest.status == 200){	
			
				document.getElementById(dataid).innerHTML = ajaxRequest.responseText;
				
			}
		}
		
		
	}
	
	
	
	//default data page and querystring
	var queryString
	var dispPage
	var timestamp = new Date().getTime();
	
	if (qstring == '') {
		queryString = '?c=' + choice + "&dataid=" + dataid + "&ts=" + timestamp;
	} else {
		queryString = '?c=' + choice + '&' + qstring + "&dataid=" + dataid + "&ts=" + timestamp;
	}	
	
	dispPage = "/jmmadmin/dispData.asp" + queryString;	
	document.getElementById(dataid).innerHTML = ' <div style="text-align:center; width:98%;"><br><br><h3>Loading View<img src="/images/spin-globe.gif" hspace="5" align="absmiddle" /></h3></div>';

	ajaxRequest.open("GET", dispPage, true);
	ajaxRequest.send(null); 

}


function darkenScreen(mode) {
	
	if(mode != 'close') {
		document.getElementById('darkenit').style.display = "block";
		document.getElementById('darkenit').style.width = document.body.clientWidth+"px";
		document.getElementById('darkenit').style.height = document.body.clientHeight+20+"px";
	} else {
		document.getElementById('darkenit').style.display = "none";	
		document.getElementById('darkenit').style.width = "0px";
		document.getElementById('darkenit').style.height = "0px";
	}
}






function refreshWindow() {
	window.location.reload();
}

var myimages=new Array()

function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}

preloadimages("/images/jmm-headerback.gif","/images/jmm-tncurve.gif","/images/mchalfcircle-blk.gif")


function submitform(theForm, field, value) {

	document.getElementById(field).value = value;
	document.getElementById(theForm).submit();


}


function url(loc) 
{ 
var id = loc.selectedIndex; 
if(id==0) return; 
var url = loc.options[id].value; 
if(url==""|| url=="#" ) return; 
window.location = url; 
}

function ajaxSelect(choice, dataid, loc) 
{ 
var id = loc.selectedIndex; 
if(id==0) return; 
var qstring = loc.options[id].value; 
if(qstring==""|| qstring=="#" ) return; 
ajaxReq(choice, dataid, qstring); 
}

function pressIMG(id, wsize) {

	if(wsize=="sml") {
		if(document.getElementById(id) != null) {
			document.getElementById(id).width = document.getElementById(id).width / 2
			document.getElementById(id).height = document.getElementById(id).height / 2
		}
	}
	

}




//specify interval between slide (in mili seconds)
var slidespeed=10000
var whichdiv=1
var hidediv=1

function showPress(numtoshow) {


//show whichdiv and hide the others

document.getElementById(whichdiv).style.display = "block";

	if( hidediv != whichdiv) {
		document.getElementById(hidediv).style.display = "none";	
	}


hidediv = whichdiv
whichdiv=(whichdiv<numtoshow)? whichdiv+1 : 1

setTimeout("showPress("+numtoshow+")",slidespeed)



}

moz=document.getElementById&&!document.all
mozHeightOffset=20

function frm_onload(f) 
{ 
	document.getElementById(f).style.height = document.getElementById(f).contentWindow.document.body.scrollHeight + "px";
}

function swapClass(id, newclass) 
{
	document.getElementById(id).className = newclass;
	
}

//-->


//-->

