//*********************************************************
if(!com) var com = new Object();
if(!com.pixelsterben) com.pixelsterben = new Object();


com.pixelsterben.getStuff = function(url,div,finish){

  request = Try.these(
      function() {return new XMLHttpRequest()},
      function() {return new ActiveXObject('Msxml2.XMLHTTP')},
      function() {return new ActiveXObject('Microsoft.XMLHTTP')}
    ) || false;
  


	request.onreadystatechange = function(){
		if (request.readyState == 4){
			if (request.status != 200){
				eval(finish);
				delete request;
			}else{
				// everything worked
				var div_element = document.getElementById(div);
				div_element.innerHTML = request.responseText;
			    eval(finish);
			}
		}
	}
	request.open("GET", url, true);
//	request.overrideMimeType=true;
//	request.setRequestHeader('Content-Type','text/html;charset=utf-8'); 
	request.send(null);
}

var hash="";
var language = 0;

init = function(rex_language, find){
	language = rex_language;
	if(find){
		window.location.hash = "";
	}
	setInterval("checkLocation();", 200);
	new Effect.Fade("detail_loading");
}

checkLocation = function(){
	if(hash != window.location.hash.substring(1, window.location.hash.length)){
		hash = window.location.hash.substring(1, window.location.hash.length)
//		alert(hash);
//		Mint.TT.behavior.record('Portfolio Click:'+ hash, '/gallery/collect.php?dfacts=1&tags='+hash);
		var back_to_top = new Effect.ScrollTo('header');
		load('gallery/collect.php?language='+language+'&tags='+hash);
	}
	
}
load = function(url){
	// Element.show('detail_loading');
	new Effect.Appear('detail_loading')
	new Effect.Fade('detail_slider', {queue: 'end', afterFinish: function(){	
	com.pixelsterben.getStuff(url,'detail_slider','new Effect.Fade("detail_loading"); initLightbox(); new Effect.Appear("detail_slider");');	
	 } });
}


tags_show_hi = function(tagstring){
	tags = String(tagstring).split(',');
	if(!tags.length) return;


	anchors = document.getElementsByTagName('a');
	if(!anchors.length) return;
	// blind all tags with className tagXYZ
	for(aa=0; aa<anchors.length;aa++){
		if(anchors[aa].id.substring(0,9) == "tagcloud_"){
			anchors[aa].className = anchors[aa].className.replace(/ blind/,"")+" blind";
		}
	}
	// restore all tags form tagstring
	for(tt=0; tt<tags.length;tt++){		
		show_div = document.getElementById("tagcloud_"+tags[tt]);
		if(show_div){
			show_div.className = show_div.className.replace(/ blind/,"");
		}
	}

}

tags_clear_hi = function(tagstring){
	anchors = document.getElementsByTagName('a');
	if(!anchors.length) return;
	for(aa=0; aa<anchors.length;aa++){
		if(anchors[aa].id.substring(0,9) == "tagcloud_"){
			anchors[aa].className = anchors[aa].className.replace(/ blind/,"");
		}
	}
}


gallery_close = function(div){
	if(!div) return
	close_div = document.getElementById(div);
//	if(close_div) close_div.style.display = "none";
	close_div.parentNode.className = 'portfolio_block';

	images = close_div.getElementsByTagName('img');
	if(images.length){
		for(ii=0; ii<images.length;ii++){
			setTimeout('new Effect.Fade("'+images[ii].id+'")',(images.length-ii)*100);
		}
	}
//	new Effect.Fade(images);
	setTimeout('new Effect.Fade("'+div+'")',350);
	setTimeout('new Effect.BlindUp("'+div+'")',500);


}



gallery_info = function(target,url){
	if(!url) return
	infoButton = document.getElementById(target+"_info");
	if(infoButton) {
		if(infoButton.className == "info"){
			infoButton.className = "info_active";
			document.getElementById(target).parentNode.className +=" open";
			com.pixelsterben.getStuff(url,target,'document.getElementById("'+target+'").style.display="block";');
		} else {
			infoButton.className = "info";		
			document.getElementById(target).parentNode.className='portfolio_block';
			infoDiv = document.getElementById(target);
			if(infoDiv) {
				infoDiv.style.display = "none";
			}
		}
			
	}
	return false;
}


  window.getScrollY = function(){ 
  							var sy = 0;
						  if (document.documentElement && document.documentElement.scrollTop)
							sy = document.documentElement.scrollTop;
						  else if (document.body && document.body.scrollTop) 
							sy = document.body.scrollTop; 
						  else if (window.pageYOffset)
							sy = window.pageYOffset;
						  else if (window.scrollY)
							sy = window.scrollY;
						  
						  return sy-100;
						}

	div_leftcolumn = document.getElementById('leftcolumn');
	if(div_leftcolumn) {
		div_leftcolumn.style.position = "relative";
	  	leftSlider = new Glider("leftcolumn",0, 0,null,null,1000,-1);
  		leftSlider.show();
  	}
  
	div_rightcolumn = document.getElementById('rightcolumn');
	if(div_rightcolumn) {
		div_rightcolumn.style.position = "relative";
		rightSlider = new Glider("rightcolumn",0, 0,null,null,1000,-1);
  		rightSlider.show();
  	}	
  	


checkShift = function(tag){

	if(window.event.shiftKey){
	   window.location.href = window.location.href+","+tag;
	   return false;
	} else {
	  return true;
	}
 
 } 


