function getValue(varname)
{
  // First, we load the URL into a variable
  var url = window.location.href;

  // Next, split the url by the ?
  var qparts = url.split("?");
  // Check that there is a querystring, return "" if not
  if (qparts.length == 0)
  {
    return "";
  }

  // Then find the querystring, everything after the ?
  var query = qparts[1];
  // Split the query string into variables (separates by &s)
  var vars = query.split("&");
  // Initialize the value with "" as default
  var value = "";
  // Iterate through vars, checking each one for varname
  for (i=0;i<vars.length;i++)
  {
    // Split the variable by =, which splits name and value
    var parts = vars[i].split("=");

    // Check if the correct variable
    if (parts[0] == varname)
    {
      // Load value into variable
      value = parts[1];

      // End the loop
      break;
    }
  }

  // Convert escape code
  value = unescape(value);

  // Convert "+"s to " "s
  value.replace(/\+/g," ");

  // Return the value
  return value;
}


function echeck(str)
{

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
   	       alert("Invalid E-mail Address");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
   	       alert("Invalid E-mail Address");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address");
		    return false;
		 }

 		 return true;					
}

function ValidateForm()
{
	var emailID=document.theemailform.email;
	var nameID=document.theemailform.name;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address");
		emailID.focus();
		return false;
	}

	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}

	if ((nameID.value==null)||(nameID.value=="")){
		alert("Please Enter your Name");
		nameID.focus();
		return false;
	}
	return true;
}

function ValidateEmail()
{
	var emailID=document.theform.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address");
		emailID.focus();
		return false;
	}

	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}

	return true;
}

function ValidateLinkForm()
{
	var nameID=document.thelinkform.name;
	var emailID=document.thelinkform.email;
	var websiteID=document.thelinkform.website;
	var oururlID=document.thelinkform.oururl;
	
	if ((nameID.value==null)||(nameID.value=="")){
		alert("Please Enter your Name");
		nameID.focus();
		return false;
	}

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address");
		emailID.focus();
		return false;
	}

	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}

	if ((websiteID.value==null)||(websiteID.value=="")){
		alert("Please Enter your valid Web Site URL");
		websiteID.focus();
		return false;
	}

	if ((oururlID.value==null)||(oururlID.value=="")){
		alert("Please Enter the URL where the link to this site is placed");
		oururlID.focus();
		return false;
	}

	return true;
}
