/****************************************************
**
** all-in-one javascript - all used code in one js-file
** reduceses the requests and raises performance ;)
**
*****************************************************/

/****************************************************
*****************************************************
**
** UA-object from sifr.js 
**
*****************************************************
*****************************************************/

var hasFlash=function(){var a=6;if(navigator.appVersion.indexOf("MSIE")!=-1&&navigator.appVersion.indexOf("Windows")>-1){document.write('<script language="VBScript"\> \non error resume next \nhasFlash = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & '+a+'))) \n</script\> \n');if(window.hasFlash!=null)return window.hasFlash}if(navigator.mimeTypes&&navigator.mimeTypes["application/x-shockwave-flash"]&&navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){var b=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;return parseInt(b.charAt(b.indexOf(".")-1))>=a}return false}();String.prototype.normalize=function(){return this.replace(/\s+/g," ")};if(Array.prototype.push==null){Array.prototype.push=function(){var i=0,a=this.length,b=arguments.length;while(i<b){this[a++]=arguments[i++]}return this.length}}if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[];var d,e;if(!a)a=window;if(!b)b=[];for(var i=0;i<b.length;i++){c[i]="b["+i+"]"}e="a.__applyTemp__("+c.join(",")+");";a.__applyTemp__=this;d=eval(e);a.__applyTemp__=null;return d}}function named(a){return new named.Arguments(a)}named.Arguments=function(a){this.oArgs=a};named.Arguments.prototype.constructor=named.Arguments;named.extract=function(a,b){var c,d;var i=a.length;while(i--){d=a[i];if(d!=null&&d.constructor!=null&&d.constructor==named.Arguments){c=a[i].oArgs;break}}if(c==null)return;for(e in c)if(b[e]!=null)b[e](c[e]);return};var parseSelector=function(){var a=/^([^#.>`]*)(#|\.|\>|\`)(.+)$/;
function r(s,t){var u=s.split(/\s*\,\s*/);var v=[];for(var i=0;i<u.length;i++)v=v.concat(b(u[i],t));return v}
function b(c,d,e){c=c.normalize().replace(" ","`");var f=c.match(a);var g,h,i,j,k,n;var l=[];if(f==null)f=[c,c];if(f[1]=="")f[1]="*";if(e==null)e="`";if(d==null)d=document;switch(f[2]){case "#":k=f[3].match(a);if(k==null)k=[null,f[3]];g=document.getElementById(k[1]);if(g==null||(f[1]!="*"&&!o(g,f[1])))return l;if(k.length==2){l.push(g);return l}return b(k[3],g,k[2]);case ".":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;k=f[3].match(a);if(k!=null){if(g.className==null||g.className.match("\\b"+k[1]+"\\b")==null)continue;j=b(k[3],g,k[2]);l=l.concat(j)}else if(g.className!=null&&g.className.match("\\b"+f[3]+"\\b")!=null)l.push(g)}return l;case ">":if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;j=b(f[3],g,">");l=l.concat(j)}return l;case "`":h=m(d,f[1]);for(i=0,n=h.length;i<n;i++){g=h[i];j=b(f[3],g,"`");l=l.concat(j)}return l;default:if(e!=">")h=m(d,f[1]);else h=d.childNodes;for(i=0,n=h.length;i<n;i++){g=h[i];if(g.nodeType!=1)continue;if(!o(g,f[1]))continue;l.push(g)}return l}}
function m(d,o){if(o=="*"&&d.all!=null)return d.all;return d.getElementsByTagName(o)}
function o(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}return r}();
var sIFR=function(){var a="http://www.w3.org/1999/xhtml";var b=false;var c=false;var d;var ah=[];var al=document;var ak=al.documentElement;var am=window;var au=al.addEventListener;var av=am.addEventListener;
var f=function(){var g=navigator.userAgent.toLowerCase();var f={a:g.indexOf("applewebkit")>-1,b:g.indexOf("safari")>-1,c:navigator.product!=null&&navigator.product.toLowerCase().indexOf("konqueror")>-1,d:g.indexOf("opera")>-1,e:al.contentType!=null&&al.contentType.indexOf("xml")>-1,f:true,g:true,h:null,i:null,j:null,k:null};f.l=f.a||f.c;f.m=!f.a&&navigator.product!=null&&navigator.product.toLowerCase()=="gecko";if(f.m)f.j=new Number(g.match(/.*gecko\/(\d{8}).*/)[1]);f.n=g.indexOf("msie")>-1&&!f.d&&!f.l&&!f.m;f.o=f.n&&g.match(/.*mac.*/)!=null;if(f.d)f.i=new Number(g.match(/.*opera(\s|\/)(\d+\.\d+)/)[2]);if(f.n||(f.d&&f.i<7.6))f.g=false;if(f.a)f.k=new Number(g.match(/.*applewebkit\/(\d+).*/)[1]);if(am.hasFlash&&(!f.n||f.o)){var aj=(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]).description;f.h=parseInt(aj.charAt(aj.indexOf(".")-1))}if(g.match(/.*(windows|mac).*/)==null||f.o||f.c||(f.d&&(g.match(/.*mac.*/)!=null||f.i<7.6))||(f.b&&f.h<7)||(!f.b&&f.a&&f.k<124)||(f.m&&f.j<20020523))f.f=false;if(!f.o&&!f.m&&al.createElementNS)try{al.createElementNS(a,"i").innerHTML=""}catch(e){f.e=true}f.p=f.c||(f.a&&f.k<312)||f.n;return f}();
function at(){return{bIsWebKit:f.a,bIsSafari:f.b,bIsKonq:f.c,bIsOpera:f.d,bIsXML:f.e,bHasTransparencySupport:f.f,bUseDOM:f.g,nFlashVersion:f.h,nOperaVersion:f.i,nGeckoBuildDate:f.j,nWebKitVersion:f.k,bIsKHTML:f.l,bIsGecko:f.m,bIsIE:f.n,bIsIEMac:f.o,bUseInnerHTMLHack:f.p}}if(am.hasFlash==false||!al.getElementsByTagName||!al.getElementById||(f.e&&f.p))return{UA:at()};function af(e){if((!k.bAutoInit&&(am.event||e)!=null)||!l(e))return;b=true;for(var i=0,h=ah.length;i<h;i++)j.apply(null,ah[i]);ah=[]}var k=af;function l(e){if(c==false||k.bIsDisabled==true||((f.e&&f.m||f.l)&&e==null&&b==false)||(al.body==null||al.getElementsByTagName("body").length==0))return false;return true}function m(n){if(f.n)return n.replace(new RegExp("%\d{0}","g"),"%25");return n.replace(new RegExp("%(?!\d)","g"),"%25")}function as(p,q){return q=="*"?true:p.nodeName.toLowerCase().replace("html:", "")==q.toLowerCase()}function o(p,q,r,s,t){var u="";var v=p.firstChild;var w,x,y,z;if(s==null)s=0;if(t==null)t="";while(v){if(v.nodeType==3){z=v.nodeValue.replace("<","&lt;");switch(r){case "lower":u+=z.toLowerCase();break;case "upper":u+=z.toUpperCase();break;default:u+=z}}else if(v.nodeType==1){if(as(v,"a")&&!v.getAttribute("href")==false){if(v.getAttribute("target"))t+="&sifr_url_"+s+"_target="+v.getAttribute("target");t+="&sifr_url_"+s+"="+m(v.getAttribute("href")).replace(/&/g,"%26");u+='<a href="asfunction:_root.launchURL,'+s+'">';s++}else if(as(v,"br"))u+="<br/>";if(v.hasChildNodes()){y=o(v,null,r,s,t);u+=y.u;s=y.s;t=y.t}if(as(v,"a"))u+="</a>"}w=v;v=v.nextSibling;if(q!=null){x=w.parentNode.removeChild(w);q.appendChild(x)}}return{"u":u,"s":s,"t":t}}function A(B){if(al.createElementNS&&f.g)return al.createElementNS(a,B);return al.createElement(B)}function C(D,E,z){var p=A("param");p.setAttribute("name",E);p.setAttribute("value",z);D.appendChild(p)}function F(p,G){var H=p.className;if(H==null)H=G;else H=H.normalize()+(H==""?"":" ")+G;p.className=H}function aq(ar){var a=ak;if(k.bHideBrowserText==false)a=al.getElementsByTagName("body")[0];if((k.bHideBrowserText==false||ar)&&a)if(a.className==null||a.className.match(/\bsIFR\-hasFlash\b/)==null)F(a, "sIFR-hasFlash")}function j(I,J,K,L,M,N,O,P,Q,R,S,r,T){if(!l())return ah.push(arguments);aq();named.extract(arguments,{sSelector:function(ap){I=ap},sFlashSrc:function(ap){J=ap},sColor:function(ap){K=ap},sLinkColor:function(ap){L=ap},sHoverColor:function(ap){M=ap},sBgColor:function(ap){N=ap},nPaddingTop:function(ap){O=ap},nPaddingRight:function(ap){P=ap},nPaddingBottom:function(ap){Q=ap},nPaddingLeft:function(ap){R=ap},sFlashVars:function(ap){S=ap},sCase:function(ap){r=ap},sWmode:function(ap){T=ap}});var U=parseSelector(I);if(U.length==0)return false;if(S!=null)S="&"+S.normalize();else S="";if(K!=null)S+="&textcolor="+K;if(M!=null)S+="&hovercolor="+M;if(M!=null||L!=null)S+="&linkcolor="+(L||K);if(O==null)O=0;if(P==null)P=0;if(Q==null)Q=0;if(R==null)R=0;if(N==null)N="#FFFFFF";if(T=="transparent")if(!f.f)T="opaque";else N="transparent";if(T==null)T="";var p,V,W,X,Y,Z,aa,ab,ac;var ad=null;for(var i=0,h=U.length;i<h;i++){p=U[i];if(p.className!=null&&p.className.match(/\bsIFR\-replaced\b/)!=null)continue;V=p.offsetWidth-R-P;W=p.offsetHeight-O-Q;aa=A("span");aa.className="sIFR-alternate";ac=o(p,aa,r);Z="txt="+m(ac.u).replace(/\+/g,"%2B").replace(/&/g,"%26").replace(/\"/g, "%22").normalize() + S + "&w=" + V + "&h=" + W + ac.t;F(p,"sIFR-replaced");if(ad==null||!f.g){
	T="transparent"; // rw
	if(!f.g){
		//p.innerHTML=['<embed class="sIFR-flash" type="application/x-shockwave-flash" src="',J,'" quality="best" wmode="',T,'" bgcolor="',N,'" flashvars="',Z,'" width="',V,'" height="',W,'" sifr="true"></embed>'].join("");
		
		//
		// The IE-Eolas-Patch-Hack for SIFR
		var fo=new FlashObject(J+"?"+Z, null, V, W, "6", N);fo.addParam("wmode", T);fo.write(p);

	}else{
		if(f.d){
			ab=A("object");
			ab.setAttribute("data",J);
			C(ab,"quality","best");
			C(ab,"wmode",T);
			C(ab,"bgcolor",N)
		}else{
			ab=A("embed");
			ab.setAttribute("src",J);
			ab.setAttribute("quality","best");
			ab.setAttribute("flashvars",Z);
			ab.setAttribute("wmode",T);
			ab.setAttribute("bgcolor",N)}
			ab.setAttribute("sifr","true");
			ab.setAttribute("type","application/x-shockwave-flash");
			ab.className="sIFR-flash";
			if(!f.l||!f.e)ad=ab.cloneNode(true)
		}
	}else ab=ad.cloneNode(true);if(f.g){if(f.d)C(ab,"flashvars",Z);else ab.setAttribute("flashvars",Z);ab.setAttribute("width",V);ab.setAttribute("height",W);ab.style.width=V+"px";ab.style.height=W+"px";p.appendChild(ab)}p.appendChild(aa);if(f.p)p.innerHTML+=""}if(f.n&&k.bFixFragIdBug)setTimeout(function(){al.title=d},0)}
