


function deleteInitialText(objInput, strInitialText)
{
	if (objInput.value == strInitialText)
	{
		objInput.value = "";
		objInput.style.color = "#000000";
	}
}

function insertInitialText(objInput, strInitialText)
{
	if (objInput.value == "")
	{
		objInput.value = strInitialText;
		objInput.style.color = "#aaaaaa";
	}
}

function addHyperLinksToContent(strElementID)
{
	objContentElement = document.getElementById(strElementID);
	myText = objContentElement.innerHTML;
	
	if (myText.indexOf("www.") > 0)
	{
		myText = myText.replace("www.", "http://www.");
		myText = myText.replace(/(\w+):\/\/[\S]+(\b|$)/gim, '<a href="$&" class="my_link" target="_blank">$&</a>');
	}

	objContentElement.innerHTML = myText;
}



function setMainImage(newSrc)
{
	document.mainimage.src = newSrc;
}

function setCaption(strNewText) 
{
	objCaptionElement = document.getElementById("captiontext");
	objCaptionElement.firstChild.data = strNewText;
}


function showElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	objElement.style.visibility = "visible";
	objElement.style.display = "block";
}

function hideElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	if (objElement != null) {
		objElement.style.visibility = "hidden";
		objElement.style.display = "none";
	}
}

function toggleElement(strElementID) 
{
	objElement = document.getElementById(strElementID);
	
	if ((objElement.style.visibility == "") || (objElement.style.visibility == "hidden"))
	{
		showElement(strElementID);
	} else {
		hideElement(strElementID);
	}
}

function toggleArticleMenuItem(strElementID)
{
	toggleElement(strElementID);
	
	if (strElementID == "sendafriend") {
		hideElement("meldongepast");
	} else if (strElementID == "meldongepast") {
		hideElement("sendafriend");
	}
}


function toggleAanvullendeInfo(myID)
{
	strBoxElementID = 'meerinformatie-'+ myID
    strLinkElementID = 'aanvullendlink-'+ myID
	
	toggleElement(strBoxElementID);
	
	objLinkElement = document.getElementById(strLinkElementID);
	
	if (objLinkElement.className == "moreinformation-plus") {
		objLinkElement.className = "moreinformation-minus";
	} else {
		objLinkElement.className = "moreinformation-plus";
	}

}


function toggleElementByCheckBox(strElementID, objCheckBox)
{
	if (objCheckBox.checked)
	{
		showElement(strElementID);
	} else {
		hideElement(strElementID);
	}
}

function toggleElementBySelect(strElementID, strValueToShow, objSelect)
{
	strSelectValue = objSelect.options[objSelect.selectedIndex].value;

	if (strSelectValue == strValueToShow)
	{
		showElement(strElementID);
	} else {
		hideElement(strElementID);
	}
}

function borderOn(objDiv)
{
	objDiv.style.border = "1px solid #175bc1";
}

function borderOff(objDiv)
{
	objDiv.style.border = "1px solid #CCCCCC";
}


function checkFileExtension(objUpload)
{
	uploadValue = objUpload.value;
	uploadName = objUpload.name;
	
	if (uploadValue != '')
	{
		extension = uploadValue.substring(uploadValue.lastIndexOf(".")+1);
		extension = extension.toLowerCase();
		
		if ((extension == 'jpg') || (extension == 'jpeg')) {
			// that's fine
		} else {
			alert("'"+ uploadName + "' heeft het verkeerde bestandstype: "+ extension.toUpperCase() + "\nAlleen JPG fotobestanden zijn toegestaan.");
		}
	}
}


function openTextBanner(position)
{
	prefix = "ad_position_";

	// close all open banners (if any);
	closeAllDoorplaatsBanners();
	
	// dim all others;
	dimAllDoorplaatsTitles();
	
	//highlight this one
	setTitleClass(position, 'selected');
	
	// get reference
	objDivTop  = document.getElementById('textbanners');
	
	divPos = ""+ findPos(objDivTop);
	
	currentLeftX = divPos.substring(0, divPos.indexOf(","));
	currentLeftY = divPos.substring(divPos.indexOf(",")+1);
	
	// set new pos
	newX = currentLeftX - 510;
	newY = currentLeftY - 200;
	
	// place
	strElementID = prefix + position;
	objAd = document.getElementById(strElementID);
	objAd.style.position = "absolute";
	objAd.style.left = newX + "px";
	objAd.style.top = newY + "px";

	// show
	showElement(strElementID);
}





function setTitleClass(position, className)
{
	strTitleElementID = "title-" + position;
	objTitle = document.getElementById(strTitleElementID);
	objTitle.className = className;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


var simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

function simpleEncode(valueArray,maxValue) {

var chartData = ['s:'];
  for (var i = 0; i < valueArray.length; i++) {
    var currentValue = valueArray[i];
    if (!isNaN(currentValue) && currentValue >= 0) {
    chartData.push(simpleEncoding.charAt(Math.round((simpleEncoding.length-1) * currentValue / maxValue)));
    }
      else {
      chartData.push('_');
      }
  }
return chartData.join('');
}
