function validate(){
	var el;
	var errors = false
	var errstr = ""
	
	el = document.getElementById("c_name");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "Your Name cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
			el.style.backgroundColor = '#ffffff'
		}
	}
	
	el = document.getElementById("c_add1");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "Street Address cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
			el.style.backgroundColor = '#ffffff'
		}
	}
	
	el = document.getElementById("c_city");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "City cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
				el.style.backgroundColor = '#ffffff'
		}
	}
	
	el = document.getElementById("c_state");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "State cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
				el.style.backgroundColor = '#ffffff'
		}
	}
		
	el = document.getElementById("c_zip");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "Zip Code cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
			el.style.backgroundColor = '#ffffff'
		}
	}

	el = document.getElementById("c_phone_biz");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "Business Phone cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
			el.style.backgroundColor = '#ffffff'
		}
	}

	el = document.getElementById("c_email");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "Email Address cannot be left blank||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
			el.style.backgroundColor = '#ffffff'
		}
	}
				
	el = document.getElementById("c_operating");
	if(el){
		if(el.selectedIndex == 0){
			errstr += "Please indicate if you will be operating this restaurant||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
				el.style.backgroundColor = ''
		}
	}
				
	el = document.getElementById("c_experience");
	if(el){
		if(el.selectedIndex == 0){
			errstr += "Please indicate if you have restaurant experience||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
				el.style.backgroundColor = ''
		}
	}
				
	el = document.getElementById("c_geo");
	if(el){
		el.value = el.value.trim()
		if(el.value == ""){
			errstr += "Please enter Geographic preference for franchise||"
			el.style.backgroundColor = '#ff9b9b'
			errors = true
		} else {
				el.style.backgroundColor = ''
		}
	}

	//display errors if we have any
	if(errors){
		showErrors(errstr, "errors");
		return false;
	} else {
		return true;
	}
	
}

function showErrors(str, container){
	window.scrollTo(0,0)
	document.getElementById(container).innerHTML = ""
	document.getElementById(container).style.display = "block"
	aryTemp = str.split("||")
	if(aryTemp.length-1 > 0){
		strErrors = "Please fix the errors highlighted in red:<ul>"
		for(x=0;x<aryTemp.length;x++){
			if(aryTemp[x].trim() != ""){
				strErrors += "<li>" + aryTemp[x] + "</li>"
			}
			//if(x>=2){ break; }
		}
		strErrors += "</ul>"
	}
	document.getElementById(container).innerHTML = strErrors
}
		
		
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	} 
}