function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}
function fetch_news(navtype){var nlistDIV=document.getElementById('news-list');var nlistPi=nlistDIV.getElementsByTagName('P');switch(navtype){case'next':var startr=parseInt(nlistDIV.getAttribute('rel').substr(0,nlistDIV.getAttribute('rel').indexOf(':')))+1;var numr=parseInt(nlistDIV.getAttribute('rel').substr(nlistDIV.getAttribute('rel').indexOf(':')+1));getNewsRecords(navtype,startr,nlistDIV,numr);$('.prev a').removeClass('inactive');break;case'prev':var startr=parseInt(nlistDIV.getAttribute('rel').substr(0,nlistDIV.getAttribute('rel').indexOf(':')))-1;var numr=parseInt(nlistDIV.getAttribute('rel').substr(nlistDIV.getAttribute('rel').indexOf(':')+1));if(startr<0){var startr=0;$('.prev a').addClass('inactive');}
getNewsRecords(navtype,startr,nlistDIV,numr);break;}}
function newRequest()
{try
{var xmlHttp=new XMLHttpRequest();}
catch(e)
{try
{var xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{try
{var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e)
{alert("Your browser does not support AJAX!");return false;}}}
return xmlHttp;}
function getNewsRecords(typenp,start,output,limit){var replacehashpattern=new RegExp('#');var url='/fetch_xml_news.php?url='+location.href.substr(location.href.lastIndexOf('/')+1,location.href.length).replace(replacehashpattern,'')+'&start='+start+'&limit='+limit;var reqObj=newRequest();reqObj.open('GET',url,true);reqObj.onreadystatechange=function(){if(reqObj.readyState==4){if(reqObj.status==200){var response=reqObj.responseXML;if(response.documentElement.getElementsByTagName('error').length==0){var showgroups=response.documentElement.getElementsByTagName('option');var count_showgroups=showgroups.length;if(count_showgroups>0){preapareOutPut(output);for(var i=0;i<count_showgroups;i++){var newli=document.createElement('P');newli.id='n'+parseInt(start+i);newli.className='homenews';var newA=document.createElement('A');newA.href=showgroups[i].getAttribute('ourl');newA.className=showgroups[i].getAttribute('class');var newSpan=document.createElement('SPAN');newSpan.className='newsdate';newSpan.innerHTML=sanitize(showgroups[i].getAttribute('datevalue'));var newText=document.createTextNode(sanitize(showgroups[i].getAttribute('value')));var newSpace=document.createTextNode(' ');newA.appendChild(newSpan);newA.appendChild(newSpace);newA.appendChild(newText);newli.appendChild(newA);output.appendChild(newli);}
output.setAttribute('rel',start+':'+limit);}}}}}
reqObj.send(null);}
function preapareOutPut(outputarea){outputarea.innerHTML='';}
function sanitize(val)
{val=val.replace(/&apos;/g,"'");val=val.replace(/&rsquo;/g,"'");val=val.replace(/&quot;/g,'!');val=val.replace(/&gt;/g,'>');val=val.replace(/&lt;/g,'<');val=val.replace(/&amp;/g,'&');return val;}
function checkSignUpForm(formV){var filterEmail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(formV.email.value==''){alert('Please input an email to proceed');return false;}else if(!filterEmail.test(formV.email.value)){alert('Please input a valid email to proceed');return false;}}
function MM_validateSignUpForm(){var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;for(i=0;i<(args.length-2);i+=3){test=args[i+2];val=MM_findObj(args[i]);if(val){nm=val.name;if((val=val.value)!=""){if(test.indexOf('isEmail')!=-1){p=val.indexOf('@');if(p<1||p==(val.length-1))errors+='- '+nm+' must contain an e-mail address.\n';}else if(test!='R'){num=parseFloat(val);if(isNaN(val))errors+='- '+nm+' must contain a number.\n';if(test.indexOf('inRange')!=-1){p=test.indexOf(':');min=test.substring(8,p);max=test.substring(p+1);if(num<min||max<num)errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';}}}else if(test.charAt(0)=='R')errors+='- '+nm+' is required.\n';}}if(errors)alert('The following error(s) occurred:\n'+errors);document.MM_returnValue=(errors=='');}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function ValidateContactEditForm(frmEdit){dirtyData=false;if(isEmptyString(frmEdit.password.value.toString()))
{alert('Password can not be Empty.');frmEdit.password.value="";frmEdit.password.focus();return(false);}
if(isEmptyString(frmEdit.passwordconfirm.value.toString()))
{alert('Confirm Password can not be Empty.');frmEdit.passwordconfirm.value="";frmEdit.passwordconfirm.focus();return(false);}
if(frmEdit.password.value.toString()!=frmEdit.passwordconfirm.value.toString())
{alert('Password is not confirmed.');frmEdit.password.value="";frmEdit.passwordconfirm.value="";frmEdit.password.focus();return(false);}
if(isEmail(frmEdit.email.value.toString())!=true)
{alert('Email is Invalid.');frmEdit.email.value="";frmEdit.email.focus();return(false);}
if(isEmail(frmEdit.emailconfirm.value.toString())!=true)
{alert('Confirm Email is Invalid.');frmEdit.emailconfirm.value="";frmEdit.emailconfirm.focus();return(false);}
if(frmEdit.email.value!=frmEdit.emailconfirm.value)
{alert('Email is not confirmed.');frmEdit.email.value="";frmEdit.emailconfirm.value="";frmEdit.email.focus();return(false);}
if(frmEdit.alternate_email.value)
{var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(!filter.test(frmEdit.alternate_email.value)){alert("Please input a valid Alternate Email Address!");frmEdit.alternate_email.focus();return false;}}}
function SetChecked(val,chkName){dml=val.form;len=dml.elements.length;for(var i=0;i<len;i++){if(dml.elements[i].name==chkName&&dml.elements[i].type==val.type&&dml.elements[i].type=='checkbox'){dml.elements[i].checked=val.checked;}}}
var your_message="You Will Lose Your Settings.. Click Cancel and Submit Changes.";var dirtyData=false;function dataChanged(){if(!dirtyData){dirtyData=true;Submitted=0;}}
function onul(e){if(dirtyData)
if(navigator.appName=="Netscape")
e.returnValue=your_message;else
window.event.returnValue=your_message;}
function checkUnitUpdateform(doc,is_primary){dirtyData=false;if(is_primary==1){if(doc.marching_member.value.length>50){alert("Maximum limit reached. Please shorten your message!");doc.marching_member.focus();return false;}
if(doc.director.value.length>200){alert("Maximum limit reached. Please shorten your message!");doc.director.focus();return false;}
if(doc.show_title.value.length>50){alert("Maximum limit reached. Please shorten your message!");doc.show_title.focus();return false;}}}
function checkPractiseForm()
{var agree=document.getElementById('confirmAgreement');if(agree.checked)
{document.getElementById('proceed').className='visible';}else{document.getElementById('proceed').className='hidden';}}
function populateContent(id,url){var reqObj=newRequest();var outputArea=document.getElementById(id).getElementsByTagName('DIV')[1];outputArea.innerHTML='<p><img src="images/ajax-loader.gif" alt="Loading Data....." /></p>';reqObj.open('GET',url,true);reqObj.onreadystatechange=function(){if(reqObj.readyState==4&&reqObj.status==200){var response=reqObj.responseText;if(response.length==0){outputArea.style.height=response.length+'px';outputArea.innerHTML='<p>No contents from the url</p>';}else{outputArea.innerHTML=response+'<br />';}}}
reqObj.send(null);}
function populateScoreDetails(id,url){var reqObj=newRequest();var outputArea=document.getElementById(id);outputArea.style.display='';outputArea.parentNode.parentNode.style.display='';outputArea.innerHTML='<p><img src="images/ajax-loader.gif" alt="Loading Data....." /></p>';alert(url);reqObj.open('GET',url,true);reqObj.onreadystatechange=function(){if(reqObj.readyState==4&&reqObj.status==200){var response=reqObj.responseText;if(response.length==0){outputArea.style.height=response.length+'px';outputArea.innerHTML='<p>No contents from the url</p>';}else{outputArea.innerHTML=response+'<br />';}}}
reqObj.send(null);}
function closeScoreDetails(id){var outputArea=document.getElementById(id);outputArea.innerHTML='';outputArea.style.display='none';outputArea.parentNode.parentNode.style.display='none';}
function getTotalClasses(idoutput){var url='getClasses.php?q=unitclass&res='+document.getElementById('unittype').value;var req_sel=newRequest();req_sel.open('GET',url,true);req_sel.onreadystatechange=function(){if(req_sel.readyState==4){if(req_sel.status==200){var resp_sel=req_sel.responseXML;var out_sel=document.getElementById('unitclass');out_sel.options.length=0;var opttag=resp_sel.documentElement.getElementsByTagName('showoptions');var count_opts=opttag.length;for(var loopR=0;loopR<count_opts;loopR++){var optName=opttag[loopR].getAttribute("name");var optVal=opttag[loopR].getAttribute("value");out_sel.options[loopR]=new Option(optName,optVal);}}}}
req_sel.send(null);}
function fetchClasses(idinput,idoutput){var url='getClasses.php?q=unitclass&res='+document.getElementById(idinput).value;var req_sel=newRequest();req_sel.open('GET',url,true);req_sel.onreadystatechange=function(){if(req_sel.readyState==4){if(req_sel.status==200){var resp_sel=req_sel.responseXML;var out_sel=document.getElementById(idoutput);out_sel.options.length=0;var opttag=resp_sel.documentElement.getElementsByTagName('showoptions');var count_opts=opttag.length;for(var loopR=0;loopR<count_opts;loopR++){var optName=opttag[loopR].getAttribute("name");var optVal=opttag[loopR].getAttribute("value");out_sel.options[loopR]=new Option(optName,optVal);}}}}
req_sel.send(null);}
function nextOption(thisv){if(thisv.value=='No'){document.getElementById('smt_enter').disabled=false;document.getElementById('num_schools').disabled=false;document.getElementById('no_details_1').style.display='';document.getElementById('no_details_2').style.display='';document.getElementById('no_details_3').style.display='';thisv.form.action='sec_form_group.php';}else{document.getElementById('no_details_1').style.display='none';document.getElementById('no_details_2').style.display='none';document.getElementById('no_details_3').style.display='none';document.getElementById('num_schools').disabled=true;document.getElementById('smt_enter').disabled=false;thisv.form.action='sec_form_single.php';}}
function PostSECMultiForm(frm_1)
{var ele=frm_1.elements;var errorfound=false;for(var i=0;i<ele.length;i++){if(document.getElementById(ele[i].name)&&document.getElementById(ele[i].name).tagName=='DIV'){if(ele[i].value==''){document.getElementById(ele[i].name).innerHTML='Please '+((ele.tagName=='SELECT')?'select':'enter')+' the value';errorfound=true;}else{document.getElementById(ele[i].name).innerHTML='';}}}
return!errorfound;}
function PostSECForm(frm_1)
{if(isEmptyString(frm_1.unitname.value.toString()))
{alert("Please Enter Unit Name");frm_1.unitname.value="";frm_1.unitname.focus();return false;}
if(isEmptyString(frm_1.unittype.value.toString()))
{alert("Please Select Unit Type");frm_1.unittype.value="";frm_1.unittype.focus();return false;}
if(isEmptyString(frm_1.unitclass.value.toString()))
{alert("Please Select Unit Class");frm_1.unitclass.value="";frm_1.unitclass.focus();return false;}
if(isEmptyString(frm_1.schoolname.value.toString()))
{alert("Please Enter School Name");frm_1.schoolname.value="";frm_1.schoolname.focus();return false;}
if(isEmptyString(frm_1.schooladdress.value.toString()))
{alert("Please Enter School Address");frm_1.schooladdress.value="";frm_1.schooladdress.focus();return false;}
if(isEmptyString(frm_1.schooldistrict.value.toString()))
{alert("Please Enter School District");frm_1.schooldistrict.value="";frm_1.schooldistrict.focus();return false;}
if(isEmptyString(frm_1.principalname.value.toString()))
{alert("Please Enter Principal Name");frm_1.principalname.value="";frm_1.principalname.focus();return false;}
if(isEmptyString(frm_1.ptelephone.value.toString()))
{alert("Please Enter Principal's Telephone number.");frm_1.ptelephone.value="";frm_1.ptelephone.focus();return false;}
if(isEmptyString(frm_1.pemail.value.toString()))
{alert("Please Enter Principal's Email");frm_1.pemail.value="";frm_1.pemail.focus();return false;}
if(isEmptyString(frm_1.directorname.value.toString()))
{alert("Please Enter Director or Instructor Name");frm_1.directorname.value="";frm_1.directorname.focus();return false;}
if(isEmptyString(frm_1.dtelephone.value.toString()))
{alert("Please Enter Director or Instructor's Telephone number.");frm_1.dtelephone.value="";frm_1.dtelephone.focus();return false;}
if(isEmptyString(frm_1.demail.value.toString()))
{alert("Please Enter Director or Instructor's Email");frm_1.demail.value="";frm_1.demail.focus();return false;}
if(isEmptyString(frm_1.studentlist.value.toString()))
{alert("Please Enter the list of students");frm_1.studentlist.value="";frm_1.studentlist.focus();return false;}}
function selfclose(){if(!self.opener){self.opener=window.parent;}
self.close();}
function PostASLAForm(frm_1)
{var filter_email=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;var filter_phone=/^([\d]{3}-\d{3}-\d{4})$/i;if(isEmptyString(frm_1.registrantname.value.toString()))
{alert("Please Enter Name");frm_1.registrantname.value="";frm_1.registrantname.focus();return false;}
if(isEmptyString(frm_1.emailaddress.value.toString()))
{alert("Please Select Email Address");frm_1.emailaddress.value="";frm_1.emailaddress.focus();return false;}else if(!filter_email.test(frm_1.emailaddress.value)){alert("Please enter a valid Email Address\neg: user@domain.com!");frm_1.emailaddress.focus();return false;}
if(isEmptyString(frm_1.circuitname.value.toString()))
{alert("Please Select Circuit Name");frm_1.circuitname.value="";frm_1.circuitname.focus();return false;}
if(isEmptyString(frm_1.circuittitle.value.toString()))
{alert("Please Enter Title");frm_1.circuittitle.value="";frm_1.circuittitle.focus();return false;}
if(isEmptyString(frm_1.circuitmailingaddress.value.toString()))
{alert("Please Enter Circuit Mailing Address");frm_1.circuitmailingaddress.value="";frm_1.circuitmailingaddress.focus();return false;}
if(isEmptyString(frm_1.telephone.value.toString()))
{alert("Please Enter Phone");frm_1.telephone.value="";frm_1.telephone.focus();return false;}else if(!filter_phone.test(frm_1.telephone.value)){alert("Please enter a valid Phone\n in the format eg:323-123-4567!");frm_1.telephone.focus();return false;}}
function updateSchoolName(ele,curIncr,totalS){ele.value=ele.value.toUpperCase();if(curIncr==0){if(document.getElementById('schoolname_'+curIncr)){document.getElementById('schoolname_'+curIncr).value=ele.value;}
for(var i=0;i<totalS;i++){if(document.getElementById('list_school_group_'+i)){document.getElementById('list_school_group_'+i).innerHTML=ele.value;}}}else{if(document.getElementById('list_school_name_'+curIncr)){document.getElementById('list_school_name_'+curIncr).innerHTML=ele.value;}}}
function login_form_submit(frm){if(frm.UserPassword.value==""||frm.Username.value==""){alert("Username or Password cannot be empty!");if(frm.Username.value==""){frm.Username.focus();}else{frm.UserPassword.focus();}
return false;}}
