// popup window function
var pWin = null
	var pWin = null
	function portWin(url, x, y) {
		pWin = window.open (url, 'newWin', 'width=' + x + ',height=' + y + ',menubar=0,scrollbars=1')

		if (window.pWin) pWin.focus()
	}
//*************************************

function display(pimage,ptitle) {
 html = "<HTML><HEAD><TITLE>'" + ptitle + "'</TITLE>" +
  "</HEAD><BODY LEFTMARGIN=0 " +
  "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>" +
  "<IMG SRC='" + myimage + "' BORDER=0 NAME=image " +
  "onload='window.resizeTo(document.image.width,document.image.height)'></CENTER>" +
  "</BODY></HTML>";
 popup=window.open('','image','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
 popup.document.open();
 popup.document.write(html);
 popup.document.focus();
 popup.document.close();
}

function DisplayFoto(img)
{
  foto1= new Image();
  foto1.src=(img);
  Control(img);
}
function Control(img)
{
  if((foto1.width!=0)&&(foto1.height!=0))
  {
    viewFoto(img);
  }
  else
  {
    loopback="Control('"+img+"')";
    interval=setTimeout(funzione,20);
  }
}
function viewFoto(img)
{
  pwidth=foto1.width+20;
  pheight=foto1.height+20;
  pstring="width="+pwidth+",height="+pheight+",scrollbars=no,resizable=no,menubar=no,toolbar=no";
  showit=window.open(img,"foto",pstring);
}

/********* password input display **************************************************/
var openwindow = null;
function coupon_popup() 
{
  pwidth=400;
  pheight=270;
  pstring="width="+pwidth+",height="+pheight+",scrollbars=0,resizable=0,menubar=0,toolbar=0,location=0,status=0";
  openwindow = window.open('coupon.asp', 'thecoupon',pstring); 

}
/***********************************************************************************/

/* clock variables and functions ***************************************************/
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}

function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " pm" : " am"
document.clock.face.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}

function startclock() {
stopclock();
showtime();
}
/***********************************************************************************/

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

