


//sets powered by layer position:
function setFooter(){
	foot=document.getElementById("footer");
	foot.style.visibility='visible';
	foot.style.position="relative";
	var x=0; var obj=foot; while(obj.offsetParent!=null){x+=obj.offsetTop; obj=obj.offsetParent;} x+=obj.offsetTop;
  bodyHeight=window.innerHeight?window.innerHeight:document.body.clientHeight;
  
  //footHeight=foot.clientHeight?foot.clientHeight:foot.getElementsByTagName('table')[0].clientHeight;
  footHeight=140;
  //alert(x+' :: '+bodyHeight+' :: '+footHeight);
	if(x<(bodyHeight-footHeight)){foot.style.top=bodyHeight-footHeight-x;}
}


//this function changes text for TextOperation textfield on mouseover.
function showTextOperation(strTitle){
	//document.getElementById('TextOperation').value = strTitle;
	return true;
}

//!for 
function currentOp(){
	return document.big_form.operation.value;
}

//can this html page to be printed?
function canPrint(){
	if (currentOp() == 'tonotepage' || currentOp() == 'contents'){
		return true;
	}else{
		return false;
	}
}

function getThePg(intNum){
	return parseInt(intNum+intPageNr1-1);
}

function isOnHTMLPageNow(){	   
	if (currentOp() == 'sitemap' || currentOp() == 'contents' || currentOp() == 'downloadpdf' || currentOp() == 'search' ||  currentOp() == 'tonotepage'){
		return true;	
	}else{
		return false;
	}
}

var varRequiresSubmit = -1;//false=0, true=1
function requiresSubmit(intNum, strOp){
	if (isOnHTMLPageNow()) {
		//return true;
		varRequiresSubmit = 1;
	} else {// in the AR.img page now
		if (isHTMLPage(intNum)) {// img -> html
			//return true;
			varRequiresSubmit = 1;
		}else {// img -> img
			//return false;
			varRequiresSubmit = 0;
		}
	}
	return false;
}

function isHTMLPage(intNum){
	var retValue = false;
	if(isNotePage(intNum)){
		retValue = true;
	}else if (intNum==intContentsIndex){
		retValue = true;
	}else{
		retValue = false;
	}
	return retValue;
}

//arrNoteNums, arrNotePageNum
function getPageNumForNotenum(notenum){
	var i;	
	//alert(notenum);
	for(i = 0; i < arrNotes.length; i++){
		if(((new String(arrNotes[i][1])).search('^'+notenum+'$'))>=0){			
			//alert('succesful search=arrNotes['+i+'][0]='+arrNotes[i][1]);
			break;
		}
	}
	//alert('intPageNr1='+intPageNr1+',arrNotes['+i+'][0]='+arrNotes[i][0]+', topage: '+(parseInt(arrNotes[i][0])+intPageNr1-1));
	return parseInt(arrNotes[i][0])+intPageNr1-1;
}

function isNotePage(intNum){
	if(arrNoteFiles.length>0){
		for(var i=0;i<arrNoteFiles.length;i++){
			if(arrNoteNum[i]==intNum){
				return true;
				break;
			}
		}
	}else{
		return false;
	}
}


function help(strUrl){
    var c;//this the url we open.                   
    c='http://www.euroland.com/arinhtml/s-cap/2002/AR_ENG';
	//alert('help coming...');
	a=window.open(escape(strUrl),'miniwin','width=550, height=560, toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1');
}

function SendURL(){
	//alert('send');
    var a;
    var b=window.location.href;
    var c;//this the url we send.
    c='http://www.euroland.com/arinhtml/?companyCode='+strCompanycode+'&artype='+strArType+'&aryear='+strArYearfolder+'&replang='+strRepLang;
	//alert(c);
	a=window.open('email_order.asp?url='+escape(c),'miniwin','height=410,width=500,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0');
}

// *****************************************************************************
// ***  jump menu functions ****************************************************

function downloadfile(){
	//alert('downloadfile');
}

function doDownload(){
	//alert('download1');
	document.big_form.operation.value='downloadpdf';
	//alert(document.big_form.operation.value);
	document.big_form.submit();
}

function sitemap_click(pageno,title,titletype,superid){
	document.big_form.operation.value='sitemap_click';
	//alert(document.big_form.operation.value+','+pageno+','+title+','+titletype+','+superid);
	document.big_form.pageno.value=pageno;
	///alert('document.big_form.pageno.value='+document.big_form.pageno.value);
	if (pageno==intContentsIndex){
		//alert('this is contents page..');
		document.big_form.operation.value='contents';
	}
	document.big_form.submit();
}

