//this is our request.querystring model from (www.powerDHTML.com)
var arrQueryString = (window.location.search).replace("?","").split("&");
document.queryString = function(name) {
	if(name == undefined) {
		return window.location.search;
	}
	else {
		//parse it out
		for(var i = 0 ; i < arrQueryString.length ; i++){
			var arrNameValue = arrQueryString[i].split("=");
			if(name == arrNameValue[0]) {
				return arrNameValue[1];
			}
		}
	}
};


	//pre-load images
	Image1 = new Image();
	Image2 = new Image();
	Image1.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif" ;
	Image2.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif" ;
	
	function ValidateSubmit() {
		var AlertText;
		AlertText = "";
		
		var Require_Name = false;
		var Require_CompanyName = false;
		var Require_Email = false;
		var Require_Phone = false;
		var Require_Fax = false;
		var Require_Address = false;
		var Require_Address2 = false;
		var Require_City = false;
		var Require_State = false;
		var Require_Zip = false;
		var Require_Country = false;
		var Require_SiteURL = true; //this should always be true
		var Require_SiteTitle = false;
		var Require_SiteDescription = false;
		var Require_SiteKeywords = false;
		var Require_Budget = false;
		var Require_Comments = false;
		
		if (Require_Name == true) {
			if (document.submitawebsite.Name.value=="") {
				AlertText += '   > Please enter your name. \n';
				document.AlertImg_Name.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Name.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_CompanyName == true) {
			if (document.submitawebsite.CompanyName.value=="") {
				AlertText += '   > Please enter a company name. \n';
				document.AlertImg_CompanyName.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_CompanyName.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Budget == true) {
			if (document.submitawebsite.Budget.value=="") {
				AlertText += '   > Please enter your budget. \n';
				document.AlertImg_Budget.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Budget.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Email == true) {
			if (document.submitawebsite.Email.value=="") {
				AlertText += '   > Please enter a valid email address. \n';
				document.AlertImg_Email.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				//validate format
				if (isEmailAddr(document.submitawebsite.Email.value) == false) {
					AlertText += '   > Please enter a valid email address. Example: \'yourname@domainname.com\' \n';
					document.AlertImg_Email.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
				} else {
					document.AlertImg_Email.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
				}
				
			}
		}
		if (Require_Phone == true) {
			if (document.submitawebsite.Phone.value=="") {
				AlertText += '   > Please enter a phone number. \n';
				document.AlertImg_Phone.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Phone.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Fax == true) {
			if (document.submitawebsite.Fax.value=="") {
				AlertText += '   > Please enter a fax number. \n';
				document.AlertImg_Fax.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Fax.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Address == true) {
			if (document.submitawebsite.Address.value=="") {
				AlertText += '   > Please enter your street address. \n';
				document.AlertImg_Address.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Address.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Address2 == true) {
			if (document.submitawebsite.Address2.value=="") {
				AlertText += '   > Please enter your street address. \n';
				document.AlertImg_Address2.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Address2.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_City == true) {
			if (document.submitawebsite.City.value=="") {
				AlertText += '   > Please enter/select a city. \n';
				document.AlertImg_City.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_City.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}

		}
		if (Require_State == true) {
			if (document.submitawebsite.State.value=="") {
				AlertText += '   > Please enter/select a state. \n';
				document.AlertImg_State.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_State.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Zip == true) {
			if (document.submitawebsite.Zip.value=="") {
				AlertText += '   > Please enter your zip code. \n';
				document.AlertImg_Zip.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Zip.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Country == true) {
			if (document.submitawebsite.Country.value=="") {
				AlertText += '   > Please enter/select a country. \n';
				document.AlertImg_Country.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Country.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_SiteURL == true) {
			if (document.submitawebsite.SiteURL.value=="") {
				AlertText += '   > Please enter your website URL. \n';
				document.AlertImg_SiteURL.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				if (document.submitawebsite.SiteURL.value=="http://") {
					AlertText += '   > Please enter your website URL. \n';
					document.AlertImg_SiteURL.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
				} else {
					//validate format
					if (checkUrl(document.submitawebsite.SiteURL) == false) {
						AlertText += '   > Please enter a valid website URL. \n';
						document.AlertImg_SiteURL.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
					} else {
						document.AlertImg_SiteURL.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
					}
				}
			}
		}
		if (Require_SiteTitle == true) {
			if (document.submitawebsite.SiteTitle.value=="") {
				AlertText += '   > Please enter a title for your website. \n';
				document.AlertImg_SiteTitle.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_SiteTitle.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_SiteDescription == true) {
			if (document.submitawebsite.SiteDescription.value=="") {
				AlertText += '   > Please enter a description for your website. \n';
				document.AlertImg_SiteDescription.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_SiteDescription.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_SiteKeywords == true) {
			if (document.submitawebsite.SiteKeywords.value=="") {
				AlertText += '   > Please enter the keywords related to your website. \n';
				document.AlertImg_SiteKeywords.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_SiteKeywords.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		if (Require_Comments == true) {
			if (document.submitawebsite.Comments.value=="") {
				AlertText += '   > Please enter your comments/message. \n';
				document.AlertImg_Comments.src = "http://www.submitawebsite.com/_IMAGES/icon_attention.gif";
			} else {
				document.AlertImg_Comments.src = "http://www.submitawebsite.com/_IMAGES/spacer.gif";
			}
		}
		
		//Display alert or process request
		if (AlertText == "") {
			return true;
		} else {
			alert('Wait, you missed something. - \n\n' + AlertText);
			return false;
		}

	}
	
	function isEmailAddr(email) {
		var result = false
		var theStr = new String(email)
		var index = theStr.indexOf("@");
		if (index > 0) {
			var pindex = theStr.indexOf(".",index);
			if ((pindex > index+1) && (theStr.length > pindex+1))
			result = true;
		}
		return result;
	}
	
	function checkUrl(theUrl) {
		if(theUrl.value.match(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i)){
			return true;
		} else {
			return false;
		}
	}
	
	//write the image
	//document.writeln('<IMG height="1" width="1" SRC="http://web-affiliate-program.web.com/track_lead/56/'+ document.queryString("SiteURL").replace(/http%3a%2f%2f/,"") +'%7C'+ document.queryString("Email") +'">');
