/*************************************************************
*  BiSCfuncs contains Javascript functions to generate
*  tables in the TOPFRAME and tables in the LEFTFRAME
*
*  It also contains other Javascript functions
*
 *<componentinfo>Product MVrenegoor</componentinfo>
 *<versioninfo>4.00 (2010-09-28)</versioninfo>'
 *<changeinfo> 4.00 (2010-09-28);tvl;</change> 
**************************************************************/
var ScreenPos = 0;			//Current position for scrolling
var ScreenStep = 0;			//Step used by scrolling
var ScreenPosToReach=0;	//End postion to reach

var OldbgColor="";
var OldClassName="";

/*************************************************************
*  Event to scroll window down
*
*	This function is called to have the main window scrolled down
**************************************************************/
function mScrollDown()
{
	ScreenPosToReach=320;
	ScreenStep = 16;
	window.setTimeout("bScroll()",40)
//	parent.main.scrollBy(0,174);
}
/*************************************************************
*  Event to scroll window up
*
*	This function is called to have the main windwo scroll up
**************************************************************/
function mScrollUp()
{
	ScreenPosToReach=-320;
	ScreenStep = -16;
	window.setTimeout("bScroll()",40)
//	parent.main.scrollBy(0,-174);
}
/*************************************************************
*  Event to scroll window up
*
*	This function is called to have the main windwo scroll up
**************************************************************/
function bScroll()
{
	parent.main.scrollBy(0,ScreenStep);
	ScreenPos = ScreenPos+ScreenStep;
	x=Math.abs(ScreenPos);
	y=Math.abs(ScreenPosToReach);
	
	if(x<y)
	{
		window.setTimeout("bScroll()",10);		
	}
	else
	{
		ScreenPos=0;
		ScreenStep=0;
		ScreenPosToReach=0;
	}
}
/*********************************************************************
'* Function    : TROver                                              *
'* Parameters  : None                                                *
'* returns     : None                                                *
'* purpose     : To highlite row we are on                           *
'*                                                                   *
'********************************************************************/
function TROver(RowId)
{
	objx=BBB_findObj(RowId);
	OldClassName=objx.className;
	objx.className=OldClassName+"_H";
//	document.body.style.cursor='pointer';
}
/*********************************************************************
'* Function    : TROut                                               *
'* Parameters  : None                                                *
'* returns     : None                                                *
'* purpose     : To highlite row we are on                           *
'*                                                                   *
'********************************************************************/
function TROut(RowId)
{
	objx=BBB_findObj(RowId);
	objx.className=OldClassName;	
//	document.body.style.cursor='default';
}
/*************************************************************
*  ReplacePage
**************************************************************/
function ReplacePage( pType)
{	
//	alert("Ja");
	myBody = document.getElementsByTagName("body")[0];
  myBodyElements = myBody.getElementsByTagName("table");	
	nr=myBodyElements.length;
	
//	nr=document.all.length;
	
//	alert(nr);

	for(i=0;i<nr;i++)		//field with ID raised
	{
		myP = myBodyElements[i];
		id=myP.id;
			
		u=id.split("=");
//		alert(u+" - "+u[0]);
		
		if(u[0]=="?state")
		{
//			alert("id="+id);
			
			if(id != "")			//if field with id is found
			{
				s = location.href;	//get url part
				x = s.split("?");
				l = x.length;

//				alert("url="+s);
			
				if(l > 0)
				{
					s = x[0];		//is url part
				}
			}
			location.replace(s+id+"&key="+pType);		//old key plus requested type    
      break;
		}
	}	    
}

/*************************************************************
*  function to set arrows as requested in ID
**************************************************************/
function SetArrows()
{
	myBody = document.getElementsByTagName("body")[0];
  myBodyElements = myBody.getElementsByTagName("table");	
	nr=myBodyElements.length;

	id="";
	for(i=0;i<nr;i++)
  {
  	myP = myBodyElements[i];
		id=myP.id;
      
    u=id.split("=");
//		alert(u+" - "+u[0]);
		
		if(u[0]=="?state")
		{
//			alert("id="+id);
      
      
    	if(id != "")
      {
        	break;
      }
   	}
  } 

   if(id!="")
   {
      x=id.split("sort=");
      for(j=1;j<4;j++)
      {
         DoArrow(j,x[1].substring(j-1,j));
      }
      x=id.split("vwr=");
      if(x[1].substring(0,6)!="agenda")		//if it is a speelijst we need to change the picture
      {
     		for (i=0;i < document.images.length; i++)
    		{
       		if(document.images[i].name == "listtype")
       		{
            	document.images[i].src="../afb/gif/agenda_kop_speellijst.gif";
          		break;
          }
       	}
      }
   }		        
}
/*************************************************************
*  Do the arrow as it should be
**************************************************************/
function DoArrow(nr,pos)
{
   img="Img"+nr;

//	alert(img+"-"+pos);

    for (i=0;i < document.images.length; i++)
    {
       if(document.images[i].name == img)
       {
          if(pos==4)		//4 is SORT_ASC
          {
             document.images[i].src="../afb/gif/pijltje_neer_oranje_agenda.gif";
          }
          else
          {
             document.images[i].src="../afb/gif/pijltje_op_oranje_agenda.gif";
          }
          break;
       }
     }
}
/*********************************************************************
'* Function    : BBB_findobj                                         *
'* Parameters  : None                                                *
'* returns     : None                                                *
'* purpose     : To highlite row we are on                           *
'*                                                                   *
'********************************************************************/
function BBB_findObj(n, d) 
{ //v4.01
  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=BBB_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); 
  return x;
}	