function sitemapEx(orderMode){
	document.big_form.operation.value='sitemap';
	document.big_form.ordering.value=parseInt(orderMode);
	//alert(document.big_form.ordering.value);
	document.big_form.submit();
}

function sitemap(){
	document.big_form.operation.value='sitemap';
	//alert(document.big_form.operation.value);
	document.big_form.submit();
}

function doSearch(){
	//alert(document.searchform.freesearch.value);	 
	document.big_form.operation.value='search';
	document.big_form.freesearch.value=document.searchform.freesearch.value;	
	//alert(document.big_form.operation.value);
	document.big_form.submit();
}

//strArType_strRepLang_strArYearfolder
function inv_jumpMenu(form_field) {
	//alert(form_field.selectedIndex);
	if(form_field.selectedIndex==1){
		return;
	}
	//var intpagenum = form_field.options[form_field.selectedIndex].value;	
	gotoPg(parseInt(form_field.options[form_field.selectedIndex].value)+intPageNr1-1);		
}

// *****************************************************************************
// ***  browse functions *******************************************************

function isPageAvailable(intNum){
	if (intNum < 1 || intNum > arrReportImages.length-1){
		return false;
	}else{
		return true;
	}
}

function setZoomControls(){
	if((document.big_form.operation.value).indexOf('picPage')>=0){
		//we can zoom here:		
		document.getElementById('font_zoom').className='menu';
		document.getElementById("mainPage").innerHTML='<img src="pages/'+arrReportImages[intPageNumber]+'" alt="" class="main" id="page1">';
		document.getElementById('img_zoom').src='images/zoom_in.gif';
		document.getElementById('img_zoom').title='zoom in';
		zoom_over='images/zoom_in_r.gif';
		zoom_out='images/zoom_in.gif'; 	 		
	}else{//set zoom disabled style:
		document.getElementById('font_zoom').className='zoom_hidden';  
	}
}

//!main goto
function gotoPg(intNum){
	if(isNaN(parseInt(intNum)) || intNum < 1 || intNum > (arrReportImages.length)){
		return;
	}
	intPageNumber = intNum;
	document.big_form.pageno.value=intPageNumber;
	
	if (arrReportImages[intNum].indexOf('.asp')>0) {	
		document.big_form.operation.value='aspPage';
		document.big_form.submit();
	}else{
		//alert(document.big_form.operation.value);
		document.big_form.operation.value='picPage';
		document.getElementById("mainPage").innerHTML='<img src="pages/'+arrReportImages[intPageNumber]+'" alt="" class="main" id="page1">';
		if ((intPageNumber-intPageNr1+1)>0){
			document.gotoPgform.pgnum.value = intPageNumber-intPageNr1+1;
			document.gotoPgformDown.pgnum.value = intPageNumber-intPageNr1+1;
		}else{
			document.gotoPgform.pgnum.value = '';
			document.gotoPgformDown.pgnum.value = '';
		}
		window.scrollTo(0,0);
	}
	setZoomControls();
	handleComboTitle(intNum);
	document.getElementById("footer").style.visibility='hidden';
	setTimeout("setFooter()", 3000);
	document.getElementById('print').className='black';
}



var arrCombo;
function handleComboTitle(intNum){
	
	if(arrCombo==null){
		arrCombo=document.getElementById('chapter').options;//omista see vaid 1 kord	
	}		
	var i=0;
		for(i = 0; i<arrCombo.length; i++){
			if(!isNaN(arrCombo[i].value)){//is numeric, not '#'
				if(parseInt(arrCombo[i].value)<=intNum-intPageNr1+1){
				}else{
					break;
				}
			}
		}
		
		if(i==2){//error handler for '______' case
			i=i-1;
		}
				
		if(intNum-intPageNr1+1 <= parseInt(arrCombo[0].value) ){
			i=1;
		}
		document.getElementById('chapter').selectedIndex=i-1;					
}

function gotoPgEx(intNum){
	if(isNaN(parseInt(intNum)) || intNum < 1 || intNum > (arrReportImages.length)){
		return;
	}
	intPageNumber = intNum;
	document.big_form.pageno.value=intPageNumber;
	
	if (arrReportImages[intNum].indexOf('.asp')>0) {	
		document.big_form.operation.value='aspPage';
		document.big_form.submit();
	}else{
		document.getElementById("mainPage").innerHTML='<img src="pages/'+arrReportImages[intPageNumber]+'" alt="" class="main" id="page1">';
		if ((intPageNumber-intPageNr1+1)>0){
			document.gotoPgform.pgnum.value = intPageNumber-intPageNr1+1;
			document.gotoPgformDown.pgnum.value = intPageNumber-intPageNr1+1;
		}else{
			document.gotoPgform.pgnum.value = '';
			document.gotoPgformDown.pgnum.value = '';
		}
		window.scrollTo(0,0);
	}
	document.getElementById("footer").style.visibility='hidden';
	setTimeout("setFooter()", 3000);
}


