var filesadded = "";
function checkloadjscssfile(filename, filetype){
 if (filesadded.indexOf("["+filename+"]")==-1){
	loadjscssfile(filename, filetype)
	filesadded+="["+filename+"]" //List of files added in the form "[filename1],[filename2],etc"
 }
 else
	alert("file already added!")
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
	var fileref=document.createElement('script')
	fileref.setAttribute("type","text/javascript")
	fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
	var fileref=document.createElement("link")
	fileref.setAttribute("rel", "stylesheet")
	fileref.setAttribute("type", "text/css")
	fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
	document.getElementsByTagName("head")[0].appendChild(fileref)
}
function addLoadEvent(func)
{	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}

}

/*override the footer function in the main JS to include a "none" option*/
AOCalendar.$calFooter=function(cal){
	var s=[];
	j=0;
	
	s[j++]=$aoCS[0]+" id=\""+cal.cId+"$footer\" width='100%' height='100%'>";
	
	var sb="<td class='nlscalsysbtn' onmouseover=\"$ao$sysover(this)\" onmouseout=\"$ao$sysout(this)\" onclick=";
	
	if(cal.opt.mode==0&&cal.opt.sClose){
		s[j++]= sb +"\"$ao$close('"+cal.cId+"')\" title='"+$calI18n.btnClose+"'><img src='"+cal.opt.themeDir+"cls.gif' /></td>";   
	};
	
	s[j++]='<td align="left" class="nlscalsysbtn" onmouseover="$ao$sysover(this)" onmouseout="$ao$sysout(this)" onclick="none_clicked(\'' + cal.cId + '\')"><img src="'+cal.opt.themeDir+'clear.gif" /></td>';
	s[j++]="<td class='nlscalstatus' align='right' id='"+cal.cId+"$status'>&nbsp;</td>";

	if(cal.opt.mode==0&&cal.opt.sSelect){
		s[j++]=sb+"\"$ao$select('"+cal.cId+"')\" title='"+$calI18n.btnSel+"'><img src='"+cal.opt.themeDir+"sel.gif' /></td>";
	};

	s[j++]="</table>";

	return s.join("");
}

function none_clicked(cId) {
    var c=aoCals[cId];
    c.rt.dtCtl.value="";
    c.hide();
	c.onSelect();
}
