var breedteLoginDiv=260;var marginLeftRight=40;var movementLogin=30;var divs=new Array();divs[divs.length]='kaart_div';function selectIndex(id,index){var currentSelect=document.getElementById(id);for(i=0;i<currentSelect.options.length;i++){if(currentSelect.options[i].value==index){currentSelect.options[i].selected=true;}}}
function initSizeDivs(){}
function showInlogDiv(aantal){if(getCookie('loginDivShown')==null||getCookie('loginDivShown')!='1'){document.getElementById('loginDiv').style.left=parseInt(parseInt(document.getElementById('loginDiv').style.left)+movementLogin)+"px";for(i=0;i<divs.length;i++){if(document.getElementById(divs[i]).style.width!=undefined&&document.getElementById(divs[i]).style.width!=''){document.getElementById(divs[i]).style.width=parseInt(parseInt(document.getElementById(divs[i]).style.width)-movementLogin)+"px";document.getElementById(divs[i]).style.marginLeft=parseInt(parseInt(document.getElementById(divs[i]).style.marginLeft)+movementLogin)+"px";if(divs[i]=='kaart_div'){document.getElementById('routeKaart').style.width=document.getElementById(divs[i]).style.width;}}else{document.getElementById(divs[i]).style.width=parseInt(document.documentElement.clientWidth-movementLogin-marginLeftRight)+"px";document.getElementById(divs[i]).style.marginLeft=movementLogin+"px";if(divs[i]=='kaart_div'){document.getElementById('routeKaart').style.width=document.getElementById(divs[i]).style.width;}}
routeKaart.checkResize();}
aantal-=movementLogin;if(aantal-movementLogin>0){setTimeout('showInlogDiv('+aantal+')',10);}else{if(document.getElementById('routeOndergrond')!=undefined){document.getElementById('routeOndergrond').style.visibility='visible';}
if(document.getElementById('publiek')!=undefined){document.getElementById('publiek').style.visibility='visible';}
if(document.getElementById('datumDag')!=undefined){document.getElementById('datumDag').style.visibility='visible';}
if(document.getElementById('datumMaand')!=undefined){document.getElementById('datumMaand').style.visibility='visible';}
if(document.getElementById('datumJaar')!=undefined){document.getElementById('datumJaar').style.visibility='visible';}
if(document.getElementById('routeSportType')!=undefined){document.getElementById('routeSportType').style.visibility='visible';}
if(document.getElementById('routeKm')!=undefined){document.getElementById('routeKm').style.visibility='visible';}
setCookie('loginDivShown','1');}}}
function hideInlogDiv(aantal){document.getElementById('loginDiv').style.left=parseInt(parseInt(document.getElementById('loginDiv').style.left)-movementLogin)+"px";for(i=0;i<divs.length;i++){if(document.getElementById(divs[i]).style.width!=undefined&&document.getElementById(divs[i]).style.width!=''){document.getElementById(divs[i]).style.width=parseInt(parseInt(document.getElementById(divs[i]).style.width)+movementLogin)+"px";document.getElementById(divs[i]).style.marginLeft=parseInt(parseInt(document.getElementById(divs[i]).style.marginLeft)-movementLogin)+"px";if(divs[i]=='kaart_div'){document.getElementById('routeKaart').style.width=document.getElementById(divs[i]).style.width;}}
routeKaart.checkResize();}
aantal-=movementLogin;if(document.getElementById('routeOndergrond')!=undefined){document.getElementById('routeOndergrond').style.visibility='hidden';}
if(document.getElementById('publiek')!=undefined){document.getElementById('publiek').style.visibility='hidden';}
if(document.getElementById('datumDag')!=undefined){document.getElementById('datumDag').style.visibility='hidden';}
if(document.getElementById('datumMaand')!=undefined){document.getElementById('datumMaand').style.visibility='hidden';}
if(document.getElementById('datumJaar')!=undefined){document.getElementById('datumJaar').style.visibility='hidden';}
if(document.getElementById('routeSportType')!=undefined){document.getElementById('routeSportType').style.visibility='hidden';}
if(document.getElementById('routeKm')!=undefined){document.getElementById('routeKm').style.visibility='hidden';}
if(aantal-movementLogin>=0){setTimeout('hideInlogDiv('+aantal+')',10);}else{setCookie('loginDivShown','');}}
function clickDiv(){if(getCookie('loginDivShown')==null||getCookie('loginDivShown')!='1'){showInlogDiv(breedteLoginDiv);}else{hideInlogDiv(breedteLoginDiv);}}
function setCookie(cookieName,value){var expires=new Date();expires.setTime(expires.getTime()+2592000000);document.cookie=cookieName+"="+escape(value)+"; expires="+expires.toGMTString();}
function getCookie(cookieName){var alen=cookieName.length;var clen=document.cookie.length;var i=0;while(i<clen){var j=i+alen;if(document.cookie.substring(i,j)==cookieName){var endstr=document.cookie.indexOf(";",j);if(endstr==-1)
endstr=document.cookie.length;return unescape(document.cookie.substring(j+1,endstr));}
i=document.cookie.indexOf(" ",i)+1;if(i==0)
break;}
return null;};var bodyTag="<style>p { margin: 0px; padding: 0px;}</style><BODY MONOSPACE STYLE=\"font:11px verdana,arial,sans-serif; font-family:monospace;\">";var ViewMode="Text";var names=new Array();var areas=new Array();function submitTextareas()
{for(i=0;i<areas.length;i++){document.getElementById(areas[i]+'_data').value=GetSource(areas[i]);}}
function SendForm(na){document.forms['nieuws'].body.value=GetSource();document.forms['nieuws'].submit();}
function SetForm(naam){SetSource(naam,document.getElementById(naam+'_data').value);}
function GetSource(naam){document.getElementById(naam).contentWindow.focus();stripMS(naam);return document.getElementById(naam).contentWindow.document.body.innerHTML;}
function SetSource(naam,text){document.getElementById(naam).contentWindow.document.body.innerHTML=text;document.getElementById(naam).contentWindow.focus();}
function CheckMode(){if(ViewMode=="Text"){return true;}else{return false;}}
function Do(naam,action){document.getElementById(naam).contentWindow.focus();document.getElementById(naam).contentWindow.document.execCommand(action,false,false);}
function createwebLink(naam){var str=prompt("\nTyp het pad naar de pagina om de hyperlink te maken:","http:\/\/");if(document.all){var link=document.getElementById(naam).contentWindow.document.selection.createRange().text;}else{var link=document.getElementById(naam).contentWindow.getSelection();}
if(link==null||link==""){link=str;}
if((str!=null)&&(str!="http://")){if(document.all){var sel=document.getElementById(naam).contentWindow.document.selection.createRange();sel.pasteHTML("<a target=\"_blank\" href=\""+str+"\">"+link+"</a>");}else{var html="<a target=\"_blank\" href=\""+str+"\">"+link+"</a>";insertLink(naam,str,link,'');}}
document.getElementById(naam).contentWindow.focus();}
function Onloaded(){for(i=0;i<names.length;i++){if(document.getElementById(names[i]).addEventListener){document.getElementById(names[i]).contentWindow.addEventListener("click",function(){return false;},true);document.getElementById(names[i]).contentWindow.addEventListener("keyup",new Function('stripMS(\''+names[i]+'\')'),true);}else if(document.getElementById(names[i]).attachEvent){document.getElementById(names[i]).contentWindow.document.attachEvent("oncontextmenu",function(){return false;});document.getElementById(names[i]).contentWindow.document.attachEvent("onkeyup",new Function('stripMS(\''+names[i]+'\') '));document.getElementById(names[i]).contentWindow.document.attachEvent("onkeydown",new Function('stripMS(\''+names[i]+'\') '));document.getElementById(names[i]).contentWindow.document.attachEvent("onkeypress",new Function('stripMS(\''+names[i]+'\') '));document.getElementById(names[i]).contentWindow.document.attachEvent("onmouseup",new Function('stripMS(\''+names[i]+'\') '));}
SetForm(names[i]);}}
function insertHTML(naam,sHTML)
{var oEditor=document.getElementById(naam).contentWindow;var oSel=oEditor.getSelection();var range=oSel.getRangeAt(0);var docFrag=range.createContextualFragment(sHTML);range.collapse(true);var lastNode=docFrag.childNodes[docFrag.childNodes.length-1];range.insertNode(docFrag);try{oEditor.document.designMode="on";}catch(e){}
if(lastNode.nodeType==Node.TEXT_NODE)
{range=oEditor.document.createRange();range.setStart(lastNode,lastNode.nodeValue.length);range.setEnd(lastNode,lastNode.nodeValue.length);oSel=oEditor.getSelection();oSel.removeAllRanges();oSel.addRange(range);}}
function insertLink(name,url,title,target)
{var oEditor=document.getElementById(name).contentWindow;var oSel=oEditor.getSelection();var range=oSel.getRangeAt(0);var emptySel=false;if(range.toString()=="")
{emptySel=true;var cap=(title!=""&&title!=null?title:url);var node=oEditor.document.createTextNode(cap);range.insertNode(node);try{oEditor.document.designMode="on";}catch(e){}
range=oEditor.document.createRange();range.setStart(node,0);range.setEnd(node,cap.length);oSel=oEditor.getSelection();oSel.removeAllRanges();oSel.addRange(range);}
var isSelInMidText=(range.startContainer.nodeType==Node.TEXT_NODE)&&(range.startOffset>0);oEditor.document.execCommand("CreateLink",false,url);oSel=oEditor.getSelection();range=oSel.getRangeAt(0);if(range.startContainer.nodeType==Node.TEXT_NODE){var node=(emptySel||!isSelInMidText?range.startContainer.parentNode:range.startContainer.nextSibling);range=oEditor.document.createRange();range.selectNode(node);oSel=oEditor.getSelection();oSel.removeAllRanges();oSel.addRange(range);}
var oEl=range.startContainer.childNodes[range.startOffset];if(oEl)
{if(target!=""&&target!=undefined)oEl.target=target;}}
function stripMS(name)
{var strNewOrg=document.getElementById(name).contentWindow.document.body.innerHTML;strNew=regexpReplace(strNewOrg,'<em style="text-decoration: underline;">([^<]*)</em>',"<i><u>$1</u></i>","gi");strNew=regexpReplace(strNew,'<span style="text-decoration: underline;">([^<]*)</span>',"<u>$1</u>","gi");strNew=regexpReplace(strNew,'<span style="font-style: italic;">([^<]*)</span>',"<i>$1</i>","gi");strNew=regexpReplace(strNew,'<em style="font-weight: bold;">([^<]*)</em>',"<i><b>$1</b></i>","gi");strNew=regexpReplace(strNew,'<span style="font-weight: bold;">([^<]*)</span>',"<b>$1</b>","gi");strNew=regexpReplace(strNew,"<(?!a)([\?])?([a-z:]+)( ([^>]*)?)?>","<$2>","gi");strNew=regexpReplace(strNew,"<(\/)?(?!u)(?!b)(?!i)(?!strong)(?!em)(?!a)([a-z:]+)>","","gi");strNew=regexpReplace(strNew,"(&nbsp;)+"," ","gi");strNew=regexpReplace(strNew,"(\r\n)","<br>","gi");strNew=regexpReplace(strNew,"(\n)","<br>","gi");strNew=regexpReplace(strNew,"(\r)","<br>","gi");strNew=regexpReplace(strNew,"<([a-z]+)>( )?<\/([a-z]+)>","","gi");strNew=regexpReplace(strNew,"(<br>){4,}","<br>","gim");if(strNewOrg.length-strNew.length>1){document.getElementById(name).contentWindow.document.body.innerHTML=strNew;}}
function regexpReplace(in_str,reg_exp,replace_str,opts)
{if(typeof(opts)=="undefined"){opts='g';}
var re=new RegExp(reg_exp,opts);return in_str.replace(re,replace_str);};function submitMailAFriend(){xajax.$('versturenButton').disabled=true;xajax_mailAFriend(xajax.getFormValues("mailAFriendForm"));return false;}
function submitSearch(){xajax.$('searchButton').disabled=true;xajax_zoeken(xajax.getFormValues("searchForm"));return false;}
function submitLogin(){xajax.$('loginButton').disabled=true;xajax_inloggen(xajax.getFormValues("loginForm"));return false;}
function submitAanmelden(){xajax.$('aanmeldenButton').disabled=true;xajax_aanmelden(xajax.getFormValues("aanmeldenForm"));return false;}
function saveRoute(){var frm=$('#saveRouteForm');if(editMode){submitTextareas();if(eigenRoutePunten==undefined||eigenRoutePunten.length==0){errorHandler.show('Je dient eerst een route op de kaart te maken, alvorens op te slaan',$('#routeKaart'));}else if(document.getElementById('naam').value==''){errorHandler.show('Je dient de naam van de route in te voeren',frm);}else{xajax.$('opslaanButton').disabled=true;document.getElementById('routeZoomLevel').value=initialZoom;switch(routeKaart.getCurrentMapType()){case G_NORMAL_MAP:var mapType='G_NORMAL_MAP';break;case G_HYBRID_MAP:var mapType='G_HYBRID_MAP';break;case G_SATELLITE_MAP:var mapType='G_SATELLITE_MAP';break;}
document.getElementById('routeMapType').value=mapType;document.getElementById('routePunten').value='';for(i=0;i<eigenRoutePunten.length;i++){document.getElementById('routePunten').value+=eigenRoutePunten[i].lat()+','+eigenRoutePunten[i].lng()+';';}
xajax_saveRoute(xajax.getFormValues("saveRouteForm"));alert('route opgeslagen');}}else{errorHandler.show('De kaart die je voor je hebt is niet te wijzigen, klik op "Een nieuwe route beginen" aan de linkerzijde om zelf een route te maken.',frm);}}
