function closeAlert( AlertObject ) {
	var Element = document.getElementById( AlertObject );
	
	$( Element ).slideUp();
}

function switchPayment( IDElement, IDValue, NameElement, NameValue ) {
	var IDObject = document.getElementById( IDElement );
	
	if ( IDObject ) {
		IDObject.value = IDValue;
	}
	
	var NameObject = document.getElementById( NameElement );
	
	if( NameObject ) {
		NameObject.innerHTML = NameValue
	} else {
		alert( 'Name object could not be set with value ' + NameValue );
	}
	
}

function toggleBox( BoxName, jQueryEffect ) {
	
	if ( ! jQueryEffect ) {
	
		//Get element that we want to toggle
		var CloseElement = document.getElementById( BoxName );
		
		//If element was found
		if ( CloseElement ) {
			if ( CloseElement.style.display == 'none' ) {
				//Element is close, then display
				CloseElement.style.display = 'block';
				//Don't continue to next, return
				return false;
			} 
	
			if ( CloseElement.style.display == 'block' ) {
				//If the element is block, then set 'none'
				CloseElement.style.display = 'none';
				//Don't continue code
				return false;
			}
		}
	} else {
		// open/close with jquery effects
		$('#' + BoxName).toggle(jQueryEffect);
	}
}

function showImage(image) {
	var newsrc = AbsPath+'upload/Product/Large/'+image;
	if(newsrc != $('#Large').attr('src')) {
	$('#Large').fadeOut(200, function() {
			$(this).attr('src',newsrc).bind('onreadystatechange load', function(){
				if (this.complete)
					$(this).fadeIn(200);
			});
		});
	}
}

function setImagePopupLargeImage(productID){ 
	if(productID != undefined){			
		var largeImageID = '#XlargeImage_' + productID;
		var largeImage = $(largeImageID);
	
		var largeImagesClass = '.ImagePopupLargeImage';
		var largeImages = $(largeImagesClass);		
		
		if(largeImage != undefined){
			largeImages.hide(); // hide all	
			largeImage.show(); // show current		
		}else{ // could not find large image
		}
	}else{ // no product id
	}
}

function toggleAmplification() {
	var imagePopup = $('#ImagePopup');	
	
	if(imagePopup != undefined){
		imagePopup.toggle();		
	}else{	// could not find image popup
	}	
}

var previousCell = null;
var previousAnchor = null;

function OpenClose(anchor, id) {
	
	var ContentObject = document.getElementById( 'ItemHolder' );
	var cell = document.getElementById( "item" + id );
	
	if ( previousCell ) {		
		var Height = parseInt( ContentObject.style.height.split("px").join("") );
		
		var CellHoeveelheid = Math.ceil( previousCell.offsetHeight / 20 );
		var CellHeight = ( CellHoeveelheid * 20 );
		
		var NewHeight = Height - CellHeight; 		
		//ContentObject.style.height = NewHeight + 'px';
	}
	
	if ( cell != null ){
		
		if ( anchor.className == "Open"  ) {
			anchor.className = "Close";
			cell.style.display = "none";
		} else {
			anchor.className = "Open";
			cell.style.display = "block";
		}
		
		if ( anchor ){
			var Height = parseInt( ContentObject.style.height.split("px").join("") );

			var CellHoeveelheid = Math.ceil( cell.offsetHeight / 20 );
			var CellHeight = ( CellHoeveelheid * 20 );
			
			var NewHeight = Height + CellHeight;
			//ContentObject.style.height = NewHeight + 'px';
		}

		if( previousCell != null && previousCell != cell ) previousCell.style.display = "none";
		if( previousAnchor != null && previousAnchor != anchor ) previousAnchor.className = "Close";

		previousCell = cell;
		previousAnchor = anchor;
	}
}
