window.load = init();


Array.prototype.inArray = function (value)
{
// Returns true if the passed value is found in the
// array. Returns false if it is not.
var i;
for (i=0; i < this.length; i++) 
{
	if (this[i] == value) 
	{
	return true;
	}
}
return false;
};



function DetectFlash(){
  var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
  
  // Check to see if the version meets the requirements for playback
  if (!hasReqestedVersion) {
  
    var pid = getVar('pid');
    if(pid == ''){
      window.location = "http://www.adobe.com/go/gntray_dl_getflashplayer";
    }
  }

}



function action(strAction)
   {
   document.location.href = strAction;
   }

function resizeFlash(height) {
 var flashmenudiv = document.getElementById('menu');
 flashmenudiv.style.height = height+'px';
 var flashobject = document.getElementById('flashmenuID');
 flashobject.style.height = height+'px';
}


function init(){
  //DetectFlash();
}

function getVar(name)
         {
         get_string = document.location.search;         
         return_value = '';
         
         do { //This loop is made to catch all instances of any get variable.
            name_index = get_string.indexOf(name + '=');
            
            if(name_index != -1)
              {
              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
              
              end_of_value = get_string.indexOf('&');
              if(end_of_value != -1)                
                value = get_string.substr(0, end_of_value);                
              else                
                value = get_string;                
                
              if(return_value == '' || value == '')
                 return_value += value;
              else
                 return_value += ', ' + value;
              }
            } while(name_index != -1)
            
         //Restores all the blank spaces.
         space = return_value.indexOf('+');
         while(space != -1)
              { 
              return_value = return_value.substr(0, space) + ' ' + 
              return_value.substr(space + 1, return_value.length);
							 
              space = return_value.indexOf('+');
              }
          
         return(return_value);        
         }



function enableDisablePaalafstandOptions(form) {
    //set field enabled / disabled
    //only check available paalafstand options
	http = createRequestObject();
	
	http.open('post',  '/_get_omheining_paalafstanden.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = PaalafstandOptionsAvailable; 
		
	var sendstr = 'paalSoort='+form.paal_soort.value+'&aantalLiggers='+form.ligger_aantal.value;
	http.send(sendstr);
}
function enableDisablePaalafstandOptions_longeercirkel(form) {
    //set field enabled / disabled
    //only check available paalafstand options
	http = createRequestObject();
	
	http.open('post',  '/_get_longeercirkel_paalafstanden.php');
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = PaalafstandOptionsAvailable; 
		
	var sendstr = 'paalSoort='+form.paal_soort.value+'&aantalLiggers='+form.ligger_aantal.value;
	http.send(sendstr);
}

function PaalafstandOptionsAvailable() {
    //alleen de paalafstanden met de ID's in de response mogen ge-enabled worden.
	if(http.readyState == 4) {
	   var blockDiv = document.getElementById('block_paal_afstand');
	   if (blockDiv) {
           var arrEnabledDivIDs = http.responseText.split(',');	       
	       var divs = getElementsByClassName('offerte_thumb','div',blockDiv);
        	var length = divs.length;
        	for(var i=0; i<length; i++){
        		var div = divs[i];
        		var ID = div.attributes.name.nodeValue;
        		if (!arrEnabledDivIDs.inArray(ID)) {
            		//div.style.visibility = 'hidden';
            		//div.style.display = 'none';
            		div.className = 'offerte_thumb dimmed';
            		//if selected then un-select
            		  var div = document.getElementById('paal_afstand_'+ID);
                        div.className = 'radio_unchecked';
                    }
        		
        	}
           for(var i=0; i<arrEnabledDivIDs.length; i++){
        		var ID = arrEnabledDivIDs[i];
        		if (ID!='') {
        		  var div = document.getElementById('paal_afstand_'+ID);
        		  //if (div) div.parentNode.style.visibility = 'visible';
        		 // if (div) div.parentNode.style.display = 'block';
        		  if (div) {
                    div.parentNode.className = 'offerte_thumb';
                    }
        		
        		  }
        	}
       }
    };	
}


/* helper functions */
function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}


function getElementsByClassName(className, tag, elm){
	var testClass = new RegExp("(^|\\s)" + className + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

