//get url parameter using
function gup(name){  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  var results = regex.exec( window.location.href );  if( results == null )    return "";  else    return results[1];}

function valappform(){
	if(document.appform.fname.value=="" || document.appform.lname.value==""){
		window.alert("Please make sure the followings are not empty:\n *Surname \n *Other names \n *Admission No.");
		return false;
	}
	if(document.appform.declaration.checked==false){
		window.alert("Please accept the declaration before proceeding.");
		return false;
	}
	if(document.appform.sex.value=="nill"){
		window.alert("Please select a valid gender");
		return false;
	}
	if(document.appform.religion.value=="nill"){
		window.alert("Please select a valid religion");
		return false;
	}
	if(document.appform.dob3.value==""){
		window.alert("Please enter a valid year of birth");
		return false;
	}
	
	if(document.appform.appclass.value=="nill"){
		window.alert("Please select a valid admission class");
		return false
	}
	
	return true;

}
//hide box
function hidePart(lid,hndlaid,flag){
		document.getElementById(lid).innerHTML='';
		document.getElementById(hndlaid).innerHTML='<a href="javascript:" onClick="showPart(\''+lid+'\',\''+hndlaid+'\',\''+flag+'\'); ret'+'urn fa'+'lse;"><font color="#ffffff">'+flag+'</font></a>';
	
}
//end hide box
function openurl(url){
	document.location.href=url;
}
//show box

function showPart(lid,hndlaid,flag){
	/*
	*lid==>the layer holding the sub-item, a little below the clickable item. 
	*hndlaid==> the layer holding the clickable item itself. this item changes on click the hold the a different cold entirely. 
	*Flag==>this is the title i.e the name written on the clickable item.
	*/
	if(flag == 'SCHOOL PORTAL'){		
		document.getElementById(lid).innerHTML='<div style="background:#CCFF99; border:solid thin #CCFF33; font:Geneva, Arial, Helvetica, sans-serif; font-size:13px"><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'ACADEMIC RESULT\',\'anim1\',\'jobdt\',\'schoolclient_login.php?arg=result\');">Check Result</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'STUDENT ASSIGNMENT\',\'anim1\',\'jobdt\',\'schoolclient_login.php?arg=pquestion\');">My Past Qustions</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'STUDENT ASSIGNMENT\',\'anim1\',\'jobdt\',\'schoolclient_login.php?arg=vexam\');">Virtual Exam</a> <hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'STUDENT ASSIGNMENT\',\'anim1\',\'jobdt\',\'schoolclient_login.php?arg=mprofile\');">My Profile</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'STUDENT ASSIGNMENT\',\'anim1\',\'jobdt\',\'schoolclient_login.php?arg=records\');">My Records</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'STUDENT ASSIGNMENT\',\'anim1\',\'jobdt\',\'schoolclient_login.php?arg=assignment\');">Online Assignment</a><hr /></div>';
	}
	if(flag == 'ABOUT US'){
		document.getElementById(lid).innerHTML='<div style="background:#CCFF99; border:solid thin #CCFF33; font:Geneva, Arial, Helvetica, sans-serif; font-size:13px"><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'OUR MISSION & VISION STATEMENT\',\'anim1\',\'jobdt\',\'mission.html\');">Our Mission & Vision</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'OUR SCHOOL POLICIES\',\'anim1\',\'jobdt\',\'policies.html\');">Our Policies</a> <hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'FROM THE DIRECTOR\\\'S DESK\',\'anim1\',\'jobdt\',\'aboutus.html\');">Director of School</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'OUR SCHOOL BOARD\',\'anim1\',\'jobdt\',\'borad.html\');">Our Team</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'CONTACT US\',\'anim1\',\'jobdt\',\'contactus.php\');">Contact Us</a><hr /></div>';
	}
	if(flag == 'ADMISSION'){
		document.getElementById(lid).innerHTML='<div style="background:#CCFF99; border:solid thin #CCFF33; font:Geneva, Arial, Helvetica, sans-serif; font-size:13px"><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'ONLINE ADMISSION\',\'anim1\',\'jobdt\',\'admission.html\');">Apply Online</a> <hr /><a href="javascript:" onClick="openurl(\'offlineform.doc\');">Download Admission Form</a><hr /></div>';
	}
	if(flag == 'ACTIVITIES'){
		document.getElementById(lid).innerHTML='<div style="background:#CCFF99; border:solid thin #CCFF33; font:Geneva, Arial, Helvetica, sans-serif; font-size:13px"><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'OUR BROAD CURRICULUM\',\'anim1\',\'jobdt\',\'curriculum.php\');">Curriculuar Activities</a><hr /><a href="#"  onClick="showDiv(\'postid\',\'350px\',\'OUR SCHOOL CALENDER\',\'anim1\',\'jobdt\',\'calender.php\');">Our Calender</a> <hr /><a href="javascript:"  onClick="showDiv(\'news\',\'400px\',\'NEWS LETTER\',\'\',\'content\',\'news.php\');">News & Events</a><hr /></div>';
	}
	if(flag == 'STAFF'){
		document.getElementById(lid).innerHTML='<div style="background:#CCFF99; border:solid thin #CCFF33; font:Geneva, Arial, Helvetica, sans-serif; font-size:13px"><a href="http://triplecrownschools.com/webmail">E-mail</a><hr /><a href="http://triplecrownschools.com/sms.html">SMS</a></div>';
	}
	document.getElementById(hndlaid).innerHTML='<a href="javascript:" onClick="hidePart(\''+lid+'\',\''+hndlaid+'\',\''+flag+'\'); ret'+'urn fa'+'lse;"><font color="#ffffff">'+flag+'</font></a>';
}
//end showbox


//drag object
//initialize
function hideDiv(id,anim){
	if(anim!=''){
		document.getElementById(anim).style.visibility='visible';	}
	document.getElementById(id).style.visibility='hidden';
	if(id=='postid'){
		document.getElementById('bgall').style.visibility='hidden';
	}
}
function showDiv(id,sze,hda,anim,lid,myurl){
	if(anim!=''){
		document.getElementById(anim).style.visibility='hidden';
	}
	document.getElementById(id).style.visibility='visible';
	if(sze == ''){
		document.getElementById(id).style.width='500px';
	}
	else{
		document.getElementById(id).style.width=sze;
	}
	document.getElementById('vtitle').innerHTML=hda;
	if(myurl!=''){
		togglenw(lid,myurl);
	}
}
//end initialize
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
if (!ns4)
return
temp=eval(name)
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)
temp.onmousedown=gons
temp.onmousemove=dragns
temp.onmouseup=stopns
}

function gons(e){
temp.captureEvents(Event.MOUSEMOVE)
nsx=e.x
nsy=e.y
}
function dragns(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}

function stopns(){
temp.releaseEvents(Event.MOUSEMOVE)
}

//drag drop function for ie4+ and NS6////
/////////////////////////////////


function drag_drop(e){
if (ie4&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx
crossobj.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
return false
}
}

function initializedrag(e){
crossobj=ns6? document.getElementById("postid") : document.all.postid
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "html" : document.compatMode && document.compatMode!="BackCompat"? "documentElement" : "body"
while (firedobj.tagName!=topelement.toUpperCase() && firedobj.id!="dragbar"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement
}

if (firedobj.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX
offsety=ie4? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}
document.onmouseup=new Function("dragapproved=false")



//end drab object
