function isOpera() { 
  return navigator.userAgent.indexOf("Opera") > -1;
}
var opera = isOpera();
function jr2(){var jr3 = document.getElementsByTagName("li");if(jr3.length){for(var i=0; i < jr3.length; i++){if(jr3[i].className == "linormal"){jr3[i].onmouseover = function() {this.className = "lihover"; };jr3[i].onmouseout = function() { this.className = "linormal"; };};};};}
function noDialogShow(url,width)
    {
    var left =screen.width - (width+10);
    window.open(url, "CMS", "dependent=yes,width="+width+"px,left="+left+"px,top=0");
    }

function modelessDialogShow(url,width,height)
    {
    var left = screen.availWidth/2 - width/2;
    var top = screen.availHeight/2 - height/2;
    window.open(url, "CMS", "dependent=yes,width="+width+"px,height="+height+",left="+left+",top="+top);
    }

function pseudoFocus()
{
    var field = document.getElementsByTagName("input");
    for(var i=0; i < field.length; i++) 
    {
        if(field[i].type == "text")
        {
            field[i].onfocus = function() {this.className += "focus"; };
            field[i].onblur = function() { this.className = this.className.replace(/focus/, ""); };
        }
    }
}
function checkAd()
{
	if(document.forms.blokinhoud.adsense)
	{
		var d=document.forms.blokinhoud.adsense;
		if(getCheckedValue(d)=='1')
		{
			document.getElementById('adpag').innerHTML=document.getElementById('ad1').innerHTML;
			document.getElementById('ad0').style.display="none";
		}
		if(getCheckedValue(d)=='0')
		{
			document.getElementById('adpag').innerHTML=document.getElementById('ad2').innerHTML;
			document.getElementById('ad0').style.display="inline";
		}
		//alert(d);
	}
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
function focusTA()
{
    var vld=document.getElementById("bericht");
    if(vld)vld.className += "focus";
}
function blurTA()
{
    var vld=document.getElementById("bericht");
    if(vld)vld.className = vld.className.replace(/focus/, "");
}
function createElm(element) {
    if (typeof document.createElementNS != 'undefined') {
        return document.createElementNS('http://www.w3.org/1999/xhtml', element);
        }
    if (typeof document.createElement != 'undefined') {
        return document.createElement(element);
        }
    return false;
}

function textareaResizer() {
    var labels = document.getElementsByTagName('label');
    for(i=0; i<labels.length; i++) {
        if(labels[i].getAttribute('title') == 'Uw bericht') {
            enlarge = createElm('a');
            enlarge.setAttribute('style', 'cursor: pointer;text-decoration:underline;');
            enlarge.onclick = function () { document.getElementById('bericht').rows += 5; }
            enlarge.setAttribute('title', 'Klik om het tekst gebied te vergroten.');
            enlarge.appendChild(document.createTextNode('Vergroot'));
            decrease = createElm('a');
            decrease.setAttribute('style', 'cursor: pointer;text-decoration:underline;');
            decrease.onclick = function () { document.getElementById('bericht').rows -= 5; }
            decrease.setAttribute('title', 'Klik om het tekst gebied te verkleinen.');
            decrease.appendChild(document.createTextNode('verklein'));

            small = createElm('small');
            small.appendChild(document.createTextNode(' ('));
            small.appendChild(enlarge);
            small.appendChild(document.createTextNode(' of '));
            small.appendChild(decrease);
            small.appendChild(document.createTextNode(' tekst gebied)'));
            labels[i].appendChild(small);
        }
    }
}
function domFunction(f, a) {
    var n = 0;
    var t = setInterval(function() {
        var c = true;
        n++;
        if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)) {
            c = false;
            if(typeof a == 'object') {
                for(var i in a) {
                    if((a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)) { 
                        c = true; 
                        break; 
                    }
                }
            }
            if(!c) { f(); clearInterval(t); }
        }
        if(n >= 60) {
            clearInterval(t);
        }
    }, 250);
};
function verstuurForm()
{
    var doc=document.forms['contact'];
    if(opera) 
    {
        if(doc)doc.onsubmit=new Function("return controleerFormOpera()");
    } else {
        if(doc)doc.onsubmit=new Function("return controleerForm()");
    }
}
function controleerForm()
{
    var doc=document.forms['contact'];
    if(doc.fnaam.value=="") {
        alert("Graag een naam invullen.\n\n[Your name is required.]")
        doc.fnaam.focus();
        return false; }
    if(doc.emeel.value=="") {
        alert("Vul a.u.b. een e-mail adres in.\n\n[Your e-mail address is required.]")
        doc.emeel.focus();
        return false; }
    if(doc.emeel.value!="") {
        var atPos = doc.emeel.value.indexOf("@")
        pPos = doc.emeel.value.indexOf(".",atPos)
        if (atPos > 0 && pPos > atPos+1)
        {  } else {
            alert("Het ingevoerde e-mail adres is niet geldig.\n\n[This email address is not valid.]");
            doc.emeel.focus();
            return false; } }
    if(doc.bericht.value=="") {
        alert("Tja... \nWat is een email zonder inhoud?\nGraag een bericht invullen.\n\n[Your comment or message please.]")
        doc.bericht.focus();
        return false; }
    return true;
}
function controleerFormOpera()
{
    var doc=document.forms['contact'];
    if(doc.fnaam.value=="") {
        alert("Graag een naam invullen.\n\n[Your name is required.]")
        return false; }
    if(doc.emeel.value=="") {
        alert("Vul a.u.b. een e-mail adres in.\n\n[Your e-mail address is required.]")
        return false; }
    if(doc.emeel.value!="") {
        var atPos = doc.emeel.value.indexOf("@")
        pPos = doc.emeel.value.indexOf(".",atPos)
        if (atPos > 0 && pPos > atPos+1)
        {  } else {
            alert("Het ingevoerde e-mail adres is niet geldig.\n\n[This email address is not valid.]");
            doc.emeel.select();
            return false; } }
    if(doc.bericht.value=="") {
        alert("Tja... \nWat is een email zonder inhoud?\nGraag een bericht invullen.\n\n[Your comment or message please.]")
        return false; }
    return true;
}




