function IsJannonce() {
    if (window.document.URL.indexOf("jannonce.be") > 0) {
        return true;
    }
    return false;
}
function _gmap(street, nr, zip, city) {
	var streetnr = street + ' ' + nr;
	var zipcity = zip + ' ' + city;
	document.write('<a href=\"http://maps.google.be/?q=' + escape(streetnr + ', ' + zipcity) + '\">' + streetnr + '</a>');
}

function numericOnly(evt){
    if (!evt) var evt = window.event;
    if ( 9 != evt.keyCode && (evt.keyCode >=47 && evt.keyCode <= 57)) 
    {
        return true;
	}
	else
	{
	    return false;
	}
}

function toggleVisibilityMulti(objects)
{
    if (typeof(objects) != 'undefined')
    {
        if (objects.length > 0)
        {
		    for (var i = 0; i < objects.length; i++)
            {
                if (objects[i].toString() != '')
                {
                    toggleVisible(objects[i].toString());
                }
            }
        }
    }
}

function toggleImg(ctlImg,image1,image2){
    if(ctlImg.src.indexOf(image1)>0){ctlImg.src = image2;}
    else{ctlImg.src = image1;}
}


function checkAll(field){
    for (i = 0; i < field.length; i++)
	    field[i].checked = true;
}

function uncheckAll(field){
    for (i = 0; i < field.length; i++)
	    field[i].checked = false ;
}


