
function returnObject(arg, formObj) {
	var myObj = null;
	if (formObj != null) {
		myObj = formObj.elements[arg];
	} else if (typeof arg == 'string') {
		myObj = document.getElementById(arg);
	} else if (typeof arg == 'object') {
		myObj = arg;
	}

	return myObj;
}

// simple function to show a container
function show(arg) {
	var myObj = returnObject(arg);
	if (myObj != null) {
		myObj.style.display = "block";
	}
}

// simple function to hide a container
function hide(arg) {
	var myObj = returnObject(arg);
	if (myObj != null) {
		myObj.style.display = "none";
	}
}

//hide Multiple hideM(field1,field2,...)
function hideM() {
	for (var i = 0; i < arguments.length; i++) {
		hide(arguments[i]);
	}
}
//show Multiple showM(field1,field2,...)
function showM() {
	for (var i = 0; i < arguments.length; i++) {
		show(arguments[i]);
	}
}

function clearInputsWithValue(form, myValue, inputType) {
	// if inputType is not specified, then use 'input' as default
	var type = (inputType == null) ? 'input' : inputType;

	var formObj = returnObject(form);

	var inputs = formObj.getElementsByTagName(type);

	// lets remove the specified value from our input values
	for ( i = 0; i < inputs.length; i++ ) {
		if(inputs[i].value.toLowerCase() == myValue) {
			inputs[i].value = '';
		}
	}
}

function scrollToTop() {
	if (document.body.scrollTop) {
		document.body.scrollTop = 0;
	} else if(document.body.scrollTo) {
		document.body.scrollTo(0,0);
	} else {
		location.href = "#top";
	}
}

//Delay function after a few seconds delay("alert('sample!')",1000);
function delay(functionToCall,delayMill){
	if(functionToCall && delayMill != null){
		window.setTimeout(functionToCall,delayMill);
	}
}


$().ready(function() {
	// validate signup form on keyup and submit
	$("#startForm").validate({
		errorContainer: $("#msgs-error"),

		rules: {
			phone: {
				required: true,
				minlength: 13
			}
		}
			
	});

});


