function hasClass(ele, cls){
    return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}

function addClass(ele, cls){
    if (!this.hasClass(ele, cls)) 
        ele.className += " " + cls;
}

function removeClass(ele, cls){
    if (hasClass(ele, cls)) {
        var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
        ele.className = ele.className.replace(reg, ' ');
    }
}

function show(ele, img){
    addClass(ele, 'black');
}

function unshow(ele){
    removeClass(ele, 'black');
}
var hidden;
function init_mousemove(){
    if (document.layers) document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = dpl_mouse_pos;
}
function dpl_mouse_pos(e){
	var xPos = e ? e.pageX : window.event.x;
	var yPos = e ? e.pageY : window.event.y;
	
	if (document.all && !document.captureEvents) {
		xPos += document[docEl].scrollLeft;
		yPos += document[docEl].scrollTop;
	}
	if (document.layers) routeEvent(e);
	if (xPos >= 480 && xPos <= 1120) {
		if(!hidden) hideThemAll();
	} else { 
		showThemAll();
	}
}
function hideThemAll() {
	unshow(document.getElementById("allshipshape"));
	unshow(document.getElementById("surlelacenville"));
	unshow(document.getElementById("zalle"));
	unshow(document.getElementById("beatbagbohemia"));
	unshow(document.getElementById("postit"));
	unshow(document.getElementById("wheredowegonowbutnowhere"));
	unshow(document.getElementById("surlelac2011"));
	unshow(document.getElementById("illustration"));
	unshow(document.getElementById("variousposters"));
	unshow(document.getElementById("eduardvogt"));
	unshow(document.getElementById("buempliznordsued"));
	unshow(document.getElementById("labradorcity"));
	hidden = true;
}
function showThemAll() {
	show(document.getElementById("allshipshape"));
	show(document.getElementById("surlelacenville"));
	show(document.getElementById("zalle"));
	show(document.getElementById("beatbagbohemia"));
	show(document.getElementById("postit"));
	show(document.getElementById("wheredowegonowbutnowhere"));
	show(document.getElementById("illustration"));
	show(document.getElementById("variousposters"));
	show(document.getElementById("surlelac2011"));
	show(document.getElementById("eduardvogt"));
	show(document.getElementById("buempliznordsued"));
	show(document.getElementById("labradorcity"));
	hidden = false;
}

function trigger() {
	if( document.getElementById('description').style.display == 'block' ){
		document.getElementById('description').style.display = 'none' ;
	} else {
		document.getElementById('description').style.display = 'block' ;
	}
}

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
	var classes = elem[i].className;
	if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
}; 

Projekte = new Array();
Projekte[0] ='<div id="allshipshape" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="allshipshape.html"><img src="images/1_All Ship Shape/Thump/EP_front_WEB_thump.jpg" alt="" width="200" height="140" />All Ship Shape</a></div>';
Projekte[1] ='<div id="surlelacenville" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="surlelacenville.html"><img src="images/2_Sur le Lac - En Ville/Thump/3_digi_enville_WEB_thump.jpg" alt="" width="200" height="280" /></a>Sur le Lac - En Ville</div>';
Projekte[2] ='<div id="zalle" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="zalle.html"><img src="images/3_Zalle/thumps/z_10_WEB_thump.jpg" alt="" width="200" height="140" />Zalle</a></div>';
Projekte[3] ='<div id="beatbagbohemia" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="beatbagbohemia.html"><img src="images/4_Beat Bag Bohemia/Thumps/1_DVD_ansicht_WEB_thump.jpg" alt="" width="200" height="140" />Beat Bag Bohemia</a></div>';
Projekte[4] ='<div id="postit" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="postit.html"><img src="images/6_Post-It/Thumps/leim_10_WEB_thump.jpg" alt="" width="200" height="140" />Post-It</a></div>';
Projekte[5] ='<div id="wheredowegonowbutnowhere" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="wheredowegonowbutnowhere.html"><img src="images/7_Where do we go now, but nowhere/Thumps/7_where_6_WEB_thump.jpg" alt="" width="200" height="140" />Where do we go now but nowhere</a></div>';
Projekte[6] ='<div id="illustration" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="illustration.html"><img src="images/8_Bad Religion/Thump/bad_bearb_WEB_thump.jpg" alt="" width="200" height="140" />Illustration</a></div>';
Projekte[7] ='<div id="variousposters" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="variousposters.html"><img src="images/10_Various Posters/thump/2_ratatat.jpg" alt="" width="200" height="280" />Various Posters</a></div>';
Projekte[8] ='<div id="surlelac2011" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="surlelac2011.html"><img src="images/9_Sur le Lac 2011/Thump/poster_bearb_WEB.jpg" alt="" width="200" height="280" />Sur le Lac 2011</a></div>';
Projekte[9] ='<div id="eduardvogt" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="eduardvogt.html"><img src="images/11_Eduard Vogt/thump/1_eduard_thump.jpg" alt="" width="200" height="140" />Eduard Vogt</a></div>';
Projekte[10]='<div id="buempliznordsued" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="buempliznordsued.html"><img src="images/5_Buempliz Nord.Sued/thump/z_2_WEB_thump.jpg" alt="" width="200" height="140" />B&uuml;mpliz Nord:S&uuml;d</a></div>';
Projekte[11]='<div id="labradorcity" class="link" onmouseover="show(this)" onmouseout="unshow(this)"><a href="labradorcity.html"><img src="images/12_Labrador City/thumb/lab_0.jpg" alt="" width="200" height="280" />Labrador City</a></div>';



function calculate(index) {
	var anzSpalten = Math.floor((window.innerWidth)/220)-2+index;
	for (var i = 0; i < anzSpalten; i++ ) {
		document.getElementById("columns").innerHTML += "<div class='column'></div>";

		switch( i ){
			case 0: document.getElementsByClassName('column')[i].innerHTML += '<div class="nav"><a href="index.html" title="dominiksieber">D</a></div>'; break;
			case 1: document.getElementsByClassName('column')[i].innerHTML += '<div class="nav"><a href="about.html">About</a>&emsp;&emsp;<a href="contact.html">Contact</a></div>'; break;
		}
		
		document.getElementsByClassName('column')[i].innerHTML += '<div class="spacer">&zwnj;</div><div class="spacer">&zwnj;</div>';
	}
	if( index == 2 )document.getElementsByClassName('column')[0].innerHTML += '<img src="images/hello.jpg" />';
	for (var i = 0; i < anzSpalten; i++ ) {
		for(var j = 0; j < Projekte.length; j = j+anzSpalten-index ) {
			if( i+j < Projekte.length ) {
				document.getElementsByClassName('column')[i+index].innerHTML += Projekte[i+j];
			}
		}
	}
}


/*
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6628476-12']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); */