function ai(){d=al.title}function ae(){if(k.bIsDisabled==true)return;c=true;if(k.bHideBrowserText)aq(true);if(am.attachEvent)am.attachEvent("onload",af);else if(!f.c&&(al.addEventListener||am.addEventListener)){if(f.a&&f.k>=132&&am.addEventListener)am.addEventListener("load",function(){setTimeout("sIFR({})",1)},false);else{if(al.addEventListener)al.addEventListener("load",af,false);if(am.addEventListener)am.addEventListener("load",af,false)}}else
 if(typeof am.onload=="function")
 {var ag=am.onload;am.onload=function(){ag();af()}}else am.onload=af;if(!f.n||am.location.hash=="")k.bFixFragIdBug=false;else ai()}k.UA=at();k.bAutoInit=true;k.bFixFragIdBug=true;k.replaceElement=j;k.updateDocumentTitle=ai;k.appendToClassName=F;k.setup=ae;k.debug=function(){aq(true)};k.debug.replaceNow=function(){ae();k()};k.bIsDisabled=false;k.bHideBrowserText=true;return k}();


var UA=sIFR.UA; // co4
UA.bIsIE7=(navigator.userAgent.toLowerCase().indexOf('msie 7')>-1);
//UA.bIsIE6
//alert(UA.bIsIE7);

if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac && !sIFR.UA.bIsIE && !sIFR.UA.bIsOpera){ //  && !UA.bIsIE7
	//sIFR.setup();
};


/****************************************************
*****************************************************
**
** swfobject.js 
**
*****************************************************
*****************************************************/

/**
 * SWFObject v1.4.2: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=key+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();
return true;
}else{
if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{
try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);
axo.AllowScriptAccess="always";}
catch(e){
if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}
if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){
var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){
_2d[i].style.display="none";
for(var x in _2d[i]){if(typeof _2d[i][x]=="function"){_2d[i][x]=null;}}}};
if(typeof window.onunload=="function"){
var oldunload=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();
oldunload();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}
if(Array.prototype.push==null){
Array.prototype.push=function(_30){
this[this.length]=_30;
return this.length;};}

var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject; // for legacy support
var SWFObject=deconcept.SWFObject;


/****************************************************
*****************************************************
**
** prototype.lite.js 
**
*****************************************************
*****************************************************/

/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

//note: modified & stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') {
			el = document.getElementById(el);
		}
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		$c(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	},

	find: function(element, what) {
		element = $(element)[what];
		while (element.nodeType != 1) element = element[what];
		return element;
	}
});

var Position = {
	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

document.getElementsByClassName = function(className) {
	var children = document.getElementsByTagName('*') || document.all;
	var elements = [];
	$c(children).each(function(child){
		if (Element.hasClassName(child, className)) elements.push(child);
	});  
	return elements;
}

//useful array functions
Array.prototype.iterate = function(func){
	for(var i=0;i<this.length;i++) func(this[i], i);
}
if (!Array.prototype.each) Array.prototype.each = Array.prototype.iterate;

function $c(array){
	var nArray = [];
	for (var i=0;i<array.length;i++) nArray.push(array[i]);
	return nArray;
}


/****************************************************
*****************************************************
**
** moo.ajax.js
**
*****************************************************
*****************************************************/

//based on prototype's ajax class
//to be used with prototype.lite, moofx.mad4milk.net.

ajax = Class.create();
ajax.prototype = {
	initialize: function(url, options){
		this.transport = this.getTransport();
		this.postBody = options.postBody || '';
		this.method = options.method || 'post';
		this.onComplete = options.onComplete || null;
		this.update = $(options.update) || null;
		this.request(url);
	},

	request: function(url){
		this.transport.open(this.method, url, true);
		this.transport.onreadystatechange = this.onStateChange.bind(this);
		if (this.method == 'post') {
			this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
			if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
		}
		this.transport.send(this.postBody);
	},

	onStateChange: function(){
		try {
			if (this.transport.readyState == 4 && this.transport.status == 200) {
				if (this.onComplete) 
					setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10);
				if (this.update)
					setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10);
				this.transport.onreadystatechange = function(){};
			}
		} catch(e) { /* Error occurs when a request is cancelled by page-unload (rw) */ /*alert("Error onStateChange:\n"+e)*/ }
	},

	getTransport: function() {
		if (window.XMLHttpRequest) return new XMLHttpRequest();
		else if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
		else return false;
	}
};


//
// the IE-no-ActiveX alternative
if (!window.XMLHttpRequest) { // keep normal Browsers away
	try {
		var t=new ActiveXObject('Microsoft.XMLHTTP'); // the normal IE6 way
	} catch(e) {
	
		// start no_ax_xmlhttpreq.js	
		/*
		coded by Kae - http://verens.com/
		use this code as you wish, but retain this notice
		*/
		
		//alert("alternative ajax");
		
		
		var kXHR_instances=0;
		var kXHR_objs=[];
		
		
		XMLHttpRequest=function(){
			//alert("create xhr instance!");
			var i=0;
			var url='';
			var responseText='';
			var iframe='';
			this.onreadystatechange=function(){
				return false;
			}
			this.open=function(method,url){
				//TODO: POST methods
				this.i=++kXHR_instances; // id number of this request
				this.url=url;
				document.body.appendChild(document.createElement('<iframe id="kXHR_iframe_'+this.i+'" style="display:none" src="/"></iframe>'));
			}
			this.send=function(postdata){
				//TODO: use the postdata
				//alert("send url:"+this.url+'?'+postdata);
				document.getElementById('kXHR_iframe_'+this.i).src=this.url+'?'+postdata;
				kXHR_objs[this.i]=this;
				setTimeout('XMLHttpRequest_checkState('+this.i+',2)',2);
			}
			//
			// some dummy function for combatibility (rw)
			this.setRequestHeader=function(){};
			
			return true;
		}
		XMLHttpRequest_checkState=function(inst,delay){
			var el=document.getElementById('kXHR_iframe_'+inst);
			if(el.readyState=='complete'){
				var html=document.frames['kXHR_iframe_'+inst].document.body.innerHTML;
				var responseText=html;
				var responseCDATA=html.substring(html.indexOf('coredatastart')+21, html.lastIndexOf('coredataend')-8).replace(/&lt;/gi, '<').replace(/&gt;/gi, '>').replace(/&amp;/gi, '&'); // Alternative for XML
				kXHR_objs[inst].responseText=responseText;
				kXHR_objs[inst].responseCDATA=responseCDATA;
				kXHR_objs[inst].readyState=4;
				kXHR_objs[inst].status=200;
				kXHR_objs[inst].onreadystatechange();
				// keep the iframe as responseXML root node (rw) - el.parentNode.removeChild(el);
			}else{
				delay*=1.5;
				setTimeout('XMLHttpRequest_checkState('+inst+','+delay+')',delay);
			}
		}
		// end no_ax_xmlhttpreq.js
	
	}
}


/****************************************************
*****************************************************
**
** moo.dom.js
**
*****************************************************
*****************************************************/

//moo.dom by Valerio Proietti (http://mad4milk.net) MIT Open Source license;
//v 1.5 (beta);

function $S() {
	var elements = [];
	$c(arguments).each(function(sel){
		if (typeof sel == 'string') {
			sel.getElements().each(function(el){
				elements.push(el);
			});
		}
		else elements.push(sel);
	});
	return elements;
}

/*------------------String Prototypes----------------------*/

Object.extend(String.prototype, {
	getElements: function(filter){
		var params = [];
		this.split(' ').each(function(arg, j){
			params[j] = param = [];
			if (arg.indexOf('#') > -1) {
				var bits = arg.split('#');
				param['tag'] = bits[0] || '*';
				param['id'] = bits[1];
			}
			else if (arg.indexOf('.') > -1) {
				var bits = arg.split('.');
				param['tag'] = bits[0] || '*';
				param['class'] = bits[1];
			}
			else param['tag'] = arg;
		});
		var filter = filter || document;
		filter = $c(filter.getElementsByTagName('*'));
		params.each(function(param, k){
			if (param['tag'] != '*' && k == 0) filter = filter.filterByTagName(param['tag']);
			else if (k != 0) filter = filter.getElementsByTagName(param['tag']);
			if (param['id']) filter = filter.filterById(param['id']);
			if (param['class']) filter = filter.filterByClassName(param['class']);
		});
		return filter;
	},
	
	getElementsBySelector: function(filter){
		if (!filter) filter = null;
		var elements = [];
		this.split(',').each(function(selector){
			elmnts = selector.replace(/^\s*|\s*$/g,"").getElements(filter);
			elmnts.each(function(el){
				elements.push(el);
			});
		});
		return elements;
	}
});


/*----------------------Array Prototypes-----------------------*/

function $c(array){
	var nArray = [];
	for (i=0;el=array[i];i++) nArray.push(el);
	return nArray;
}

Object.extend(Array.prototype, {
	iterate: function(func){
		for(var i=0;ob=this[i];i++) func(ob, i);
	},

	action: function(actions){
		this.each(function(el){
			if (actions.initialize) actions.initialize.apply(el);
			for(action in actions){
				if (action.slice(0,2) == 'on') el[action] = actions[action];
			}
		});
	},
	
	filterById: function(id){
		var found = [];
		this.each(function(el){
			if (el.id == id) found.push(el);
		});
		return found;
	},

	filterByClassName: function(className){
		var found = [];
		this.each(function(el){
			if (Element.hasClassName(el, className)) found.push(el);
		});
		return found;
	},

	filterByTagName: function(tagName){
		var found = [];
		this.each(function(el){
			if (el.tagName.toLowerCase() == tagName) found.push(el);
		});
		return found;
	},

	getElementsByTagName: function(tagName){
		var found = [];
		this.each(function(el){
			$c(el.getElementsByTagName(tagName)).each(function(tn){
				found.push(tn);
			});
		});
		return found;
	}
});

if(!Array.prototype.each) Array.prototype.each = Array.prototype.iterate;


/****************************************************
*****************************************************
**
** moo.fx.js
**
*****************************************************
*****************************************************/

/*
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,
		keepCentered: false, /* rw add: keeps an absolute positioned element centered while changing size :) */
		topEl: '', /* rw add: this is the absolute positioned element, maybe on top */
		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;
		if (this.options.keepCentered) {
			this.startTop=$(this.options.topEl).offsetTop; /* rw add: remember start top position */
		}
		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) {
		try {
			this.el = $(el);
			this.el.style.overflow = "hidden";
			this.iniWidth = this.el.offsetWidth;
			this.iniHeight = this.el.offsetHeight;
			this.setOptions(options);
		} catch (e) { };
	}
});

fx.Height = Class.create();
Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), {	
	increase: function() {
		if (this.options.keepCentered) { // rw add
			$(this.options.topEl).style.top = Math.round(this.startTop-((this.now-this.from)/2)) + "px"; /* rw add: setting top position half the value of size growing, so it remains centered */
			if (UA.bIsIE7) $(this.options.topEl).style.height = (Math.round(this.now)+21) + "px"; // rw add: ie7 fix: manually size outer window
		} // rw add
		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);
}


/****************************************************
*****************************************************
**
** moo.fx.pack.js - do we really need this one?
**
*****************************************************
*****************************************************/

/****************************************************
*****************************************************
**
** moo.show.lite.js
**
*****************************************************
*****************************************************/

// mooShow 1.04
// (c)2006 Stuart Eaton - http://www.eatpixels.com
//
// Credit where credit is due: Inspiration from Lightbox (http://www.huddletogether.com/projects/lightbox2/)
// and Couloir (http://www.couloir.org/js_slideshow/) and of course moo.fx (http://moofx.mad4milk.net/
// moo.fx and prototype are covered by their own respective license terms.

var mooShows=new Object();
var isPair=false;

var blankImg=appPath+'file/all/b.gif';

var mooLastWidth=498;
var mooLastHeight=200;

function moo_start(id, nr, orl) {
	if (!mooShows[id]) mooShows[id]=new mooshow(id); // create new mooshow objects
	create_mooshow(id, nr || 0, orl);
}
	
function create_mooshow(showName, shownumber, orl) {
	photoArray=eval(showName); // set up image array based on id
	shownumber++; // add 1 to shownumber so it starts on 1 not 0
	var isp=(photoArray[0].length > 8);
	if ( (!isp && photoArray.length <= 2) || (isp && photoArray.length <= 3) ) {
		mooShows[showName].overlayNav='no';
	} else {
	}
	if(this.topNav=='no' || photoArray.length<=2) {
		Element.hide(showName+'_topNav');
		
	} else {
		mooShows[showName].updateTopNav(showName);
	}
	if (!orl) {
		mooShows[showName].jumptoImage(shownumber);
	} else {
		var w=photoArray[0][1];
		var h=photoArray[0][2];
		Element.setHeight(showName+'_overlayNav', h);
		Element.setWidth(showName+'_overlayNav', ( (isp) ? w*2 : w ));
		if (mooShows[showName].overlayNav=='yes') Element.show(showName+'_overlayNav');
		if (mooShows[showName].IPTCinfo=='yes') Element.show(showName+'_zoombutton');
	}
}

