function checkEmail(strEmail) { return (strEmail.search(/^[\w\.\-_]*[A-Z|a-z|0-9]{1}@([\w\-_]+\.)+[A-Za-z]{2,4}$/) != -1) }
function fnChkSendFrm() {
	var msgErr		= "De volgende velden zijn niet, of niet juist, ingevuld:\n\n";
	var msgName		= "- uw naam\n";
	var msgEmail	= "- uw e-mailadres\n";
	var msgReceiver = "- naam ontvanger\n";
	var msgEmailRec	= "- e-mailadres ontvanger\n";
	var oFrm = document.forms.frmFriend;
	var errLvl = 0;
	var errMsg = "";

	if(oFrm.txtNameSender.value == '') { errLvl = 1; errMsg += msgName; }
	if((oFrm.txtEmailSender.value == '') || (checkEmail(oFrm.txtEmailSender.value) == false)) { errLvl = 1; errMsg += msgEmail; }
	if(oFrm.txtNameRecipient.value == '') { errLvl = 1; errMsg += msgReceiver; }
	if((oFrm.txtEmailRecipient.value == '') || (checkEmail(oFrm.txtEmailRecipient.value) == false)) { errLvl = 1; errMsg += msgEmailRec; }

	if(errLvl != 0) {
		alert(msgErr + errMsg);
	} else {
		oFrm.submit();
	}
}
function fnChkReactionFrm() {
	var msgErr		= "De volgende velden zijn niet, of niet juist, ingevuld:\n\n";
	var msgName		= "- uw naam\n";
	var msgEmail	= "- uw e-mailadres\n";
	var msgPhone	= "- uw telefoonnummer\n";
	
	var oFrm = document.forms.frmReact;
	var errLvl = 0;
	var errMsg = "";

	if(oFrm.txtName.value == '') { errLvl = 1; errMsg += msgName; }
	if(oFrm.txtPhone.value == '') { errLvl = 1; errMsg += msgPhone; }
	if((oFrm.txtEmail.value == '') || (checkEmail(oFrm.txtEmail.value) == false)) { errLvl = 1; errMsg += msgEmail; }

	if(errLvl != 0) {
		alert(msgErr + errMsg);
	} else {
		oFrm.submit();
	}
}

var mouseOverId = false;
var oldMouseOverId = false;
var openFaq = false;

var btnOn = new Image(15, 15);
btnOn.src = "img/btSecTopOn.gif";
var btnOff = new Image(15, 15);
btnOff.src = "img/btSecTopOff.gif";

function printrental(type, contID, wonType) {
	window.open("print_version.asp?id=" + type + "&ctid=" + contID + "&wontype=" + wonType + "", "printrental", "top=10,left=10,width=700,height=800,scrollbars=1");
}

function respondrental(type, contID, wonType) {
	window.open("respond_version.asp?id=" + type + "&ctid=" + contID + "&wontype=" + wonType + "", "respondrental", "top=10,left=10,width=700,height=800,scrollbars=1");
}
function sendafriendrental(type, contID, wonType) {
	window.open("sendtofriend_version.asp?id=" + type + "&ctid=" + contID + "&wontype=" + wonType + "", "sendtofriendrental", "top=10,left=10,width=700,height=800,scrollbars=1");
}

function mouseOverSection(id) {
	var t = document.getElementById("mnuSecTop" + id);
	var b = document.getElementById("mnuSecBot" + id);

	if (oldMouseOverId && oldMouseOverId != id) {
		mouseRealOutSection(oldMouseOverId);
	}
	mouseOverOriginal = "Off"
	if (arguments.length == 2) {
		mouseOverOriginal = "On"
	}
	try {
		var m = document.getElementById("mnuSecDiv" + id);
		m.style.left = (getOffsetLeft(t)) + "px"
		m.style.top = (getOffsetTop(t)+41) + "px"
		m.style.display = "block";
	} catch(e) { }
	if (t.className.indexOf("ItemOn") == -1) {
		var str;
		if (t.src.toString().indexOf("?repurl=") > -1) {
			t.className = t.className + " FilterRequired";
			t.style.filter = "";
			str = t.src.toString().substr(t.src.toString().indexOf("?repurl=") + 8)
		} else {
			str = t.src;
		}
		t.src = str.replace("_Off.png","_Hover.gif");
	}
	mouseOverId = id;
}

function mouseOutSection(id) {
	oldMouseOverId = mouseOverId;
	mouseOverId = false;
	setTimeout("mouseRealOutSection('"+id+"',true)", 100);
}

function mouseRealOutSection(id) {
	var t = $("mnuSecTop" + id);
	var b = document.getElementById("mnuSecBot" + id);
	if (!mouseOverId) {
			if (!t.hasClassName("ItemOn")) {
				var str;
				if (t.hasClassName("FilterRequired")) {
					t.removeClassName("FilterRequired");
					t.removeClassName("IsOff");
					str = t.src.replace("_Hover.gif","_Off.png");
					t.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+str+'",sizingMethod="scale")';
					str = "/img/white.gif?repurl=" + str;
				} else {
					str = t.src.replace("_Hover.gif","_Off.png");
				}
				t.src = str;
				
			}
		try {
			var m = document.getElementById("mnuSecDiv" + id);
			m.style.display = "none";
		} catch(e) { }
	}
}

function getOffsetLeft(el) { 
	var eltemp = el;
	var ol = el.offsetLeft; 
	while((eltemp = eltemp.offsetParent) != null) 
   	ol += eltemp.offsetLeft;
	return ol;
}

