
// ---------- Browser Check ---------- //

function browserCheck() 
{
	this.ns4 = (document.layers)? true:false;
	this.ie = (document.all&&(!window.opera))? true:false;
	this.dom = (document.getElementById)? true:false;
	this.ns6 = (window.sidebar)? true:false;
	this.moz = (window.sidebar||navigator.userAgent.indexOf('Gecko')!=-1)? true:false;
	this.opera = (window.opera)? true:false;
	this.mac = (navigator.userAgent.indexOf('Mac')!=-1)? true:false;
}
is = new browserCheck();

// ---------------------------------- //


// ------ Objects & Properties ------ //

function getObject(id) 
{
	if (typeof(id) == "object") { return id; }
	if(is.ie && !is.dom) this.obj = document.all[id];
	else if(is.ns4) this.obj = document.id;
	else this.obj = document.getElementById(id);
	return this.obj;
}

function getObjectStyle(obj) 
{ 
	return is.ns4 ? obj : obj.style; 
}

function getObjectInnerHtml(obj) // NS4??
{ 
	return obj.innerHTML; 
}

function setObjectInnerHtml(obj, html)
{
	if(is.ns4) 
	{
		obj.document.open();
		obj.document.write(html);
		obj.document.close();
	}
	else obj.innerHTML = html;
}

// ---------------------------------- //


// ------ In-Page PopUp Window ------ //

function openPopUpWin(iFrameID, height, width)
{
	el = getObject(iFrameID);
	getObjectStyle(el).display='block'; 
	getObjectStyle(el).height=height+'px'; 
	getObjectStyle(el).width=width+'px';
	el.style.top=(((is.ie)?document.body.scrollTop:window.pageYOffset)+100)+'px';
}

// ---------------------------------- //


// --------- Calendar PopUp --------- //

function calPopUp(df,mf,yf)
{
	getObject('iframeEditor').src='pop_calendar.aspx?df='+
								  df+'&mf='+mf+'&yf='+yf+
								  '&sd='+getObject(df).value+
								  '&sm='+getObject(mf).value+
								  '&sy='+getObject(yf).value;
	openPopUpWin('iframeEditor', 195, 198);					  
}
	
// ---------------------------------- //


// --- ImageButton to Reset Forms --- //

function resetimage(src,confirm)
{
	this.src=src;
	this.confirm=confirm;
	this.alt="Reset";
	this.write=resetimage_write;
}

function resetimage_write()
{
	document.write('<a ');
	document.write(' href="javascript:');
	if (this.confirm) document.write('if(confirm(\'Are you sure you want to reset?\'))');
	document.write('document.forms[' + (document.forms.length - 1) + '].reset();void(0);">');
	document.write('<img src="' + this.src + '" alt="' + this.alt + '"');
	document.write(' border="0"');
	if (this.name)document.write(' name="' + this.name + '"');
	if (this.height)document.write(' height=' + this.height);
	if (this.width)document.write(' width=' + this.width);
	if (this.otheratts)document.write(' '+ this.otheratts);
	document.write('></a>');
}

// ---------------------------------- //


// ------ Automatic File Icons ------ //

function fileIcon(fileName)
{
	var ext = fileName.substring(fileName.indexOf('.')+1);
	if (ext!="pdf"&&ext!="doc") ext = "file";
	document.write("<img src='images/file_icons/" + ext + ".gif'/>");
}

// ---------------------------------- //

// ------- Show/hide div -------- //

function ChangeDivVisible(obj) {
	obj.style.display = (obj.style.display == '') ? 'none' : '';
	return obj.style.display == '';
}

// ---------------------------------- //

