﻿function resizer()
{
  var globalHeight = $('#globalheadercontainer').height();
  var headerHeight = $('#headercontainer').height();
  var menuHeight = 0;//$('#menucontainer').height();
  var footerHeight = $('#footer').height();
  
  var centerContentHeight = ($(window).height() - globalHeight - headerHeight - footerHeight - menuHeight);
  var contentOffset = $('#centerContent').height();

  if(contentOffset < centerContentHeight)
  {
    document.getElementById("contentcontainer").style.height = centerContentHeight + "px";
  }
  else if(contentOffset > centerContentHeight)
  {
    document.getElementById("bodycontainer").style.height = (contentOffset + globalHeight + headerHeight + footerHeight + menuHeight + 20) + "px";
    document.getElementById("outercontainer").style.height = (contentOffset + globalHeight + headerHeight + footerHeight + menuHeight + 20) + "px";
    document.getElementById("innercontainer").style.height = (contentOffset + globalHeight + headerHeight + footerHeight + menuHeight + 20) + "px";
    
    document.getElementById("contentcontainer").style.height = (contentOffset + 20) + "px";
  }
}

$(document).ready(function(){
  resizer();
  $("div.rounded").corner("round");
});

$(window).bind("resize", function(){
  resizer();
});

/////////////////////////////// LOGIN ///////////////////////////////
function CheckLoginForm(objLoginButton, userNameFieldId, passwordFieldId, strDefaultUserNameTxt, strDefaultPasswordTxt)
{
  var userName = trim(document.getElementById(userNameFieldId).value);
  var password = trim(document.getElementById(passwordFieldId).value);
  
  var alertTxt = "";
  
  if(userName == strDefaultUserNameTxt || userName == "")
    alertTxt += "U dient uw gebruikersnaam in te vullen\n";
  
  if(password == strDefaultPasswordTxt || password == "")
    alertTxt += "U dient uw wachtwoord in te vullen\n";  
  
  if(alertTxt == "")
  {
    __doPostBack(objLoginButton, "");
    return true;
  }
  else
  {
    alert(alertTxt);
    return false;
  }  
}

function SetDefaultPassWordText(objPasswordField, strDefaultPasswordText)
{
  document.getElementById(objPasswordField).value = strDefaultPasswordText;
}

function clearField(objTextBox, strDefaultText)
{
  if(objTextBox.value == strDefaultText)
    objTextBox.value = ""; 
}

function checkFieldCleared(objTextBox, strDefaultText)
{
  if(trim(objTextBox.value) == "")
    objTextBox.value = strDefaultText;
}

function IsEmail( emailStr) {
  var objRegExp  = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,3}$/i;
  return objRegExp.test(emailStr);
}

function trim(inputString) {
   if (typeof inputString != "string") { return inputString; }
   if(inputString == "") {return inputString;}
   
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") {
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) {
   // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue;
}

/////////////////////////////// VALIDATION ///////////////////////////////
function IsNumeric(intStr)
{
    if(intStr == null || intStr == 'undefined')
        return false;

    if (intStr.match(/^[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?$/))
        return true;
    else
        return false;
}

function IsEmail( emailStr) {
  var objRegExp  = /^[a-z]\w*([.\-]\w+)*@[a-z]\w*([.\-]\w+)*\.[a-z]{2,3}$/i;
  return objRegExp.test(emailStr);
}