var mooshow = Class.create();
mooshow.prototype = {

	initialize: function(showName) {
		this.id = showName;
		this.busy = 0;
		this.counter = 0;
		this.photoArray = eval(this.id);
		this.numberOfImages = this.photoArray.length-2;
		this.IPTCinfoStatus = 0;
		// new 9 static settings
		this.speed=500;
		this.fadeSpeed=500;
		this.topNav='yes';
		this.overlayNav='yes';
		//this.dropShadow='no';
		//this.captions='no';
		//this.border=0;
		this.copyright='yes';
		this.IPTCinfo=(showName=="zoomShow") ? 'no' : 'yes';
	},
	
	nextImage: function() {
		if(this.busy<1){
			this.busy=1;
			if(this.counter < this.numberOfImages) {
				this.counter ++;
			} else {
				this.counter = 0;
			}
			this.loadImage();
		}
	},
	
	prevImage: function() {
		if(this.busy<1){
			this.busy=1;
			if(this.counter > 0) {
				this.counter --;
			} else {
				this.counter = this.numberOfImages;
			}
			this.loadImage();			
		}
	},
	
	jumptoImage: function(counter) {
		if(this.busy<1){
			this.busy=1;
			this.counter = counter-1;
			this.loadImage();		
		}
	},
	
	switchContent: function(newArray) {
		if(this.busy<1){
			this.busy=1;
			this.photoArray = eval(newArray);
			this.numberOfImages = this.photoArray.length -2;
			this.counter = 0;
			this.loadImage();		
		}
	},
	
	updateIPTCinfoToggle: function() {
		TB_overlaySize();
		//alert("c:"+this.counter);
		moo_start('zoomShow', this.counter);
	},
	
	updateTopNav: function(showName) {
		Element.setInnerHTML(showName+'_topNav', ''); // ???
		this.topNavContent = $(showName+'_topNav').innerHTML; // ???
		
		//this.topNavContent = '<div><span class="cnt">'+(this.counter+1) + ' / ' + (this.photoArray.length-1) + '</span>';
		this.topNavContent = '<div><a href="#" onclick="mooShows[&#39;'+showName+'&#39;].prevImage(); return false;">&lt;</a>';
		for (var i=1; i<this.photoArray.length; i++) {
			if (i==this.counter+1) {
				this.topNavContent=this.topNavContent+'<span>'+i+'</span>';
			} else {
				this.topNavContent=this.topNavContent+'<a href=\'#'+i+'\' onclick=\'mooShows[&#39;'+showName+'&#39;].jumptoImage('+i+'); return false;\'>'+i+'</a>';
			}
		}
		this.topNavContent+='<a href="#" onclick="mooShows[&#39;'+showName+'&#39;].nextImage(); return false;">&gt;</a>';
		document.getElementById(showName+'_topNav').innerHTML = this.topNavContent+"</div>";
	},
	
	// -----------------------------------------------------------------------------------

	loadImage: function() {
		//get showname
		showName=this.id;
		// update top navigation
		if (this.topNav=='yes') this.updateTopNav(showName);
		// show laoding animation
		//alert("w/h:"+Element.getWidth(showName+'_imageContainer')+":"+Element.getHeight(showName+'_imageContainer'));
		var corr=(UA.bIsIE7) ? Math.round(( ( ( (showName=="zoomShow") ? 950 : Element.getWidth(showName+'_outerContainer') ) )-Element.getWidth(showName+'_imageContainer'))/2) : 0; // idiot explorer 7 hack
		$(showName+'_loading').style.left=Math.round(((Element.getWidth(showName+'_imageContainer')-32)/2)+corr)+'px';
		$(showName+'_loading').style.top=Math.round((Element.getHeight(showName+'_imageContainer')-32)/2)+'px';
		Element.show(showName+'_loading'); // causes IE to make bg higher :(
		//alert("corr:"+corr);
		// hide IPTC info
		Element.hide(showName+'_zoom');
		Element.hide(showName+'_zoombutton');
		// overlay navigation
		//if (this.overlayNav=='yes') // <- BUG (removed)!!!
		Element.hide(showName+'_overlayNav');
		//
		// rw - check for a image pair
		isPair=(this.photoArray[this.counter].length > 8);
		//alert('isPair:'+isPair);
		// preload in new image
		newImgPreloader1=new Image();
		newImgPreloader2=new Image(); // rw
		newImgPreloaderProtect = new Image(); //image protection
		// if image is preloaded
		newImgPreloader1.onload=function(){
			//alert("image 1 loaded - pair: "+isPair);
			// when loaded
			$(showName+'_imageContainer').style.visibility='visible';
			if(showName=='zoomShow')$(showName+'_imageContainer').innerHTML = $(showName+'_imageContainer').innerHTML + '<img src="'+appPath+'file/all/b.gif"  style="z-index:123456;position:absolute;left:0;top:0;width:100%;height:100%;display:inline"/>'; //image protection
			// hide current photo
			Element.setSrc(showName+'_image1', blankImg);
			Element.setOpacity(showName+'_image1',0);
			Element.setSrc(showName+'_image2', blankImg);
			Element.setOpacity(showName+'_image2',0);
			// hide laoding animation
			Element.hide(showName+'_loading');
			// set captions to blank space
			//Element.setInnerHTML(showName+'_captions', '&nbsp;');
			// set copyright to blank
			Element.setInnerHTML(showName+'_copyright', '');
			// get new sizes
			//newHeight=newImgPreloader1.height;
			//newWidth=newImgPreloader1.width;
			newHeight=mooShows[showName].photoArray[mooShows[showName].counter][2];
			newWidth=mooShows[showName].photoArray[mooShows[showName].counter][1];
			// resize containers to new size
			//this.resizeTopNavWidth=new fx.Width(showName+'_topNav', {duration: mooShows[showName].speed});
			//this.resizeCaptionWidth=new fx.Width(showName+'_captions', {duration: mooShows[showName].speed});
			this.resizeOuterContainerHeight=new fx.Height(showName+'_imageContainer', {duration: mooShows[showName].speed, keepCentered: true, topEl: 'TB_window' });
			this.resizeOuterContainerWidth=new fx.Width(showName+'_imageContainer', {duration: mooShows[showName].speed, onComplete: function() {
				// use given size from array instead of real image size - so we can scale them down on demand
				var w=mooShows[showName].photoArray[mooShows[showName].counter][1];
				var h=mooShows[showName].photoArray[mooShows[showName].counter][2];
				mooLastWidth=(isPair) ? w*2 : w;
				mooLastHeight=h
				// set up next image
				Element.setSrc(showName+'_image1', newImgPreloader1.src);
				if (isPair) Element.setSrc(showName+'_image2', newImgPreloader2.src); // rw
				// reposition overlay nav
				//Element.setHeight(showName+'_overlayNav', (newImgPreloader1.height));
				//Element.setWidth(showName+'_overlayNav', ( (isPair) ? newImgPreloader1.width*2 : newImgPreloader1.width ));
				Element.setHeight(showName+'_overlayNav', h);
				Element.setWidth(showName+'_overlayNav', ( (isPair) ? w*2 : w ));
				if (UA.bIsIE7) Element.setWidth(showName+'_overlayNav', ((showName=="zoomShow") ? 950 : 498) ); // should be always now! --- q'n'd fix
				//
				// rw: set image size
				Element.setHeight(showName+'_image1', h);
				Element.setWidth(showName+'_image1', w);
				//Element.setHeight(showName+'_image1', (newImgPreloader1.height));
				//Element.setWidth(showName+'_image1', (newImgPreloader1.width));
				if (isPair) {
					//alert("showing img 2 now!");
					Element.show(showName+'_image2');
					w=mooShows[showName].photoArray[mooShows[showName].counter][1];
					h=mooShows[showName].photoArray[mooShows[showName].counter][2];
					Element.setHeight(showName+'_image2', h);
					Element.setWidth(showName+'_image2', w);
					//Element.setHeight(showName+'_image2', (newImgPreloader1.height));
					//Element.setWidth(showName+'_image2', (newImgPreloader1.width));
				}
				// end rw
				//show captions
				//if (mooShows[showName].captions=='yes') Element.setInnerHTML(showName+'_captions', mooShows[showName].photoArray[mooShows[showName].counter][7]+'&nbsp;');
				// copyright
				//if (mooShows[showName].copyright=='yes') Element.setInnerHTML(showName+'_copyright', mooShows[showName].photoArray[mooShows[showName].counter][6]);
				if (mooShows[showName].copyright=='yes') Element.setInnerHTML(showName+'_copyright', 'Copyright &copy; Duravit');
				var corr=(UA.bIsIE7) ? Math.round(( ( ( (showName=="zoomShow") ? 950 : Element.getWidth(showName+'_outerContainer') ) )-Element.getWidth(showName+'_imageContainer'))/2) : 0; // idiot explorer 7 hack
				$(showName+'_copyright').style.right=(10+corr)+'px'; // ie7 - doesn't affect other browsers
				// new moo.fx 'fader'
				this.fader1=new fx.Opacity(showName+'_image1', {duration: mooShows[showName].fadeSpeed, onComplete:function() { 
					mooShows[showName].busy=0;
					// overlay navigation
					if (mooShows[showName].overlayNav=='yes') Element.show(showName+'_overlayNav');
					//IPTC panel height
					if (mooShows[showName].IPTCinfo=='yes') Element.show(showName+'_zoombutton');
					Element.setWidth(showName+'_zoom', newImgPreloader1.width);
					if (mooShows[showName].IPTCinfoStatus==1) { mooShows[showName].IPTCinfoStatus=0; mooShows[showName].updateIPTCinfoToggle(); }
				}});
				// call fader fx
				if (isPair) {
					this.fader2=new fx.Opacity(showName+'_image2', {duration:mooShows[showName].fadeSpeed, onComplete:function() { /*alert("image 2 faded in!");*/ }});
					this.fader2.hide(); this.fader2.toggle();
				}
				this.fader1.hide(); this.fader1.toggle();
			}});
			
			// get current sizes
			oldHeight=Element.getHeight(showName+'_imageContainer');
			if (UA.bIsIE7 && oldHeight==0) oldHeight=400; // fix another ie7 bug - on first image, no height is given :(
			oldWidth=Element.getWidth(showName+'_imageContainer');

			// call moo.fx and when done switchImage()
			// rw this.resizeTopNavWidth.custom(oldWidth,newWidth);
			// rw this.resizeCaptionWidth.custom(oldWidth,newWidth);
			//alert("width? "+newWidth);
			//alert("height? "+oldHeight+" -> "+newHeight);
			//alert("oldHeight:"+oldHeight+" - "+$(showName+'_imageContainer').innerHTML );
			this.resizeOuterContainerHeight.custom(oldHeight,newHeight);
			this.resizeOuterContainerWidth.custom(oldWidth,( (isPair) ? newWidth*2 : newWidth ));
		};
		
		if (isPair) { // create a preloader chain - rw
			newImgPreloader2.onload=function(){
				//alert("image 2 loaded - goin to load img 1:"+mooShows[showName].photoArray[mooShows[showName].counter][8]);
				newImgPreloader1.src=mooShows[showName].photoArray[mooShows[showName].counter][0]; // preloader src
			}
			newImgPreloader2.src=this.photoArray[this.counter][8]; // preloader src
		} else { // create a single preloader
			newImgPreloader1.src=this.photoArray[this.counter][0]; // preloader src
		}
	}
	
	// -----------------------------------------------------------------------------------

}


//	Additional methods for Element by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//	- and Stuart Eaton (eatpixels.com)

// !!! Replacing by moo.dom ???

