function openLotusWindow(url){
	dijit.byId('dialogWindow').show();dijit.byId('dialogWindow').setHref(url);
	topFlash = document.getElementById("centerTop");
	//topFlash.style.display = "none";
}
function getCourses(typeID){
	actionURL = "DESIGN/Inschrijven/courseAjax.php?Action=getCourses&courseType=" + typeID;
	var deferred = dojo.xhrGet({
        url: actionURL,
        handleAs: "text",
        timeout: 5000,
		preventCache: true,
		content: {
			typeID: typeID
		},
        handle: function(response, ioArgs){
                if(response instanceof Error){
					dojo.byId("courses").innerHTML(response);
                    console.error(response);
                }else{
					
					dojo.byId("courses").innerHTML = response;
                }
                return response;
        }
	});
}
function getCoursData(courseID){
	actionURL = "DESIGN/Inschrijven/courseAjax.php?Action=getCourseData&courseID=" + courseID;
	var deferred = dojo.xhrGet({
        url: actionURL,
        handleAs: "text",
        timeout: 5000,
		preventCache: true,
		content: {
			courseID: courseID
		},
        handle: function(response, ioArgs){
                if(response instanceof Error){
                    console.error(response);
                }else{
					dojo.byId("courseData").innerHTML = response;
                }
                return response;
        }
	});
}
function postBestelling(id,Action){
	dojo.xhrPost({
		preventCache: true,
		url: "page.php?ID=1190",
		handleAs: "text",
		form: "bestelling",
		load: function( data, evt) { 
			if (Action=="Recalculate"){
					//dijit.byId("offerteContents").setContent(data);
					document.location.reload();
			}
		},
		handle: function(response, ioArgs){
		}
	});
}
function number_format( number, decimals, dec_point, thousands_sep ) {    
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
function calculateTotal(){
	total = 0;
	prodArrStr = document.getElementById("products").value;
	eval("var productArray=new Array(" + prodArrStr + ")");
		alert(prodArrStr + document.getElementById("price" + productArray[0]).value);
		alert(document.getElementById("price" + productArray[i]).value.replace(/,/,"."));
	for (i=0;i<productArray.length;i++){
		alert(document.getElementById("price" + productArray[i]).value.replace(/,/,"."));
		price = parseFloat(document.getElementById("price" + productArray[i]).value.replace(/,/,"."));
		number = parseFloat(document.getElementById("aantal" + productArray[i]).value);
		total+= (price * number);
	}
	dojo.byId("totalAmount").innerHTML = "Totaalprijs &euro; " + number_format(total,2,",",".");
}
function voegToeAanBestelling(contentID,prijs){
	actionURL = "page.php?ID=1190&Action=Order&contentID=" + contentID + "&price=" + prijs;
	var deferred = dojo.xhrGet({
        url: actionURL,
        handleAs: "text",
        timeout: 5000,
		preventCache: true,
		content: {
			contentID: contentID
		},
        handle: function(response, ioArgs){
                if(response instanceof Error){
                    console.error(response);
                }else{
					//alert(response);
					dijit.byId("offerteContents").setContent(response);
					
					dijit.byId('dialogWindow').show();dijit.byId('dialogWindow').setHref('page.php?ID=1311');
					calculateTotal();
                }
                return response;
        }
	});
}
function voegToeAanBestellingTextiel(contentID,prijs){
	actionURL = "page.php?ID=1190&Action=Order&contentID=" + contentID + "&price=" + prijs;
	var deferred = dojo.xhrGet({
        url: actionURL,
        handleAs: "text",
        timeout: 5000,
		preventCache: true,
		content: {
			contentID: contentID
		},
        handle: function(response, ioArgs){
                if(response instanceof Error){
                    console.error(response);
                }else{
					//alert(response);
					//dijit.byId("offerteContents").setContent(response);
					
					dijit.byId('dialogWindow').show();dijit.byId('dialogWindow').setHref('page.php?ID=1311&contentID=' + contentID);
					calculateTotal();
                }
                return response;
        }
	});
}
function voegSpecsToeAanBestelling(){
	dojo.xhrPost({
		preventCache: true,
		url: "page.php?ID=1190",
		handleAs: "text",
		form: "contentSpecs",
		load: function( data, evt) {
			dijit.byId("offerteContents").setContent(data);
			dijit.byId('dialogWindow').show();dijit.byId('dialogWindow').setHref('page.php?ID=1311');
		},
		handle: function(response, ioArgs){
		}
	});
}
function aanpassenKleurMaat(productID,contentID){
	actionURL = "page.php?ID=1311&Action=Change&productIDsession=" + productID;
	var deferred = dojo.xhrGet({
        url: actionURL,
        handleAs: "text",
        timeout: 5000,
		preventCache: true,
		content: {
			productID: productID,
			contentID: contentID
		},
        handle: function(response, ioArgs){
                if(response instanceof Error){
                    console.error(response);
                }else{
					dijit.byId('dialogWindow').show();dijit.byId('dialogWindow').setHref('page.php?ID=1311&Action=Change&productIDsession=' + productID + '&contentID=' + contentID);
					calculateTotal();
                }
                return response;
        }
	});
}
function verwijderUitOfferteaanvraag(productID,pos){
	actionURL = "page.php?ID=1190&Action=Delete&productID=" + productID + "&pos=" + pos;
	var deferred = dojo.xhrGet({
        url: actionURL,
        handleAs: "text",
        timeout: 5000,
		preventCache: true,
		content: {
			productID: productID
		},
        handle: function(response, ioArgs){
                if(response instanceof Error){
                    console.error(response);
                }else{
					dijit.byId("offerteContents").setContent(response);
					calculateTotal();
                }
                return response;
        }
	});
}
function expandContractSimple(objectID){
	expObj = document.getElementById(objectID);
	if (expObj.style.display=="block"){
		expObj.style.display = "none";
	} else {
		expObj.style.display = "block"; 
	}
}
function getWindowSize(whatSize) {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winW = window.innerWidth;
    winH= window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winW = document.documentElement.clientWidth;
    winH= document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winW = document.body.clientWidth;
    winH = document.body.clientHeight;
  }
 if (whatSize=="w"){ return winW;}
 if (whatSize=="h"){ return winH;}
}
function positionLayer(){
	 object = document.getElementById("content");
	 height= getWindowSize('h');
	 object.style.height = (height - 170 - 38) + "px";
	 object = document.getElementById("rightSide");
	 height= getWindowSize('h');
	 object.style.height = (height - 170 - 38) + "px";
}
	