/*
function toggleLanguageSelector(e) {
	if (this.className.search(/\bclosed\b/g) >= 0) {
		this.className = this.className.replace(/\s*\bclosed\b/g, '');
		this.className += ' open';
		this.style.height = this.rel;
	} else {
		// Minimize language selector
		this.className = this.className.replace(/\s*\bopen\b/g, '');
		this.className += ' closed';
		this.style.height = "20px";
	}
}
*/

//
//
function chooseLanguage(e) {
	e = e || window.event;

	var div = document.getElementById('language-selector');
	var select = document.getElementById('current-language');
	/*if (div && (div.className.search(/\bopen\b/g) >= 0)) {*/
		// Cancel bubbling
		e.cancelBubble = true;
		if (e.stopPropagation) { e.stopPropagation(); }

		var title = this.firstChild.nodeValue;
		var abbr  = this.getAttribute('lang');
		var form = div.getElementsByTagName('form').item(0);
		if (select && form) {
			select.value = abbr;
			form.submit();
		}
	/*}*/
	div = null;
	select = null;

	return false;
}

/*
function enhanceLanguageSelector()
{
	var div = document.getElementById('language-selector');
	if (div) {
		
		div.setAttribute('style','border-bottom:1px solid rgb(255,244,200);border-top:1px solid rgb(255,244,200);color:#666600;cursor:pointer;cursor:hand;');
		var form   = div.getElementsByTagName('form').item(0);
		var img   = div.getElementsByTagName('img').item(0);
		var select = document.getElementById('current-language');
		if (form && select) {
			var lang = false;
			var options = select.getElementsByTagName('option');
			var ul = createElm('ul');
			ul.style.display = 'none';
			form.appendChild(ul);
			var txt;
			for (var i = 0; i < options.length; i++) {
				txt = options[i].firstChild.nodeValue;
				var li = createElm('li');
				// Set flag image as list item background
				li.style.backgroundImage = 'url("http://www.asianproperties.nl/site/img/'+ options[i].value +'.gif")';
				li.style.cursor = 'pointer';
				li.lang = options[i].value;
				li.onclick = chooseLanguage;
				li.title= ""+txt;
				li.onmouseover = function () {this.style.textDecoration='underline'};
				li.onmouseout = function () {this.style.textDecoration='none'};
				li.appendChild( document.createTextNode(txt) );
				// Set selected language
				if (i == select.selectedIndex) {
					li.className += ' current';
					lang = txt;
				}
				ul.appendChild(li);
				li = null;
			}

			// Add toggle behavior to <div>
			div.className += ' closed';
			//div.onclick = toggleLanguageSelector;
			div.onmouseover = toggleLanguageSelector;
			div.onmouseout = toggleLanguageSelector;
			div.rel = i * 20 + "px" ;

			// Hide select box, show unordered list
			select.style.display = 'none';
			ul.style.display = '';
			img.style.display = 'none';
		}

		// Delete JS references to DOM nodes from memory
		form	= null;
		select	= null;
		options	= null;
		ul		= null;
		div		= null;
		img		= null;
	}
}
*/

