﻿// JScript File


var imageCreated = false;
	
function setPanelposition(sender){

	var objOverlay = document.getElementById('overlay');
	var objPanel = document.getElementById(dragPanel);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.width = (arrayPageSize[0] + 'px');
	objOverlay.style.display = 'block';
	objOverlay.className = 'trans50';
	
    // create image
    /*
    if(!imageCreated){
    
        var objImage = document.createElement("img");
        objImage.setAttribute('id','loadingImage');
        objImage.src = 'http://www.veilinghuisbouwman.eu/Images/loading.gif';
        objImage.style.position = "absolute";
        objImage.style.height = (80 + 'px');
	    objImage.style.width = (300 + 'px');
        
        objOverlay.appendChild(objImage); 
        imageCreated = true;
    }
    
    var objLoadingImage = document.getElementById('loadingImage');
	// center loadingImage if it exists
	if (objLoadingImage) {
		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - objLoadingImage.width) / 2) + 'px');
		objLoadingImage.style.display = 'block';
	}
    */

	
	
	objPanel.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 400) / 2) + 'px');
	objPanel.style.left = (((arrayPageSize[0] - 620) / 2) + 'px');
	objPanel.style.display = 'block';
    
    arrayPageSize = getPageSize();
	objOverlay.style.height = (arrayPageSize[1] + 'px');
    
}

function closeBackground(){
    var objOverlay = document.getElementById('overlay');
    //var objLoadingImage = document.getElementById('loadingImage');
    var objPanel = document.getElementById(dragPanel);
    objPanel.style.display = 'none';
    objOverlay.style.display = 'none';
    //objLoadingImage.style.display = 'none';
}
function setPreBid(){
    
    var setPreBid = document.getElementById(HyperLinkPreBid);
    var CountUserBids = document.getElementById(HiddenFieldCountUserBids);
    setPreBid.innerHTML = CountUserBids.value;
}
function setShoppingCart(){
    var setShoppingCart = document.getElementById(HyperLinkShoppingCart);
    var CountUserShoppingCart = document.getElementById(HiddenFieldCountUserShoppingCart);
    setShoppingCart.innerHTML = CountUserShoppingCart.value;
}

function popitup(imgURL) {
    if(imgURL == 'Kaart-Brummen-Groot.jpg'){
        newwindow=window.open('','name','height=304,width=321,resizable=yes,scrollbars=no');
    }
    else{
        newwindow=window.open('','name','height=600,width=800,resizable=yes,scrollbars=no');
    }
	newwindow=window.open('','name','height=600,width=800,resizable=yes,scrollbars=no');
	var tmp = newwindow.document;
	tmp.write('<html><head><title>Afbeeldingen</title>');
	tmp.write('<link rel="stylesheet" href="Popup.css">');
	tmp.write('</head><body>');
	tmp.write('<a href="javascript:self.close()"><img src="http://www.bouwmanveilingen.com/Images/' + imgURL + '" alt="Klik afbeelding om window te sluiten" border="0"/></a>');
	tmp.write('</body></html>');
	tmp.close();
	if (window.focus) {newwindow.focus()}
	return false;
}

	

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function gotoTop(){
    document.location.href = '#topPage';
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}