# -*- tcl -*-

proc TEItools_PI_frontpage { args } {
    global TEItools_frontpage_file
    set TEItools_frontpage_file $args
}

rename TitlePage {}

proc TitlePage {} {
    global TEItools_frontpage_file
    global TEItools_frontpage_value
    
    if { [info exists TEItools_frontpage_value] } {
	set TEItools_frontpage_file $TEItools_frontpage_value
    }
    
    if { ![info exists TEItools_frontpage_file] } {
	Error "frontpage style used, but no title page file defined.
Use `-style frontpage,frontpage=<file>'."
	return
    }

    if { ![file readable $TEItools_frontpage_file] } {
	Error "Cannot find frontpage file: $TEItools_frontpage_file"
	return
    }
    
    return "

\\begin{picture}(0,0)(0,0)
\\put([frontpagePlacement]){[insertGraphicFile $TEItools_frontpage_file]}
\\end{picture}
\\thispagestyle{empty}\\clearpage
[TitlePageHook]
"
}

proc frontpagePlacement {} {
    return "-90,-750"
}
