function addLoadEvent(func) {
    var oldonload = window.onload;

    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function textNav(id, status, color) {
	if(status == "on") {
		document.getElementById(id).style.backgroundColor = color;
	} else {
		document.getElementById(id).style.backgroundColor = '';
	}
	
	document.getElementById(id).style.cursor = 'pointer';
}

function show(id, type) {
	if (document.getElementById){
		document.getElementById(id).style.display = type;
	}
}

function hide(id) {
	if (document.getElementById){
		document.getElementById(id).style.display = 'none';
	}
}

function open_window1(url, width, height) {
	mywin1 = window.open(url,"win1",'alwaysRaised=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + width + ',height=' + height);
	mywin1.resizeTo(width, height);
	mywin1.focus();
}

function send_parent(href) {
	window.opener.location = href;
	window.close();
}

function miniInput(a) {
	
	if(a == 1) {
		var mText=new Array ('-- Enter name --','');
		var oInput=document.getElementById("name");
		if(oInput.value==mText[0]) {
			oInput.value=mText[1];
		}
	}
	
	if(a == 2) {
		var mText=new Array ('-- Enter phone number --','');
		var oInput=document.getElementById("phone");
		if(oInput.value==mText[0]) {
			oInput.value=mText[1];
		}
	}
	
	if(a == 3) {
		var mText=new Array ('-- Enter email address --','');
		var oInput=document.getElementById("email");
		if(oInput.value==mText[0]) {
			oInput.value=mText[1];
		}
	}
	
	if(a == 4) {
		var mText=new Array (' -- Enter comments --','');
		var oInput=document.getElementById("comments");
		if(oInput.value==mText[0]) {
			oInput.value=mText[1];
		}
	}
}

function in_array(needle, haystack) {
	for(var j = 0; j < haystack.length; j++) {
		if(needle == haystack[j]) {
			return true;
		}
	}
	return false;
}

function check_required_new(form, fields) {
	//alert(fields.length);
	
	for(var i = 0; i < form.elements.length; i++) {
		if(in_array(form.elements[i].name, fields)) {
			//alert(form.elements[i].type);
			if(form.elements[i].type == "text" || form.elements[i].type == "password") {
				if(form.elements[i].value == "") {
					alert(form.elements[i].name + " is a required field");
					form.elements[i].focus();
					return false;
				}
			} else if(form.elements[i].type == "select-one") {
				//alert(fields[i].name + " is a pull-down");
				if(form.elements[i].selectedIndex == 0) {
					alert(form.elements[i].name + " is a required field");
					form.elements[i].focus();
					return false;
				}
			} else if(form.elements[i].type == 'radio') {
				var radio = form.elements[i].name;
				//alert(form[radio].length);
				for(var j = 0; j < form[radio].length; j++) {
					if(form[radio][j].checked == true) {
						var checked = true;
					}
				}
				
				if(checked != true) {
					alert(form.elements[i].name + " is a required field");
					form.elements[i].focus();
					return false;
				}
			} else if(form.elements[i].type == 'textarea') {
				if(form.elements[i].value == "") {
					alert(form.elements[i].name + " is a required field");
					form.elements[i].focus();
					return false;
				}
			}
		}
	}
	return true;
}
	

	
