﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function PopupWindow(strURL,strName,strWidth,strHeight)
{
var hWindow;
if (strWidth != '') {strWidth = 'width=' + strWidth ;}
if (strHeight != '') {strHeight = 'Height=' + strHeight;} 
hWindow = window.open(strURL , '', 'dependent=yes, hotkeys=no, titlebar=no, fullscreen=no, channelmode=no, toolbar=no, location=no, directories=no, status=no, menubars=no, resizable=no,' + strWidth + ', ' + strHeight + ', top=150, left=70');
}

function getElementById_s(id){
	var obj = null;
	if(document.getElementById){
	/* Prefer the widely supported W3C DOM method, if
	available:-
	*/
	obj = document.getElementById(id);
	}else if(document.all){
	/* Branch to use document.all on document.all only
	browsers. Requires that IDs are unique to the page
	and do not coincide with NAME attributes on other
	elements:-
	*/
	obj = document.all[id];
	}
	/* If no appropriate element retrieval mechanism exists on
	this browser this function always returns null:-
	*/
	return obj;
}

//Load extern file in div
var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid){
    document.getElementById(containerid).innerHTML = "<br><center><img src='/images/loading.gif' border=0></center>";

    var page_request = false;
    if (window.XMLHttpRequest){ // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()}
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    } 
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    page_request.onreadystatechange=function(){
    loadpage(page_request, containerid)
    }
    page_request.open('GET', url, true)
    page_request.send(null)
}

function loadpage(page_request, containerid){
    var rep;
    if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
    {
    rep = page_request.responseText;
    document.getElementById(containerid).innerHTML = "";
    document.getElementById(containerid).innerHTML =  "" + rep + "";
    }
}

function loadobjs(){
    if (!document.getElementById)
    return
    for (i=0; i<arguments.length; i++){
    var file=arguments[i]
    var fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src", file);
    }
    else if (file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel", "stylesheet");
    fileref.setAttribute("type", "text/css");
    fileref.setAttribute("href", file);
    }
    }
    if (fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
}

function getElementById_s(id) {
    var obj = null;
    if (document.getElementById) {
        /* Prefer the widely supported W3C DOM method, if
        available:-
        */
        obj = document.getElementById(id);
    } else if (document.all) {
        /* Branch to use document.all on document.all only
        browsers. Requires that IDs are unique to the page
        and do not coincide with NAME attributes on other
        elements:-
        */
        obj = document.all[id];
    }
    /* If no appropriate element retrieval mechanism exists on
    this browser this function always returns null:-
    */
    return obj;
}

function Nieuwsbriefaanmelden(strEmail) {
    if (strEmail != '') {
        ajaxpage('/nieuwsbriefaanmeld.aspx?email=' + strEmail, 'nieuwsbrief');
    }
}

function checktext(obj, strdefaultvalue) {
    if (obj.value == strdefaultvalue) {
        obj.value = '';
    }
}

function resettext(obj, strdefaultvalue) {
    if (obj.value == '') {
        obj.value = strdefaultvalue;
    }
}

function showhidealternatieven() {
    var objBox;
    objBox = getElementById_s("showhidealternatievenbox");
    if (objBox != null) {
        if (objBox.className == "hidealternatieven")
        { objBox.className = "showalternatieven" } else {objBox.className = "hidealternatieven"; }
    }
}

function leesmeer() {
    var objBox;
    objBox = getElementById_s("algemeen");
    if (objBox != null) {
        objBox.className = "product_detail_algemeen_show";
    }
    var linkleesmeer;
    linkleesmeer = getElementById_s("linkleesmeer");
    linkleesmeer.className = "hiddentab";
}

/*-------TAB -------*/
function activetab(tab) {
    activetab1(tab);
    setTimeout("activetab1('" + tab + "')", 5);
}
function activetab1(tab) {

    var intTeller;
    var obj;
    var strtab;

    intTeller = 1;

    strtab = 'tab' + intTeller;
    while (getElementById_s(strtab) != null) {
        obj = getElementById_s(strtab);
        if (strtab == tab) {
            obj.className = 'product_detail_showtab';
        } else {
            obj.className = 'hiddentab';
        }
        intTeller++;
        strtab = 'tab' + intTeller;
    }

    intTeller = 1;

    strtab = 'tab' + intTeller;
    while (getElementById_s(strtab) != null) {
        obj = getElementById_s(strtab);
        if (strtab == tab) {
            document.images[strtab + '_image'].src = '/images/' + strtab + '_ro.jpg';
        } else {
            document.images[strtab + '_image'].src = '/images/' + strtab + '.jpg';
        }
        intTeller++;
        strtab = 'tab' + intTeller;
    }
}


var prev;
var next;
var submenu;
var submenuholder;

function initSubmenu() {
    if (next == null) { next = getElementById_s('next'); }
    if (prev == null) { prev = getElementById_s('prev'); }
    if (submenu == null) {submenu = getElementById_s('submenu');}
    if (submenuholder  == null ) {submenuholder = getElementById_s('submenuholder');}
    if (next != null) {
        if (submenuholder.scrollTop + 38 >= submenuholder.scrollHeight) {
            next.style.visibility = "hidden";
        } else {next.style.visibility = "visible";}
    }
    if (prev != null) {
        if (submenuholder.scrollTop - 38 < 0) {
            prev.style.visibility = "hidden";
        } else {
        prev.style.visibility = "visible";
        }
    }
}

function nextclick() {

    if (submenu != null) {
        submenuholder.scrollTop = submenuholder.scrollTop + 38;
        initSubmenu();
    }
}
function prevclick() {
    if (submenu != null) {
        submenuholder.scrollTop = submenuholder.scrollTop - 38;
        initSubmenu();
    }
}


/*-------scroll -------*/

function ScrollLinks(a) {
  for (I=1; I<=a; I++){
   scroll(1,I)
  }
 }