function stripHTML(html){
    return html.replace(/(<([^>]+)>)/ig,"");
}
function findPos(obj){
    if(obj!=null){
        var curleft = curtop = 0;
        if (obj.offsetParent) {
            do {
			    curleft += obj.offsetLeft;
			    curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
        }
        return [curleft,curtop];
     }else{return [0,0]}
}

function show(documentId)
{
	var id = document.getElementById(documentId);
	id.style.visibility = "visible";
	id.style.display = "block";
	
	//Show the hidelink
	var HideLink = documentId+'Hide';
	document.getElementById(HideLink).style.visibility = "visible";
	document.getElementById(HideLink).style.display = "block";
	
	//Hide the showlink
	var ShowLink = documentId+'Show';
	document.getElementById(ShowLink).style.visibility = "hidden";
	document.getElementById(ShowLink).style.display = "none";
}
function hide(documentId)
{
	var id = document.getElementById(documentId);
	id.style.visibility = "hidden";
	id.style.display = "none";
	
	//Hide the hidelink
	var HideLink = documentId+'Hide';
	document.getElementById(HideLink).style.visibility = "hidden";
	document.getElementById(HideLink).style.display = "none";
	
	//Show the showlink
	var ShowLink = documentId+'Show';
	document.getElementById(ShowLink).style.visibility = "visible";
	document.getElementById(ShowLink).style.display = "block";
}

/* Einde Navigatiestructuur zoekresultaten */


function OpenWin(field, he, wi){
	window.open(field,'_new','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=' + wi + ',height=' + he)
}

function OpenWin2(field, he, wi){
	window.open(field,'_new','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=' + wi + ',height=' + he)
}


// fake print() for IE4.x
if ( !printIsNativeSupport() )
  window.print = printFrame;

// main stuff
function printFrame(frame, onfinish) {
  if ( !frame ) frame = window;

  if ( printIsNativeSupport() ) {
    /* focus handling for this scope is a temporary IE5Beta workaround,
       and should be unnecessary for IE5 RTM.
    */
    var focused = document.activeElement;
    frame.focus();
    frame.self.print();
    if ( onfinish ) onfinish();
    if ( !focused.disabled ) focused.focus();
    return;
  }

  if ( frame.document.readyState !== "complete" &&
       !confirm("The document to print is not downloaded yet! Continue?") )
  {
    return;
  }

  var eventScope = printGetEventScope(frame);
  var focused = document.activeElement;

  window.printHelper = function() {
    execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
    printFireEvent(frame, eventScope, "onafterprint");
    printWB.outerHTML = "";
    if ( onfinish ) onfinish();
    if ( !focused.disabled ) focused.focus();
    window.printHelper = null;
  }

  document.body.insertAdjacentHTML("beforeEnd",
    "<object id=\"printWB\" width=0 height=0 \
    classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");

  printFireEvent(frame, eventScope, "onbeforeprint");
  frame.focus();
  window.printHelper = printHelper;
  setTimeout("window.printHelper()", 0);
}

// helpers
function printIsNativeSupport() {
  var agent = window.navigator.userAgent;
  var i = agent.indexOf("MSIE ")+5;
  return parseInt(agent.substr(i)) >= 5 && agent.indexOf("5.0b1") < 0;
}

function printFireEvent(frame, obj, name) {
  var handler = obj[name];
  switch ( typeof(handler) ) {
    case "string": frame.execScript(handler); break;
    case "function": handler();
  }
}

function printGetEventScope(frame) {
  var frameset = frame.document.all.tags("FRAMESET");
  if ( frameset.length ) return frameset[0];
  return frame.document.body;
}

function MM_openBrWindow(theURL,winName,width,height)
{ //v2.0
  height = height ;
  var winl = (screen.width - width) / 2;
  var wint = (screen.height - height) / 2;
  var i = width ;
  var j = height ;
  var features = 'scrollbars=no,resizable=no,width='+width+',height='+height+',top='+wint+',left='+winl+'';
  var popupscherm;
  popupscherm=window.open(theURL,winName,features);
  //popupscherm.resizeTo(i,j);
  popupscherm.focus();
}

function MM_openBrWindow2(theURL,winName,width,height,scroll)
    { //v2.0
        height = height ;
        var winl = (screen.width - width) / 2;
        var wint = (screen.height - height) / 2;
        var i = width ;
        var j = height ;
        var scrbars = scroll;
        var features = 'scrollbars='+scrbars+',resizable=no,width='+width+',height='+height+',top='+wint+',left='+winl+'';
        var popupscherm;
        popupscherm=window.open(theURL,winName,features);
        //popupscherm.resizeTo(i,j);
        popupscherm.focus();
    }

// Extended Tooltip Javascript
// copyright 9th August 2002, 3rd July 2005
// by Stephen Chapman, Felgall Pty Ltd

// permission is granted to use this javascript provided that the below code is not altered
var DH = 0;var an = 0;var al = 0;var ai = 0;if (document.getElementById) {ai = 1; DH = 1;}else {if (document.all) {al = 1; DH = 1;} else { browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {an = 1; DH = 1;}}} function fd(oi, wS) {if (ai) return wS ? document.getElementById(oi).style:document.getElementById(oi); if (al) return wS ? document.all[oi].style: document.all[oi]; if (an) return document.layers[oi];}
function pw() {return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;}
function mouseX(evt) {if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return null;}
function mouseY(evt) {if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null;}
function popUp(evt,oi) {if (DH) {var wp = pw(); ds = fd(oi,1); dm = fd(oi,0); st = ds.visibility; if (dm.offsetWidth) ew = dm.offsetWidth; else if (dm.clip.width) ew = dm.clip.width; if (st == "visible" || st == "show") { ds.visibility = "hidden"; } else {tv = mouseY(evt) + 20; lv = mouseX(evt) - (ew/4); if (lv < 2) lv = 2; else if (lv + ew > wp) lv -= ew/2; if (!an) {lv += 'px';tv += 'px';} ds.left = lv; ds.top = tv; ds.visibility = "visible";}}}

//functies voor check op prijsveld -> enkel numerieke waarden en komma zijn toegelaten
function CheckInputPrice(field) {
	var strValidChars = "0123456789,";
	var strChar;
			
	var tekst = field.value;
	var iLen = String(tekst).length;
	var iMax;
	var newTekst, deel1, deel2;
	
	if (iLen > 0) {
		iMax = iLen;
		for (i = 0; i < iMax; i++) {
			strChar = tekst.charAt(i);
			if (strValidChars.indexOf(strChar) == -1) {
				if (iLen == 1) {
					tekst = tekst.substring(i, iLen - 1);
				}
				else {
					if (iLen == i) {
						newTekst = tekst.substring(0, i);
					}
					else {
						deel1 = tekst.substring(0, i);
						deel2 = tekst.substring(i + 1, iLen);
						newTekst =  deel1 + deel2;
					}
					iMax = iMax--;
					tekst = newTekst;
					iLen = String(tekst).length;
				}
			}
			field.value = tekst;
		}
	}
} 

// --------- function show CallUp ----------

/*
var httpReq = false;

function loadXmlHttpObject(){
	try { httpReq = new ActiveXObject("Msxml2.XMLHTTP"); 
	}catch (e){
		try { httpReq = new ActiveXObject("Microsoft.XMLHTTP"); }
		catch (e) { httpReq = false; }
	}
	if (!httpReq && typeof XMLHttpRequest != 'undefined'){ httpReq = new XMLHttpRequest(); }
}

function CallUp(evt, AdID, type, divClick){
	//alert(location.host);
	var divInfo = document.getElementById("CUinfo");
	var divHtml = document.getElementById("CUhtml");
	if (divInfo) { divInfo.style.visibility = "hidden"; }
	if (divHtml.style.visibility == "hidden"){
		divHtml.style.top = (mouseY(evt) + 10).toString() + "px";
		if ((mouseX(evt)-150) < 0){
			divHtml.style.left = mouseX(evt).toString() + "px";
		}else {
			divHtml.style.left = (mouseX(evt) - 150).toString() + "px";
		}
		loadXmlHttpObject();
		var url = "/Controls/ShowAddCallUp.aspx?ID=" + AdID.toString() + "&type=" + type;
		httpReq.open("GET", url, true);
		httpReq.onreadystatechange = function(){
			if (httpReq.readyState == 2 || httpReq.readyState == 3 || httpReq.readyState == 1){
				divHtml.innerHTML = "Loading ...";
			}
			else if(httpReq.readyState == 4){
				var htmlCode = httpReq.responseText;
				divHtml.innerHTML = htmlCode;
			}
	    }
	    httpReq.send(null);
    	
	    divHtml.style.visibility = "visible";
	}
	else {
		divHtml.style.visibility = "hidden";
		if (divClick == false){
			if (divInfo){
				divInfo.style.visibility = "visible";
			}
		}
	}
}
*/

// ------------------------------------------
function testAds(div){
	httpReq = false;
	
	adsDivHtml = document.getElementById(div);
	var scriptHtml = ""
	var m3_u = (location.protocol=='https:'?'https://10.0.0.104/openads/www/delivery/ajs.php':'http://10.0.0.104/openads/www/delivery/ajs.php');
	var m3_r = Math.floor(Math.random()*99999999999);
	if (!document.MAX_used) document.MAX_used = ',';
	var url = m3_u + "?what=&amp;blockcampaign=1&amp;campaignid=0&amp;cb=" + m3_r
	if (document.MAX_used != ',') url += "&amp;exclude=" + document.MAX_used;
	url += "&amp;loc=" + escape(window.location);
	if (document.context) url += "&context=" + escape(document.context);
	if (document.mmm_fo) url += "&amp;mmm_fo=1";
	
	loadXmlHttpObject();
	httpReq.open("GET", url, true);
	httpReq.send(null);
	httpReq.onreadystatechange = function(){
		if (httpReq.readyState == 2 || httpReq.readyState == 3 || httpReq.readyState == 1){
			adsDivHtml.innerHTML = "";
		}
		else if(httpReq.readyState == 4){
			var htmlCode = httpReq.responseText;
			alert(htmlCode);
			alert("<script type='text/javascript'>" + htmlCode + "</script>");
			//adsDivHtml.innerHTML = "<script type='text/javascript'>" + htmlCode + "</script>";
		}
	}

	
	adsDivHtml.innerHTML = scriptHtml;
}


function ShowAds(words){
httpReq = false;
	var divHtml = document.getElementById("AdsDiv");
	loadXmlHttpObject();
	if (words == "Wat wil je zoeken?"){
		words = "";
	}else{
		words = words.replace(/  /, " ").replace(/ /, ",")
	}
	var url = "Controls/ShowSiteAds.aspx?q=" + words + "";
	httpReq.open("GET", url, true);
	httpReq.send(null);
	httpReq.onreadystatechange = function(){
		if (httpReq.readyState == 2 || httpReq.readyState == 3 || httpReq.readyState == 1){
			divHtml.innerHTML = "";
		}
		else if(httpReq.readyState == 4){
			var htmlCode = httpReq.responseText;
			divHtml.innerHTML = htmlCode;
			//document.getElementById("openadscontent").refresh();
		}
	}
	
}

function toggleVisible(objID){
    var obj = document.getElementById(objID);
    if(obj){
        if(obj.style.display=='block'){
            obj.style.display='none';
        }else{
            obj.style.display='block';
        }
    }   
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
function clickButtonAllBrowsers(id) {
    var button = document.getElementById(id);
    if (button.dispatchEvent) {
        var e = document.createEvent('MouseEvents');
        e.initEvent('click', true, true);
        button.dispatchEvent(e);
    }
    else {
        button.click();
    }
}
//function getCookie_DoFSCommand(command, args) {
//    if (command == "getCookie") {
//        setFlashCookie(1);
//    }
//}
function setFlashCookie(nr) {
    eraseCookie("_root.cookieValue");
    createCookie("_root.cookieValue",nr);
}
function getBrowserName() {
    var BrowserDetect = {
        init: function() {
            this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
            this.version = this.searchVersion(navigator.userAgent)
			                            || this.searchVersion(navigator.appVersion)
			                            || "an unknown version";
            this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },
        searchString: function(data) {
            for (var i = 0; i < data.length; i++) {
                var dataString = data[i].string;
                var dataProp = data[i].prop;
                this.versionSearchString = data[i].versionSearch || data[i].identity;
                if (dataString) {
                    if (dataString.indexOf(data[i].subString) != -1)
                        return data[i].identity;
                }
                else if (dataProp)
                    return data[i].identity;
            }
        },
        searchVersion: function(dataString) {
            var index = dataString.indexOf(this.versionSearchString);
            if (index == -1) return;
            return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
        },
        dataBrowser: [
		                            {
		                                string: navigator.userAgent,
		                                subString: "Chrome",
		                                identity: "Chrome"
		                            },
		                            { string: navigator.userAgent,
		                                subString: "OmniWeb",
		                                versionSearch: "OmniWeb/",
		                                identity: "OmniWeb"
		                            },
		                            {
		                                string: navigator.vendor,
		                                subString: "Apple",
		                                identity: "Safari"
		                            },
		                            {
		                                prop: window.opera,
		                                identity: "Opera"
		                            },
		                            {
		                                string: navigator.vendor,
		                                subString: "iCab",
		                                identity: "iCab"
		                            },
		                            {
		                                string: navigator.vendor,
		                                subString: "KDE",
		                                identity: "Konqueror"
		                            },
		                            {
		                                string: navigator.userAgent,
		                                subString: "Firefox",
		                                identity: "Firefox"
		                            },
		                            {
		                                string: navigator.vendor,
		                                subString: "Camino",
		                                identity: "Camino"
		                            },
		                            {		// for newer Netscapes (6+)
		                                string: navigator.userAgent,
		                                subString: "Netscape",
		                                identity: "Netscape"
		                            },
		                            {
		                                string: navigator.userAgent,
		                                subString: "MSIE",
		                                identity: "Explorer",
		                                versionSearch: "MSIE"
		                            },
		                            {
		                                string: navigator.userAgent,
		                                subString: "Gecko",
		                                identity: "Mozilla",
		                                versionSearch: "rv"
		                            },
		                            { 		// for older Netscapes (4-)
		                                string: navigator.userAgent,
		                                subString: "Mozilla",
		                                identity: "Netscape",
		                                versionSearch: "Mozilla"
		                            }
	                            ],
        dataOS: [
		                            {
		                                string: navigator.platform,
		                                subString: "Win",
		                                identity: "Windows"
		                            },
		                            {
		                                string: navigator.platform,
		                                subString: "Mac",
		                                identity: "Mac"
		                            },
		                            {
		                                string: navigator.platform,
		                                subString: "Linux",
		                                identity: "Linux"
		                            }
	                            ]

    };
    BrowserDetect.init();
    return BrowserDetect.browser;
}
//var translateText = function(key, functionOnComplete){
///// <summary>sends a request to the webservice which in turn uses a resource file to translate values</summary>
///// <param name="key">the key as it is listed in the resource file</param>
///// <param name="functionOnComplete">create a function object which will be called once asynch translation completes
/////        for example: var onTranslated = function(result, eventArgs){mycontrol.value=result;};
///// </param>
//    try{
//        var test = CCV.kkServices.Translate(key, functionOnComplete, translateText_Failed);
//    }catch(e){}
//}

//translateText_Failed = function(result, eventArgs){
//    //alert(result._message);
//}
