// This script is used to signup users in laikasys from external site
//
// Verions: 1.0 beta by Kim Hansen
// --------------------
// Still needed:
// - way to select what newsletter to sign up for (by the user)
// - setting for send welcome mail to user
// - checker for all the group and user ids (not not valid then report error)
//

// EMAIL VALIDATION
function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

// Field validator
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value==""||value=="Indtast dit navn")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

// VALIDATING FORM
function validate_form(thisform)
{
with (thisform)
  {
	if(validate_required(name,"Navn ikke udfyldt korrekt!")==false) {
		name.focus();return false;
	}
  	if(validate_email(email,"Ingen gyldig e-mail er indtastet!")==false) {
		email.focus();return false;
	}
  	
  }
}
 
// REQUESTS STATUS
var feedbackstatus = document.location.search.substring(1).split('statusmessage=')[1];
//alert(feedbackstatus);


// OUTPUT the FORM






// IF FEEDBACK THE OUTPUT
if (feedbackstatus!='' && feedbackstatus!==undefined)
  {
//  alert(feedbackstatus);
document.write("<div style='"+Formfeedbackstyle+"' align='center'>"+unescape(feedbackstatus)+"</div>");
  }
  else
  {
  document.write("<form style='padding:0px;margin:0px;' onsubmit='return validate_form(this);' action='http://www.laikasys.dk/saveformdata.asp' method='post' name='newsletterform' id='newsletterform'>");
document.write("<input type='hidden' name='domain' value='"+set_domain+"'>");
document.write("<input type='hidden' name='signupgroupid' value='"+signupgroupid+"'>");
document.write("<input type='hidden' name='usergroupid' value='"+set_user_group_id+"'>");
document.write("<input type='hidden' name='returnURL' value='"+ window.location.href +"'>");
document.write("<input type='hidden' name='set_scriptlang' value='"+set_scriptlang+"'>");
document.write("<input type='hidden' name='set_scripttype' value='"+set_scripttype+"'>");
document.write("<input type='hidden' name='set_scriptreturnwelcomemail' value='"+set_scriptreturnwelcomemail+"'>");

//	document.write("<span style='font-weight:bold;padding-top:0px;'>");
//		document.write(Formnametext);
//	document.write("</span><br />");
	document.write("<input type='text' id='name' name='name' value='Navn' style='" + texbg + "'/><br />");
//	document.write("<span style='font-weight:bold;'>");
//		document.write(Formemailtext);
//	document.write("</span><br />");
	document.write("<input type='text' id='email' name='email' value='Email' style='" + texbg + "'/><br />");
	document.write("<input type='submit' name='submit' value='"+Formsubmittext+"' style='"+Formsubmitstyle+"'>");
document.write("</form>");
  }



