sealWin = 1;
///////////////////////////////////////////////////////////////////////////////////////////////
//Delete Confirmation
///////////////////////////////////////////////////////////////////////////////////////////////

function DeleteConfirm(PageID,Type,TypeID){
	if (confirm("Are you sure you want to delete?")) {
		if (Type == "Press") {
			location = '/cms/submit.asp?PageID='+PageID+'&SubmitType=DeletePress&PressReleaseID='+TypeID
		} else if (Type == "Project") {
			location = '/cms/submit.asp?PageID='+PageID+'&SubmitType=DeleteProject&ProjectID='+TypeID
		} else if (Type == "Pia") {
			location = '/cms/submit.asp?PageID='+PageID+'&SubmitType=DeletePia&PiaID='+TypeID
		} else if (Type == "Section") {
			location = '/cms/cmshome.asp?cmsarea=sections&SubmitType2=DeleteSection&SectionID='+TypeID
		} else {
			location = '/cms/submit.asp?PageID='+PageID+'&SubmitType=DeletePage'
		}
	} else {
		return false
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////
//Delete Confirmation
///////////////////////////////////////////////////////////////////////////////////////////////

function DeleteAlert() {
	alert("Please make sure all child pages are deleted before deleting this page.")
}

///////////////////////////////////////////////////////////////////////////////////////////////
//Form validation
///////////////////////////////////////////////////////////////////////////////////////////////

function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}

function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function validInt(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var num = parseInt(formField.value,10);
 		if (isNaN(num))
 		{
 			alert('Please enter a number for the "' + fieldLabel +'" field.');
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}


function validDate(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		var elems = formField.value.split("/");
 		
 		result = (elems.length == 3); // should be three components
 		
 		if (result)
 		{
 			var day = parseInt(elems[0],10);
			var month = parseInt(elems[1],10);
 			var year = parseInt(elems[2],10);
			result =  allDigits(elems[0]) && (day > 0) && (day < 32) &&
					 allDigits(elems[1]) && (month > 0) && (month < 13) &&
					 allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4));
 		}
 		
  		if (!result)
 		{
 			alert('Please enter a date in the format DD/MM/YYYY for the "' + fieldLabel +'" field.');
			formField.focus();		
		}
	} 
	
	return result;
}


	function checkpassword() {
		
		if (document.Users.Name.value == "") {
			alert("You need to enter a Name")
			return false
		} else {
			Ok = "Yes"
		}
		
		if (document.Users.MembershipNumber.value == "") {
			alert("You need to enter a Membership Number")
			return false
		} else {
			Ok = "Yes"
		}
		
		if (document.Users.Telephone.value == "") {
			alert("You need to enter a Telephone Number")
			return false
		} else {
			Ok = "Yes"
		}
		
		if (document.Users.Birth.value == "") {
			alert("You need to enter a Birth Place")
			return false
		} else {
			Ok = "Yes"
		}
		
		if (document.Users.Email.value == "") {
			alert("You need to enter an Email Address")
			return false
		} else {
			Ok = "Yes"
		}
		
		if (document.Users.Username.value == "") {
			alert("You need to enter a Username")
			return false
		} else {
			Ok = "Yes"
		}
	
		if (document.Users.Password.value == document.Users.VerifyPassword.value) {
			Ok = "Yes"
		}
		else {
			alert("Your passwords don't match")
			Ok = "No"
		}
		if (document.Users.Password.value.length >= 6) {
			Ok = "Yes"
		}
		else {
			alert("Your passwords needs to be greater than 6 characters")
			Ok = "No"
		}
		if (Ok == "No") {
			return false
		} else {
			return true
		}
	}
	
	function checkmemnumber() {
		if (document.Users.Name.value == "") {
			alert("You need to enter a Name")
			return false
		}
		if (document.Users.MembershipNumber.value == "") {
			alert("You need to enter a Membership Number")
			return false
			
		}
		if (document.Users.Birth.value == "") {
			alert("You need to enter a Birth Place")
			return false
		}
		if (document.Users.Email.value == "") {
			alert("You need to enter an Email Address")
			return false
		}
		return true
	}

	function checkemail(){
	var emailID=document.emailform.Emailadres
	
		if (document.emailform.Voorletters.value == ""){
			alert("Vul alstublieft uw Voorletters in");
		} else if (document.emailform.Achternaam.value == ""){
			alert("Vul alstublieft uw Achternaam in");
		} else if (document.emailform.Adres.value == ""){
			alert("Vul alstublieft uw Adres in");
		} else if (document.emailform.Postcode.value == ""){
			alert("Vul alstublieft uw Postcode in");	
		} else if (document.emailform.Woonplaats.value == ""){
			alert("Vul alstublieft uw Woonplaats in");	
		} else if (document.emailform.Geboortedatum.value == ""){
			alert("Vul alstublieft uw Geboortedatum in");	
		} else if ((emailID.value==null)||(emailID.value=="")){
			alert("Vul alstublieft uw E-mailadres in")
		}else if (echeck(emailID.value)==false){
		} else if (document.emailform.textarea1.value == ""){
			alert("Vul alstublieft uw Ik heb een vraag in");	
		
		}else{
		document.emailform.submit()
		}
	}
	
	
	function checkdonation(){
	var emailID=document.donation.Emailadres
	
		if (document.donation.Voorletters.value == ""){
			alert("Vul alstublieft uw Voorletters in");
		} else if (document.donation.Achternaam.value == ""){
			alert("Vul alstublieft uw Achternaam in");
		} else if (document.donation.Adres.value == ""){
			alert("Vul alstublieft uw Adres in");
		} else if (document.donation.Postcode.value == ""){
			alert("Vul alstublieft uw Postcode in");	
		} else if (document.donation.Woonplaats.value == ""){
			alert("Vul alstublieft uw Woonplaats in");	
		} else if (document.donation.Geboortedatum.value == ""){
			alert("Vul alstublieft uw Geboortedatum in");	
		} else if (document.donation.bank.value == ""){
			alert("Vul alstublieft uw (Post)bank rekeningnr in");	
		} else if ((emailID.value==null)||(emailID.value=="")){
			alert("Vul alstublieft uw E-mailadres in")
		}else if (echeck(emailID.value)==false){
	
		
		}else{
		document.donation.submit()
		}
	}
	
	
	
