/*
moo.fx, simple effects library built with prototype.js (http://prototype.conio.net).
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE.
for more info (http://moofx.mad4milk.net).
Sunday, March 05, 2006
v 1.2.3
*/

var fx = new Object();
//base
fx.Base = function(){};
fx.Base.prototype = {
	setOptions: function(options) {
	this.options = {
		duration: 500,
		onComplete: '',
		transition: fx.sinoidal
	}
	Object.extend(this.options, options || {});
	},

	step: function() {
		var time  = (new Date).getTime();
		if (time >= this.options.duration+this.startTime) {
			this.now = this.to;
			clearInterval (this.timer);
			this.timer = null;
			if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);
		}
		else {
			var Tpos = (time - this.startTime) / (this.options.duration);
			this.now = this.options.transition(Tpos) * (this.to-this.from) + this.from;
		}
		this.increase();
	},

	custom: function(from, to) {
		if (this.timer != null) return;
		this.from = from;
		this.to = to;
		this.startTime = (new Date).getTime();
		this.timer = setInterval (this.step.bind(this), 13);
	},

	hide: function() {
		this.now = 0;
		this.increase();
	},

	clearTimer: function() {
		clearInterval(this.timer);
		this.timer = null;
	}
}

//stretchers
fx.Layout = Class.create();
fx.Layout.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.el.style.overflow = "hidden";
		this.iniWidth = this.el.offsetWidth;
		this.iniHeight = this.el.offsetHeight;
		this.setOptions(options);
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {
	increase: function() {
		this.el.style.height = this.now + "px";
	},

	toggle: function() {
		if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0);
		else this.custom(0, this.el.scrollHeight);
	}
});

fx.Width = Class.create();
Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), {
	increase: function() {
		this.el.style.width = this.now + "px";
	},

	toggle: function(){
		if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0);
		else this.custom(0, this.iniWidth);
	}
});

//fader
fx.Opacity = Class.create();
fx.Opacity.prototype = Object.extend(new fx.Base(), {
	initialize: function(el, options) {
		this.el = $(el);
		this.now = 1;
		this.increase();
		this.setOptions(options);
	},

	increase: function() {
		if (this.now == 1 && (/Firefox/.test(navigator.userAgent))) this.now = 0.9999;
		this.setOpacity(this.now);
	},

	setOpacity: function(opacity) {
		if (opacity == 0 && this.el.style.visibility != "hidden") this.el.style.visibility = "hidden";
		else if (this.el.style.visibility != "visible") this.el.style.visibility = "visible";
		if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + opacity*100 + ")";
		this.el.style.opacity = opacity;
	},

	toggle: function() {
		if (this.now > 0) this.custom(1, 0);
		else this.custom(0, 1);
	}
});

//transitions
fx.sinoidal = function(pos){
	return ((-Math.cos(pos*Math.PI)/2) + 0.5);
	//this transition is from script.aculo.us
}
fx.linear = function(pos){
	return pos;
}
fx.cubic = function(pos){
	return Math.pow(pos, 3);
}
fx.circ = function(pos){
	return Math.sqrt(pos);
}

var mailarray=[109,97,105,108,64,100,101,114,45,117,104,114,101,110,108,97,100,101,110,46,100,101]
var mail_id89='' //variable to contain encrypted email
for (var i=0; i<mailarray.length; i++)
 mail_id89+=String.fromCharCode(mailarray[i])

function email(){
 document.write('<img src="../pics/mail.gif" alt="" />&nbsp;'+'<a style="white-space:nowrap;" href="mailto:'+mail_id89+'">mail [at] der-uhrenladen [dot] de</a>')
 }

function number(x) {
if (x==1) return "Eins"; if (x==2) return "Zwei"; if (x==3) return "Drei";
if (x==4) return "Vier"; if (x==5) return "F&uuml;nf"; if (x==6) return "Sechs";
if (x==7) return "Sieben"; if (x==8) return "Acht"; if (x==9) return "Neun";
if (x==10) return "Zehn"; if (x==11) return "Elf"; if (x==12) return "Zw&ouml;lf";
return x; //default
}
function ishtime(h,m) {
h = number(h)
if (m<=3 || m>57) return h+" Uhr";
if (m<=7)  return "F&uuml;nf nach "+h;
if (m<=12) return "Zehn nach "+h;
if (m<=17) return "Viertel nach "+h;
if (m<=23) return "Zwanzig nach "+h;
if (m<=28) return "F&uuml;nf vor halb "+h;
if (m<=33) return "halb "+h;
if (m<=38) return "F&uuml;nf nach halb "+h;
if (m<=43) return "Zwanzig vor "+h;
if (m<=48) return "Viertel vor "+h;
if (m<=53) return "Zehn vor "+h;
if (m<=58) return "F&uuml;nf vor "+h;
return "h:m"; // never reached?
}
function daytime(h) {
if (!h || h>21) return " nachts"
if (h<12) return " morgens";
if (h<=17) return " nachmittags";
return " abends"; // default
}
function ish(h,m) {
if (!h && !m) { // if no time supplied, use the system time
time = new Date()
h = time.getHours()
m = time.getMinutes()
}
z = daytime(h);
h = h % 12 // fix to 12 hour clock
if (m>57 && time.getSeconds()>30) m++; // round seconds
if (m>60) m=0 // round up minutes
if (m>23) h++ // round up hours
if (h>12)  h = 1 // the clock turns round..
if (h==0) h = 12
return "Es ist jetzt ca. "+ishtime(h,m)+z+"."
}
function cazeit() {
 document.writeln(ish());
 }

function ist_Valid() {

   var msg = "";

   if (kontaktFormular.eMail.value.indexOf("@") < 1 ||
       kontaktFormular.eMail.value.indexOf(".") < 1) {
     msg += "- bitte geben Sie eine g&uuml;ltige E-Mail-Adresse ein!\n";
   }

   if(kontaktFormular.vorName.value == "") {
     msg += "- Leeres Feld: Vorname:\n";
   }

   if(kontaktFormular.nachName.value == "") {
     msg += "- Leeres Feld: Nachname:\n";
   }

   if(kontaktFormular.betreff.value == "") {
     msg += "- Leeres Feld: Betreff:\n";
   }

   if(kontaktFormular.telefon.value == "" ||
      kontaktFormular.telefon.value == "[0-9-()\/+]*$") {
     msg += "- bitte geben Sie f&uuml;r R&uuml;ckfragen Ihre Telefonnummer ein:\n";
   }

   if(kontaktFormular.nachricht.value == "") {
     msg += "- Leeres Feld: Nachricht:\n";
   }

   if(msg == "") {
     return true;
   }
   alert(msg);
   return false;
 }