//****************************************************************
//****************************************************************
	var arrowImage = 'img/select_arrow.gif';
	var arrowImageOver = 'img/select_arrow_over.gif';
	var arrowImageDown = 'img/select_arrow_down.gif';	
	var selectBoxIds = 0;
	var currentlyOpenedOptionBox = false;
	var editableSelect_activeArrow = false;
	
	function selectBox_switchImageUrl()
	{
		if(this.src.indexOf(arrowImage)>=0){
			this.src = this.src.replace(arrowImage,arrowImageOver);	
		}else{
			this.src = this.src.replace(arrowImageOver,arrowImage);
		}	
	}
	
	function selectBox_showOptions()
	{
		if(editableSelect_activeArrow && editableSelect_activeArrow!=this){
			editableSelect_activeArrow.src = arrowImage;
			
		}
		editableSelect_activeArrow = this;
		
		var numId = this.id.replace(/[^\d]/g,'');
		var optionDiv = document.getElementById('selectBoxOptions' + numId);
		if(optionDiv.style.display=='block'){
			optionDiv.style.display='none';
			/* if(navigator.userAgent.indexOf('MSIE')>=0)document.getElementById('selectBoxIframe' + numId).style.display='none';*/
			this.src = arrowImageOver;	
		}else{			
			optionDiv.style.display='block';
			/* if(navigator.userAgent.indexOf('MSIE')>=0)document.getElementById('selectBoxIframe' + numId).style.display='block';*/
			this.src = arrowImageDown;	
			if(currentlyOpenedOptionBox && currentlyOpenedOptionBox!=optionDiv)currentlyOpenedOptionBox.style.display='none';	
			currentlyOpenedOptionBox= optionDiv;			
		}
	}
	
	var activeOption;
	function highlightSelectBoxOption()
	{
		if(this.style.backgroundColor=='#316AC5'){
			this.style.backgroundColor='';
			this.style.color='';
		}else{
			this.style.backgroundColor='#316AC5';
			this.style.color='#FFF';			
		}	
		
		if(activeOption){
			activeOption.style.backgroundColor='';
			activeOption.style.color='';			
		}
		activeOption = this;
		
	}
	
