
// -----------------------------------------------------------------------------------

//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},
	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},
	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},
	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},
	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},
	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

// -----------------------------------------------------------------------------------

//
//	Extending built-in Array object
//	- array.removeDuplicates()
//	- array.empty()
//
Array.prototype.removeDuplicates = function () {
	for(i = 1; i < this.length; i++){
		if(this[i][0] == this[i-1][0]){
			this.splice(i,1);
		}
	}
}

// -----------------------------------------------------------------------------------

Array.prototype.empty = function () {
	for(i = 0; i <= this.length; i++){
		this.shift();
	}
}

// -----------------------------------------------------------------------------------

var SameAspect = Class.create();

SameAspect.prototype = {
	
	// initialize()
	// Constructor runs on completion of the DOM loading. Loops through anchor tags looking for 
	// 'lightbox' references and applies onclick events to appropriate links. The 2nd section of
	// the function inserts html at the bottom of the page which is used to display the shadow 
	// overlay and the image container.
	//
	initialize: function() {	
		if (!document.getElementsByTagName){ return; }

		// pak alle csc-textpic-imagerow elementen
		var imagerows = document.getElementsByClassName('csc-textpic-imagerow');
		// loop door alle elementen van deze imagerow
		for (var r=0; r<imagerows.length; r++) {
			// pak alle img elementen van deze imagerow
			var row = imagerows[r];
			var imagesInRow = row.getElementsByTagName('img');
			var hoogtes = $A();
			
			// vul hoogtes met hoogte van dit plaatje
			for ( var img=0; img < imagesInRow.length; img++)	{
				var plaatje = imagesInRow[img];
				hoogtes.push(Element.getHeight(plaatje));
			}
			if(hoogtes.max() != hoogtes.min()) {
				// corrigeer hoogtes
				for ( var img=0; img < imagesInRow.length; img++)	{
					
					var plaatje = imagesInRow[img];
					//Element.setHeight(plaatje, hoogtes.min());
					var clipp = 'rect(0 '+Element.getWidth(plaatje)+'px '+hoogtes.min()+'px 0)';
					Element.setStyle(plaatje, {clip: 'rect(0 '+Element.getWidth(plaatje)+'px '+hoogtes.min()+'px 0)' } );
					//Element.setStyle(plaatje, {visibility: 'hidden'} );
				}
			}
		}
/*
		// loop through all anchor tags
		for (var i=0; i<anchors.length; i++){
			var anchor = anchors[i];
			
			var relAttribute = String(anchor.getAttribute('rel'));
			
			// use the string.match() method to catch 'lightbox' references in the rel attribute
			if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
				if(Element.getWidth(anchor.firstChild) < Element.getHeight(anchor.firstChild)) {
					
					// corrigeer aspect
					Element.setHeight(anchor.firstChild, 101);
				}
			
			}
		}
*/
	}

}



function initSameAspect() { mySameAspect = new SameAspect(); }
Event.observe(window, 'load', initSameAspect, false);