//////////////////find DOM code///////////////
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if (document.getElementById) {isID = 1; isDHTML = 1;}
else {
if (document.all) {isAll = 1; isDHTML = 1;}
else {
browserVersion = parseInt(navigator.appVersion);
if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {isLayers = 1; isDHTML = 1;}
}}

function findDOM(objectID,withStyle) {
	if (withStyle == 1) {
		if (isID) { return (document.getElementById(objectID).style) ; }
		else { 
			if (isAll) {return (document.all[objectID].style); }
		else {
			if (isLayers) {return (document.layers[objectID]);}
		};}
	}
	else {
		if (isID) { return (document.getElementById(objectID)) ; }
		else { 
			if (isAll) {return (document.all[objectID]); }
		else {
			if (isLayers) {return (document.layers[objectID]);}
		};}
	}
}
///////////////////// end FindDOM ///////////////

function validate(item, type, notice, maxlen, evalString){ // negative for N/A, 0 for no limit but not blank, positive for maxlength
	valid = true;
	errormsg = notice;
	if(type == "String"){
		if(isBlank(item.value)){
			valid = false;
		}
	}
	if(type == "Number"){
		if(blank(item.value).length == 0 || isNaN(item.value)){
			valid = false;
		}
	}
	if(type == "Custom"){
		if(!eval(evalString)){
			valid = false;
		}
	}
	if(type == "Email"){
		if(isBlank(item.value) || !checkEmail(item.value)){
			valid = false;
		}
	}
	if(type == "TextArea"){
		if(isBlank(item.innerHTML))
			valid = false;
	}
	if(!valid){
		alert(errormsg);
		item.focus();
	}
	return valid;
}

function blank(aString){
	var str = String(aString);
	if (str.toLowerCase() == "undefined" || str.toLowerCase() == "null")
		return "";
	return str;
}

function checkNumeric(theInput)
{
	if(isNaN(theInput.value)&&theInput.value!="")
	{
		theInput.value = "";
		alert("Please enter a number");
		theInput.focus();
		return false;
	}
	return true;
}
function isBlank(item){
	temp1 = blank(item);
	temp1 = temp1.replace(/\s/g,"");
	if (temp1.length == 0)
		return true;
	return false;
}

function checkEmail(value){
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(value) && r2.test(value));
}
//check if user select business address then business name is compulsary
function previewImage(imagename){
	window.open('zoomin.asp?imgname=' + imagename, 'preview', 'width=700, height=650, scrollbars=1, resizable=1');
}