// De framecheck functie
function framesCheck(check, currentURL, frameHeight, frameMaxWidth) {
  if ( check != 1 ) return false;

	if( ! ( top.content_frame ) ) {
    top.location.replace( 'http://www.examen.nl/index.html?url=' + currentURL + '&h=' + frameHeight + '&mw=' + frameMaxWidth );
  }
}

function framesCheckScan(check, currentURL, frameHeight, frameMaxWidth) {
  if ( check != 1 ) return false;

	if( ! ( top.content_frame ) ) {
    top.location.replace( 'http://www.examen.nl/index.html?url=' + currentURL + '%26marker=ok&h=' + frameHeight + '&mw=' + frameMaxWidth );
  }
}


// Functie voor het opvragen van URL parameters
function gup( name ){  
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null ) {   
    return "";
  }
  else {
    return results[1];
  }
}

function urlencode( str ) {
  str = escape( str );
  str = str.replace('+', '%2B');
  str = str.replace('%20', '+');
  str = str.replace('*', '%2A');
  str = str.replace('/', '%2F');
  str = str.replace('@', '%40');
  return str;
}

function urldecode(str) {
  str = str.replace('+', ' ');
  str = unescape(str);
  return str;
}

function setFrameParams( param_url, param_height, param_maxwidth, param_framecheck ) {
  if ( param_url ) {
	  frame_url = param_url;
  }
  if ( param_height && !isNaN( param_height * 1 ) ) {
    frame_height = param_height;
  }
  if ( param_maxwidth && !isNaN( param_maxwidth * 1 ) ) {
    frame_maxwidth = param_maxwidth;
  }
  
  //alert(frame_url+frame_height+frame_maxwidth);
  // Set iframe to maxwidth
  if (frame_maxwidth == 1) {
    // Reset maxwidth
    frame_maxwidth = 0;
    // Clear the RightBar
    document.getElementById("RightBar").innerHTML = "";
    // Hide RightBar
    document.getElementById("RightBar").style.display = "none";
    // Display ContentSection in full width
    document.getElementById("ContentSection").style.width = "980px";
  }
  else {
    if ( param_framecheck != 1 ) {
      // Get RightBar content from temporary store     
      document.getElementById("RightBar").innerHTML = rightBarHtml;
    }
    // Show RightBar
    document.getElementById("RightBar").style.display = "block";
    // Display ContentSection in normal width
    document.getElementById("ContentSection").style.width = "634px";
  }
  
  // Set iframe src
  document.getElementById("content_frame").src = urldecode(frame_url);
  // Set iframe height
  document.getElementById("content_frame").style.height = frame_height + "px";
             
  if ( param_framecheck != 1 ) {
    // Reload the top banner
    document.getElementById("banner_top").src = document.getElementById("banner_top").src;
  }
}