Object.extend(Element, {
	getWidth: function(element) {
   	element = $(element);
   	return element.offsetWidth; 
	},
	
	getHeight: function(element) {
   	element = $(element);
   	return element.offsetHeight; 
	},
	
	setWidth: function(element,w) {
   	element = $(element);
   	element.style.width = w +"px";
	},

	setHeight: function(element,h) {
 		element = $(element);
   	element.style.height = h +"px";
	},

	setTop: function(element,t) {
   	element = $(element);
   	element.style.top = t +"px";
	},

	setSrc: function(element,src) {
   	element = $(element);
   	element.src = src; 
	},
	
	setAlt: function(element,alt) {
   	element = $(element);
   	element.alt = alt; 
	},
	
	setOpacity: function(element,opacity) {
   	element = $(element);
   	element.style.opacity = opacity; 
	},

	setHref: function(element,href) {
   	element = $(element);
   	element.href = href; 
	},
	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	},

	hide: function(element) {
   	element = $(element);
   	element.style.display = 'none';
 	},

 	show: function(element) {
  	element = $(element);
   	element.style.display = 'inline';
 	}
});

// ---------------------------------------------------


// TB stuff

function TB_overlaySize() {
	showInlineWindow(952, 420);
	TB_writecode();
}

function TB_writecode() {
	//
	// writing moo.show code
	var s=''+
	'<img onclick="TB_hide()" style="float:right; margin-left:10px;" title="Close Zoom" src="'+appPath+'file/all/icon_closewin_gr.gif" width="20" height="20" alt="Close" /><div id="zoomShow_topNav" style="overflow: hidden; width: 340px;" class="mooshow_topNav"></div>'+
	'<div style="background-color:#fff; padding:0px 1px 1px 1px; clear:both;">'+
	'	<div style="display: inline;" id="zoomShow" class="mooshow"><div id="zoomShow_outerContainer" class="mooshow_outerContainer">'+
	'	<div id="zoomShow_contentContainer" class="mooshow_contentContainer">'+
	'		<div id="zoomShow_imageContainer" style="background-color:#cacaca; visibility:hidden;"><img style="overflow: hidden; height:400px; width:475px;" src="'+appPath+'file/all/b.gif" class="mooshow_image" id="zoomShow_image1" height="400"'+
	'		><img style="display:none; overflow: hidden; height: 1px; width: 1px; visibility: hidden;" src="'+appPath+'file/all/b.gif" class="mooshow_image" id="zoomShow_image2" height="1"'+
	'		width="1"></div><img style="display: none;" src="'+appPath+'file/all/ani_loader_big2.gif" id="zoomShow_loading" class="mooshow_loading"'+
	'		  alt="Loading"><div id="zoomShow_copyright" class="mooshow_copyright">Copyright © Duravit</div>'+
	'		<div id="zoomShow_overlayNav" class="mooshow_overlayNav" style="height: 296px; width: 249px; display: inline;">'+
	'			<a href="#1" id="zoomShow_prevLink" class="mooshow_prevLink" onclick="mooShows[\'zoomShow\'].prevImage();"></a>'+
	'			<a href="#1" id="zoomShow_nextLink" class="mooshow_nextLink" onclick="mooShows[\'zoomShow\'].nextImage();"></a>'+
	'		</div>'+
	'		<div id="zoomShow_zoom" class="mooshow_zoom" style="width: 249px; display: none;"></div>'+
	'		<a href="#" onclick="mooShows[\'zoomShow\'].updateIPTCinfoToggle(); return false;"><img style="display: none;" src="'+appPath+'file/all/moo_info.gif" id="zoomShow_zoombutton" class="mooshow_zoombutton"></a>'+
	'	</div>'+
	'</div></div><script></script></div>';
	$("TB_window").innerHTML=s;
}



/****************************************************
*****************************************************
**
** universal inline box-handling ala thickbox
**
*****************************************************
*****************************************************/

function showInlineWindow(w, h, special) {
	var pagesize=TB_getPageSize();	
	var arrayPageScroll=TB_getPageScrollTop();
	var titleHtml1='<div class="title"><div class="titletext">';
	var titleHtml2='</div><div class="closewin" onclick="TB_hide()" title="'+lang.Close+'">&nbsp;</div><div class="brclear hide showie7"></div><br class="brclear" /></div>';
	var sw=getSiteWidth();
 	var sh=getSiteHeight();
	if (UA.bIsIE) $("TB_overlay").style.width=$("TB_HideSelect").style.width=sw+"px";
	$("TB_overlay").style.height=$("TB_HideSelect").style.height=sh+"px";
	$("TB_overlay").style.display=$("TB_HideSelect").style.display="block";
	$("TB_overlay").onclick=TB_hide;
	var winRef=(w > 498) ? $("TB_window") : $("TB_window_small");
	//Element.addClassName(winRef, 'hidden');
	winRef.innerHTML=(special && special.title) ? titleHtml1+special.title+titleHtml2 : '';
	if (special && special.image) { // create image code
		special.code='<img src="'+special.image+'" alt="Image" onload="TB_done()" />';
	} else {
		TB_done();
	}
	if (special && special.code) winRef.innerHTML+=special.code;
	if (special && special.flashUrl) {
		winRef.innerHTML+='<div id="flash-win"></div>';
		var winObj = new SWFObject(special.flashUrl, "flashwin", "936", "686", "7", "#ffffff"); // "896", "634"
	  winObj.addVariable("baseURL", special.flashUrl.substring(0,special.flashUrl.lastIndexOf('/')+1));
		//winObj.addParam("wmode", "transparent"); <- why do we need this? sux in firefox (catalogs)
		winObj.addParam("scale", "noscale");
		var res=winObj.write('flash-win');
		if (!res) $('flash-win').innerHTML=lang.missingFlashPlayerText;
	}
	winRef.style.width=w+"px";
	winRef.style.height=h+"px";
	winRef.style.left=Math.round((sw-w)/2)+"px";
	winRef.style.top=Math.round((arrayPageScroll[1]+((pagesize[1]-h)/2)))+"px";
	winRef.style.display="block";
	var color=(special && special.color) || '#005099';
	var border=(special && special.color) ? special.border+'px solid '+color : 'none';
	winRef.style.border=border;
	//alert("win:"+$$('#TB_window.title').length);
	
	//$S('#TB_window .title')[0].style.backgroundColor=col;
	
//	var fader1=new fx.Opacity( ( (w > 498) ? 'TB_window' : 'TB_window_small' ), {duration:500, onComplete:function() { }});
//	fader1.hide();
//	fader1.toggle();
//  => much better performance w/out fading windows

}

function showContent(titleEl, contentEl, h) {
	var hd=titleEl.innerHTML;
	if (hd.length>60) hd=hd.substr(0,60)+'&#133;';
	showInlineWindow(498, h, {title:hd, code:$(contentEl).innerHTML, color:'#005099', border:1});
}

/** 
* Temp: test the new thickbox 2.0 dimension methods (for inline windows)
* @author	Ralf Walter
* @param {String}	
* @return {String}	Returns 
*/
function TB_getPageScrollTop(){
	var yScrolltop;
	if (self.pageYOffset) {
		yScrolltop = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScrolltop) 
	return arrayPageScroll;
}

function TB_getPageSize(){
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = new Array(w,h) 
	return arrayPageSize;
}

function TB_done() {
	Element.removeClassName('TB_window_small', 'hidden');
	Element.removeClassName('TB_window', 'hidden');
}

function TB_hide() {
	storeBusy=false;
	$("TB_overlay").style.display="none";
	$("TB_HideSelect").style.display="none";
	$("TB_window").style.display="none";
	$("TB_window").innerHTML='';
	$("TB_window_small").style.display="none";
	$("TB_window_small").innerHTML='';
	$("product-matrix").style.visibility="hidden"; // special case
	if (document.getElementById("teaser")) $("teaser").style.visibility='visible'; // extra für Opera
	isMatrixOn=false;
}


/****************************************************
*****************************************************
**
** the native duravit.js code
**
*****************************************************
*****************************************************/

//
// global Vars
var myFX={}; // namespace for moo.fx instances
var myUser=null; // the user-object - populated by json-data
var pageIsLoaded=false; // set to true onload
var ppResolution=300; // download-resolution for press photos
var isXms=false; // needs to change also the bg-image in CSS
if (wgaLanguage == 'eg') isXms=false;


// needs reviewing - moo.dom, prototype, etc.

function focusSearchField(obj) {
	if (obj.value==searchDefVal) obj.value="";
	//obj.style.color="#005099";
	//obj.style.borderColor="#005099";
	obj.className+=" form-focus";
}

function blurSearchField(obj) {
	if (obj.value=="") obj.value=searchDefVal;
	//obj.style.color="#a9bacb";
	//obj.style.borderColor="#6b9ac2";
	obj.className=obj.className.replace(/ form-focus/, "");
}

function foldColumn(id, denyUA) {
	if(denyUA && UA.bIsSafari) return;
	var cn=document.getElementById(id).className;
	var state=(cn.indexOf("fc-closed")>-1) ? true : false;
	document.getElementById(id).className=(cn.indexOf("fc-closed")>-1) ? cn.replace(/fc-closed/gi, "") : cn+"fc-closed";
	setCookie("column-"+id+"="+state); // set cookie
}

function foldBlock(id, denyUA, openonly) {
	if(denyUA && UA.bIsSafari) return;
	var cn=document.getElementById(id).className;
	if (openonly && cn.indexOf("fb-closed") == -1) return;
	var state=(cn.indexOf("fb-closed")>-1) ? true : false;
	document.getElementById(id).className=(cn.indexOf("fb-closed")>-1) ? cn.replace(/ fb-closed/gi, "") : cn+" fb-closed";
	setCookie("block-"+id+"="+state); // set cookie
	// todo:
	// Ajax-Nachladen bei initial geschlossenem Block - spter :)
}

function foldAllBlocks(state) {
	if (state) {
		$S('.foldable-block').each(function(el) {
				el.className = el.className.replace(/ fb-closed/gi, "");
		})
	} else {
		$S('.foldable-block').each(function(el) {
				el.className+= " fb-closed";
		})
	}
}

var faqItemSelected=null;
function foldFAQ(id, srcEl) {
	if (srcEl) srcEl.blur();
	el=document.getElementById(id);
	if (faqItemSelected!=null) { // close old
		eo=document.getElementById(faqItemSelected);
		//eo.className=eo.className.replace(/ exclusive-style/gi, "");
		eo.getElementsByTagName('A')[0].style.backgroundPosition='0 11px'; // DT A 
		eo.getElementsByTagName('DD')[0].style.display='none';
		eo.getElementsByTagName('DT')[0].style.backgroundColor='transparent';
	}
	if (faqItemSelected==id) { // close only
		faqItemSelected=null;
		return;
	}
	//el.className=el.className+" exclusive-style";
	el.getElementsByTagName('A')[0].style.backgroundPosition='0 -89px'; // DT A 
	el.getElementsByTagName('DD')[0].style.display='block';
	el.getElementsByTagName('DT')[0].style.backgroundColor='#e8e8e8';
	faqItemSelected=id;
}

function hasNoAjax() {
	return false;
}

function setCookie(str, days) {
	if (!days) days=365;
	var expireDate = new Date();
	expireDate.setTime(expireDate.getTime() + (days * 24 * 60 * 60 * 1000)); // Cookie TTL
	document.cookie = str+"; expires="+expireDate.toGMTString();
	//alert(document.cookie);
}

var isMatrixOn=false;

function switchProductMatrix() { // switch visibility of p-mx
	var pm=$('product-matrix');
	// evtl. hier für bestimmte browser flash-elemente ausblenden - oder aus performance-gründen ;)
	if (!isMatrixOn) { hideFlash(document.getElementById('wrapper1'), 165, 490) } else { showFlash(); };
	if (!isMatrixOn) {
		pm.style.visibility='visible';
		var sw=getSiteWidth();
	 	var sh=getSiteHeight();
		if (UA.bIsIE) $("TB_overlay").style.width=$("TB_HideSelect").style.width=sw+"px";
		$("TB_overlay").style.height=$("TB_HideSelect").style.height=sh+"px";
		$("TB_overlay").style.display=$("TB_HideSelect").style.display="block";
		$("TB_overlay").onclick=TB_hide;
		if (document.getElementById("teaser")) $("teaser").style.visibility='hidden'; // extra für Opera
		isMatrixOn=true;
	} else {
		TB_hide();
		isMatrixOn=false;
	}
	setProductMatrix();
	if (isMatrixOn) {
		var res=pmObj.write("pm-flash");
		if (!res) $('pm-flash').innerHTML=lang.missingFlashPlayerText;
	} else {
		$('pm-flash').innerHTML='';
	}
}

