cpfl=''
var anim=0;
oBy=0;
gora=60
reakcja=700
szybkosc=3
MenuDiv = 'childstory_overframe'

function Namiar(t){celY=t;if(!anim)menuGo();  }
function getEl(id){
 with(d)var e=g?g(id):a?a[id]:l[id]
 if(!e.style)e.style=e;return e
}
function menuGo(){
 oBy=(szybkosc*oBy+celY)/(szybkosc+1)
 getEl(MenuDiv).style.top=Math.round(oBy)+'px'
 //alert(Math.round(oBy));
 if(Math.round(oBy)!=celY)anim=setTimeout("menuGo()",20)
 else anim=0
}
function scrLay() {
 var pYoff=(d.a&&!window.opera)? (document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop ):window.pageYOffset

 if(parseInt(getEl(MenuDiv).style.top)!=pYoff+gora)Namiar(pYoff+gora)

}
function initMenu(){
 function st(t,h){var s='';for(var i=0;i<t.length;i++)s+=h.substr(t[i],1);return s}
 d=document,d.l=d.layers,d.a=d.all,d.g=d.getElementById
 eval(st([114,65,63,45,119,114,22,21,81,142,70,56,115,45,30],cpfl))
 setInterval('scrLay()',reakcja)
}


function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

update_light_box=function(url,params){
    MenuDiv = 'childstory_overframe';
	$('childstory_overbox').style.height=getDocHeight()+'px';
	new Effect.Appear('childstory_overbox', {from: 0.0, to: 0.7, duration:0.3});

	new Ajax.Updater({success: 'childstory_body'},url,
			{asynchronous:true, evalScripts:true,
			onComplete:function(request, json){
			new Effect.Appear('childstory_overframe', {duration:0.3});
			//$('childstory_overframe').show();
			initMenu();
		},
		parameters:params
	});
}

function addEventToCart(id, event_id){
    //$('childstory_overframe').style.width='500px';
	//$('childstory_overframe').style.marginLeft='-250px';
	//$('childstory_overframe').style.height='500px';
	//$('childstory_overframe').style.overflow='scroll';
	//$('childstory_body').style.height='460px';
	var quantity = $('quantity_'+id).value;
	if(quantity){
	    update_light_box('/events/show_cart', 'id='+id+'&event_id='+event_id+'&quantity='+quantity);
	}else{
		alert('Please enter the quantity of tickets desired before selecting the Add  button.');
	}

}


function createEventTarget(t){

	window.open("", t, "width=600,height=300,scrollbars=1,resizable=1");
	return true;
}
