var cbtn;
var openload;
var oldbtn;
var clthis;
var btnswap;
var openthis;
image1 = new Image();
image1.src = "/images/load.gif";

function loadwindow(urlnum,findthis,sid,btntype) {
	if(cbtn == sid && oldbtn== btntype) {
		closeit(sid);
	}
	else {
		if(cbtn > 0 && oldbtn != '') {
			closeit(cbtn);
		}
		cbtn= sid;
		oldbtn= btntype;
		openthis = btntype+sid;
		clthis = openthis;
		loader= "load"+sid;
		openload="load"+sid;
		btnswap = findthis;
		var btn = new getQuicklinkObj(findthis);
		btn.setAttribute("oldsrc",btn.getAttribute('origsrc'));
		btn.setAttribute("origsrc",btn.getAttribute('oversrc'));		
		if(btntype == 'D'||btntype == 'H') {
			var btn = new getQuicklinkObj(loader);
			if (btn.getAttribute('opened')) {
				btn.style.display ='';
				pdiframesize();
			}
			else {
				btn.innerHTML ="<div style='text-align:center;'><img src='/athletics/inc_files/load.gif' alt='' width='62' height='6' border='0' style='border:solid 1px #000000;'></div>";						
				btn.style.display ='';
				if(btntype == 'H') {
					getQuicklinkObj('datareader').src='/athletics/inc_files/data_retriever.asp?highlightid='+urlnum+'&id='+sid+'&button='+findthis;
				}
				if(btntype == 'D') {
					getQuicklinkObj("datareader").src="/athletics/inc_files/data_retriever.asp?scheduleid="+sid+"&id="+sid+"&button="+findthis;
				}
			}
		}
		else {
			var btn = new getQuicklinkObj(openthis);
			btn.style.display ='';
			pdiframesize();
		}
		//Set this to swap row 4 background on button click
		//getQuicklinkObj("row4_" + sid).style.background = "url('/images/at_row4_open.gif') no-repeat";
	}
}

function closeit(sid) {
	var btn = new getQuicklinkObj(btnswap);
	btn.setAttribute("origsrc",btn.getAttribute('oldsrc'));
	btn.src = btn.getAttribute('oldsrc');
	if (getQuicklinkObj("datareader")) {
		getQuicklinkObj("datareader").src="";
	}
	var xt = oldbtn+cbtn;
	var btn = new getQuicklinkObj(xt);
	btn.style.display ='none';
	var btn = new getQuicklinkObj(openload);
	if (btn.style.display =='')	{				
		btn.style.display ='none';
	}
	
	
	//getQuicklinkObj("row4_" + sid).style.background = "url('/images/at_row4.gif') no-repeat";
	
	/*
		if(oldbtn == 'H'||oldbtn=='D') {
			getQuicklinkObj("cframe").height = 0;
			getQuicklinkObj("holder").height = 0;
			getQuicklinkObj("holder").className='closeiframe';
			getQuicklinkObj("dwindowcontent").height = 0;
			var clthis = new getQuicklinkObj("dwindow");
			clthis.style.top=myy;
			clthis.height = 0;
		}
		*/
			pdiframesize();
		cbtn = 0;
		oldbtn='';	
}
function filldata(filldatawith) {
	var btn = new getQuicklinkObj(openload);
	btn.innerHTML = filldatawith;	
	btn.setAttribute('opened','hasdata');	
	pdiframesize();
}
function getQuicklinkObj(obj) {
	if (document.getElementById)
		return document.getElementById(obj)
	else if (document.all)
		return document.all[obj]
}
function pdiframesize()	{
	var aIF = window.parent.document.getElementsByTagName('IFRAME')
	var objIF
	for (x=0; x<aIF.length;x++) {
		if(aIF[x].id.substring(0,2) == 'if') objIF = aIF[x]
	}
	var objBody = document.getElementById('__pdIFRAMEarea') 
	objIF.style.height = objBody.offsetHeight;	
}

function openGallery(itemId) {
	window.open('/athletics/inc_files/inc_athgallery.asp?newsid='+itemId, '_blank', 'location=no, menubar=no, scrollbars=no, status=no, resizable=no, height=411, width=246, left=495, top=255, screenX=495, screenY=255, titlebar=no');
}
