

var iBlinks = 0;
var intrBlinkStep="";
var blink;

var intrBlinkNaarBoven = "";
var iBlinks2 = 0;
var blink2;


function blinkStep(){
	if(iBlinks % 2 == 0){
		blink.className = 'tdStapInfoBlink';
	}else{
		blink.className = 'tdStapInfo';
	}
	iBlinks++;
	
	if( iBlinks > 3  ){		
		iBlinks = 0;
		window.clearInterval(intrBlinkStep);
		intrBlinkStep="";
		return false;
	}
}

function blinkNaarBoven(){
	if(iBlinks2 % 2 == 0){
		blink2.className = 'tdNaarBovenBlink';
	}else{
		blink2.className = 'tdNaarBoven';
	}
	iBlinks2++;
	
	if( iBlinks2 > 4  ){
		iBlinks2 = 0;
		//blink2.style.border = 'none';
		window.clearInterval(intrBlinkNaarBoven);
		intrBlinkNaarBoven="";
		return false;
	}
}



function showStep(iClick){
	for(i=1;i<=9;i++){
		el = document.getElementById('step'+i);
		el.className = "offerteStep";
	}
	el = document.getElementById('step'+iClick);
	el.className = "offerteStepActive";
	return false;
}
 


function getIndexByValue(val, el){
	for(i=0;i<el.options.length;i++){		
		if(el.options[i].value == val) return i;
	}
}

function hideUnhide(sElement, val){
	if(val > 0 )
		document.getElementById(sElement).style.visibility = 'visible';
}

// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function imagePopup(imageURL,imageTitle){
//alert(imageURL);
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(300,300);');
writeln('width=300-(document.body.clientWidth-document.images[0].width);');
writeln('height=300-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["'+imageTitle+'"].width;');writeln('window.innerHeight=document.images["'+imageTitle+'"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="'+imageTitle+'" src='+imageURL+' style="display:block"></body></html>');
close();		
}
return false;
}

	var xmlHttp=null;

// Bridge XMLHTTP to XMLHttpRequest in pre-7.0 Internet Explorers
 
if (typeof XMLHttpRequest == "undefined")
  XMLHttpRequest = function() {
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch(e) {};
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch(e) {};
    try { return new ActiveXObject("Msxml2.XMLHTTP"); }     catch(e) {};
    try { return new ActiveXObject("Microsoft.XMLHTTP"); }  catch(e) {};
 
    throw new Error("This browser does not support XMLHttpRequest or XMLHTTP.");
  };
 
// ...
 


var elResponseText ;
function stateChanged()
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById(elResponseText).innerHTML=xmlHttp.responseText;
	}
}

var xmlArray = new Array();
var iXml = 0;
function toSession(sTitle, value){
	var url;
	//var xmlHttp;
	iXml++;
	xmlArray[iXml] = new XMLHttpRequest();
	
	url = '/graniet/toSession.asp?name='+sTitle+'&val='+value+'&rand='+Math.random();

	xmlArray[iXml].open("GET",url,false);
	xmlArray[iXml].send(null);
	
}

function checkInput(sValid,el){
	orgVal = el.value;
	arr = orgVal.split("");
	newVal = "";
	
	for(var i in arr) {
		if(sValid.indexOf(arr[i]) > -1)
			newVal += arr[i];
	}
	
	el.value = newVal;
	
}

