var punchCount = 3;
var currentPunch = 1;
var delay = 5000;
var hideDelay = 10000;
function showPunch() {	
	var punchImg = document.getElementById("punchImg");
	if(punchImg) {
		punchImg.src = "images/punch" + currentPunch + ".gif"
		currentPunch++;	
		opacity('punchImg', 0, 100, 1000);
		if(currentPunch <= punchCount) {
		  setTimeout(hidePunch, hideDelay);
		}
	}
}


function hidePunch() {	
	var punchImg = document.getElementById("punchImg");	
	opacity('punchImg', 100, 0, 1000);
	setTimeout(showPunch, delay);
}

setTimeout(showPunch, delay);

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
} 

function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
} 

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function validate_required(field,alerttxt)
{
with (field)
	{
	if (value==null||value==""||value==alerttxt){
		field.value = alerttxt;
		return false
	} else {return true}
	}
}

function validate_form(thisform)
{
var valid = true;
with (thisform)
{
if (validate_required(name,"You must enter your name!")==false)
  {name.focus();valid= false}
if (validate_required(email,"You must enter a valid email address!")==false)
  {email.focus();valid= false}
else if (validate_email(email,"Email address is not valid!")==false)
  {email.focus();valid= false}
if (validate_required(comment,"You must enter a comment!")==false)
  {comment.focus();valid= false}

}
return valid;
}

function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
  {field.value = alerttxt + " - " + field.value;return false}
else {return true}
}
}
