/**
 * cross DOM getElementById()
 */ 
function crossDomId(x) {
	if(document.all && !document.getElementById){
		return document.all.x;
	}
	else{
		return document.getElementById(x);
	}
}

function getElementsByClassName(clsName) { 
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
		if ( elem.className == clsName ){
			arr[arr.length] = elem;
		}
	}
	return arr;
}

function hideElement(element){

  element.style.display = 'none';
}

/**
 * resize thumbnails of Fotogalerie
 */
function resizeFgThumbs(){

  var aThumbs = getElementsByClassName('fgimg');
  var iCf = 1; // verhältnis von Höhe zu Breite
  var counter = 1;
  var faktor = 1;

  if(aThumbs.length > 0){
	
	for(i=0; i < aThumbs.length; i++){

		if(aThumbs[i].height > aThumbs[i].width){
		  
		  iCf = aThumbs[i].height / aThumbs[i].width;
		  aThumbs[i].height = 100;
		  aThumbs[i].width = aThumbs[i].height / iCf;
		}
		else if(aThumbs[i].width > aThumbs[i].height){

		  iCf = aThumbs[i].width / aThumbs[i].height;
		  aThumbs[i].width = 100;
		  aThumbs[i].height = aThumbs[i].width / iCf;
		  
		  var mt = (100 - aThumbs[i].height)/2;

		  aThumbs[i].style.marginTop = mt+'px';
		  
		}
		else if(aThumbs[i].height == aThumbs[i].width){

		  aThumbs[i].height = 100;
		  aThumbs[i].width = 100;
		}
		
		if(counter/(5*faktor) == 1){

			aThumbs[i].parentNode.style.marginRight = '0px';
			faktor ++;
		}
		
		counter++;
	}
  }
}
