// Javascript functions
// "PhotoSlider" Copyright 2005(C) by Chris Arnold Jager.
// Version 1.1 Sunday 12/06/2005

//IE specific popup parameters
var popup;
var popbody;

//*******************************
//Function for fixed popup window
//*******************************
function popwindow(url)
{
  //Select height and width for the fixed popup window
  var window_height = 480;
  var window_width  = 640;

  //Determine center positions for popup window
  var center_spacing_vertical   = (screen.height - window_height) / 2;
  var center_spacing_horizontal = (screen.width - window_width) / 2;
		
  newwindow=window.open(url,'name','height='+window_height+',width='+window_width+',left='+center_spacing_horizontal+',top='+center_spacing_vertical+',toolbar=no,location=no,directories=no,menuBar=no,scrollbars=no,resizable=no','status=no');
  if (window.focus) {newwindow.focus()}
  
}

//*******************************************
//Function for automatic resized popup window
//*******************************************
function popwindow_auto_resize(image,window_height,window_width) 
{
  //Get browser string
  var detect = navigator.userAgent.toLowerCase();
  //Check for IE browser
  var ie_detected = check_it('msie',detect);
 
  //Determine center positions for popup window
  var center_spacing_vertical   = (screen.height - window_height) / 2;
  var center_spacing_horizontal = (screen.width - window_width) / 2;	
	
  if(ie_detected){ //IE method(not blocked by IE)
    popup = window.createPopup();
    popbody = popup.document.body;
    
    //popbody.style.border = "dashed black 2px";
    popbody.innerHTML = "<img src='"+ image +"' onClick='parent.popup.hide()' title='Imprimir ficha cadastral'>";
       
    popup.show(center_spacing_horizontal, center_spacing_vertical-70, window_width, window_height, document.body);
  }
  else{ //Mozilla method
    html = "<HTML><HEAD><TITLE>Enlarged View</TITLE></HEAD><BODY LEFTMARGIN=0 MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER> <IMG SRC='" + image + "' BORDER=0 NAME=image ></CENTER> </BODY></HTML>";
	  
    popup=window.open('','image','height='+window_height+',width='+window_width+',left='+center_spacing_horizontal+',top='+center_spacing_vertical+',toolbar=no,location=no,directories=no,menuBar=no,scrollbars=no,resizable=no','status=no');
    popup.document.open();
    popup.document.write(html);
    popup.window.focus(); //For compatibility with Mozilla
    popup.document.close();  	
  }
}

function check_it(string,detectstring)
{
	var place = detectstring.indexOf(string) + 1;
	return place;
}