function getOffsetTop (el) { 
   var eltemp2 = el;
   var ot = el.offsetTop; 
   while((eltemp2 = eltemp2.offsetParent) != null) 
   	ot += eltemp2.offsetTop;
	return ot;
}

function faqOpen(id) {
	if (openFaq) {
		faqClose(openFaq);
	}
	document.getElementById("faq" + id + "_open").style.display="block";
	document.getElementById("faq" + id + "_closed").style.display="none";
	openFaq = id;
	window.location = "#f" + id;
}

function faqClose(id) {
	document.getElementById("faq" + id + "_open").style.display="none";
	document.getElementById("faq" + id + "_closed").style.display="block";
	openFaq = false;
}

function enlarge() {
	if (arguments.length == 1) {
		url = arguments[0].replace("thumb","large").replace("small","large").replace("normal","large").replace("leftbar","large").replace("rightbar","large");
		window.open("enlarge.asp?img="+url,'intermarislarge','width=300,height=200,top=100,left=200');
	}
}

function fnChkSearchFrm()
{
	var sSearchStr = document.forms.frmSearch.q.value;
	if(sSearchStr.length < 3)
	{
		alert("Vul minimaal 3 karakters in a.u.b.");
	} else {
		document.forms.frmSearch.submit();
	}
}

function trapEnter(e, enterFunction){
  try {
    if (!e) e = window.event;
    if (e.keyCode == 13){
      e.cancelBubble = true;
      if (e.returnValue) e.returnValue = false;
      if (e.stopPropagation) e.stopPropagation();
      if (enterFunction) eval(enterFunction);
      return false;
    } else {
      return true;
    }     
  }
  catch (e) {  }
 }


function setFrameHeight() {
	if (document.getElementById('frmContent') != null)
	{
		var winHeight = 0;
		if(typeof(window.innerHeight) == 'number') { winHeight = window.innerHeight; } 
		else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { winHeight = document.documentElement.clientHeight; } 
		else if (document.body && ( document.body.clientWidth || document.body.clientHeight)) { winHeight = document.body.clientHeight; }
		var obj = document.getElementById('frmContent');
		winHeight = winHeight - 192;
		obj.style.height = winHeight;
	}
}
var nCurrTab = 1;
function fnSwitchTab(Nr) {
	var currTab = document.getElementById("tdTab" + nCurrTab);
	var newTab = document.getElementById("tdTab" + Nr);
	var currDiv = document.getElementById("divTab" + nCurrTab);
	var newDiv = document.getElementById("divTab" + Nr);
	currTab.className = currTab.attributes.rel.value;
	newTab.className = "tab tabOn";
	currDiv.style.display = "none";
	newDiv.style.display = "block";
	nCurrTab = Nr;
}
	
var SlideShow = Class.create({
	_element : null,
	_photo1 : null,
	_photo2 : null,
	_coverOverlay : null,
	_coverText : null,
	_photos : [],
	_idx : 0,
	_image : function(src, idx, hideByDefault) {
		return "<img src=\"" + src + "\" width=\"772\" alt=\"IntermarisHoeksteen\" title=\"\" id=\"homepagePhoto" + idx + "\" class=\"homepagePhoto\" " + (typeof hideByDefault != "undefined" && hideByDefault ? " style=\"display:none;\"" : "") + " />";
	},
	_cover : function(text) {
		return "<div id=\"cover-overlay\" style=\"display:none;\"></div><div id=\"cover-text\" style=\"display:none;\"><div class=\"padding\">" + text +"</div>";
	},
	_swapPhoto : function(src) {
		var newPhoto = null, oldPhoto = null;
		if (this._photo1.visible()) {
			newPhoto = this._photo2;
			oldPhoto = this._photo1;
		} else {
			newPhoto = this._photo1;
			oldPhoto = this._photo2;
		}
		newPhoto.style.zIndex = 15;
		newPhoto.src = src;
		oldPhoto.style.zIndex = 10;
		Effect.Appear(newPhoto, {
			duration: 5,
			afterFinish: function() {
				oldPhoto.hide();
			}
		});
	},
	_nextPhoto : function() {
		var oldIndex = this._idx;
		if (this._idx+1 < this._photos.length) {
			this._idx++;
		} else {
			this._idx = 0;
		}
		if (this._idx != oldIndex) {
			this._swapPhoto(this._photos[this._idx].src);
			this._waitForNext();
		}
	},
	_waitForNext : function() {
		var t = this;
		(function() {
			t._nextPhoto();
		}).delay(6);
	},
	_waitForCover : function() {
		var t = this;
		(function() {
			Effect.Appear(t._coverOverlay, {
				duration: 4,
				to: 0.45
			});
			Effect.Appear(t._coverText, {
				duration: 5
			});
		}).delay(1);
	},
	initialize : function(photos, text) {
		this._element = $("mainPhoto");
		var t = this;
		photos.each(function(photo) {
			var newimage = new Image();
			newimage.src = photo;
			t._photos.push(newimage);
		});
		if (this._photos.length > 0) {
			
			var s = this._image(photos[0], 1) +
				this._image("", 2, true);
				//this._cover(text);
				
			this._element.update(s);
			this._photo1 = $("homepagePhoto1");
			this._photo2 = $("homepagePhoto2");
			//this._coverOverlay = $("cover-overlay");
			//this._coverText = $("cover-text");
			this._waitForNext();
			//this._waitForCover();
		} else {
			this._element.update( this._image("/img/splashHomepage.jpg", 1) );
		}
	}
});