//window.onload = resizeColumns;
//window.onresize = resizeColumns;

function resizeColumns(oEvent)
{
    window.onresize = function(){}
   var header = elemById('header');
	var contenttext = elemById('contenttext');
	var subblok = elemById('subblok');
	var footer = elemById('contentfooter');
	
   //get largest height
   try {
	contenttext.style.height="auto";
	subblok.style.height="auto";
      var contenttextHeight = contenttext.offsetHeight;
      var subblokHeight = subblok.offsetHeight;
      var tallestColumnHeight = Math.max(contenttextHeight,subblokHeight);

      var totalHeight = header.offsetHeight + tallestColumnHeight;
      var windowHeight = measure('window').y;


      ///Either stretch the layout, or equalize the columns:
      //stretch
      if (totalHeight < windowHeight)
      {
         var remainingHeight = windowHeight - header.offsetHeight - footer.offsetHeight - 80;

         contenttext.style.height = windowHeight
          - header.offsetHeight
          - footer.offsetHeight
          - getStyleValue(contenttext,'padding-bottom',true)
          + 'px';

         subblok.style.height = windowHeight
          - header.offsetHeight
          - footer.offsetHeight
          - getStyleValue(subblok,'padding-bottom',true)
          - getStyleValue(subblok,'padding-top',true)
          + 'px';
      }
      //equalize
      else
      {
	
         if (tallestColumnHeight == contenttext.offsetHeight)
         {
            subblok.style.height = contenttext.offsetHeight
             - getStyleValue(subblok,'padding-bottom',true)
             - getStyleValue(subblok,'padding-top',true)
             + 'px';
         }
         else
         {
            contenttext.style.height = subblok.offsetHeight
             - getStyleValue(contenttext,'padding-bottom',true)
             + 'px';
         }
      }

      elemById('center').style.height = header.offsetHeight + contenttext.offsetHeight + 'px';
      
       if (!oEvent)
           oEvent = window.event;
       
       
      // setTimeout("window.onresize=resizeColumns", 200);
	   setTimeout("resizeColumns(null)", 200);
   } catch(e) {
		//alert(e||e.description)
   }
}

function popitup(url)
{
   var windowWidth = measure('window').x;
   var windowHeight = measure('window').y;

   var centerWidth = windowWidth / 2;
   var centerHeight = windowHeight / 2;
   centerHeight = centerHeight - 102;
   centerWidth = centerWidth - 182;

	newwindow=window.open(url,'name','top='+centerHeight+',left='+centerWidth+',height=205,width=365');
	if (window.focus) {newwindow.focus()}
	return false;
}

// used for checking all search options at the 'opdrachten' search
var checkflagFunc = "true";
var checkflagExp = "true";
var checkflagReg = "true";


function checkFunc(field) {
   if (checkflagFunc == "true")
   {
      for (i = 0; i < field.length; i++)
      {
         field[i].checked = false;
      }
      checkflagFunc = "false";
      //independit_search.functie.value = "-";
      return "Uncheck All";
   }
   else
   {
      for (i = 0; i < field.length; i++)
      {
         field[i].checked = true;
      }
      checkflagFunc = "true";
      //independit_search.functie.value = "*";
      return "Check All";
   }
}
function checkExp(field) {
   if (checkflagExp == "true")
   {
      for (i = 0; i < field.length; i++)
      {
         field[i].checked = false;
      }
      checkflagExp = "false";
      independit_search.expertise.value = "-";
      return "Uncheck All";
   }
   else
   {
      for (i = 0; i < field.length; i++)
      {
         field[i].checked = true;
      }
      checkflagExp = "true";
      independit_search.expertise.value = "*";
      return "Check All";
   }
}
function checkReg(field) {
   if (checkflagReg == "true")
   {
      for (i = 0; i < field.length; i++)
      {
         field[i].checked = false;
      }
      checkflagReg = "false";
      //independit_search.regio.value = "-";
      return "Uncheck All";
   }
   else
   {
      for (i = 0; i < field.length; i++)
      {
         field[i].checked = true;
      }
      checkflagReg = "true";
      //independit_search.regio.value = "*";
      return "Check All";
   }
}

/* checkform fields of the login page and the forgot password page */