function inv_goto_page(num){
	if (isPageAvailable(parseInt(num)+intPageNr1-1)){
		intPageNumber = num+intPageNr1-1;
		gotoPg(num+intPageNr1-1);
	}
}
function inv_goto_first_page() {		
	intPageNumber = 1;
	gotoPg(parseInt(intPageNumber));
}
function inv_goto_previous_page() {
	if (isPageAvailable(parseInt(intPageNumber)-1)){
		intPageNumber-=1
		gotoPg(parseInt(intPageNumber));
	}
}
function inv_goto_next_page() {
	if (isPageAvailable(parseInt(intPageNumber)+1)){
		intPageNumber+=1
		gotoPg(parseInt(intPageNumber));
	}
}
function inv_goto_last_page() {
	intPageNumber=parseInt(arrReportImages.length)-1;
	gotoPg(parseInt(intPageNumber));	
}

// ***  zoom functions *********************************************************

function inv_zoom() {
  if(document.images["page1"]==null){
    var div=document.getElementById("mainPage");
    var mapName=div.getElementsByTagName('map')[0].name;
    var tmpMap=div.innerHTML.substring(div.innerHTML.search(/<map/i));
    if(zoom_out=='images/zoom_in.gif'){
		  div.innerHTML='<img src="print/'+arrReportImages2[intPageNumber]+'" alt="" class="main">'+tmpMap;
      document.getElementById('img_zoom').src='images/zoom_out.gif';
      document.getElementById('img_zoom').title='zoom out';
      zoom_over='images/zoom_out_r.gif';
      zoom_out='images/zoom_out.gif';
    }else{
		  div.innerHTML='<img src="images/'+arrReportImages2[intPageNumber]+'" usemap="#'+mapName+'" alt="" class="main">'+tmpMap;
		  
      document.getElementById('img_zoom').src='images/zoom_in.gif';
      document.getElementById('img_zoom').title='zoom in';
      zoom_over='images/zoom_in_r.gif';
      zoom_out='images/zoom_in.gif';
    }
		return;
	}
	var current_img_width=document.images["page1"].width;
	if (current_img_width<900){
		document.getElementById("mainPage").innerHTML='<img 		src="print/'+arrReportImages[intPageNumber]+'" alt="" class="main" id="page1">';
		document.getElementById('img_zoom').src='images/zoom_out.gif';
		document.getElementById('img_zoom').title='zoom out';
		zoom_over='images/zoom_out_r.gif';
		zoom_out='images/zoom_out.gif';
		
	}
	else{
		document.getElementById("mainPage").innerHTML='<img src="pages/'+arrReportImages[intPageNumber]+'" alt="" class="main" id="page1">';
		document.getElementById('img_zoom').src='images/zoom_in.gif';
		document.getElementById('img_zoom').title='zoom in';
		zoom_over='images/zoom_in_r.gif';
		zoom_out='images/zoom_in.gif';
	}
}

// ***  utils ******************************************************************
//print this page
function inv_print_this_page() {

	//var int_width=800;
	//var int_height=450;
	//var winX = (screen.width - int_width) / 2;
	//var winY = (screen.height - int_height) / 2;
	if((document.big_form.operation.value).indexOf('picPage')>=0){
		var str_url ='print/'+arrReportImages[intPageNumber];
	}else{
		var gsm=arrReportImages[intPageNumber];
		var gstr=gsm.substr(0,gsm.indexOf("."));
		var gsm2="";
		var gstr2="";
		for(gg=1;gg<arrReportImages2.length;gg++){
			gsm2=arrReportImages2[gg];
			gstr2=gsm2.substr(0,gsm2.indexOf("."));
			if(gstr==gstr2){
				var str_url ='print/'+arrReportImages2[gg];
			}
		}
	}
	//str_WinParams = 'width=' + int_width + ',top=' + 0+',left=' + 0 + ',menubar=1,toolbar=0,scrollbars=1,resizable=1,status=1,location=0';
	//win = window.open('print.asp?str_url='+str_url, '', str_WinParams);
	document.images["print"].src=str_url;
	//alert("For high quality printing please open PDF file under link 'Printer friendly document'.");
	window.print();
	
}
// eof
