function returnContent(paramValue)
{
	var strContent = eval(String(paramValue));
	window.document.write(strContent);
}

function returnFlash(intCampaignID)
{
		var strHtml;
		strHtml = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"579\" height=\"500\" id=\"BA\" align=\"middle\">";
		strHtml += "<param name=\"movie\" value=\"http://static.itrack.it/clients/British_Airways_fase_4/c" + intCampaignID + "/ba.swf\" />";
		strHtml += "<param name=\"quality\" value=\"high\" />";
		strHtml += "<param name=\"bgcolor\" value=\"#ffffff\" />";
		strHtml += "<embed src=\"http://static.itrack.it/clients/British_Airways_fase_4/c" + intCampaignID + "/ba.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"579\" height=\"500\" name=\"BA\" align=\"middle\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
		strHtml += "</object>";
		
		window.document.write(strHtml);
}

function verifyEmail(s) {
	var chrs = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-@';
	var sLen = s.length; var i=0, c=0, cCnt=0, step=0;
	if (sLen < 6) return false;
	while (i < sLen){
		c=s.charAt(i);
		if (!(chrs.indexOf(c)>=0 || (c=='_' && step<1))) return false;
		if (c=='.') { if (cCnt<1) return false; cCnt=0; }
		if (c=='@') { if (step>0) return false; if (cCnt<1) return false; step++; cCnt=0; }
		cCnt=cCnt+1; i++;
	}	
	if (cCnt < 3 || cCnt > 5 || step==0 || (s.indexOf(".")<0) ) return false;
	return true;
}
function validateFields() {
	var strAlertMessage = '';
	
	//title validation
	if(window.document.regform.title.selectedIndex == 0) strAlertMessage += strAlertTitle + "\n";

	//first name validation
	var strFirstname = window.document.regform.firstname.value;
	if(strFirstname == '') strAlertMessage += strAlertFirstname + "\n";
	
	//last name validation
	var strLastname = window.document.regform.lastname.value;
	if(strLastname == '') strAlertMessage += strAlertLastname + "\n";
	
	//email  validation
	var strEmail = window.document.regform.email.value;
	if(!verifyEmail(strEmail)) strAlertMessage += strAlertEmail + "\n";
	
	//terms validation
	var acceptedTerms = window.document.regform.terms.checked;
	if(!acceptedTerms) strAlertMessage += strAlertTerms + "\n";

	//swedish question validation
	if((getURLParam("campaignid") == "8983")||(getURLParam("campaignid") == "9276"))
	{
		var strSEAnswer = window.document.regform.sequestion.value;
		if(strSEAnswer == '') strAlertMessage += "Du skal give et svar\n";
	}

	//if no errors, then continue
	if(strAlertMessage != '') {
		alert(strAlertIntro + "\n" + strAlertMessage);
	} else {
		window.document.regform.action = "../../signup_utf8.asp";
		window.document.regform.submit();		
	}
}

function displayTitleOption(strSelect, arrOptions, arrOptionValues, strHtml)
{
	strHtml = "";
	for(var intCurrentOption = 0; intCurrentOption < arrOptions.length; intCurrentOption++) {
		strHtml += "<option value=\"" + arrOptionValues[intCurrentOption] + "\"";
		if(strSelect == arrOptionValues[intCurrentOption]) {
			strHtml += " selected";
		}
		strHtml += ">" + arrOptions[intCurrentOption];
		strHtml += "</option>";
	}
	window.document.write(strHtml);
}

// statements run on load
function runOnLoad() {

	if(window.document.getElementById('strButtonSubmit')) {
		window.document.getElementById('strButtonSubmit').innerHTML = strButtonSubmit;
	}

	if(window.document.getElementById('strTranslatedSendInvites')) {
		window.document.getElementById('strTranslatedSendInvites').innerHTML = strTranslatedSendInvites;
	}

	if(window.document.getElementById('strTranslatedCloseText')) {
		window.document.getElementById('strTranslatedCloseText').innerHTML = strTranslatedCloseText;
	}
}

function validateTips()
{
	var strAlertMessage = "";
	var bAnyEmail = false;

	for(var i = 0; i < window.document.regform.recipients.length; i++) {
		var strEmailFieldValue = window.document.regform.recipients[i].value
		if(strEmailFieldValue != "") {
			if(verifyEmail(strEmailFieldValue)) {
				bAnyEmail = true;
			} else {
				//strAlertMessage += "\nEmail " + i; 
				strAlertMessage += strTranslatedEmailDisplayText + " " + (i+1) + "\n";
			}
		}
	}

	if(!bAnyEmail) {
		alert(strAlertIntro + "\n" + strAlertEmail);
		return;
	}

	if(strAlertMessage == "") {
		window.document.regform.submit();
	} else {
		//if(strAlertMessage == "") strAlertMessage = "\n" + paramTipHeadline;
		//alert(paramIntro + "\n" + strAlertMessage);

		alert(strAlertIntro + "\n" + strAlertMessage);
	}
}

function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return strReturn;
}

function displayErrorMsg(parammDisplay)
{
	if(String(parammDisplay) == "show") {
		window.document.getElementById("errorContainer").style.display = "";
	} else {
		window.document.getElementById("errorContainer").style.display = "none";
	}
}