function setProductMatrix() { // set size and position of p-mx
	var pm=$('product-matrix');
	var l=(!UA.bIsIE7)?10:390;
	//alert(isHome);
	var t=(isHome)?-202:10;
	var iemac=(UA.bIsIEMac)?-10:0;
	var saf=(UA.bIsSafari)?0:0;
	var elm=$('wrapper1');
	while (elm.offsetParent) {
		t+=elm.offsetTop;
		l+=elm.offsetLeft;
		elm=elm.offsetParent;
	}
	pm.style.top=(t+iemac+saf)+"px";
	pm.style.left=(l+iemac-27)+"px";
	var w=(!UA.bIsIE7)?24:34;
	pm.style.width='980px'; // (document.getElementById('border').offsetWidth-w)+'px';
}


function switchLoginContainer() {
	var lc=document.getElementById('login-container');
	var dis=(lc.style.display!='none')?'none':'block';
	lc.style.display=dis;
}


var hiddenFlash=[];
function hideFlash(baseElem, min, max) {
	if (!baseElem) baseElem=document;
	var emb=baseElem.getElementsByTagName('EMBED');
	if (emb.length==0) emb=baseElem.getElementsByTagName('OBJECT');
	for (var i=0; i<emb.length; i++) {
		var t=getTotalTop(emb[i]);
		if (t > min && t < max) {
			emb[i].style.visibility='hidden';
			hiddenFlash[hiddenFlash.length]=emb[i];
		}
	}
}

function showFlash() {
	for (var i=0; i<hiddenFlash.length; i++) {
		hiddenFlash[i].style.visibility='visible';
	}
	hiddenFlash=[];
}

function getTotalTop(elm) {
	var t=0;
	while (elm.offsetParent) {
		t+=elm.offsetTop;
		elm=elm.offsetParent;
	}
	return t;
}

var pmSelectedSeries='';
var pmSelectedCategory='';

function pmChangeSeries(selObj, form, elem, ddc) {
	//var sel=document.forms['prodnavForm'].elements['prodnavCategories'];
	var sel=document.forms[form].elements[elem];
	var sid=selObj.options[selObj.selectedIndex].value;
	//var isDDC=(sid=='ddc') ? true:false;
	if (sid=='' || sid=='ddc') sid='all';
	var selCat=sel.options[sel.selectedIndex].value;
	sel.options.length=1; // All Cat's löschen
	//
	// set categories
	for (var i=0; i < pmSelectorSeries[sid].length; i++) {
		sel.options[i+1]=new Option(pmSelectorSeries[sid][i].name, pmSelectorSeries[sid][i].id, false, (pmSelectorSeries[sid][i].id==selCat)?true:false );
	}
	if (ddc && sid=='all') {
		sel.options[i+1]=new Option('Duravit Design Center', 'ddc', false, false );
	}
}

function pmChangeCategory(selObj, form, elem, ddc) {
	//var sel=document.forms['prodnavForm'].elements['prodnavSeries'];
	var sel=document.forms[form].elements[elem];
	var cid=selObj.options[selObj.selectedIndex].value;
	//var isDDC=(cid=='ddc') ? true:false;
	if (cid=='' || cid=='ddc') cid='all';
	var selSer=sel.options[sel.selectedIndex].value;
	sel.options.length=1; // All Ser's löschen
	//
	// set series
	pmSelectorCategories[cid].sort();
	for (var i=0; i < pmSelectorCategories[cid].length; i++) {
		sel.options[i+1]=new Option(pmSelectorCategories[cid][i].name, pmSelectorCategories[cid][i].id, false, (pmSelectorCategories[cid][i].id==selSer)?true:false );
	}
}

function selectToURL(selObj) {
	window.location.href=selObj.options[selObj.selectedIndex].value;
}

function tableRuler() {
	var tables=document.getElementsByTagName('table');
	for (var i=0; i<tables.length; i++) {
		if(tables[i].className.indexOf('ruler')!=-1) {
			var trs=tables[i].getElementsByTagName('tr');
			for(var j=0;j<trs.length;j++) {
				if(trs[j].parentNode.nodeName=='TBODY' && trs[j].parentNode.nodeName!='TFOOT') {
					trs[j].onmouseover=function(){this.className='ruled';return false}
					trs[j].onmouseout=function(){this.className='';return false}
				}
			}
		}
	}
}

function stretchContentColumn() {
	try {
		//content-column
		//alert("body:"+document.body.offsetHeight+" content:"+document.getElementById("content-column").offsetHeight);
		var sh=getSiteHeight();
		var vh=getVpHeight();
		//alert(sh+" < "+vh);
		if (sh < vh) {
			//alert("stretch by:"+(vh-sh)+"\nsizer-h:"+$('sizer').offsetHeight+"\ncontainer-measure-h:"+$('content-measure').offsetHeight );
			var homeh=(isHome) ? 212 : 0;
			var free=$('sizer').offsetHeight-174-homeh-$('content-measure').offsetHeight-45; // total - header - right-content - footer
			//alert('free:'+free);
			$('stretch-col').style.height=( free+(vh-sh) )+'px';
			$('stretch-col').style.display='';
		}
	} catch (e) { }
}









// refactored code follows...

/*****************************************************************
* 
* Common Functions
* 
******************************************************************/

/** 
* Gets the the width of the document including scrollbars
* @author	Ralf Walter
* @return {Int}	Returns the width in pixels
*/
function getSiteWidth() { // derived from thickbox.js
	if (document.width) { // added rw
		xScroll = document.width;
	} else if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
 	}
 	return xScroll;
}

/** 
* Gets the the height of the document including scrollbars and scrollable size
* @author	Ralf Walter
* @return {Int}	Returns the height in pixels
*/
function getSiteHeight() { // derived from thickbox.js
	if (window.innerHeight && window.scrollMaxY) {	
		//alert(1);
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		//alert(2+' '+document.body.scrollHeight+' > '+document.body.offsetHeight);
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		//alert(3+' '+document.body.scrollHeight+' > '+document.body.offsetHeight);
		yScroll = document.body.offsetHeight;
 	}
 	return yScroll;
}

function getScrollTop() {
	//
	// replace by TB_getPageScrollTop() of TB 2.0 ??? Let's see how it works
	if (window.scrollX) { // all except Explorer
		return window.scrollX;
	} else if (document.documentElement && document.documentElement.clientHeight) {	// Explorer 6 Strict Mode
		return document.documentElement.scrollTop;
	} else if (document.body) { // other Explorers
		return document.body.scrollTop;
	}
}

/** 
* Gets the width of the viewport - without scrolling overflow, but with scrollbar (should not!)
* @author	Ralf Walter
* @return {Int}	Returns width in pixels
*/
function getVpWidth() {
	if (window.innerHeight) { // all except Explorer
		return self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight) {	// Explorer 6 Strict Mode
		return document.documentElement.clientWidth;
	} else if (document.body) { // other Explorers
		return document.body.clientWidth;
	}
}

/** 
* Gets the height of the viewport - without scrolling overflow, but with scrollbar (should not!)
* @author	Ralf Walter
* @return {Int}	Returns height in pixels
*/
function getVpHeight() {
	if (window.innerHeight) { // all except Explorer
		return self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {	// Explorer 6 Strict Mode
		return document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		return document.body.clientHeight;
	}
}

/**
* Applies highlight effect - requires moo.fx
* fx.Flash
* @author Dmytro Shteflyuk --- http://kpumuk.info/php/extending-moo-fx-with-custom-effect-fx-flash/lang/en/
*/

fx.Flash = Class.create();
Object.extend(Object.extend(fx.Flash.prototype, fx.Base.prototype), {	
	hD: "0123456789ABCDEF",
	
	initialize: function(el, options) {
		this.el = $(el);

		var color_from = (options && options.color_from) || "#ffffff";
		var color_to = (options && options.color_to) || "#ff0000";
		var color_f = this.h2d(color_from.substr(1));
		var color_t = this.h2d(color_to.substr(1));
		
		var _options = {
			red: [color_f >> 16, color_t >> 16],
			green: [(color_f >> 8) & 255, (color_t >> 8) & 255],
			blue: [color_f & 255, color_t & 255],
			count: 1
		};
		Object.extend(_options, options || {});
		if (_options.onComplete) _options.flashOnComplete = _options.onComplete;
		this.setOptions(_options);
	},
	
	increase: function() {
		var r = this.d2h(this.now * (this.options.red[0] - this.options.red[1]) / 255 + this.options.red[1]);
		var g = this.d2h(this.now * (this.options.green[0] - this.options.green[1]) / 255 + this.options.green[1]);
		var b = this.d2h(this.now * (this.options.blue[0] - this.options.blue[1]) / 255 + this.options.blue[1]);
		this.el.style.backgroundColor = "#" + r + g + b;
	},

	toggle: function() {
		if (this.flashCount == undefined) this.flashCount = this.options.count;
		this.options.onComplete = this.onComplete.bind(this);
		this.custom(255, 0);
	},
	
	onComplete: function() {
		this.flashCount--;
		if (this.flashCount == 0)
		{
			this.flashCount = undefined;
			this.options.onComplete = this.options.flashOnComplete;
		} else
			this.options.onComplete = this.toggle.bind(this);
		//this.custom(0, 255); Sebastian: wenn aktiv Farbe faded zurueck
	},
	
	d2h: function(d) {
		var h = this.hD.substr(d & 15, 1);
		while (d > 15) { d >>= 4; h = this.hD.substr(d & 15, 1) + h; }
		if (h.length == 1) h = "0" + h;
		return h;
	},
	
	h2d: function(h) {
		return parseInt(h, 16);
	}
});

var aktiv;
function jumpAndFade(el) {
	if(aktiv!=undefined){
		 var effectaktiv = new fx.Flash("active"+aktiv, {color_from:"#c8e2f4",color_to:"#ffffff",count:1,duration:4000});
		 effectaktiv.toggle();
	}
	var effect = new fx.Flash("active"+el, {color_from:"#ffffff",color_to:"#c8e2f4",count:1,duration:4000});
	effect.toggle();
	aktiv = el;
}

/** 
* Displays a flash catalog in inline popup
* @author	Ralf Walter
* @param {String} url Flash-Movie URL	
*/
function previewCatalog(url, titel) {
	showInlineWindow(936, (686+23), {title:titel, flashUrl:url, color:'#005099', border:1});
}


/** 
* Applies image rollover events to all images with "ro"-class in document - called on load
* @author	Ralf Walter
*/
function setRollOverEvents() {
	$S('img.ro').each(function(element){
		element.onmouseover = function(){
			this.src=this.src.replace(/\.gif/gi, '_hi.gif');
		}
		element.onmouseout = function(){
			this.src=this.src.replace(/_hi\.gif/gi, '.gif');
		}
	});
}

/** 
* Does the confirm checkbox handling for retailer print stuff 
* @author	Ralf Walter
*/
var confOk=false;
function confConditions() {
	if ($('fConfirmConditions').checked) {
		$('list-table').style.visibility='visible';
		if (UA.bIsIE) $('list-table').style.display='block'; // IE hack
		$('fConfirmConditions').checked=true;
		confOk=true;
	} else {
		if (confOk) $('fConfirmConditions').checked=true;
	}
}

/** 
* All code that will be executed after the page has been loaded
* @author	Ralf Walter
*/
//function debugkey(e){
//	try {
//		var kk=e.keyCode || 0
//		//alert(kk+'-'+ck);
//		if (kk==192) {
//			$('debugBox').innerHTML=$('debugBox').innerHTML.replace(/%cc%/, $('cctime').innerHTML);
//			$('debugBox').style.display='block';
//		}
//	} catch (e) {}
//}
//document.onkeyup=debugkey;

var storage;
var storageOnloadFunction;
window.onload=function() { 
	
	storage=StorageManager.getInstance().getStorage();
	if (storageOnloadFunction) {
		storage.setOnload( storageOnloadFunction );
		storage.load();
	}

	/* *
	storage.setOnload( function()
	{
		alert("Storage ready!");
		if(storage.contains('scfquiz')) {
			alert("stg.get: "+storage.get('scfquiz').nick+" / "+storage.get('scfquiz').formsent);
		}
		storage.put('scfquiz', {nick:'Ralf', formsent:false});
		storage.save();
	});
	storage.load();
	* */


	pageIsLoaded=true;
	if (showPrintDialog) {
		window.print();
		return; // skip other onload-actions
	}
	tableRuler();
	if (!$('ecardview')) {
		stretchContentColumn(); // not working in ecard-viewer
	}
	setRollOverEvents();

	//
	// check TML-Warnings
	/*
	try {
		if (document.getElementById("debugBox").innerHTML.indexOf("warning(s) detected")>-1 || document.getElementById("debugBox").innerHTML.indexOf("stacktrace")>-1) {
			document.getElementById("debugIndicator").style.display="block";
			document.getElementById("debugBox").style.display="block";
		}
	} catch (e) { };
	*/
	// TEST TEST TEST!!!!
	//this will make all the list items inside the element with id = container red.
	/*
	$S('.container-left li').each(function(element){
		element.onclick = function(){
			Element.remove(this);
		}
	});
	*/
	
	//document.onmousedown=function(evt) { document.title=(' click:'+evt.target.tagName+':'+evt.target.id); }
	
	
	if (!$('ecardview')) {
		myFX.loginBox=new fx.Height($('login-container') , {duration: 200, onComplete: function() { } });
		myFX.inlineWinH=new fx.Height($('TB_window_small'), {duration: 200, keepCentered: true, topEl: 'TB_window_small', onComplete: TB_done });
		getUserInfo(); // rwuser gets the user data an displays it in the myduravit-box
		setCartIcons(); // rwuser sets the "filled"-state of the cart icon if it finds some that are in download list
		if (typeof(moodShow)!="undefined") moo_start('moodShow', 0, true); // creates a mooshow-instance for image-viewer in product milieu if needed
	} // else alert("you're on ecard!");
	
	if (isHome) {
		if (isXms) {
			onloadXms();
		} else {
			onloadShowcase();
		}
	}
	
	try { if (doFoldBlock) foldBlock(doFoldBlock, null, true); } catch(e) {};
	
	tooltip.init ();
	
}
function onloadShowcase() {
	try {
	if (isXms) {
		$('teaser').style.backgroundImage='url('+xmsNormBg+')';
		$('teaser').innerHTML='';
	}
	var so = new SWFObject(showcaseURL, "slideshow", "100%", "202", "7", "#ffffff");
	so.addParam("base", showcaseURL.substring(0,showcaseURL.lastIndexOf('/')+1));
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "sameDomain");
	so.addVariable("xmlPath", showcaseXML);
	var res=so.write("teaser");
	//if (!res) alert("No Flash installed!");
	} catch (e) { }
}
function onloadXms() {
	try {
		var so = new SWFObject(xmsURL, "slideshow", "100%", "202", "7", "#ffffff");
		so.addParam("base", showcaseXmsURL.substring(0,showcaseXmsURL.lastIndexOf('/')+1));
		so.addParam("scale", "noscale");
		so.addParam("wmode", "transparent");
		so.addParam("allowScriptAccess", "sameDomain");
		// 
		// xms special
		so.addVariable("closeLink", "javascript:onloadShowcase()");
		so.addVariable("sendEcardLink", xmsCardSendURL);
		so.addVariable("sendEcardTarget", "_blank");
		so.addVariable("sendEcardBtnTxt", xmsSendTitle);
		so.addVariable("soundMode", "true");
	
		var res=so.write("teaser");
		if (!res) $('teaser').style.backgroundImage='url('+appPath+'file/flash/xmas_home_bg2.jpg)'; // alternative bg image xms
	} catch (e) {
		//alert("WTF! "+e);
	}
}
function soundMode(state) {
}


