﻿var currentPage = new String();

var backImagesRight = new Array();
backImagesRight[0] = "coralRight.png";
backImagesRight[1] = "OrhideeRight.png";

var backImagesLeft = new Array();
backImagesLeft[0] = "coralLeft.png";
backImagesLeft[1] = "OrhideeLeft.png";


function average() {
    var items = average.arguments.length;
    var sum = 0;

    for (i = 0; i < items; i++) {
        sum += average.arguments[i];
    }

    return (sum / items);
}
function showRandomMarginPictures(leftVerticalPosition, rightVerticalPosition) {
    if (showMargins == false) {
        leftVerticalPosition = null;
        rightVerticalPosition = null;
    }

    var randomNr = Math.floor(Math.random() * (backImagesLeft.length));
    
    if (randomNr == 0 || currentPage == "home") {
        if (leftVerticalPosition)
        {
            document.getElementById('marginleft').style.backgroundImage = "url('images/coralLeft.png')";
            document.getElementById('marginleft').style.backgroundPosition = "right bottom";
        }
    }
    else {
        if (leftVerticalPosition)
        {
            document.getElementById('marginleft').style.backgroundImage = "url(images/" + backImagesLeft[randomNr]  + ")";
        }
        if (rightVerticalPosition)
        {
            document.getElementById('marginright').style.backgroundImage = "url(images/" + backImagesRight[randomNr]  + ")";
        }
    }
}
function getUrlParam( 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 removeUrlParam(URL, param)
{
	URL = String(URL);
	var regex = new RegExp( "\\?" + param + "=[^&]*&?", "gi");
	URL = URL.replace(regex,'?');
	regex = new RegExp( "\\&" + param + "=[^&]*&?", "gi");
	URL = URL.replace(regex,'&');
	URL = URL.replace(/(\?|&)$/,'');
	regex = null;
	return URL;
}

