﻿function tv(strElementId,strLinkId)
{
    // used for links that reveal a hidden div: the div strElementId gets set to visible, the link strLinkId to hidden
    // requires prototype.js
   Element.show(strElementId);
   Element.hide(strLinkId);
    
}

var Privacy = {

    formValidation: function() 
    {
         var strEmail =  $F('email');
         var strFull_name =  $F('full_name');
         var strYob =  $F('yob');
         
         var regex = /^\s*$/i;
         
         if(regex.test(strFull_name)){
                Element.show('feedback_container_privacy');
                $("strText").innerHTML = "Hier voornaam en achternaam invullen, aub";
                  return false;
          } 
          if(regex.test(strYob)){
                Element.show('feedback_container_privacy');
                $("strText").innerHTML = "Hier minimaal je geboorte jaar invullen, aub";
                 return false;
          } 
          regex = /^(.+)@(\w+)(\.)(.+)$/;
          if(!regex.test(strEmail)){
                Element.show('feedback_container_privacy');
                $("strText").innerHTML = "Hier correct e-mailadres in vullen, aub";
                return false;
          }
          Element.hide('feedback_container_privacy');
          return true;
    }
   
}

function checkTerms(f)
{
    if(f.terms.checked)
    {
        replaceButton( $('btnSubmit') );
        return true;
    }
    else
    {
        alert("Je hebt de gebruikersvoorwaarden niet geaccepteerd");
        return false;    
    }
}

function checkTermsPayment(f)
{
    if(f.terms.checked)
    {
        f.submit();
        return true;
    }
    else
    {
        alert("Je hebt de gebruiksvoorwaarden niet geaccepteerd");
        return false;    
    }

}


function detectflash(){

	var blnFlash = 0;
	
	noautoinstall = ""

	if(navigator.appName == "Microsoft Internet Explorer" && 
		(navigator.appVersion.indexOf("Mac") != -1 || 
		 navigator.appVersion.indexOf("3.1") != -1)){
			noautoinstall = "true";
		}

	if (navigator.appName == "Microsoft Internet Explorer" &&
		 noautoinstall != "true"){
			blnFlash = 1;
		}
	else if(navigator.plugins){
		if(navigator.plugins["Shockwave Flash"]){
			blnFlash = 1;
		}
		else if(navigator.plugins["Shockwave Flash 2.0"]){
			blnFlash = 1;
		}

		else{
			blnFlash = 0;
		}
	}
	else {
		blnFlash = 0;
	}
	return blnFlash;
};

/////// start image rotator //////////////

var billBoard = new Array();
var boardNum;
var boardSpeed;
var prefix;
var amOfpictures =5;

function loadAll(action) {

  if(action == 1){
	prefix = ''
  }
  if(action == 2){
	prefix = '2'
  }
  for (var i=1; i <= amOfpictures; i++){
		billBoard[i] = new Image();
		billBoard[i].src = "images/" +  "slideshow_" + i +".jpg";
		//billBoard[i].src = "images/" + prefix + "slideshow_" + i +".jpg";
  }

  boardNum = 1;
  boardSpeed = 2000;

  
} //loadAll 


function rotateBoard() {
  if (boardNum < (billBoard.length - 1)) {
    boardNum++;
  }
  else {
    boardNum = 1;
  }
  document.billBoard.src = billBoard[boardNum].src;
  setTimeout('rotateBoard()',boardSpeed);
}
/////// end image rotator //////////////

function checkTextAreaLength(field, maxlimit)
{
	if (field.value.length >= maxlimit)
	{   
	    field.value = field.value.substring(0, maxlimit);
	}
}

function chkPcboek(f){

	var postCode = f.postcode.value;
	postCode = postCode;
	if(postCode != '') {
		var postcodeReg = "^(([0-9]{4}( ?)([a-zA-Z]{2})?))$";                            
		var regex = new RegExp(postcodeReg);
		if (!regex.test(postCode)){
			alert(postCode + " Dit is geen correcte postcode.");	
			return false;
		}
		else
			return true; 
	}



}