/*****************************************************************
* 
* User + Download (AJAX/JSON-) stuff
* 
******************************************************************/

var storeBusy=false;
var storeId=null;

/** 
* Starts a request to get user specific data and optional sends a action to be executed on backend
* @author	Ralf Walter
* @param {String}	mode Optional: Specifies a action to the server - can be "login" or "logout"
* @return {Async}	Returns a asynchronous function call to "processMyDuravit" after request is completed
*/
function getUserInfo(mode) {
	if (!storeBusy && pageIsLoaded) {
		storeBusy=true;
		var postParams='&';
		if (mode=="logout") postParams+='loginAction=logout&';
		if (mode=="login") postParams+='loginAction=login&fEmail='+$('login-user').value+'&fPassword='+escape(encodeURIComponent($('login-password').value))+'&fRememberMe='+$('fRememberme').checked;
		//alert(postParams);
		//return;
		new ajax(appPath+'html/getuserinfo.json', {postBody:'id='+((new Date).getTime())+postParams, onComplete:processMyDuravit });
		//window.open(appPath+'html/getuserinfo.json?'+postParams);
	}
}

/** 
* Starts a request to get the download list from the current user object and displays the download list window
* If no downloads are in the list, nothing happens
* @author	Ralf Walter
* @return {Async}	Returns a asynchronous function call to "processDownloadList" after request is completed
*/
function getDownloadList(preventMsg) {
	if (!storeBusy && pageIsLoaded) {
		storeBusy=true;
		showDownloadList(); // oldskool! remove... asap
		showInlineWindow(498, 100, {title:lang.DownloadBasket, border:1, color:'#005099'});
		//window.open(appPath+'xml/getdownloadlist.xml');
		if (!myUser.downloads || myUser.downloads==0) { 
			//if (!preventMsg) alert('There are no downloads');
			new ajax(appPath+'xml/downloadlist_empty_text.xml', {postBody:'id='+((new Date).getTime()), onComplete:processDownloadList });
			return;
		} 
		new ajax(appPath+'xml/getdownloadlist.xml', {postBody:'id='+((new Date).getTime()), onComplete:processDownloadList });
	}
}

/** 
* Stores user information on the server - can be downloads or notes
* @author	Ralf Walter
* @param {String}	mode Tells the method what kind of data to store - can be "download" or "note"
* @param {Object}	dataobj Contains the data in an object - structure depends on mode
* @return {Async}	Returns a asynchronous function call to "processMyDuravit" after request is completed
*/
function storeUserInfo(mode, dataobj) {
	if (!storeBusy && pageIsLoaded) {
		storeBusy=true;
		var postParams='&';
		//alert(dataobj.zip);
		var zip=(dataobj.zip) ? dataobj.zip : '';
		if (mode=="download") {
			postParams+='storeAction=download&id='+dataobj.id+'&productId='+dataobj.productId+'&downloadId='+dataobj.storeId+'&url='+dataobj.url+'&zip='+zip+'&name='+urlenc(dataobj.name)+'&type='+dataobj.type;
		} else if (mode=="note") {
			//var ooo=eval('('+ unescape(dataobj.comparisonProperties) +')' );
			//alert(ooo.colors);
			//alert('comparisonProperties:'+unescape(dataobj.comparisonProperties));
			postParams+='storeAction=note&comparisonProperties='+dataobj.comparisonProperties+'&nodeId='+dataobj.nodeId+'&externalNr='+dataobj.externalNr+'&title='+dataobj.title+'&description='+dataobj.description+'&assetId='+dataobj.assetId+'&url='+dataobj.url;
		}
		//alert('postParams:\n'+postParams);
		//window.open(appPath+'html/getuserinfo.json?'+postParams);
		new ajax(appPath+'html/getuserinfo.json', {postBody:'id='+((new Date).getTime())+postParams, onComplete:processMyDuravit });
	}
}

/** 
* Calls the "storeUserInfo" method to store a download (shortcut-method)
* @author	Ralf Walter
* @param {Object}	obj	Object that contains the download-parameters
*/
function storeDL(obj) {
	storeId=obj.storeId;
	storeUserInfo('download', obj);
}

/** 
* Calls the "storeUserInfo" method to store a note (shortcut-method)
* @author	Ralf Walter
* @param {Object}	obj	Object that contains the note-parameters
*/
function storeNote(obj) {
	storeId=obj.storeId;
	storeUserInfo('note', obj);
}

/** 
* Processes the response data from requests send by methods "getUserInfo" and "storeUserInfo" - onComplete-callback
* Manages the appearance of the my-duravit box on the right side
* @author	Ralf Walter
* @param {XMLHTTPRequest}	request Contains a reference to the request object
*/
var processMyDuravitCallBack=null;
function processMyDuravit(request){ // callback fn
	//alert(request.responseText);
	//alert("kekse gefunden:"+document.cookie);
	storeBusy=false;
  try {
	  myUser=eval('('+request.responseText+')'); // JSON "parsen"
	  $('user_notes').innerHTML=myUser.notes;
	  $('user_downloads').innerHTML=myUser.downloads;
	  // oldskool $('user_status').innerHTML=myUser.status;
	  if (myUser.isValidUser) {
 			$('user_status').innerHTML='<span onclick="userShowLoginDetails(); return false;" title="'+lang.LoginStatusLoggedIn+'">'+myUser.name+'</span>';
 			$('user_status_extended').innerHTML='<span id="user_login_details" style="display:none;">'+lang.LoggedInAs+':<br />'+myUser.name+'<br /><a href="#" onclick="userLogOut(); return false;">'+lang.Logout+'</a></span>';
 		} else {
			$('user_status').innerHTML='<span onclick="userShowLoginForm(); return false;">'+lang.Login+'</span>';
			$('user_status_extended').innerHTML='';
		}

	  $('login-error').style.display='none';
	  if (myUser.createClientCookie!='') { // create cookie if necessary
		  //alert("KEKS:"+myUser.createClientCookie);
	  	document.cookie=myUser.createClientCookie;
	  }
	  if (myUser.loginAction=='login' || myUser.loginAction=='logout') { // changing the user state requires cart update
			if ($S('.force-reload-login').length > 0) {
  			window.location.reload(true);
  			return;
			}
	  	setCartIcons(true);
	  }
	  if (myUser.loginAction=='logout') {
			//alert("logout:"+  $S('.force-reload').length );
			if ($S('.force-reload').length > 0) {
  			window.location.reload(true);
  			return;
			}
		}
	  if (myUser.loginAction=='login') {
	  	if (myUser.isValidUser) {
		  	//
		  	// successful login - close login box
		  	myFX.loginBox.hide();
		  	//
		  	// Ask for refresh form
		  	//if (($('user-form'))) {
		  	if ($S('.should-reload').length > 0) { 
		  		if ( confirm(lang.ReloadFormSite) ) {
		  			window.location.reload(true);
		  			return;
		  		}
		  	}
		  } else {
		  	//
		  	// login failed
		  	if (myUser.acceptCookies) {
	  			$('login-error').style.display='block';
	  		} else {
	  			// test: $('login-error').style.display='block'; $('login-error').innerHTML='Keine Kekse, kein Login!';
	  		}
		  }
		} else if (myUser.storeAction=='download') {
			if (myUser.storeState==0) {
				try {
					setCartFull($S('#'+storeId+' img.dl-cart')[0], true); // set animated cart-full gif
					setTimeout("setCartFull($S('#"+storeId+" img.dl-cart')[0])", 3000);
				} catch (e) {
					//alert("Something went wrong :(\n\ne01: "+e+"\n\nstoreId:"+storeId);
				}
			} else {
				//if (myUser.storeState!=3) alert('Download not saved! Code:'+myUser.storeState); // on code 3 - not stored cause file was in list - no message
			}
		} else if (myUser.storeAction=='cleardownload') {
			if (myUser.downloads==0) TB_hide();
		}
		if (!(myUser.loginAction=='logout') && !myUser.isAnonymous) {
		  try { $('fRememberme').checked=myUser.rememberMe; } catch(e) { }
		  //alert("checkbox set!");
		}
		if (typeof(processMyDuravitCallBack)=='function') processMyDuravitCallBack();
		//
		// Show detailed error messages in extra window
  	if (myUser.errorMessage!='') {
  		var code='<div style="height:100px; background-color:#fff; padding:10px;">'+myUser.errorMessage+'</div>';
  		showInlineWindow(498, 130, {title:lang.Hint, code:code, color:'#005099', border:1});
  	}
	  //alert("rmc:"+$('fRememberme').checked);
	} catch(e) {
	  //alert('Invalid JSON data (1):\n'+request.responseText+'\n\n\nCode:\n'+e);
	  //$('content-column').innerHTML=('Invalid JSON data:\n'+request.responseText+'\n\n\nCode:\n'+e);
	}
}