function checkpage(){

if (document.mainform.KeynoteID.value == ""){
	alert("Please add a Keynote image");
	return false;
}else if (document.mainform.Title.value == ""){
	alert("Please add a Title");
	return false;
}else{
	return true;
	}
}
function checkpress(){

if (document.mainform.KeynoteID.value == ""){
	alert("Please add a Keynote image");
	return false;
}else if (document.mainform.Headline.value == ""){
	alert("Please add a Headline");
	return false;
}else if (document.mainform.Synopsis.value == ""){
	alert("Please add a Synopsis");
	return false;
}else{
	return true;
	}
}
function checkproject(){

if (document.mainform.KeynoteID.value == ""){
	alert("Please add a Keynote image");
	return false;
}else if (document.mainform.Title.value == ""){
	alert("Please add a Title");
	return false;
}else{
	return checkbox_checker_pia()
	}
}



function checkbox_checker_pia()
{
var checkbox_choices = 0;
for (counter = 0; counter < mainform.PIAs.length; counter++)
{

if (mainform.PIAs[counter].checked){ 
checkbox_choices = checkbox_choices + 1; }
}

if (checkbox_choices < 1 )
{
alert("Please select a PIA")
return false;
} else {
return checkbox_checker_country()
}

}

function checkbox_checker_country()
{
var checkbox_choices = 0;
for (counter = 0; counter < mainform.Countries.length; counter++)
{

if (mainform.Countries[counter].checked){ 
checkbox_choices = checkbox_choices + 1; }
}

if (checkbox_choices < 1 )
{
alert("Please select a Country")
return false;
} else {
return true;
}

}

												
	function echeck(str) {
	
			var at="@"
			var dot="."
			var quote="'"
			var comma=","
			var scomma=";"
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			
			if (str.indexOf(quote)!=-1){
			   alert("Vul alstublieft een juist e-mailadres in")
			   return false
			}
			if (str.indexOf(comma)!=-1){
			   alert("Vul alstublieft een juist e-mailadres in")
			   return false
			}
			if (str.indexOf(scomma)!=-1){
			   alert("Vul alstublieft een juist e-mailadres in")
			   return false
			}			
			
			if (str.indexOf(at)==-1){
			   alert("Vul alstublieft een juist e-mailadres in")
			   return false
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   alert("Vul alstublieft een juist e-mailadres in")
			   return false
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			    alert("Vul alstublieft een juist e-mailadres in")
			    return false
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
			    alert("Vul alstublieft een juist e-mailadres in")
			    return false
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			    alert("Vul alstublieft een juist e-mailadres in")
			    return false
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
			    alert("Vul alstublieft een juist e-mailadres in")
			    return false
			 }
			
			 if (str.indexOf(" ")!=-1){
			    alert("Vul alstublieft een juist e-mailadres in")
			    return false
			 }
	
	 		 return true					
		}
		
function populateKeynote(imageIn,imageID){
	document.all.keynote.innerHTML = '<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="181" HEIGHT="181"><TR><TD WIDTH="181" HEIGHT="181" ALIGN="center" VALIGN="middle"><IMG SRC="/resources/keynote/' + imageIn + '" NAME="KeynoteImage" ONLOAD="resizeKeynote()"></TD></TR></TABLE>';
	document.CMSForm.KeynoteID.value = imageID;
}

function doBlink() {
	var blink = document.all.tags("BLINK")
	for (var i=0; i<blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
	if (document.all)
		setInterval("doBlink()",1000)
}

function godrop()
{
	box = document.forms[0].navi;
	destination = box.options[box.selectedIndex].value;
	if (destination.substr(0,7) == "http://") {
		window.open(destination,"mywindow"); 
	} else {
		location.href = destination;
	}
	//if (destination) location.href = destination;
}


function popUp(url) {
	sealWin=window.open(url,"keypop",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=370,height=200');
	self.name = "mainWin"; 
	}
	
function closeIT() {
if (sealWin != "1") sealWin.close();
}

function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(visCnt) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}

