var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all
var lastErr;
generateHelp();
generateError();
generateMsg();
generateSideHelp();
//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp


function hideMessageBox(){
	hideboxErr();
	return false;
}
function hideElement(elmID)
  {
  for (i = 0; i < document.all.tags(elmID).length; i++)
  {
   obj = document.all.tags(elmID)[i];
   obj.style.visibility = 'hidden';
  }
 }
 
 function showElement(elmID)
  {
   for (i = 0; i < document.all.tags(elmID).length; i++)
   {
    obj = document.all.tags(elmID)[i];
    obj.style.visibility = '';
   }
  }

function getImagePageLeft(img) {
  var x, obj;
  
  if (ns6) {
    if (img.container != null)
      return img.container.pageX + img.x;
    else
      return img.x;
  }
  if (ie4) {
    x = 0;
    obj = img;
    while (obj.offsetParent != null) {
      x += obj.offsetLeft;
      obj = obj.offsetParent;
    }
    x += obj.offsetLeft;
    return x;
  }
  return -1;
}

function getImagePageTop(img) {
  var y, obj;
  if (ns6) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  if (ie4) {
    y = 0;
    obj = img;
    while (obj.offsetParent != null) {
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    y += obj.offsetTop;
    return y;
  }
  return -1;
}

function getImage(name) {
    return eval('document.all.' + name);
  
}


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
crossobj.style.top=tempy+e.clientY-offsety
return false
}
}