/** 
* Shows the inline window for the download list with a loading animation
* @author	Ralf Walter
*/
function showDownloadList() {
 	var w=getSiteWidth();
 	var h=getSiteHeight();
	if (UA.bIsIE) $("TB_overlay").style.width=w +"px";
	$("TB_overlay").style.height=h +"px";
	$("TB_overlay").style.display="block";
	$("TB_overlay").onclick=TB_hide;
	//
	// more stuff
	if (UA.bIsIE) $("TB_HideSelect").style.width=w +"px";
	$("TB_HideSelect").style.height=h +"px";
	$("TB_HideSelect").style.display="block";
	//
	// set the window in place
	$("TB_window_small").innerHTML='';
	$("TB_window_small").style.left=Math.round((w-498)/2)+"px";
	$("TB_window_small").style.display="block";
}

/** 
* Processes the response data from requests send by method "getDownloadList" - onComplete-callback
* Response data is a xml text-node that contains the html pushed to the inline window
* @author	Ralf Walter
* @param {XMLHTTPRequest}	request Contains a reference to the request object
*/
function processDownloadList(request) {
	//alert("responseXML:"+":"+typeof(request.responseXML)+":"+request.responseXML);

	//alert(request.responseXML.getElementsByTagName("ajax-response")[0].childNodes[0].nodeValue);
	var responseData='';
	try {
		responseData=request.responseXML.getElementsByTagName("ajax-response")[0].childNodes[0].nodeValue; // the normal way
	} catch(e) {
		responseData=request.responseCDATA; // the IE6 with no ax or maybe IE5-Mac way
	}
	//alert("responseData:"+(responseData));
	storeBusy=false;
  try {
		$("TB_window_small").innerHTML+=responseData;
		var maxH=getVpHeight()-20-20-23; // abstand oben - abstand unten - höhe titlebar
		var innerH=$("inline-content").scrollHeight;
		var h=(innerH > maxH) ? maxH : innerH;
		if (h<100) h=100; // keep min height
		var oldHeight=Element.getHeight('TB_window_small');
		myFX.inlineWinH.custom(oldHeight,h+23);
		$("inline-content").style.height=h+"px";
		setRollOverEvents();
	} catch(e) {
	  //alert('Invalid download XML data:\n'+'\n\n\nCode:\n'+e);
	  return;
	}
}

/** 
* Closes the download inline window and sends a request to the server with a remove-download-action
* After that, my-duravit box and cart icons will be refreshed :)
* @author	Ralf Walter
* @return {Async}	Returns a asynchronous function call to "processMyDuravit" and "setCartIcons" after request is completed
*/
function clearDownloadList() {
	TB_hide();
	new ajax(appPath+'html/getuserinfo.json', {postBody:'id='+((new Date).getTime())+'&storeAction=clearalldownloads', onComplete:function() { processMyDuravit(this.transport); setCartIcons(true); } });
}

/** 
* Deletes a single download element from the list
* @author	Ralf Walter
* @param {String}	url The URL as unique id 
* @return {Async}	Returns a asynchronous function call to "processMyDuravit" and "setCartIcons" after request is completed
*/
function clearDownload(url) {
	$("ic-container").innerHTML='Updating list ...';
	//alert('downloadurl='+url);
	new ajax(appPath+'html/getuserinfo.json', {postBody:'id='+((new Date).getTime())+'&storeAction=cleardownload&downloadurl='+url, onComplete:function() { processMyDuravit(this.transport); getDownloadList(true); setCartIcons(true); } });
}

/** 
* Initiates a login action via AJAX - shortcut method
* @author	Ralf Walter
*/
function userLogIn() {
	if (pageIsLoaded) {
		$('login-error').style.display='none';
		getUserInfo('login');
	}
}

/** 
* Initiates a logout action via AJAX - shortcut method
* @author	Ralf Walter
*/
function userLogOut() {
	if (pageIsLoaded) getUserInfo('logout');
}

/** 
* Displays details about the currently logged in user
* @author	Ralf Walter
*/
function userShowLoginDetails() {
	if (pageIsLoaded) {
		if ($('user_login_details').style.display=='inline') {
			$('user_login_details').style.display='none';
		} else {
			$('user_login_details').style.display='inline';
		}
	}
}

/** 
* Displays the user login form
* @author	Ralf Walter
*/
function userShowLoginForm() {
	//alert($('login-container').style.display);
	if ($('login-container').style.display=='block') { // just close
		$('login-error').style.display='none';
		myFX.loginBox.toggle();
		return;
	}
	$('login-container').style.display='block';
	myFX.loginBox.hide();
	myFX.loginBox.toggle();
}

/** 
* Requests a short download list in json-format to find out which images to set in "filled"-state
* The function is called onload and looks for elements containing the "dl-cart" class
* @author	Ralf Walter
* @return {Async}	Returns a asynchronous function call to "processCartIcons" after request is completed
*/
function setCartIcons(forceClear) {
	if ($S('.dl-cart').length > 0) { // is there a cart icon in the document?
		if (forceClear) { // set all icons to clear state
			$S('img.dl-cart').action({
				initialize:function() { 
					setCartEmpty(this);
				}
			});
		}
		new ajax(appPath+'html/getshortdownloads.json', {postBody:'id='+((new Date).getTime()), onComplete:processCartIcons });
	}
}

/** 
* Sets the cart icon to empty state
* @author	Ralf Walter
* @param {HTMLObject}	imgref Reference to DOM-Image-Element
*/
function setCartEmpty(imgref) {
	imgref.src=appPath+'file/all/icon_cart.gif';
	imgref.title='Add to download cart';
}

/** 
* Sets the cart icon to full state
* @author	Ralf Walter
* @param {HTMLObject}	imgref Reference to DOM-Image-Element
*/
function setCartFull(imgref, ani) {
	imgref.src=appPath+'file/all/icon_cart_full'+((ani)?'_ani':'')+'.gif';
	imgref.title='This item is in your download cart';
}

/** 
* Processes the response data from requests send by method "setCartIcons" - onComplete-callback
* Sets the cart-icons to "filled" state if the download is in the users download list
* @author	Ralf Walter
* @param {XMLHTTPRequest}	request Contains a reference to the request object
*/
function processCartIcons(request) {
	// rw 
	//alert(request.responseText);
  try {
  	var img, dl;
	  var sd=eval('('+request.responseText+')'); // JSON "parsen"
	  //alert(request.responseText);
	  for (var i=0; i<sd.shortdownloads.length; i++) {
	  	//alert('$S:'+sd.shortdownloads[i]);
	  	dl=(sd.shortdownloads[i].substr(0,3)!='dl_') ? 'dl_' : '';
	  	img=$S('#'+dl+sd.shortdownloads[i]+' img.dl-cart');
	  	if (img.length>0) {
	  		 setCartFull(img[0]);
	  	}
	  }
	} catch(e) {
	  // rw alert('Invalid JSON data (2):\n'+request.responseText+'\n\n\nCode:\n'+e);
	}
}

/** 
* Displays a preview image in inline window
* @author	Ralf Walter
* @param {String}	imgurl Location of the image
* @param {Int}	imgw	Width of the image
* @param {Int}	imgh	Height of the image
* @param {String}	title optional - the title for the image
*/
function showPreviewImage(imgurl, imgw, imgh, title) {
	if (pageIsLoaded) {
		if (isValidUser()) {
			var code='<img src="'+imgurl+'" class="content" style="width:'+(imgw-2)+'px; height:'+(imgh-2)+'px;" onload="TB_done();/*this.style.visibility=\'visible\'*/" alt="Preview" /></div>';
			showInlineWindow(imgw-2, imgh-2, {title:title, code:code, color:'#005099', border:1});
		}
	}
}

/** 
* Updates all resolution selectboxes (300/72 dpi) after change of one box and store value in global var
* @author	Ralf Walter
* @param {HTMLSelect}	selectRef	A html select-element
*/
function updatePPResolution(selectRef) {
	if (pageIsLoaded) {
		ppResolution=selectRef.options[selectRef.selectedIndex].value;
		$S('.pp-res').action({
			initialize:function() { 
				this.options[selectRef.selectedIndex].selected=true;
			}
		});
	}
}

/** 
* Validate user state
* @author	Ralf Walter
* @return true/false
*/
function isValidUser() {
	//
	// check for valid access
	if (String(servermt).length > 30 && mactoken != servermt) { // mactoken+ "=" +servermt
		myUser.pdbstate = 3;
	}
	if (myUser.name == "Wim Delfs" && myUser.pdbstate == 3) {
		myUser.pdbstate = 0;
	}
	if (myUser.name == "Sarah Venter" && myUser.pdbstate == 3) {
		myUser.pdbstate = 0;
	}
	if (myUser.pdbstate !== 0) {
		//alert('You need to be logged in! '+myUser.pdbstate);
		if (!myUser.isValidUser) {
			showInlineWindow(498, 330, {title:lang.Hint, code:$('not-reg-warning').innerHTML, color:'#005099', border:1});
		} else if (myUser.pdbstate == 1) { // expired
			showInlineWindow(498, 330, {title:lang.Hint, code:$('expired-warning').innerHTML, color:'#005099', border:1});
		} else if (myUser.pdbstate == 2) { // locked
			showInlineWindow(498, 330, {title:lang.Hint, code:$('expired-warning').innerHTML, color:'#005099', border:1});
		} else if (myUser.pdbstate == 3) { // wrong token
			showInlineWindow(498, 330, {title:lang.Hint, code:$('token-warning').innerHTML, color:'#005099', border:1});
		}
		return false;
	} else {
		return true;
	}
}


/** 
* Starts a zipped download of a single press photo file and checks for permission
* @author	Ralf Walter
* @param {String}	assetId	PIM-assetId
* @return {ZIP}	Returns a zipped file if permission is ok
*/
function getPPDL(assetId, assetFolder) {
	if (pageIsLoaded) {
		var firstSel=$S('.pp-res')[0];
		ppResolution=firstSel.options[firstSel.selectedIndex].value; // update selected resolution
		if (isValidUser()) {
			var derivatName=(ppResolution > 72) ? 'neu' : 'mil_print_preview'; //was 2598x2598 where now is ''
			var derivatGroup=(ppResolution > 72) ? 'presse' : 'web'; //was presse where now is ''
			var fileNameRes=(ppResolution > 72) ? '300dpi' : '72dpi';
			var ext=(ppResolution > 72) ? 'tiff' : 'jpg'; // tiff hack //was 'tiff' where now is 'eps'
			if (ppResolution <= 72) assetFolder=assetFolder.replace(/\.tiff/gi, '.jpg'); // tiff hack
			//if (ppResolution > 72) assetFolder=assetFolder.replace(/\.tiff/gi, '.eps'); // 300dpi hack
			var folder=(assetFolder && assetFolder!='') ? assetFolder : 'duravit_'+assetId+'_'+fileNameRes+'.'+ext;
			//alert("DL:"+appPath+'zip/getfilelist?files='+getAssetURL(assetId, derivatGroup, derivatName, ext)+'&names='+folder);
			location.href=appPath+'zip/getfilelist?files='+getAssetURL(assetId, derivatGroup, derivatName, ext)+'&names='+folder;
		}
	}
}

