var bgstr="<th background='images/header_row_bg.gif' style='background-repeat:repeat-x' border='0'>";
var bgstr1="<TH bgcolor='lightblue'>";
var DEFAULT_TABLE="<TABLE border=1 cellspacing=0 cellpadding=3 style='border-collapse: collapse' width='100%'>";

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"


var bouncelimit=32 //(must be divisible by 8)
var direction="up"
var wait_message="<br><br><br><br><p align='center'><img src='images/wait.gif'><font face='tahoma' size=4>&nbsp;<b>Please WAIT... Retrieving Information ...</font></p><br>";

function pad_20(strng)
{
	var loc="";
	for (var zz=0;zz<strng.length;zz++)
	{
		if (strng.substring(zz,zz+1)==" ")
			loc=loc+"%20";
		else
			loc=loc+strng.substring(zz,zz+1);
	}
	return loc;
}

function Display_BM(message)
{
	if (message!="" && message != " ")
		alert(message);
}

function initbox()
{	
	if (!dom&&!ie&&!ns4)
		return
	crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin	
	if (screen.width==800)
	{
		crossobj.left=50
	}
	else if(screen.width==1024)
	{
		crossobj.left=150
	}
	else
		crossobj.left=250

	crossobj.left=0
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	crossobj.top=scroll_top-250+calunits
	crossobj.visibility=(dom||ie)? "visible" : "show"
	dropstart=setInterval("dropin()",50)
}

function dropin()
{
	scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
	if (parseInt(crossobj.top)<50+scroll_top)
	{
		crossobj.top=parseInt(crossobj.top)+40+calunits
	}
	else
	{
		clearInterval(dropstart)
		bouncestart=setInterval("bouncein()",50)
	}
}

function bouncein()
{
	crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
	if (bouncelimit<0)
		bouncelimit+=8
	bouncelimit=bouncelimit*-1
	if (bouncelimit==0)
	{
	clearInterval(bouncestart)
	}
}

function dismissbox()
{
	if (window.bouncestart) clearInterval(bouncestart)
	crossobj.visibility="hidden"
}

function truebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function getCol(rwhash,colvalue)
{
	for (var z in rwhash)
	{
		if (z==colvalue)
			return rwhash[z];			
	}
}
function getColumn(rwstr,colvalue)
{
	var tmp="";
	var colpos=0;
	var blstr=0;
	var part1=0;
	var part2=0;
	var tmpstr1="";
	tmpstr1=rwstr;
	var tmp="";
	while (1)
	{
		part1=tmpstr1.indexOf(":");
		part2=tmpstr1.indexOf(",");
		
		if (colvalue==tmpstr1.substring(0,part1))
		{
			if (part2==-1)
			{
				tmp=tmpstr1.substring(part1+1);
				return tmp;
			}
			else
			{
				tmp=tmpstr1.substring(part1+1,part2);
				return tmp;
			}
		}
		colpos=colpos+1;

		if (part2==-1)
		{
			tmp="";
			break;
		}
		tmpstr1=tmpstr1.substring(part2+1);
		colpos=part2;
		if (colpos>=rwstr)
			break;
	}
	return tmp;
}

function ret_color(clrst)
{					
	var clrstring="";
	var clrtmp;
	var red;
	var blue;
	var green;
	
	clrstring=clrst;
	red=parseInt(clrstring.substring(0,clrstring.indexOf(",")));
	clrstring=clrstring.substring(clrstring.indexOf(",")+1);
	green=parseInt(clrstring.substring(0,clrstring.indexOf(",")));
	clrstring=clrstring.substring(clrstring.indexOf(",")+1);
	blue=parseInt(clrstring);
	clr="";
	clr=clr+red.toString(16);
	clr=clr+green.toString(16);
	clr=clr+blue.toString(16);
	clr="#"+clr;
	return clr;
}

function ShowError(handler)
{
	DWRUtil.useLoadingMessage("Loading...");
}
function MyCookie(name,val,domain,path)
  {
    this.name=name;
    this.value=val;
    this.domain=domain;
    this.path=path;
    var dtsec=new Date();
    dtsec.setSeconds(dtsec.getSeconds()+(60*60*24*3));
    this.expires=dtsec.toGMTString();
    this.toString=function()
    {
      return this.name+"="+this.value+"; expires="+this.expires+"; path="+this.path+"; domain="+this.domain;
    }
  }

function Get_Cookie(name) {
    if(typeof document.cookie == "string"){
        var start = document.cookie.indexOf(name+"=");
        var len = start+name.length+1;
        if ((!start)&&
            (name != document.cookie.substring(0,name.length))){
               return null;
           }
        if (start == -1) return null;
        var end = document.cookie.indexOf(";",len);
        if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(len,end));
    }else{
        /* document.cookie is not a string so return an
           empty string. When tested this will type-convert to
           boolean false (accurately) giving the impression that
           client-side cookies are not available on this system:-
        */
        return "";
    }
}

function callLogout()
{
	if (Get_Cookie("SessionID")==null || Get_Cookie("SessionID")=="" )
	{
		window.open("index.jsp","_parent");
		return;
	}
	var div=document.getElementById("txtHint");
	var el;
	var finstring;
	var st;
	var ss;
	var cls=0;
	var hint="";
	
	clear_session_settings();
	hint=hint+"<br><p align='center'><font face='tahoma' size=3>You have successfully Logged out of Web2School - Student Guardian</font></p>";
	hint=hint+"<tr><td align='center' fgcolor='BLUE' bgcolor='WHITE'>";
	hint=hint+"<FONT FACE='Tahoma' size=2 ><B><a href='index.jsp' target='_parent'>Login Here</a></B></FONT>";

	hint=hint+"</td></tr>";
	div.innerHTML=hint;
	//StuGrdClass.jsp
	//closeWindow();
	//window.close();
	//this.parent.close();
	//this.parent.parent.close();
}

function clear_session_settings()
{		
	document.cookie="Host="+'';
	document.cookie="Port="+'';
	document.cookie="CurrentSystemID="+'';
	document.cookie="Stu=''";
	document.cookie="UID="+'';
	document.cookie="PWD="+'';
	document.cookie="SessionID="+'';
	document.cookie="SchoolYear="+'';
	document.cookie="UserPersonnelID="+'';
	document.cookie="UserFullName="+'';
	document.cookie="Name"+"="+'';
	document.cookie="SchoolName"+"="+'';
	document.cookie="LoginMessage"+"="+'';
	document.cookie="BroadcastMessage"+"="+'';
	document.cookie="AttViewPer="+'';
	document.cookie="GBAssignView="+'';
	document.cookie="GradeView="+'';
	document.cookie="ProgressView="+'';
	document.cookie="TransView="+'';
	document.cookie="CourseRights="+'';
	document.cookie="CourseModify="+'';
	document.cookie="HealthView="+'';			
	document.cookie="DisciplineView="+'';			
	document.cookie="ScheduleView="+'';
	document.cookie="StandardView="+'';
	document.cookie="DefaultTerm="+'';
	document.cookie="CurrentContext="+'';
	var nc=Get_Cookie("NameCount");
	for (i=1;i<nc;i++)
	{
		document.cookie="s"+i+"="+'';
	}
	document.cookie="NameCount="+'';
	document.cookie="CurrentCalID="+'';

}