function initializedrag(e)
{
	crossobj=ns6? document.getElementById("showimage") : document.all.showimage
	helpTxt=ns6? document.getElementById("hlpTxt") : document.all.hlpTxt
	
	crossobjErr=ns6? document.getElementById("showimageErr") : document.all.showimageErr
	//errTxt=ns6? document.getElementById("errTxt") : document.all.errTxt
	
	var firedobj=ns6? e.target : event.srcElement
	var topelement=ns6? "HTML" : "BODY"
	
	while (firedobj.tagName!=topelement&&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.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
}
////drag drop functions end here//////

function hideboxAll(){
hideboxErr();
hidebox();
hideboxGen();
hideboxSideHelp();
//alert('sd');
}

function hideboxErr(){
crossobjErr=ns6? document.getElementById("showimageErr") : document.all.showimageErr
//errTxt=ns6? document.getElementById("errTxt") : document.all.errTxt
//errTitle=ns6? document.getElementById("errTitle") : document.all.errTitle
if (ie4||ns6)
{
	crossobjErr.style.visibility="hidden"
}
else if (ns4)
{
	document.showimageErr.visibility="hide"
}
if(ie4) showElement('SELECT');
if(document.getElementById(lastErr) != null)
	setErrFocus(lastErr);
}

function hideboxGen(){
crossobjGen=ns6? document.getElementById("showimageGen") : document.all.showimageGen
//errTxt=ns6? document.getElementById("errTxt") : document.all.errTxt
//errTitle=ns6? document.getElementById("errTitle") : document.all.errTitle
if (ie4||ns6)
{
	crossobjGen.style.visibility="hidden"
}
else if (ns4)
{
	document.showimageGen.visibility="hide"
}
if(ie4) showElement('SELECT');
if(document.getElementById(lastErr) != null )
	setErrFocus(lastErr);
}

function hideboxSideHelp(){

crossobjSideHelp=ns6? document.getElementById("showimageSideHelp") : document.all.showimageSideHelp

if (ie4||ns6)
{
	crossobjSideHelp.style.visibility="hidden"
}
else if (ns4)
{
	document.showimageSideHelp.visibility="hide"
}

if(ie4) showElement('SELECT');
if(document.getElementById(lastErr) != null )
setErrFocus(lastErr);

}

function hidebox(){
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
//helpTxt=ns6? document.getElementById("hlpTxt") : document.all.hlpTxt
//helpTitle=ns6? document.getElementById("hlpTitle") : document.all.hlpTitle
if (ie4||ns6)
{
	crossobj.style.visibility="hidden"
}
else if (ns4)
{
	document.showimage.visibility="hide"
}
if(ie4) showElement('SELECT');
if(document.getElementById(lastErr) != null)
	setErrFocus(lastErr);

}

function showSideHelp(url,e,aImage,tHeight,tWidth){
hideboxAll();
crossobj=ns6? document.getElementById("showimageSideHelp") : document.all.showimageSideHelp
place = ns6? document.getElementById(aImage) : eval('document.all.' + aImage);


var TipBoxTop = getImagePageTop(place); // TIP BOX TOP POSITION
var TipBoxLeft =  getImagePageLeft(place); // TIP BOX LEFT POSITION

crossobj.style.left=TipBoxLeft+35;
crossobj.style.top=TipBoxTop;
crossobj.style.height=tHeight;
crossobj.style.width=tWidth;


if(ie4) hideElement('SELECT');

if (ie4||ns6)
{
crossobj.style.visibility="visible"
document.getElementById("cframe").src=url;
document.getElementById("cframe").style.height=tHeight -10;
document.getElementById("cframe").style.width=tWidth;

}
else if (ns4)
{
document.showimage.visibility="visible"
document.getElementById("cframe").src=url;
document.getElementById("cframe").style.height=tHeight -10;
document.getElementById("cframe").style.width=tWidth;

}

}

function showScrollHelp(url,e,aImage,tHeight,tWidth){
hideboxAll();
crossobj=ns6? document.getElementById("showimageSideHelp") : document.all.showimageSideHelp
place = ns6? document.getElementById(aImage) : eval('document.all.' + aImage);


var TipBoxTop = getImagePageTop(place); // TIP BOX TOP POSITION
var TipBoxLeft =  getImagePageLeft(place); // TIP BOX LEFT POSITION

crossobj.style.left=TipBoxLeft;
crossobj.style.top=TipBoxTop;
crossobj.style.height=tHeight;
crossobj.style.width=tWidth;


if(ie4) hideElement('SELECT');



if (ie4||ns6)
{
crossobj.style.visibility="visible"
document.getElementById("cframe").src=url;
document.getElementById("cframe").style.height=tHeight -10;
document.getElementById("cframe").style.width=tWidth;

}
else if (ns4)
{
document.showimage.visibility="visible"
document.getElementById("cframe").src=url;
document.getElementById("cframe").style.height=tHeight -10;
document.getElementById("cframe").style.width=tWidth;

}

}

function show(title,txt,e,aImage){
//hideboxAll();
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
helpTxt=ns6? document.getElementById("hlpTxt") : document.all.hlpTxt
helpTitle=ns6? document.getElementById("hlpTitle") : document.all.hlpTitle
place = ns6? document.getElementById(aImage) : eval('document.all.' + aImage);

var TipBoxTop = getImagePageTop(place); // TIP BOX TOP POSITION
var TipBoxLeft =  getImagePageLeft(place); // TIP BOX LEFT POSITION
 
crossobj.style.left=TipBoxLeft;
crossobj.style.top=TipBoxTop;

if(ie4) hideElement('SELECT');



if (ie4||ns6)
{
helpTxt.innerHTML = txt;
helpTitle.innerHTML = title;
crossobj.style.visibility="visible"
}
else if (ns4)
{
document.helpTxt.innerHTML = txt;
document.helpTitle.innerHTML = title;
document.showimage.visibility="visible"
}

} 

function showHelp(title,txt,e,aImage){
hideboxAll();
crossobj=ns6? document.getElementById("showimage") : document.all.showimage
helpTxt=ns6? document.getElementById("hlpTxt") : document.all.hlpTxt
helpTitle=ns6? document.getElementById("hlpTitle") : document.all.hlpTitle
place = ns6? document.getElementById(aImage) : eval('document.all.' + aImage);

var TipBoxTop = getImagePageTop(place); // TIP BOX TOP POSITION
var TipBoxLeft =  getImagePageLeft(place); // TIP BOX LEFT POSITION

crossobj.style.left=TipBoxLeft+10;
crossobj.style.top=TipBoxTop;




if(ie4) hideElement('SELECT');



if (ie4||ns6)
{
helpTxt.innerHTML = txt;
helpTitle.innerHTML = title;
crossobj.style.visibility="visible"
}
else if (ns4)
{
document.helpTxt.innerHTML = txt;
document.helpTitle.innerHTML = title;
document.showimage.visibility="visible"
}

}

function showErr(title,txt){
crossobjErr=ns6? document.getElementById("showimageErr") : document.all.showimageErr
if (ns6)
{
errTxt=ns6? document.getElementById("errTxt") : document.all.errTxt
errTitle=ns6? document.getElementById("errTitle") : document.all.errTitle
}

 	var clientHeight;
 	var clientWidth;
 	var docTop;
 	var docLeft;
if(ie4){
 hideElement('SELECT');
}	
     if (ie4) 
     {
       clientHeight = document.body.clientHeight;
       clientWidth = document.body.clientWidth;
       docTop = document.body.scrollTop;
       docLeft = document.body.scrollLeft;
     } 
     else if (ns6)
     {
       // Fudge for the scrollbars
       clientHeight = window.innerHeight -20;
       clientWidth = window.innerWidth - 20;
       docTop = window.pageYOffset;
       docLeft = window.pageXOffset;
     }

if (ie4||ns6)
{
errTxt.innerHTML = txt;
//errTitle.innerHTML = title;
crossobjErr.style.visibility="visible"
}
else if (ns4)
{
document.errTxt.innerHTML = txt;
//document.errTitle.innerHTML = title;
document.showimageErr.visibility="visible"
}
var errHeight = crossobjErr.style.width;
//alert(crossobjErr.style.width);
//alert(errHeight);
crossobjErr.style.left=(docLeft + clientWidth/2) - 180 ;
crossobjErr.style.top=(docTop + clientHeight/2) - 125;
//crossobjErr.style.left=250 ;
//crossobjErr.style.top=70;

//alert(txt);
}



function showMsg(heading,title,txt,errFocus){
lastErr = errFocus;
tempFocus=ns6? document.getElementById("btnCls") : document.all.btnCls
crossobjGen=ns6? document.getElementById("showimageGen") : document.all.showimageGen
if (ns6)
{

GenTxt=ns6? document.getElementById("GenTxt") : document.all.GenTxt
GenTitle=ns6? document.getElementById("GenTitle") : document.all.GenTitle
GenHead=ns6? document.getElementById("GenHead") : document.all.GenHead
}

 	var clientHeight;
 	var clientWidth;
 	var docTop;
 	var docLeft;
 if(ie4){
  hideElement('SELECT');
 }	
     if (ie4) 
     {
       clientHeight = document.body.clientHeight;
       clientWidth = document.body.clientWidth;
       docTop = document.body.scrollTop;
       docLeft = document.body.scrollLeft;
     } 
     else if (ns6)
     {
       // Fudge for the scrollbars
       clientHeight = window.innerHeight -20;
       clientWidth = window.innerWidth - 20;
       docTop = window.pageYOffset;
       docLeft = window.pageXOffset;
     }

if (ie4||ns6)
{
GenTxt.innerHTML = txt;
GenTitle.innerHTML = title;
GenHead.innerHTML = heading;
crossobjGen.style.visibility="visible"
}
else if (ns4)
{
document.GenTxt.innerHTML = txt;
document.GenTitle.innerHTML = title;
document.GenHead.innerHTML = heading;
document.showimageGen.visibility="visible"
}
var GenHeight = crossobjGen.style.width;
//alert(crossobjErr.style.width);
//alert(errHeight);
crossobjGen.style.left=(docLeft + clientWidth/2) - 180 ;
crossobjGen.style.top=(docTop + clientHeight/2) - 125;
//crossobjErr.style.left=250 ;
//crossobjErr.style.top=70;

}

function generateHelp(){
document.write("<div id='showimage' style='position:absolute;width:250px;left:410;top:200;z-index:999'>");
document.write("<table border='0' width='250' bgcolor='#026FC2' cellspacing='0' cellpadding='2'>");
document.write("  <tr>");
document.write("    <td width='100%'><table border='0' width='100%' cellspacing='0' cellpadding='0'");
document.write("    height='36'>");
document.write("      <tr>");
document.write("        <td id='dragbar' style='cursor:hand' width='100%' ><ilayer width='100%' onSelectStart='return false'>");
document.write("              <layer  width='100%' onMouseover='dragswitch=1;if (ns4) drag_dropns(showimage)' onMouseout='dragswitch=0'><font face='Verdana'");
document.write("        color='#FFFFFF' face='verdana' size='1' style='padding:10px'><b>Help</b></font></layer>");
document.write("              </ilayer></td>");
document.write("        <td style='cursor:hand'><a href='#' alt='Next (Alt-C)' onClick='hidebox();return false'><img src='/img/page_blue.gif' width='12'");
document.write("        height='14' border=0></a></td>");
document.write("      </tr>");
document.write("      <tr>");
document.write("            <td width='100%' bgcolor='#FFFFFF' style='padding:10px' colspan='2'>");
document.write("              <b><font id='hlpTitle' face='verdana' size='1' color='#000000'>&nbsp;</font></b>");
document.write("              <hr size='1' noshade color='#3366CC'>");
document.write("              <div align='justify'><font id='hlpTxt' face='verdana' size='1'  color='#000000' >&nbsp;</font></div>");
document.write("            </td>");
document.write("      </tr>");
document.write("    </table>");
document.write("    </td>");
document.write("  </tr>");
document.write("</table>");
document.write("</div>");
hidebox();
}

function generateError(){
document.write("<div id='showimageErr' style='position:absolute;width:250px;left:410;top:200;z-index:999'>");
document.write("<table border='0' width='350' bgcolor='red' cellspacing='0' cellpadding='2'>");
document.write("  <tr>");
document.write("    <td width='100%'><table border='0' width='100%' cellspacing='0' cellpadding='0'");
document.write("    height='36'>");
document.write("      <tr>");
document.write("        <td id='dragbarErr'  width='100%' ><ilayer width='100%' onSelectStart='return false'>");
document.write("              <layer  width='100%' onMouseover='dragswitch=1;if (ns4) drag_dropns(showimageErr)' onMouseout='dragswitch=0'><font face='Verdana'");
document.write("        color='#FFFFFF' face='verdana' size='1' style='padding:10px'><b>Error in Submit</b></font></layer>");
document.write("              </ilayer></td>");
document.write("        <td style='cursor:hand'><a href='#' alt='Next (Alt-C)' onClick='hideboxErr();return false'><img src='/img/close_crossed.gif' width='12'");
document.write("        height='14' border=0></a></td>");
document.write("      </tr>");
document.write("      <tr>");
document.write("            <td width='100%'  bgcolor='#FFFFFF' style='padding:10px' colspan='2'>");
document.write("              <b><font id='errTitle' face='verdana' size='1' color='#000000'>Following Errors Occured</font></b>");
document.write("              <hr size='1' noshade color='red'>");
document.write("              <div align='justify'><font id='errTxt' face='verdana' size='1'  color='#000000' >&nbsp;</font></div>");
document.write("            </td>");
document.write("      </tr>");
document.write("      <tr>");
document.write("        <td bgcolor='#FFFFFF' align='center' colspan='2' ><a href='#' onClick='hideboxErr();return false'><font ");
document.write("         face='verdana' size='1'  color='#000000' >Close</a> [Alt-C]</td>");
document.write("      </tr><tr><td bgcolor='#FFFFFF' height='3' colspan='2'>&nbsp;</td></tr>");
document.write("    </table>");
document.write("    </td>");
document.write("  </tr>");
document.write("</table>");
document.write("</div>");
hideboxErr();
}

function generateMsg(){
document.write("<div id='showimageGen' style='position:absolute;width:250px;left:410;top:200;z-index:999'>");
document.write("<table border='0' width='350' bgcolor='red' cellspacing='0' cellpadding='2'>");
document.write("  <tr>");
document.write("    <td width='100%'><table border='0' width='100%' cellspacing='0' cellpadding='0'");
document.write("    height='36'>");
document.write("      <tr>");
document.write("        <td id='dragbarGen'  width='100%' ><ilayer width='100%' onSelectStart='return false'>");
document.write("              <layer  width='100%' onMouseover='dragswitch=1;if (ns4) drag_dropns(showimageGen)' onMouseout='dragswitch=0'><b><font id='GenHead' face='Verdana'");
document.write("        color='#FFFFFF' face='verdana' size='1' style='padding:10px'>Error in Input</font></b></layer>");
document.write("              </ilayer></td>");
document.write("        <td style='cursor:hand'><a href='#' onClick='hideboxGen();return false'><img src='/img/close_crossed.gif' width='12'");
document.write("        height='14' border=0></a></td>");
document.write("      </tr>");
document.write("      <tr>");
document.write("            <td width='100%'  bgcolor='#FFFFFF' style='padding:10px' colspan='2'>");
document.write("              <b><font id='GenTitle' face='verdana' size='1' color='#000000'>Following Errors Occured</font></b>");
document.write("              <hr size='1' noshade color='red'>");
document.write("              <div align='justify'><font id='GenTxt' face='verdana' size='1'  color='#000000' >&nbsp;</font></div>");
document.write("            </td>");
document.write("      </tr>");
document.write("      <tr>");
document.write("        <td bgcolor='#FFFFFF' align='center' colspan='2' ><a href='#' onClick='hideboxGen();return false'><font ");
document.write("         face='verdana' size='1'  color='#000000' >Close</a></td>");
document.write("      </tr><tr><td bgcolor='#FFFFFF' height='3' colspan='2'>&nbsp;</td></tr>");
document.write("    </table>");
document.write("    </td>");
document.write("  </tr>");
document.write("</table>");
document.write("</div>");
hideboxGen();
}

function generateSideHelp(){
document.write("<div id='showimageSideHelp' style='position:absolute;width:250px;left:410;top:200;z-index:999'>");
document.write("<table border='0' width='100%' height='100%' bgcolor='#026FC2' cellspacing='0' cellpadding='2'>");
document.write("  <tr valign='top'>");
document.write("    <td width='100%'><table border='0' width='100%' cellspacing='0' cellpadding='0'");
document.write("    height='100%' >");
document.write("      <tr valign='top'>");
document.write("        <td id='dragbar' style='cursor:hand' width='100%' ><ilayer width='100%' onSelectStart='return false'>");
document.write("              <layer  width='100%' onMouseover='dragswitch=1;if (ns4) drag_dropns(showimageSideHelp)' onMouseout='dragswitch=0'><font face='Verdana'");
document.write("        color='#FFFFFF' face='verdana' size='1' style='padding:10px'><b>Help</b></font></layer>");
document.write("              </ilayer></td>");
document.write("        <td style='cursor:hand'><a href='#' alt='Next (Alt-C)' onClick='hideboxSideHelp();return false'><img src='/img/page_blue.gif' width='12'");
document.write("        height='14' border=0></a></td>");
document.write("      </tr>");
document.write("      <tr valign='top'>");
document.write("            <td width='100%' height='100%' bgcolor='#FFFFFF' style='padding:10px' colspan='2'>");
document.write("              <iframe id='cframe' src='/empty.html' ></iframe>");
document.write("            </td>");
document.write("      </tr>");
document.write("    </table>");
document.write("    </td>");
document.write("  </tr>");
document.write("</table>");
document.write("</div>");
hideboxSideHelp();
}

//new function for help table


/***********************************************
* Highlight Table Cells Script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TD"

//var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e){
var highlightcolor = '#EAEAEA';	
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}



// end help table 