function deletePhoto()
{
  if (confirm('Weet je zeker dat je deze foto wilt verwijderen?'))
  {
     $('imgTools').elements['_a'].value='del';
     $('imgTools').submit();
     return true; 
  }else{
  return false;
  }
}





function setTijdscapsuleDate()
{
    if(document.forms['capsule'])
    {
    var datenow = new Date()
    with(document.forms['capsule'])
         {
            for (var intI = 0; intI < elements['daySelect'].options.length; intI++)
            {
                if ( parseInt(datenow.getDate()) == parseInt(elements['daySelect'].options[intI].value) )
                {
                    elements['daySelect'].selectedIndex = intI;
                }
            };
            for (var intI = 0; intI < elements['monthSelect'].options.length; intI++)
            {
                if ( parseInt(datenow.getMonth() + 1) == parseInt(elements['monthSelect'].options[intI].value) )
                {
                    elements['monthSelect'].selectedIndex = intI;
                }
            };
            for (var intI = 0; intI < elements['yearSelect'].options.length; intI++)
            {
                if ( parseInt(datenow.getFullYear() + 1) == parseInt(elements['yearSelect'].options[intI].value) )
                {
                    elements['yearSelect'].selectedIndex = intI;
                }
            };
        };
 	};
}

function checkTijdscapsule()
{
     
	//if(document.forms['capsule'].q1.value == '')
	//{
	//	alert('Je hebt geen tekst ingetypt');
	//	return false
	//}
	

	var strday =  document.forms['capsule'].elements['daySelect'].options[document.forms['capsule'].elements['daySelect'].selectedIndex].value
	var strmonth =  document.forms['capsule'].elements['monthSelect'].options[document.forms['capsule'].elements['monthSelect'].selectedIndex].value
	var stryear =  document.forms['capsule'].elements['yearSelect'].options[document.forms['capsule'].elements['yearSelect'].selectedIndex].value
	
	//check if date is min. one year later
	var submitDate = new Date()
	submitDate.setFullYear(stryear,strmonth -1 , strday)
	//alert(submitDate);
	var todayNextyear = new Date()
	todayNextyear.setFullYear(todayNextyear.getFullYear() + 1)
			
	if (submitDate < todayNextyear)
	{
	    alert('De verzenddatum moet minimaal\neen jaar in de toekomst liggen');
        return false;
    }
    
	// check if valid date
	var checkDate = stryear + '-' + strmonth + '-' + strday;
	var testDate = new Date();
	
	testDate.setFullYear(2000);
	testDate.setMonth(00);
	testDate.setDate(01);
	
	testDate.setFullYear(stryear);
	testDate.setMonth(strmonth - 1);
	testDate.setDate(strday);
	
	stryear = '' +  testDate.getFullYear();
	strmonth = '' + parseInt(testDate.getMonth() + 1);
	strday = '' + testDate.getDate();
	if (strday.length < 2)
	{
		strday = '0' + strday
	}
	if (strmonth.length < 2)
	{
		strmonth = '0' + strmonth
	}
	checkDate2 = stryear + '-' + strmonth + '-' + strday;
	if (checkDate != checkDate2)
	{
		alert('Controleer de datum alsjeblieft');
		return false
	}
	return true;	
}

function setHome(waarde)
	{		
	    if(navigator.appName != "Microsoft Internet Explorer")
		{
		
			window.open("http://www.schoolbank.nl/promo.html?_a=favorite");
		}
		else
		{
		
            waarde.style.behavior='url(#default#homepage)';
			waarde.setHomePage('http://www.schoolbank.nl');
			return false;
		
		}
	}
	
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
        begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
        end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}


function varCookieCheck(value)
{
    var varCookie = getCookie("__utmv");
    if (varCookie == null)
        return false;
    varCookie = varCookie.replace(/^\d*\./, '');
    return (varCookie == value) ? true : false;
}

function getParam(name){
    if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(location.search))
        return decodeURIComponent(name[1]);
}
