function reportError() {
 alert("failed");	
}

function genRequest(path, via, id, args) {
	alert("value" + Validate(document.getElementById("form1")));
		if (Validate(document.getElementById("form1"))) {
			$(id).innerHTML = '<h3>Loading <img src="images/loading.gif" /></h3>';
			var str = escape(args);
			alert(str);
			var url = path;
			var pars = "q=" + str;
			var myAjax = new Ajax.Updater({success: id},url,{method: via, parameters: pars, onFailure: reportError});
		} else {
			alert("Please enter valid URL.");
		}
}
/*function genRequest(path, via, id, args) {
	alert("value" + Validate(document.getElementById("form1")));
}*/
function Validate(form) { 
    var v = new RegExp(); 
    v.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
    if (!v.test(form["url"].value)) { 
       // alert("You must supply a valid URL."); 
        return false; 
    } else{
		return true;
	}
} 




function submitRequest() {

	var keywords = document.form1.tags.value;
	var title = document.form1.title.value;
	var catId = document.form1.catId.value;
	var url = document.form1.url.value;

	if (keywords != ""){
		keywords = "&keywords=" + keywords;
	}
	
	if (title != "" ){
		title = "&title=" + title;
	}
	
	if (url != "" ){
		url = "url=" + url;
	}
	if (catId != "" ){
		catId = "&catId=" + catId;
	}

//alert("http://localhost:81/capstone/testGetUrl.php" + url +  title + keywords + catId +"");
//document.location = "http://localhost:81/capstone/testGetUrl.php" + url +  title + keywords + catId +"";	
	document.location = "http://capstone.bsblume.com/testGetUrl.php?" + url +  title + keywords + catId +"";	

}


