function PopUpForm(){
	var html = document.getElementById('addCode').innerHTML;
	html = html.replace("##change##", "1");
	html = html.replace("##strCAPTCHA##", "strCAPTCHA");
	html = html.replace("##bloodline##", "bloodline");
	html = html.replace("##code##", "code");
	html = html.replace("##form1##", "form1");
	$.modal(html);
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function SaveCode(){
	var form = document.getElementById("form1");
	if (form.bloodline.selectedIndex == 0){
		alert("Please select your bloodline.");
		return false;
	}
	
	if (!IsNumeric(form.code.value)){
		alert("Please enter a valid 9 digit numeric coven code.");
		return false;
	}
	
	if (form.strCAPTCHA.value == ''){
		alert("Please enter the correct security code.");
		return false;
	}
	
	$.get('ValidateCaptcha.asp?q='+form.strCAPTCHA.value+'&bl='+form.bloodline.value+'&code='+form.code.value, function(data){
		if (data == 'true'){
			$('#iframe1').attr('src', 'image.asp');
			$.modal.close();
			location.href = "index.asp";
		}
		else {
			alert(data);
			$('#iframe1').attr('src', 'image.asp');
			document.getElementById('strCAPTCHA').value = "";
			return false;
		}
	});

}

function removeCode(code){
	$.get('removeCode.asp?q='+code, function(data){
		if (data == 'true'){
			location.href = "index.asp";
		}
	});
}