function showKostenWerkblad(iRandafwerking, iLengte){
	
	url = 'offerte/getbladprijs.asp?afwerking='+iRandafwerking+'&lengte='+iLengte;
	
	xmlHttp = new XMLHttpRequest();
	elResponseText = 'geschattekosten';
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function getColorInformation(id){
	url = 'offerte/getColorInformation.asp?id='+id;	
	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = httpResponseColorInfo;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function httpResponseColorInfo(){		
	if (xmlHttp.readyState == 4)
	{
		if(xmlHttp.status==200) 
		{
			var arColorInfo = new Array();
			//fill  the array with the responsetext from the url
			eval(xmlHttp.responseText);
			fillColorPopupDiv(arColorInfo);
		}
	}
} 

function showKleurKeuzes(sType){
	url = 'offerte/offerte1_kleurkeuze.asp?steentype='+sType;
	
	xmlHttp = new XMLHttpRequest();
	elResponseText = 'divKleurKeuzes';
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function getOpstellingInfoForPopup(id){
	url = 'offerte/getOpstellingInfo.asp?id='+id+'&rand='+Math.random();	
	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = httpResponseAfmeting;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function httpResponseAfmeting(){
	if (xmlHttp.readyState == 4)
	{
		if(xmlHttp.status==200) 
		{
			var arAfmetingInfo = new Array();
			//fill  the array with the responsetext from the url
			eval(xmlHttp.responseText);
			fillPopupOpstelling(arAfmetingInfo);
			arAfmetingInfo = null;
		}
	}
}

function getSpoelbakInfoForPopup(ID){
	url = 'offerte/getSpoelbakInfo.asp?id='+ID+'&rand='+Math.random();	
	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = httpResponseSpoelbak;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return false;
}

function httpResponseSpoelbak(){
	if (xmlHttp.readyState == 4)
	{
		if(xmlHttp.status==200) 
		{
			var arSpoelbakInfo = new Array();
			//fill  the array with the responsetext from the url
			eval(xmlHttp.responseText);		
			fillPopupSpoelbak(arSpoelbakInfo);		
			arSpoelbakInfo = null;
		}
	}
}
function getKraanInfoForPopup(ID){
	url = 'offerte/getKraanInfo.asp?id='+ID+'&rand='+Math.random();	
	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = httpResponseKraan;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return false;
}
function httpResponseKraan(){
	if (xmlHttp.readyState == 4)
	{
		if(xmlHttp.status==200) 
		{
			var arKraanInfo = new Array();
			//fill  the array with the responsetext from the url
			eval(xmlHttp.responseText);		
			fillPopupKraan(arKraanInfo);		
			arKraanInfo = null;
		}
	}
}

function getKraanDataArray(sManufacturer,iPage,iCat,sSubcat){
	url = 'offerte/getKranenLijst.asp?page='+iPage+'&manufacturer='+sManufacturer+'&cat='+iCat+'&subcat='+sSubcat+'&rand='+Math.random();	
	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = httpResponseKraanDataArray;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	return false;
}
function httpResponseKraanDataArray(){
	if (xmlHttp.readyState == 4)
	{
		if(xmlHttp.status==200) 
		{
			var arKraanListData = new Array();
			//fill  the array with the responsetext from the url
			eval(xmlHttp.responseText);		
			fillKraanListOnPage(arKraanListData);
			
			//save array on client side
			saveCacheKraanArray(arKraanListData);
			
			//delete array
			arKraanListData = null;
		}
	}
}

function getAchterKantInfoForPopup(ID){
	
	url = 'offerte/getAchterkantInfo.asp?rand='+Math.random();	
	xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = httpResponseAchterkant;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function httpResponseAchterkant(){
	if (xmlHttp.readyState == 4)
	{
		if(xmlHttp.status==200) 
		{
			var arAchterkantInfo = new Array();
			//fill  the array with the responsetext from the url
			eval(xmlHttp.responseText);		
			fillPopupAchterkant(arAchterkantInfo);		
			arAchterkantInfo = null;
		}
	}
}



function xmlCatalog(url){
	xmlHttp = new XMLHttpRequest();
	elResponseText = 'catalogdiv';
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


var navClicked = false;
function nav(page, keywords, params, direction, totalItems){
	if(navClicked == false){
		navClicked = true;
		document.getElementById('btnNext').disabled = true;
		document.getElementById('btnBack').disabled = true;
		url = "small_catalog.asp?page="+page+"&direction="+direction+"&keywords="+keywords+""+params+"&totalItems="+totalItems;		
		document.location.href = url;
	}
}


function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function ucaseFirst(sString){
	return sString.substring(0,1).toUpperCase() + sString.substring(1);  
}

var moveToX;
var moveToY;
var elementTomove;

function moveit(elMove, x, y){
	moveToX = x;
	moveToY = y;
	elementTomove = elMove;
	doMove();
}

function doMove() {
	if (document.all) {
		moveBy = 10;
		if(document.all.elementTomove.style.posLeft - moveToY < 10)
			moveBy = document.all.elementTomove.style.posLeft - moveToY;
			
		document.all.elementTomove.style.posLeft = document.all.elementTomove.style.posLeft + moveBy;
		if (document.all.elementTomove.style.posLeft > moveToY)
			setTimeout("moveit()",100);
	}
	else if (document.layers) {
		document.elementTomove.left += 10;
		if (document.elementTomove.left < screen.width)
			setTimeout("moveit()",100);
	}
}


function highlightBlok(el){
		if(el.className == 'blok'){
			el.className = 'blokOver';
		}
		
		if(el.className == 'blokActive'){
			el.className = 'blokActiveOver';
		}
	}
	
	function unHighlightBlok(el){
		if(el.className == 'blokOver'){
			el.className = 'blok';
		}
		
		if(el.className == 'blokActiveOver'){
			el.className = 'blokActive';
		}
	}
	
function cmInputOnFocus (obj) {
			//obj.className= 'zoektekst2';
	        obj.style.backgroundImage = 'none';
	        //obj.value = '';
		}

function cmInputOnBlur (obj) {
	handleKeyUpAfmeting(obj);
	if (obj.value == '') {
		//obj.className= 'zoektekst';
		obj.style.backgroundImage = 'url(images/bg-input-centimeters.jpg)';							
	}
}

function changeCur(style){
	if(style == '')
		document.body.style.cursor = 'default';
	else
		document.body.style.cursor = "url('/graniet/images/"+style+".cur'), auto";
}
	
function expandHtmlElem(el){
	return false;
}

function submitAkkoord(){
	selLeverWeek = document.getElementById('afleverWeek');
	iWeek = selLeverWeek.options[selLeverWeek.selectedIndex].value;
	if(iWeek < 1){
		alert("U dient een voorkeurs leverweek te kiezen!");
		afleverDiv = document.getElementById('leverweekDiv');
		afleverDiv.style.background='#FF8F8F';
	}
	else{
		elForm =document.getElementById('frmWerkblad');
		elForm.action= elForm.action + '&leverweek='+iWeek;
		elForm.submit();
	}
	return false;
}

function getViewportHeight(){
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	
	return myHeight;
}

function setContentHeight(){
	
	myHeight = getViewportHeight();
	var iHeaderHeight = 0 ;
	iHeaderHeight = document.getElementById("header").offsetHeight;
	document.getElementById("content").style.height = (myHeight-iHeaderHeight)+"px";
}

function verifyPopupOnScreen(divPopup){
		//normally the top offset for the popup is set in css. 
		//But when a really small viewport is used it needs the placed more to the top.
		//otherwise the buttons can't be seen/clicked
		
		var iViewHeight = getViewportHeight();
		divBlanket = divBlanket = document.getElementById('popupBlanket');
		
		//als popup buiten beeld valt, dan hoger plaatsen.
		if((divPopup.offsetHeight + divPopup.offsetTop) > iViewHeight){
			iHeightOffScreen = (divPopup.offsetHeight + divPopup.offsetTop) - iViewHeight;
			divPopup.style.top = (divPopup.offsetTop - iHeightOffScreen )+'px';
			divBlanket.style.top = (divBlanket.offsetTop - iHeightOffScreen )+'px';
		}
}


