/*
----------------------------------------------------------------------------------------
	Copyright: Element Electronic Media
	This Code May Not Be Duplicated Without
	The  Written Consent of Element Electronic Media
	info@element.co.za
-----------------------------------------------------------------------------------------

*/


// do not change inittotalzoom is not what you think it is. 

// To change the default zoom value change it in the zoommenu dropdown box


function select_drop(dropbox, selectedvalue)

// function to select a specific value in a drop down box

{
	for (t = 0; t < dropbox.options.length ; t++ )

	{
		if (dropbox.options[t].value == selectedvalue)

		{

			dropbox.selectedIndex= t;

			return true;

		}

	}

	return false;

}




function loadpage(pageType)
{
// load a page in main frame according to pageType
// -1 = Previous page
//  0 = Current page
// +1 = Next page

//	 checkfile();

//	alert (activefile);
	activefile= parseInt(activefile) + parseInt (pageType);
//	if (pageType == 0)
	if (activefile > lastfile )
	{
//		alert(pageType == 0);
//		alert(activefile > lastfile);

		activefile =firstfile;	
//	alert (activefile);
	}	

	if (activefile < firstfile )

	{
		activefile =lastfile;	
//	alert (activefile);
	}	

//	tfile =parent.main.location;

 	newfile = filepath + filename +activefile +fileext;

	parent.main.location= newfile;



	theform.zoomVal.value=inittotalzoom;

//	newZoomValue(0);


//	alert (activefile);

	return false;

}







function loadfirst(pageType)

{
// load a page in main frame according to pageType
// -1 = Previous page
//  0 = Current page
// +1 = Next page

//	alert (activefile);
	activefile= 1;

 	newfile = filepath + filename +activefile +fileext;
	parent.main.location= newfile;



	theform.zoomVal.value=inittotalzoom;
	return false;

}






function change_page()

{
	lastval='';
	boxval = theform.contentdropdown.options[theform.contentdropdown.selectedIndex].value;
//	check if boxval is an iteger
//	if not get last value of boxval
	activefile = parseInt(boxval);
	a = String (activefile);
	if (a.length != boxval.length)
	{
		lastval = boxval.substr( a.length, boxval.length);
	}
//	alert (lastval);
 	newfile = filepath + filename +activefile +fileext+lastval;
	parent.main.location= newfile;
	theform.zoomVal.value=inittotalzoom;

//	alert (activefile);


}


function print_page()

{

	select_drop(theform.zoommenu, '80');

	newZoomValue(0);

	parent.main.focus();

	parent.main.print();

}







function MM_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=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}

function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}

function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_preloadImages() { //v3.0

 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}


function checkfile()
{
//	t = "test";
//	t = parent.main.location;
	t = '3'+parent.main.location;
//	alert (t);
	t = String (t);
//	alert (t);
	var	firstPos = t.indexOf(filename);
//	alert (firstPos);
	if (firstPos != -1)
	{
//		alert (t);
		firstPos += filename.length;
		t = t.substring(firstPos,t.length);
		var	lastPos =  t.indexOf(fileext);	
		t = t.substring(0,lastPos);
//		alert ('t = ' &t);
		if (t !='' &&  t != activefile)
		{
//			activefile = t;
//			alert (t);
		}	
	}
}