function validateLogin(theForm) {
   if (theForm.name.value == '') {
      alert('U moet een inlog naam invoeren.');
      theForm.name.focus();
      return false;
   }
   if (theForm.pass.value == '') {
      alert('U moet een wachtwoord invoeren.');
      theForm.pass.focus();
      return false;
   }
   return true;
}

function isValidEmailJS(strEmail)
{  var strPattern = "^[-_.\+\\w]+@((([\\w]|[\\w][\\w-]*[\\w])\\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$";
   var regexp = new RegExp(strPattern);
   var boolResult = regexp.test(strEmail.toLowerCase());
   return boolResult;
}

function validateForgottenPass(theForm) {
   var email = theForm.email.value;

   if (email == "")
   {
      alert('U moet een email adres invoeren');
      return false;
   } else if (!isValidEmailJS(email)) {
      alert('U heeft een ongeldige email adres ingevoerd.');
      return false;
   }
   return true;
}

function validateChangePass(theForm) {
   var ww = theForm.ww.value;
   var ww1 = theForm.ww1.value;
   var ww2 = theForm.ww2.value;
   
   
   if (ww == "")
   {
      alert('Vul aub alle velden in');
      return false;
   }
   if (ww1 == "")
   {
      alert('Vul aub alle velden in');
      return false;
   }
   if (ww2 == "")
   {
      alert('Vul aub alle velden in');
      return false;
   }
   if (ww2 != ww1)
   {
      alert('De wachtwoorden zijn niet gelijk');
      return false;
   }
   return true;
}


/* free lancers zoekpagin */
/** de_select_all
*  making it able to deselct all kinds of checkboxes.
*
*/
function de_selectAll() {
   var selectBox = window.document.search_freelancers.selectBox;
   var checked = selectBox.checked;
   
   var checkBoxes = elemsByClass('checkbox');
   var boolNewStatus;

   if (checkBoxes)
   {
      if (checked)
         boolNewStatus = true;
      else
         boolNewStatus = false;
      
      for (var i=0;i<checkBoxes.length ;i++ )
      {
         checkBoxes[i].checked = boolNewStatus;
      }
   }

   return true;
}

function validateFreeLancers_search(theForm) {
   var checkBoxes = elemsByClass('checkbox');
   var checked = false;

   if (checkBoxes)
   {
      for (var i=0;i<checkBoxes.length;i++ )
      {
         if (checkBoxes[i].checked)
         {
            checked = true;
            break;
         }
      }

      if (!checked)
      {
         alert('U moet minstens 1 van de competenties aanvinken.');
         return false;
      }

      if (theForm.zipcode1.value != "") {
         if (!theForm.zipcode1.value.match(/^[0-9]{4}/)) {
            alert('Er mogen alleen 4 getallen van de postcode ingevoerd worden.');
            theForm.zipcode1.focus();
            return false;
         }

         if (theForm.zipcode2.value != "") {
            if (!theForm.zipcode2.value.match(/[a-zA-Z]{2}/)) {
               alert('Het tweede veld van de postcode bevat alleen letters.');
               theForm.zipcode2.focus();
               return false;
            }
         } else {
            alert('U dient een valide postcode in te voeren.');
            theForm.zipcode2.focus();
            return false;
         }
      }
      
      if (theForm.datumfield.value != "") {
         if (!theForm.datumfield.value.match(/[0-9]{2}-[0-9]{2}-[0-9]{4}/)) {
            alert('U moet een geldige datum invoeren.');
            theForm.datumfield.focus();
            return false;
         }
      } else {
         alert('U moet een datum invoeren.');
         theForm.datum.focus();
         return false;
      }

      return true;
   }
}
/* end */

function validateTipForm(form) {
   if (form.lara.value == '') {
      alert('Het lara nummer is verplicht.');
      form.lara.focus();
      return false;
   }

   return true;
}


function validateSearch(){

   for(i=0; i<document.independit_search.competenties.length; i++)
      if(document.independit_search.competenties[i].checked == true)  
         var comp = "jaaaaaa";
   if(!comp){
      alert("Selecteer alstublieft een competentie")
      return false;
   }

   for(i=0; i<document.independit_search.regio.length; i++)
      if(document.independit_search.regio[i].checked == true)  
         if(comp) 
            return true;
   alert("Selecteer alstublieft een Provincie")
   return false;
}