function NewWindow(mypage,myname,w,h,scroll){
  var win= null;
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

/* Button functions *****************************************************************/

function PrintButton(){
    document.write('<form>'
    + '<input class="bggray text_white smcaps borderblack textsize1 dontprint" type=button name=print value="Print" '
    + 'onClick="javascript:window.print()"></form>');
}

function CloseButton(){
    document.write('<form>'
    + '<input class="textsize1 bggray text_white smcaps borderblack" type="button" value="Close" '
    + 'onclick="javascript:window.close()"></form>');
}

function PitzerTM(){
var name = "webmaster";
var domain = "fmmga.com";
document.write('<center class="toppad5 textsize2 text_darkblue">Web design & development by '
    + '<a class="text_darkblue" href="mailto:' + name + '@' + domain + '\">'
    + '<i> Bob PitzerŪ</i><img class="borderclgalight" src="images/pitzware.gif" height="15" width="15"></a></center>');
}

function TopButton(x,y){
    document.write('<form>'
    + '<input class="textsize1 bggray text_white smcaps borderblack" type="button" value="Top" '
    + 'onclick="javascript:window.scroll(\'x\',\'y\')"></form>');
}

function EmailButton(name,domain,caption){
var address = "'mailto:" + name + "@" + domain + "'"
document.write('<form>'
    + '<input class="textsize1 bggray text_white smcaps borderblack" type="button" value="'+ caption + '" '
    + 'onclick="javascript:parent.location=' + address + '"></form>');
}

function BackButton(){
    document.write('<form>'
    + '<input class="textsize1 bggray text_white smcaps borderblack" type=button value="Return" '
    + 'onClick="javascript:history.go(-1)"></form>');
}
/******************************************************************************************/

/* This block provides the code for the SINGLE LINE SCROLLER ******************************/

var l1 = 0; // left of ticker in pixel, or 0 to position relative
var t1 = 0; // top of ticker in pixel, or 0 to position relative
/* var w1 = 800; // width of ticker in pixel */
var ie = document.all ? true : false;
var first = true;
var l2 = l1;
var l3 = l1 - l2;
var l = l2;
/*function tickinit(w1) {
        if (ie) {
        if (l1 == 0 && t1 == 0) {
        pos = document.all['tickpos'];
        l1 = getLeft(pos);
        t1 = getTop(pos);
        }
        ticktext.style.posTop = t1;
        }
    else {
        if (l1 == 0 && t1 == 0) {
        pos = document.anchors['tickpos'];
        l1 = pos.x;
        t1 = pos.y;
        }
        document.ticktext.pageY = t1;
        }
        l2 = l1 + w1;
        l3 = l1 - l2;
        l = l2;
        setInterval('tick()', 10);
}
*/
function getLeft(ll) {
        if (ll.offsetParent)
        return (ll.offsetLeft + getLeft(ll.offsetParent));
    else 
        return (ll.offsetLeft);
}

function getTop(ll) {
        if (ll.offsetParent)
        return (ll.offsetTop + getTop(ll.offsetParent));
    else
        return (ll.offsetTop);
}

function tick() {
    l = l - 0.5;
    if (l < l3) l = l2;
    cl = l1 - l;
    cr = l2 - l;
    if (ie) {
        ticktext.style.posLeft = l;
        ticktext.style.posTop = t1;
        ticktext.style.clip = "rect(auto "+cr+"px auto "+cl+"px)";
    if (first) ticktext.style.visibility = "visible";
        }
    else {
        document.ticktext.pageX = l;
        document.ticktext.clip.left = cl;
        document.ticktext.clip.right = cr;
    if (first) document.ticktext.visibility = "show";
        }
    first = false;
}
/***********************************************************************************/

	// Flooble.com's Animated Text script. Will animate a specified 
	// bit of text (determined by the ID of containing tag) by 
	// highlighting it with specified color one character at a time 
	// in a moving pattern.
	//
	// Summary of use: 
	//     call animate(tagID, color); where "tagID" is the ID 
	//     of the tag that contains text to be animated,
	//     and "color" is the color to use to highlight the text with.
	//
	// For more information, and detailed instructions, see 
	//     http://www.flooble.com/scripts/animate.php
	//
	// Copyright (c) 2002 by Animus Pactum Consulting Inc.
	// This script comes with no warranties whatsoever. 
	// Animus Pactum Consulting will not be responsible
	// for any damages resulting from its use.

        var ie4 = false;
        if(document.all) {
                ie4 = true; 
        }       
        function setContent(name, value) {
                var d;  
                if (ie4) { 
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }       
                d.innerHTML = value;    
        }       

	function getContent(name) {
		var d;
                if (ie4) {
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }
                return d.innerHTML;
	}

        function setColor(name, value) {
                var d;  
                if (ie4) { 
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }
                d.style.color = value;  
        }

	function getColor(name) {
                var d;
                if (ie4) {
                        d = document.all[name];
                } else {
                        d = document.getElementById(name);
                }
                return d.style.color;
        }

        function animate(name, col) {
		var value = getContent(name);
		if (value.indexOf('<span') >= 0) { return; }
		var length = 0;
                var str = '';
		var ch;
		var token = '';
		var htmltag = false;	
                for (i = 0; i < value.length; i++) {
			ch = value.substring(i, i+1);
			if (i < value.length - 1) { nextch = value.substring(i+1, i+2); } else { nextch = ' '; }
			token += ch;
			if (ch == '<' && '/aAbBpPhHiIoOuUlLtT'.indexOf(nextch) >= 0) { htmltag = true; }
			if (ch == '>' && htmltag) { htmltag = false; }
			if (!htmltag && ch.charCodeAt(0) > 30 && ch != ' ' && ch != '\n') {		
                        	str += '<span id="' + name + '_' + length + '">' + token + '</span>';
				token = '';
				length++;
			}
                }
                setContent(name, str);
                command = 'animateloop(\'' + name + '\', ' + length + ', 0, 1, \'' + col + '\')';
                setTimeout(command , 100);
        }

        function animateloop(name, length, ind, delta, col) {
		var next = ind + delta;
		if (next >= length) { delta = delta * -1; next = ind + delta; }
		if (next < 0) { delta = delta * -1; next = ind + delta; }
                setColor(name + '_' + ind, getColor(name + '_' + next));
                setColor(name + '_' + next, col);
                command = 'animateloop(\'' + name + '\', ' + length + ', ' + next + ', ' + delta + ', \'' + col + '\')';
                setTimeout(command , 100);
        }
