﻿function addOnload(newFunction) {
	var oldOnload = window.onload;
	
	if (typeof oldOnload == "function") {
		window.onload = function() {
			if (oldOnload) {
				oldOnload();
			}
			newFunction();
		}
	}
	else {
		window.onload = newFunction;
	} 
}

//addOnload(checkRequired);
addOnload(addImageRefresh);

function checkRequired() {
	document.valuationRequest.onsubmit = checkBlanks;
	document.valuationRequest1.onsubmit = checkBlanks;
}

function checkBlanks() {
	allInputs = document.getElementsByTagName("*");
	for (i=0; i<allInputs.length; i++) {
	if (allInputs[i].className)
		if (allInputs[i].className.indexOf("required")>-1)
			if (allInputs[i].value == "") {
				alert("'"+allInputs[i].name+"' is required field. Please fill the form");
				allInputs[i].focus();
				return false;
				}
	}
	return true;
}

function addImageRefresh() {
	buttonRefresh = document.getElementById("refresh");
	buttonRefresh.style.cursor = "pointer";
	buttonRefresh.onclick = refreshImage;
	buttonRefresh = document.getElementById("refresh1");
	buttonRefresh.style.cursor = "pointer";
	buttonRefresh.onclick = refreshImage1;
}

function refreshImage() {
	imageNewLocation = 	document.numbers.src.substring(0,document.numbers.src.indexOf("php")+3);
	//alert(imageNewLocation);
	document.numbers.src = imageNewLocation + "?id=" + (new Date()).getTime();
	//alert(document.numbers.src);
}
function refreshImage1() {
	imageNewLocation = 	document.numbers1.src.substring(0,document.numbers1.src.indexOf("php")+3);
	//alert(imageNewLocation);
	document.numbers1.src = imageNewLocation + "?id=" + (new Date()).getTime();
	//alert(document.numbers.src);
}
