var auctionRemain=10,notifier="",countdown="",url="",pars="",target="",remain=0,maintimer=0,antalltimere=0,auctionTimerId=new Array(),timer=new Array(),remainArr=new Array(),idleTime=200000,timeOut="";
function init(){Event.observe(document.body,"mousemove",resetIdle,true);
setIdle()
}function onIdleFunction(){window.location="http://ebud.no/timeout.html"
}function resetIdle(){window.clearTimeout(timeOut);
setIdle()
}function setIdle(){timeOut=window.setTimeout("onIdleFunction()",idleTime)
}Event.observe(window,"load",init,false);
hentTimere=function(){var b=$$(".auksjon");
var a=0;
for(a=0;
a<b.length;
a++){auctionTimerId[a]=b[a].innerHTML;
antalltimere++
}};var auksjoner=$$("auksjon");
var counter=0;
for(counter=0;
counter<auksjoner.length;
counter++){timer[counter]=1
}initAuksjoner=function(b){hentTimere();
var a=0;
while(a<auctionTimerId.length){sjekkAuksjonSlutt(auctionTimerId[a],a);
a++}};
rand=function(a,b){return Math.floor((Math.random()*(b-a+1))+a)
};giBud=function(c,g,h,b){var e="oppdaterAuksjon.php",d="?auctionid="+escape(c)+"&userid="+escape(h),f=document.getElementById("budsum_"+c),a="gjeldende_pris_"+c,i=document.getElementById("notifier_"+c);
new Ajax.Request(e+d,{onSuccess:function(q){var j=q.responseText,l=new Array();
l=j.split("|");
i.innerHTML=l[0];
if(b==1){document.getElementById("budsum_"+c).innerHTML=l[2];
var p=new Array(),o=new Array(),n=new Array(),k=0,m="";
p=l[2].split(",");
o=p[1].split("");
n=p[0].split("");
for(k=0;
k<n.length;
k++){m=m+'<div class="tall_l blaa_'+n[k]+'"></div>'
}m=m+'<div class="tall_l blaa_dot"></div>';
for(k=0;
k<o.length;
k++){m=m+'<div class="tall_m blaa_'+o[k]+'"></div>'
}document.getElementById("budsum_"+c).innerHTML=m;
new Effect.Highlight(document.getElementById("storpris_"+c),{startcolor:"#ffff99",endcolor:"#ffffff"})
}document.getElementById("budkonto_bud").innerHTML=l[1];
document.getElementById("notifier_"+c).innerHTML=l[3];
document.getElementById("gjeldende_pris_"+c).innerHTML=l[2];
new Effect.Highlight(document.getElementById("budleder_"+c),{startcolor:"#ffff99",endcolor:"#ffffff"});
if(b==2){new Effect.Highlight(document.getElementById("gjeldende_pris_"+c),{startcolor:"#ffff99",endcolor:"#ffffff"})
}}})};
leggAutobud=function(c,a,d){var f=document.getElementById("budkonto_bud");
var e="leggAutobud.php";
var b="?auctionid="+escape(c)+"&userid="+escape(d);
new Ajax.Request(e+b,{onSuccess:function(g){notifier.innerHTML=g.responseText;
new Ajax.Request("hentBrukerBud.php?userid="+escape(d),{onSuccess:function(i){var h=i.responseText;
f.innerHTML=h
}})}})
};oppdaterAuksjonPris=function(a){var b=document.getElementById("budsum_"+a);
new Ajax.Request("hentAuksjonpris.php?auctionid="+escape(a),{onSuccess:function(d){var c=d.responseText;
b.innerHTML=c
}})};oppdaterMiniAuksjonPris=function(a){var b=document.getElementById("gjeldende_pris_"+a);
new Ajax.Request("hentMiniAuksjonpris.php?auctionid="+escape(a),{onSuccess:function(d){var c=d.responseText;
b.innerHTML=c
}})};oppdaterAuksjonSparepris=function(a){var b=document.getElementById("dusparer_pris_"+a);
new Ajax.Request("hentAuksjondusparer.php?auctionid="+escape(a),{onSuccess:function(d){var c=d.responseText;
b.innerHTML=c
}})};oppdaterLedertabell=function(a){new Ajax.Request("hentAuksjonleder.php?auctionid="+escape(a),{onSuccess:function(b){document.getElementById("notifier_"+a).innerHTML=b.responseText
}})};hentAuksjontid=function(a){new Ajax.Request("hentAuksjontid.php?auctionid="+escape(a),{onSuccess:function(b){return b.responseText
}})};auksjonIkkestartet=function(a){var b=document.getElementById("notifier_"+a);
b.innerHTML="Auksjonen har ikke startet enda. Legg autobud i stedet."
};hentAuksjonvinner=function(a){var b=document.getElementById("notifier_"+a);
new Ajax.Request("hentAuksjonvinner.php?auctionid="+escape(a),{onSuccess:function(d){var c=d.responseText;
b.innerHTML=c
}})};sjekkAuksjonSlutt=function(b,a){var e=document.getElementById("countdown_"+b),d="sjekkAuksjonsslutt.php?auctionid="+escape(b),h="klokkeramme_"+b,g=180,c=10,f=true;
e.innerHTML='<img src="_images/laster.png">';
new Ajax.Request(d,{onSuccess:function(i){g=i.responseText;
if(g==-4){document.getElementById(h).style.backgroundPosition="0px -1224px";
e.innerHTML="";
f=false
}else{if(g==-3){document.getElementById(h).style.backgroundPosition="0px -615px";
e.innerHTML="";
f=false
}else{if(g==-2){document.getElementById(h).style.backgroundPosition="0px -818px";
e.innerHTML="";
f=false
}else{if(g=="-1"){e.innerHTML="";
f=false
}else{if(g==0){e.innerHTML="";
document.getElementById(h).style.backgroundPosition="0px -1021px";
g=0;f=false
}else{}}}}}}});
clearInterval(timer[a]);
timer[a]=0;
timer[a]=setInterval(function(){if(g==0){document.getElementById(h).style.backgroundPosition="0px -1021px"
}else{if(g<=30&&g>15){document.getElementById(h).style.backgroundPosition="0px -206px"
}else{if(g<=15&&g>0){document.getElementById(h).style.backgroundPosition="0px -408px"
}else{if(g>=30){document.getElementById(h).style.backgroundPosition="0px 0px"
}}}}if(f){if(g==-4){document.getElementById(h).style.backgroundPosition="0px -1224px"
}if(g==-3){document.getElementById(h).style.backgroundPosition="0px -615px"
}if(g==-2){document.getElementById(h).style.backgroundPosition="0px -818px"
}if(g==-1){document.getElementById(h).style.backgroundPosition="0px -1021px"
}if(g==20||g==3||g==2||g==1||g==30||g==40||g==50||g==55||g==58||g==65||g==70||g==90||g==80){new Ajax.Request("hentAuksjontid.php?auctionid="+escape(b),{onSuccess:function(i){c=i.responseText;
if(c<=0){f=false;
e.innerHTML=""
}g=c;oppdaterLedertabell(b);
oppdaterMiniAuksjonPris(b);
oppdaterAuksjonSparepris(b);
oppdaterAuksjonPris(b)
}})}timeRemain=Math.floor(g/60)+":"+(g%60<10?"0":"")+g%60;
clockRemain=timeRemain.split(":");
minutter1=clockRemain[0].substring(0,1);
minutter2=clockRemain[0].substring(1,2);
sekunder1=clockRemain[1].substring(0,1);
sekunder2=clockRemain[1].substring(1,2);
if(minutter1==""){minutter1=0
}if(minutter2==""){minutter2=0
}if(sekunder2=="/"){grafikkdiv.innerHTML="123"
}else{imgMin1='<input class="klokke_forside klokke_'+minutter2+'" type="button" value="">';
imgMin2='<input class="klokke_forside klokke_'+minutter1+'" type="button" value="">';
imgSek1='<input class="klokke_forside klokke_'+sekunder1+'" type="button" value="">';
imgSek2='<input class="klokke_forside klokke_'+sekunder2+'" type="button" value="">';
colon='<input class="klokke_forside colon" type="button" value="">';
e.innerHTML=imgMin1+imgMin2+colon+imgSek1+imgSek2
}}if(g>1){g--
}},1000)
};bgFocus=function(a){bgFocus_remove();
document.getElementById(a).style.backgroundColor="#FFF7C0";
if(a=="nybruker_navn"){document.getElementById("reg_info_brukernavn").style.color="black";
document.getElementById("reg_info_brukernavn").style.fontWeight="normal";
document.getElementById("reg_info_brukernavn").innerHTML="Ditt brukernavn vil identifisere deg på leder-/vinnertabellen. Minst 6 tegn."
}if(a=="nybruker_mobil"){document.getElementById("reg_info_mobil").style.color="black";
document.getElementById("reg_info_brukernavn").style.fontWeight="normal";
document.getElementById("reg_info_mobil").innerHTML="Mobilnummeret må være korrekt for at du skal kunne motta varer du har vunnet."
}if(a=="nybruker_epost"){document.getElementById("reg_info_epost").style.color="black";
document.getElementById("reg_info_brukernavn").style.fontWeight="normal";
document.getElementById("reg_info_epost").innerHTML="For at vi skal kunne sende deg viktige meldinger."
}if(a=="nybruker_passord"){document.getElementById("reg_info_passord").style.color="black";
document.getElementById("reg_info_brukernavn").style.fontWeight="normal";
document.getElementById("reg_info_passord").innerHTML="Passordet ditt må være mellom 6 og 20 tegn."
}};bgFocus_remove=function(){document.getElementById("reg_info_brukernavn").innerHTML="";
document.getElementById("reg_info_mobil").innerHTML="";
document.getElementById("reg_info_epost").innerHTML="";
document.getElementById("reg_info_passord").innerHTML="";
document.getElementById("nybruker_navn").style.backgroundColor="white";
document.getElementById("nybruker_passord").style.backgroundColor="white";
document.getElementById("nybruker_epost").style.backgroundColor="white";
document.getElementById("nybruker_velgbrukerklasse").style.backgroundColor="white";
document.getElementById("nybruker_startpakke").style.backgroundColor="white";
document.getElementById("nybruker_betaling").style.backgroundColor="white";
document.getElementById("nybruker_vepost").style.backgroundColor="white";
document.getElementById("nybruker_vmobil").style.backgroundColor="white";
document.getElementById("nybruker_mobil").style.backgroundColor="white"
};function validateInputNewUser(a,b){var d=document.getElementById(a).value;
var b=document.getElementById(b);
var c=Math.floor(Math.random()*10000);
if(d.length>2){new Ajax.Request("validateNewuser.php?input="+(d)+"&section="+escape(a)+"&rand="+c,{onSuccess:function(e){b.innerHTML=e.responseText
}})}}Broadcaster=function(){this.listeners={}
};(function(a){a.defaultScope=this;
a.listen=function(c,d,b){if(!this.listeners[c]){this.listeners[c]=[]
}this.listeners[c].push({callback:d,scope:b});
return d
};a.subscribe=a.listen;
a.stopListening=function(f,h){var d=this.listeners,b=f,g=h,e;
if(d[b]){for(e=0;
e<d[b].length;
e++){if(d[b][e].callback==g){d[b].splice(e,1)
}}}};a.unsubscribe=a.stopListening;
a.broadcast=function(f){var b=this.listeners[f],e=this.listeners["*"],c,d;
if(b||e){c=Array.prototype.slice.call(arguments,1);
if(b){for(d=0;
d<b.length;
d++){b[d].callback.apply(b[d].scope||this.defaultScope,c)
}}if(e){for(d=0;
d<e.length;
d++){e[d].callback.apply(e[d].scope||this.defaultScope,arguments)
}}}};a.fire=a.broadcast;
a.send=a.broadcast
})(Broadcaster.prototype);
var Ebud={broadcaster:new Broadcaster(),onReady:function(){var a=$$("input[name=authenticity_token]");
this.authenticityToken=a.length>0&&a[0].readAttribute("value");
this.broadcaster.fire("ready")
},reload:function(){window.location.reload()
}};Ebud.b=Ebud.broadcaster;
Ebud.LabelSwap=Class.create({initialize:function(b,a){this.label=b;
this.input=a;
if(!this.input.value){this.observe()
}this.label.hide()
},extractValue:function(){return this.label.innerHTML
},observe:function(){var b=this;
var c=function(){b.input.value=""
},d=function(){b.input.value=b.extractValue()
},a=function(){b.input.stopObserving("focus",c);
b.input.stopObserving("blur",d);
b.input.stopObserving("keyup",a)
};this.input.observe("focus",c);
this.input.observe("blur",d);
this.input.observe("keyup",a);
d()}});
Ebud.LabelSwap.locate=function(){return $$("form p.inputlabel").map(function(c){var b=c.down("label"),a=c.down("input");
if(b&&a){return new Ebud.LabelSwap(b,a)
}}).compact()
};Ebud.b.listen("ready",function(){Ebud.labelableInputs=Ebud.LabelSwap.locate();
$$("form.disableonsubmit").each(function(a){a.observe("submit",function(){var b=a.down("input[type=submit]");
b&&b.disable()
})})});
document.observe("dom:loaded",function(){initAuksjoner();
Ebud.onReady()
});