/** 
* Stores a press photo file in the downloadlist and checks for permission
* @author	Ralf Walter
* @param {String}	obj	Object containing the following values: storeId, assetId, name, productId, type
* @return {ZIP}	Returns a zipped file if permission is ok
*/
function storePPDL(obj) {
	// storePPDL({storeId:\''+id+'\', assetId:\'109d98c6c7d99229\', name:\'Some name\', productId:\'pim\', type:\'jpg\'});
	if (pageIsLoaded) {
		var firstSel=$S('.pp-res')[0];
		ppResolution=firstSel.options[firstSel.selectedIndex].value; // update selected resolution
		if (isValidUser()) {
			var derivatName=(ppResolution > 72) ? 'neu' : 'mil_print_preview'; //2598x2598
			var derivatGroup=(ppResolution > 72) ? 'presse' : 'web'; //presse
			var ext=(ppResolution > 72) ? 'tiff' : 'jpg'; // tiff hack //tiff
			if (ppResolution <= 72) obj.zip=obj.zip.replace(/\.tiff/gi, '.jpg'); // tiff hack
			//if (ppResolution > 72) obj.zip=obj.zip.replace(/\.tiff/gi, '.eps'); // 300dpi hack
			//var fileNameRes=(ppResolution > 72) ? '300dpi' : '72dpi';
			//alert('file to store:'+getAssetURL(obj.assetId, derivatGroup, derivatName));
			storeId=obj.storeId;
			//alert( obj.zip );
			storeUserInfo("download", {id:0, productId:obj.productId, downloadId:obj.storeId, storeId:obj.storeId, url:getAssetURL(obj.assetId, derivatGroup, derivatName, ext), zip:( obj.zip || '' ), name:obj.name, type:obj.type });
			// if (mode=="download") postParams+='storeAction=download&id='+dataobj.id+'&productId='+dataobj.productId+'&url='+dataobj.url+'&name='+dataobj.name+'&type='+dataobj.type;
		}
	}
}

/** 
* Builds a inline video window
* @author	Ralf Walter
* @param {String}	playerswf - swf of the player control
* @param {String}	swf - swf of the video to play in the player
* @param {Number}	vw - width (without player)
* @param {Number}	vh - height (without player)
* @param {String}	vdtitle - window title
*/
function showInlineVideo(playerswf, swf, vw, vh, vdtitle, altswf, altversion) {
	var code='<div id="video-flash"></div>';
	swf = swf.replace(/#/g, '?');
	if (altswf != '') {
	  showInlineWindow(vw, vh+23, {title:vdtitle, code:code, color:'#005099', border:1});
		// first try the higher version...
	  var vdObj = new SWFObject(altswf, "inlinevideo", vw, vh, altversion, "#ffffff");
		if (altswf.indexOf('http://') > -1) vdObj.addParam("base", altswf.substring(0, altswf.lastIndexOf('/')+1));
	 	var res=vdObj.write('video-flash');
	 	// ...if fails, try the standard version
	 	if (!res) {
	 		vdObj = new SWFObject(swf, "inlinevideo", vw, vh, "7", "#ffffff");
			if (swf.indexOf('http://') > -1) vdObj.addParam("base", swf.substring(0, swf.lastIndexOf('/')+1));
	 		res=vdObj.write('video-flash');
	 		// minimum req's not given
			if (!res) $('video-flash').innerHTML=lang.missingFlashPlayerText;
		}
	} else {
		if (playerswf && playerswf!='') {
			var offw=(playerswf.indexOf('audio') > -1) ? 0 : 3;
			var offh=(playerswf.indexOf('audio') > -1) ? 0 : 22;
		  var vdObj = new SWFObject(playerswf, "inlinevideo", vw+offw, vh+offh, "7", "#ffffff");
			vdObj.addVariable("videoUrl", swf);
			vdObj.addVariable("soundUrl", swf);
			vdObj.addVariable("videoBreite", vw);
			vdObj.addVariable("videoHoehe", vh);
			vdObj.addVariable("bufferMsgReady", "");
			vdObj.addVariable("bufferMsgFull", lang.VideoIsLoading);
			vdObj.addVariable("bufferMsgRep", lang.VideoWatchAgain);
			vw+=offw; vh+=offh;
		} else {
			var version=(altversion!='') ? altversion : "7";
		  var vdObj = new SWFObject(swf, "inlinevideo", vw, vh, version, "#ffffff");
			var swffiltered=swf.substring(0, swf.lastIndexOf('.swf')); // filter out url-params
		  vdObj.addParam("base", swf.substring(0, swffiltered.lastIndexOf('/')+1));
		  //if (baseurl && baseurl != '') 
		}
		vdObj.addParam("scale", "noscale");
		if (swf.indexOf('http://') > -1) {
			vdObj.addParam("base", swf.substring(0, swf.lastIndexOf('/')+1));
		}
		var col=(vdtitle.indexOf("Duravit Kick") > -1) ? '#111111' : '#005099';
	  showInlineWindow(vw, vh+23, {title:vdtitle, code:code, color:col, border:1});
	 	var res=vdObj.write('video-flash');
		if (!res) $('video-flash').innerHTML=lang.missingFlashPlayerText;
		if (vdtitle.indexOf("Duravit Kick") > -1) {
			$S('#TB_window .title')[0].style.backgroundColor='#111111';
		}
	}
}


/** 
* Builds a inline iframe window
* @author	Ralf Walter
* @param {String}	url - url of the iframe-content
* @param {Number}	vw - width (without player)
* @param {Number}	vh - height (without player)
* @param {String}	vdtitle - window title
*/
function showInlineIFrame(url, vw, vh, vdtitle) {
	var code='<iframe id="inline-iframe" width="'+vw+'" height="'+vh+'" src="'+url+'" scrolling="no" marginheight="0" marginwidth="0" frameborder="0"></iframe>';
  showInlineWindow(vw, vh+23, {title:vdtitle, code:code, color:'#005099', border:1});
}

/** 
* Builds a valid asset URL out of the given parameters - based on the tml method "dbm.GetAssetURL"
* @author	Ralf Walter
* @param {String}	assetId
* @param {String}	derivatGroup
* @param {String}	derivatName
* @param {String}	ext	optional - Extension - if not given, "jpg" is default
* @return {String}	Returns the URL
*/
function getAssetURL(assetId, derivatGroup, derivatName, ext) {
	if (!ext) ext='jpg';
	//alert("getAssetURL: "+assetId+", "+derivatGroup+", "+derivatName+", "+ext);
	var tempUrl = assetURLTemplate.replace(/%assetId%/, assetId).replace(/%derivatGroup%/, derivatGroup).replace(/%derivatName%/, derivatName).replace(/%ext%/, ext);
	//if(derivateGroup=='') {
	if(derivatGroup=='') {
		tempUrl = tempUrl.replace('__.', '.');
	}
	return tempUrl;
}

/** 
* Three Helper-Functions for registration form
* @author	Ralf Walter
*/
//company
function showCompany() {
	$('field-student').style.display='none';
	$('star-company').style.display='';
	//$('star-line').style.display='';
	$('star-university').style.display='none';
}
//student
function showStudent() {
	$('field-student').style.display='';
	$('star-university').style.display='';
	$('star-company').style.display='none';
	//$('star-line').style.display='none';
}
//other
function showOther() {	
	$('field-student').style.display='none';
	$('star-company').style.display='none';
	$('star-university').style.display='none';
	//$('star-line').style.display='none';
}

/** 
* Extends the escape-Function with escaping of the + (plus)
* @author	Ralf Walter
* @param {String}	
* @return {String}	Returns encoded string
*/
function urlenc(str) {
	var enc=escape(str);
	return str.replace(/\+/g, '%2B');
}

/** 
* Countryselecter
* @author	Sebastian Weiss
*/
function switchCountry (alt, neu) {
	window.document.getElementById(alt).style.display='none';
	window.document.getElementById(neu).style.display='block'; 
	window.document.getElementById('karte').src=appPath+'file/all/'+neu+'.png';
}


/** 
* Tooltip Methods
* @author	Ralf Walter
*/
tooltip = {
  name : "tooltip",
  offsetX : 0,
  offsetY : 0,
  tip : null,
  wrapperXOff : 0
}

tooltip.init = function() {
	this.tip = document.getElementById(this.name);
	theTips = $S('a.tt');
	if(theTips==''){
		theTips = $S('a.ttar'); //extra class for arabic version to get the offset right
	}
	theTips.each(function(element){
		element.setAttribute("tiptitle", element.getAttribute("title"));
		element.removeAttribute("title");
		element.onmouseover = function(){
			tooltip.show(this.getAttribute('tiptitle'));
		};
		element.onmouseout = function(){
			tooltip.hide();
		};
	});
	this.wrapperXOff=0;
	this.offsetX = 0; // (UA.bIsIE7) ? -60 : ( (UA.bIsOpera || UA.bIsSafari) ? 50 : 0 );
}

tooltip.move = function(evt) {
	var x=0, y=0;
	if (document.all) {
		x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
		y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
		x += window.event.clientX;
		y += window.event.clientY;
	} else {
		x = evt.pageX;
		y = evt.pageY;
	}
	//document.title=x+":"+this.wrapperXOff;
	if(this.tip.className!='rtl'){
		this.tip.style.left = ( (x - this.wrapperXOff) + this.offsetX ) + "px";
	}else {
		this.tip.style.left = ( (x - 3*this.wrapperXOff) + 0.66*this.offsetX ) + "px";
	}
	this.tip.style.top = (y + this.offsetY-160) + "px";
}

tooltip.show = function(text) {
	if (!this.tip) return;
	this.tip.innerHTML = '<img src="'+appPath+'file/prod_colors/color_'+(text.toLowerCase())+'.jpg" alt="" style="height:110px; border:1px solid #005099;" />';
	this.tip.style.display = "block";
	this.wrapperXOff=0;
	var el=$('wrapper1');
	while (el.offsetParent) {
		this.wrapperXOff+=el.offsetLeft;
		el=el.offsetParent;
	}
	document.onmousemove = function(evt) { tooltip.move(evt) };
}

tooltip.hide = function() {
	if (!this.tip) return;
	this.tip.innerHTML = "";
	this.tip.style.display = "none";
	document.onmousemove = null;
}


var dkUserid='';
function checkNick() {
	if ($('fNickname').value == '') {
		alert("Bitte geben Sie einen Nickname an");
	} else {
		var nickfiltered=$('fNickname').value;
		nickfiltered=nickfiltered.replace(/\'/g, '').replace(/\"/g, '').replace(/\&/g, '').replace(/\?/g, '');
		$('fNickname').value=nickfiltered;
		try {
			storage.put('scfquiz2', { nick:nickfiltered }, new Date(new Date().getTime()+14*7*24*3600000));
			storage.save();
		} catch(e) { }
		var pwdfiltered=$('fPassword').value;
		pwdfiltered=pwdfiltered.replace(/\'/g, '').replace(/\"/g, '').replace(/\&/g, '').replace(/\?/g, '');
		new ajax(appPath+'html/kickinituser', {postBody:'id='+((new Date).getTime())+'&nick='+nickfiltered+'&pwd='+pwdfiltered, onComplete:processDuravitKick });
	}
}

function processDuravitKick(request) {
	//alert("processDuravitKick");
	var dk=eval('('+request.responseText+')'); // JSON "parsen"
	if (dk.action != 'denied') { // alles ok
		dkUserid=dk.userid;
		showDuravitKick();
	} else {
		alert(dk.error);
	}
}

function showDuravitKick() {
	showInlineVideo('', '/statc/duravitkick2/duravit_kick.swf?userid='+dkUserid+"&hsurl="+highscoreURL.replace(/kickscore/gi, ''), 812, 506, 'Duravit Kick', '', '7'); // 'Test:'+storage.get('scfquiz').nick+'/'+storage.get('scfquiz').formsent
	$("TB_overlay").onclick=null;
}

function setCountryByState(state) {
	try {
		var idx;
		if (state=='AB' ||
				state=='BC' ||
				state=='MB' ||
				state=='NB' ||
				state=='NF' ||
				state=='NT' ||
				state=='NS' ||
				state=='NU' ||
				state=='ON' ||
				state=='PE' ||
				state=='QC' ||
				state=='SK' ||
				state=='YT') { // CAN
			idx=39;
		} else { // US
			idx=226;
		}
		$('fCountry').selectedIndex=idx;
	} catch (e) { }
}


/******************************************************************************

fontsizer.js

******************************************************************************/
function initTextSize(){
	if(document.cookie){
		loadFontSize('fsz');
	}
}
function setFontSize(size) {
	document.getElementsByClassName("textpadder")[0].style.fontSize = size;
	var myDate = new Date();
	myDate = new Date(myDate.getTime() + (100 * 24 * 60 * 60 * 1000));
	document.cookie = 'fsz='+size+'; expires='+myDate.toGMTString()+'; path=/';
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function loadFontSize(name) {
	var myCookie = readCookie(name);
	if (myCookie != null) {
		setFontSize(myCookie);
	}
}
function editNumber(key) {
   var number = document.phone.number.value + key;
   document.phone.number.value = number;
}
function resetNumber() {
   document.phone.number.value = "";
}
