var anim = {
	vars : {
		div_id : 'right_panel',
		div : null,
		pfeil_id : 'big_pfeil',
		pfeil : null,
		animRight : null,
		animLeft : null,
		pfeilRight : null,
		pfeilLeft : null,
		big_bild_id : 'big_bild',
		big_bild : null
	},
	init : function () {
		anim.vars.div = YAHOO.util.Dom.get(anim.vars.div_id);
		anim.vars.pfeil = YAHOO.util.Dom.get(anim.vars.pfeil_id);
		anim.vars.big_bild = YAHOO.util.Dom.get(anim.vars.big_bild_id);
		animAttributes = {
			left: {	to: 340, unit: 'px' }
		};
		anim.vars.animRight = new YAHOO.util.Anim(anim.vars.div, animAttributes, 1 , YAHOO.util.Easing.easeOut);
		animAttributes = {
			left: {	to: 320, unit: 'px' }
		};
		anim.vars.pfeilLeft = new YAHOO.util.Anim(anim.vars.pfeil, animAttributes, 1, YAHOO.util.Easing.easeOut);
		anim.vars.animRight.onComplete.subscribe(function() { anim.vars.pfeilLeft.animate(); });
		// now vice versa
		animAttributes = {
			left: { to: 70,	unit: 'px' }
		};
		anim.vars.animLeft = new YAHOO.util.Anim(anim.vars.div, animAttributes, 1 , YAHOO.util.Easing.easeOut);
		animAttributes = {
			left: {	to: 360, unit: 'px' }
		};
		anim.vars.pfeilRight = new YAHOO.util.Anim(anim.vars.pfeil, animAttributes, 1, YAHOO.util.Easing.easeIn);
		anim.vars.pfeilRight.onComplete.subscribe(function() { anim.vars.animLeft.animate(); });
//		alert(get_cookie("hiddenRPanel"));
		if (get_cookie("hiddenRPanel") == "True") {
			YAHOO.util.Dom.setStyle(anim.vars.div, 'left', '340px');
			YAHOO.util.Dom.setStyle(anim.vars.pfeil, 'left', '320px');
			YAHOO.util.Dom.setStyle(anim.vars.big_bild, 'height', '90%');
			YAHOO.util.Dom.setStyle(anim.vars.big_bild, 'top', '5%');
		}
	},
	hide : function () {
		magnifier.kill();
		anim.vars.animRight.animate();
		document.cookie = "hiddenRPanel=True;path=/";
		if (document.location.pathname != '/') // not on the startpage!
		  (new YAHOO.util.Anim(anim.vars.big_bild, {height: {to:90, from:70, unit:'%'},top:{to:5, from:13, unit:'%'}},
			1, YAHOO.util.Easing.easeOut)).animate();
	},
	show : function () {
		magnifier.kill();
		anim.vars.pfeilRight.animate();
		document.cookie = "hiddenRPanel=False;path=/";
		if (document.location.pathname != '/') // not on the startpage!
		  (new YAHOO.util.Anim(anim.vars.big_bild, {height: {to:70, from:90, unit:'%'},top:{to:13, from:5, unit:'%'}},
			1, YAHOO.util.Easing.easeOut)).animate();
	}
}

YAHOO.util.Event.onDOMReady(anim.init);
//YAHOO.util.Event.on(window, 'load', anim.init);

//Get cookie routine by Shelley Powers 
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