function createImgSelect()
{
	var div = document.getElementById('language-selector');
	if (div) 
	{
		var form   = div.getElementsByTagName('form').item(0);
		var select = document.getElementById('current-language');
		if (form && select) 
		{	
			//select.className='selectBoxInput';		
			var div = document.createElement('DIV');
			//div.style.styleFloat = 'left';
			div.style.width = select.offsetWidth + 40 + 'px'; // img:15 + padding:1 + padding-sBcurrent:20 + margin-sBcurrent:4
			div.style.position = 'relative';
			div.id = 'selectBox' + selectBoxIds;
			var parent = select.parentNode;
			parent.insertBefore(div,select);
			div.appendChild(select);	
			div.className='selectBox';
			div.style.zIndex = 10000 - selectBoxIds;
			
			var img = document.createElement('IMG');
			img.src = arrowImage;
			img.className = 'selectBoxArrow';
			img.onmouseover = selectBox_switchImageUrl;
			img.onmouseout = selectBox_switchImageUrl;
			img.onclick = selectBox_showOptions;
			img.id = 'arrowSelectBox' + selectBoxIds;

			div.appendChild(img);
		
			var optionDiv = document.createElement('DIV');
			optionDiv.id = 'selectBoxOptions' + selectBoxIds;
			optionDiv.className='selectBoxOptionContainer';
			optionDiv.style.width = div.offsetWidth-2 + 'px';
			div.appendChild(optionDiv);
			
			/*
			// Added iframe behind the "select box" in order to cover select boxes below in IE. 
			// Ref: problem with windowed vs. window less elements.
			
			if(navigator.userAgent.indexOf('MSIE')>=0)
			{
				var iframe = document.createElement('<IFRAME src="about:blank" frameborder=0>');
				iframe.style.width = optionDiv.style.width;
				iframe.style.height = optionDiv.offsetHeight + 'px';
				iframe.style.display='none';
				iframe.id = 'selectBoxIframe' + selectBoxIds;
				div.appendChild(iframe);
			}
			*/
			
			/*if(dest.getAttribute('selectBoxOptions'))
			{
				var options = dest.getAttribute('selectBoxOptions').split(';');*/
				var lang = false;
				var options = select.getElementsByTagName('option');
				var optionsTotalHeight = 0;
				var optionArray = new Array();
				for(var no=0;no<options.length;no++)
				{
					var txt = options[no].firstChild.nodeValue;
					var anOption = document.createElement('DIV');
					/*var langt = options[no].split('-');
					//anOption.innerHTML = options[no][1];
					anOption.innerHTML = langt[1];*/
					anOption.appendChild(document.createTextNode(txt));
					anOption.style.background = 'scroll left center no-repeat transparent url("http://www.asianproperties.nl/site/img/'+ options[no].value +'.gif")';
					anOption.className='selectBoxAnOption';
					anOption.onclick = chooseLanguage;
					anOption.lang = options[no].value;
					anOption.style.width = optionDiv.style.width.replace('px','') - 22 + 'px'; 
					anOption.onmouseover = highlightSelectBoxOption;
					if (no == select.selectedIndex) {
						anOption.id += 'sBcurrent' + selectBoxIds;
						lang = txt;
					}
					optionDiv.appendChild(anOption);	
					optionsTotalHeight = optionsTotalHeight + anOption.offsetHeight;
					optionArray.push(anOption);
					anOption = null;
				}
				optionDiv.style.height = no * 20 + "px";
				
				// 
				if(optionsTotalHeight > optionDiv.offsetHeight)
				{
					for(var no=0;no<optionArray.length;no++)
					{
						optionArray[no].style.width = optionDiv.style.width.replace('px','') - 42 + 'px'; 	
					}	
				}
				
				// sBcurrent
				// zet geselecteerde waarde in het 'veld'
				if(document.getElementById('sBcurrent' + selectBoxIds))
				{
					var sel = document.createElement('DIV');
					sel.style.position = 'relative';
					sel.style.background = document.getElementById('sBcurrent' + selectBoxIds).style.background;
					sel.style.width = select.offsetWidth - 34 + 'px';
					sel.style.padding = '1px 0 0 20px';
					sel.style.marginLeft = '4px';
					sel.style.cursor = 'default';
					sel.innerHTML = document.getElementById('sBcurrent' + selectBoxIds).innerHTML;
					sel.onclick = selectBox_showOptions;
					sel.id = 'sbcurr' + selectBoxIds;
					var parent2 = div.parentNode;
					parent2.insertBefore(sel,div);
					div.appendChild(sel);	
				}

				optionDiv.style.display='none';
				optionDiv.style.visibility='visible';
				
				// Hide select box, show div-select list
				select.style.display = 'none';
				
			/*}*/
			selectBoxIds = selectBoxIds + 1;
						
		}
	}
}
window.onload=createImgSelect;
	
//****************************************************************










/*window.onload=enhanceLanguageSelector;*/



























var foobar = new domFunction(function() {
    pseudoFocus();
    textareaResizer();
    verstuurForm();
    jr2();
    });

