//<!--

function getNumber()
{
	myString = new String(parent.main.location.href);
	var findString = '.htm';
	tvar = (myString.indexOf(findString,0));
	pageNumber = 0;
	for (x=1;x<5;x++)
	{
		tempString = (myString.substr((tvar-x),x))
		if (!isNaN(tempString))
		// is number
		{
			pageNumber = tempString;
		}
		else
		// not numeric
		{
			x = 10;

		}
	}
	return pageNumber;
}

function SetPageTitles()
{
	document.navForm.Title.value = parent.main.document.title;

	//thenum = getNumber();
	//if (thenum == 0)
	//{
	//	document.navForm.PageCounter.value = '';
	//}
	//else
	//{
	//	document.navForm.PageCounter.value = 'Page ' + thenum + ' of  '+ lastfile;
	//}
}
function SetPageTitlesBottom()
// set page titles when
// clicking through from a search link
{
	if (!parent.nav){
	
	}
	else{
		parent.nav.navForm.Title.value = parent.main.document.title;
	
		thenum = getNumber();
		if (thenum == 0)
		{
				parent.nav.navForm.PageCounter.value = '';
		}
		else
		{		
				parent.nav.navForm.PageCounter.value = 'Page ' + thenum + ' of  '+ lastfile;	
		}	
	}
}

function movePage(theVar)
{
	myString = new String(parent.main.location.href);
	var findString = '.htm';
	tvar = (myString.indexOf(findString,0));
	endpart = myString.substr(tvar);
	/* If a named anchor indicated by a # exits in the url remove it  */
	var hash = (endpart.indexOf('#',0));
	if (hash>=0){
		endpart = '.html';
	}
	countnumbers=0;
	for (x=1;x<5;x++)
	{
		tempString = (myString.substr((tvar-x),x))
		
		if (!isNaN(tempString))
		// is number
		{
			pageNumber = tempString;
			countnumbers=countnumbers+1;		
		}
		else
		// not numeric
		{
			// exit		
			firstpart = (myString.substr(0,(tvar-x)+1));
			x = 10;
		}
	}
	
	if (countnumbers == 0){
		if (gPageBaseUrl==""){
			parent.main.location.href = gPageNotFoundUrl;
		}
		else{	
			parent.main.location.href = gPageBaseUrl + "1.html";
		}
	}
	else{
		pageNumber = parseInt(pageNumber) + (parseInt(theVar));
		if (pageNumber < firstfile)
		{	pageNumber = lastfile;}
		if (pageNumber > lastfile)
		{	pageNumber = firstfile;}
		parent.main.location.href = firstpart + pageNumber +endpart;
		gPageBaseUrl = firstpart;
		pageLoop();
	}
	
	
}
		
function movePageSpecific(theVar, theAnchor)
{
	var hash;
	if ((theVar=="")||(gPageBaseUrl=="")){
		parent.main.location.href = gPageNotFoundUrl;
	}
	else{
		if (theAnchor==""){
			hash = "";
		}else{
			hash = "#";
		}
		parent.main.location.href = gPageBaseUrl + theVar + ".html"+hash+theAnchor;
		pageLoop();
	}
}	
function pageLoop()
{	
	SetPageTitles();
	setTimeout('pageLoop()',100);
}


function movePageHomelink(theVar)
{
	if (theVar==""){
		//parent.main.location.href = "botframe.html"
		parent.main.location.href = gPageHomelink+"1.html";
	}
	else{
		parent.main.location.href = gPageHomelink + theVar + ".html";
		//setTimeout('SetPageTitles()',100);
		//setTimeout('SetPageTitles()',10000);
	}
}	
function selectMenuNav(selectmenu)
{
	var menuindex = selectmenu.selectedIndex;
	var menuvalue = selectmenu.options[menuindex].value;
	var splitString = menuvalue.split("#");
	var pg = (splitString[0]);
	var pganchor = (splitString[1]);
	movePageSpecific(pg,pganchor);
}
function getPDFpage(pagenum){
	var pdffile;
	var pdflink;
	if (pagenum>0&&pagenum<10){
		zero = "000";
	}
	else if (pagenum>=10&&pagenum<100){
		zero = "00";
	}
	else if (pagenum>=100){
		zero = "0";
	}
	
//	alert(pagenum);
	if (pagenum=='' ){
				pdffile = "http://telkom.quickreport.co.za/telkom_ar_2005/index.htm";	
					return pdffile;
	}
	else{
		pdffile = "downloads/pg/pg"+zero+parseInt(pagenum)+".pdf";
		return pdffile;
	}
	return pdffile;

}
function winClose()
{
		if (!win.closed){
			win.close();	
		}
		else {
			return false;			
		}
}
function printthispage()
{
	pagenum = getNumber();
	pdflink = getPDFpage(pagenum);		
	win = window.open(pdflink,"",'top=300,left=400,width=10,height=10');
	//win.document.write("<html><head><title>Print PDF");
 	//win.document.write("</title></head><body>");
  	//win.document.write("<span style=\"font-family:arial;font-size:11px;\">");
  	//win.document.write("<b>PRINT PDF</b><br>This window will ");
   //win.document.write("close automatically ");
  	//win.document.write("</font>");
  	//win.document.write("</body></html>");

	//win.location.href=pdflink;	
	//setTimeout("winClose()",5000);
}
function printNow()
{
	pagenum = getNumber();
	pdfpage = getPDFpage(pagenum);	
	win.location.href="downloads/financials.xls";
	alert ("1");
	win.alert("here I am");
	win.print();
		alert ("2");
	//win.close();
}
function gotoInPage(strtxt) {
	var txt, i, found;
	if (strtxt == "")	return false;
	if (gBrowser==NN) {
		if (!win.find(strtxt)) {
			gFoundSearchItem = true;
			while(win.find(strtxt, false, true))
			n++;
		} else n++;
		if (n == 0) {
			gFoundSearchItem = false;
			//alert(str + " was not found on this page.");
		}
	}

	if (gBrowser==IE) {
		txt = win.document.body.createTextRange();
		for (i = 0; i <= n && (found = txt.findText(strtxt)) != false; i++) {
			txt.moveStart("character", 1);
			txt.moveEnd("textedit");
		}
		if (found) {
			gFoundSearchItem = true;
			txt.moveStart("character", -1);
			txt.findText(strtxt);
			txt.select();
			txt.scrollIntoView();
			n++;
		}
		else {
			if (n > 0) {
			n = 0;
			findInPage(strtxt);
		}
		else {
			gFoundSearchItem = false;
			//alert(str + " was not found on this page.");
			}
		}
	}
return false;
}
function follow(n,el) { 
if(document.images){ 
(new Image()).src="stats.gif%3Fcontrol="+n; 
} 
return true;} 
//--> 
