function toggle(box) {
	boxes = new Array('1','2','3');
	showbox = document.getElementById('detail' + box);
	arrow = document.getElementById('indicator' + box);
	if (showbox.style.display=='') {
		showbox.style.display='none';
		arrow.src = 'http://my.techdata.ch/images/arrow_down.gif';
	}else{
		for (i=0;i<boxes.length;i++)
		{
			if(boxes[i] != box)
			{
				document.getElementById('detail' + boxes[i]).style.display='none';
				document.getElementById('indicator' + boxes[i]).src='http://my.techdata.ch/images/arrow_down.gif';
			}
		}
		showbox.style.display='';
		arrow.src='http://my.techdata.ch/images/arrow_up.gif';
	}
}

function mozilla() {
	try {
		if (isExplorer=='0') {
			var v = document.getElementsByTagName('select');
			var o;
			for (var i=0;i<v.length;i++) {
				o = v[i];
				if (o!=null) {
					if (o.className=='formcombo') {
						 o.className='formcombomoz';
					}
					if (o.className=='errorCombo') {
						 o.className='errorCombomoz';
					}
					if (o.className=='formcomborec') {
						 o.className='formcomborecmoz';
					}
					if (o.className=='formcombospec') {
						 o.className='formcombospecmoz';
					}
					if (o.className=='errorComborec') {
						 o.className='errorComborecmoz';
					}
					if (o.className=='errorCombospec') {
						 o.className='errorCombospecmoz';
					}
				}
			}
		}
	} catch (e) {}
}

function uml(aStr) {
	try {
		aStr = aStr.replace("ä", "&auml;");
		aStr = aStr.replace("ö", "&ouml;");
		aStr = aStr.replace("ü", "&uuml;");
		aStr = aStr.replace("Ä", "&Auml;");
		aStr = aStr.replace("Ö", "&Ouml;");
		aStr = aStr.replace("Ü", "&Uuml;");
		aStr = aStr.replace("ß", "&szlig;");
	} catch(e) {}
	return aStr;
}

function switchView(obj) {
	try {
		var v = document.getElementById(obj);
		if (v.style.display=='inline') {
			v.style.display='none';
		} else {
			v.style.display='inline';
		}
	} catch(e) {}
}

function trim(s) {
	return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

function $(id) {
	return document.getElementById(id);
}

var ua = navigator.userAgent.toLowerCase();

function codeBoxNextButtonHandler() {
	var code = $('EVENTCODE');
	var r = 0;
	r = validate('empty', code.value, 'EVENTCODE', 'formfield');
	if(r > 0) {
		MsgBox.internalAlert('Hinweis', 'Kein Code eingegeben');
		return;
	}
	var ajax = new AJAX();
	var params = 'r=' + Math.random() + '&code=' + code.value;
	ajax.callPage('/ajax/code_validator.asp?' + params, function(respText) {
		if(trim(respText) == 'SUCCESS') {
			MsgBox.hide();
			document.location.href= "/campaigns/ev20101118125556817.asp";
		} else {
			if (trim(respText) == 'FAILED') {
				MsgBox.internalAlert('Hinweis', 'Falscher Code');
				return;
			} else {
				if (trim(respText) == 'NOCODE') {
					MsgBox.internalAlert('Hinweis', 'Kein Code eingegeben');
					return;
				}
			}
		}
	});
}
function codeBoxCloseButtonHandler(obj) {
	MsgBox.codeWindowObj.hide();
}
function onCodeIn(e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if ( code == 13) {
		DoGlobalSubmit = false;
		codeBoxNextButtonHandler();
	}
}

function lgpwBoxNextButtonHandler() {
	var lg = $('LG');
	var pw = $('PW');
	var r = 0;
	r = validate('empty', lg.value, 'LG', 'formfield');
	if (r==0) {
		r = validate('email', lg.value, 'LG', 'formfield');
	}
	r = r + validate('empty', pw.value, 'PW', 'formfield');
	if(r > 0) {
		MsgBox.internalAlert('Hinweis', 'Bitte erg&auml;nzen/korrigieren Sie Ihre Angaben in den rot markierten Feldern.');
		return;
	}
	var ajax = new AJAX();
	var params = 'r=' + Math.random() + '&lg=' + lg.value + '&pw=' + pw.value;
	ajax.callPage('/ajax/lgpw_validator.asp?' + params, function(respText) {
		if(trim(respText) == 'SUCCESS') {
			MsgBox.hide();
			document.location.href= "/campaigns/ev20111122132741783.asp";
		} else {
			if (trim(respText) == 'FAILED') {
				MsgBox.internalAlert('Hinweis', 'Ihre Angaben waren falsch');
				return;
			} else {
				if (trim(respText) == 'NOCODE') {
					MsgBox.internalAlert('Hinweis', 'Keine Daten eingegeben');
					return;
				}
			}
		}
	});
}
function lgpwBoxCloseButtonHandler(obj) {
	MsgBox.lgpwWindowObj.hide();
}

Ext = {
	isStrict : (document.compatMode == "CSS1Compat"),
    isOpera : (ua.indexOf("opera") > -1),
	isSafari : (/webkit|khtml/).test(ua),
    isSafari3 : this.isSafari && ua.indexOf('webkit/5') != -1,
    isIE : !this.isOpera && ua.indexOf("msie") > -1,
    isIE7 : !this.isOpera && ua.indexOf("msie 7") > -1,
    isGecko : !this.isSafari && ua.indexOf("gecko") > -1,
    isWindows : (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1),
    isMac : (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1),
    isAir : (ua.indexOf("adobeair") != -1),
    isLinux : (ua.indexOf("linux") != -1),
	getViewHeight : function(full) {
		return full ? this.getDocumentHeight() : this.getViewportHeight();
    },
	getViewWidth : function(full) {
		return full ? this.getDocumentWidth() : this.getViewportWidth();
    },
    getDocumentHeight: function() {
		var scrollHeight = !this.isStrict ? document.body.scrollHeight : document.documentElement.scrollHeight;
        return Math.max(scrollHeight, this.getViewportHeight());
    },
    getDocumentWidth: function() {
        var scrollWidth = !this.isStrict ? document.body.scrollWidth : document.documentElement.scrollWidth;
		return Math.max(scrollWidth, this.getViewportWidth());
    },
    getViewportHeight: function(){
		if(this.isIE){
			return this.isStrict ? document.documentElement.clientHeight :document.body.clientHeight;
        } else {
            return self.innerHeight;
        }
    },
    getViewportWidth: function() {
		if(this.isIE){
            return this.isStrict ? document.documentElement.clientWidth : document.body.clientWidth;
        } else {
			return self.innerWidth;
        }
    },
	getScrollTop : function() {
		return !this.isStrict ? document.body.scrollTop : document.documentElement.scrollTop;
	}
};

Ext.apply = function(o, c, defaults){
    if(defaults){
        Ext.apply(o, defaults);
    }
    if(o && c && typeof c == 'object'){
        for(var p in c){
            o[p] = c[p];
        }
    }
    return o;
};

Ext.apply(Function.prototype, {
    createCallback : function(/*args...*/){
        var args = arguments;
        var method = this;
        return function() {
            return method.apply(window, args);
        };
    },
    createDelegate : function(obj, args, appendArgs){
        var method = this;
        return function() {
            var callArgs = args || arguments;
            if(appendArgs === true){
                callArgs = Array.prototype.slice.call(arguments, 0);
                callArgs = callArgs.concat(args);
            }else if(typeof appendArgs == "number"){
                callArgs = Array.prototype.slice.call(arguments, 0);
                var applyArgs = [appendArgs, 0].concat(args);
                Array.prototype.splice.apply(callArgs, applyArgs);
            }
            return method.apply(obj || window, callArgs);
        };
    },
    defer : function(millis, obj, args, appendArgs){
        var fn = this.createDelegate(obj, args, appendArgs);
        if(millis){
            return setTimeout(fn, millis);
        }
        fn();
        return 0;
    },
    createSequence : function(fcn, scope){
        if(typeof fcn != "function"){
            return this;
        }
        var method = this;
        return function() {
            var retval = method.apply(this || window, arguments);
            fcn.apply(scope || this || window, arguments);
            return retval;
        };
    },
    createInterceptor : function(fcn, scope){
        if(typeof fcn != "function"){
            return this;
        }
        var method = this;
        return function() {
            fcn.target = this;
            fcn.method = method;
            if(fcn.apply(scope || this || window, arguments) === false){
                return;
            }
            return method.apply(this || window, arguments);
        };
    }
});

var MsgBox = {
	windowObj : null,
	innerWindowObj : null,
	codeWindowObj : null,
	lgpwWindowObj : null,
	faxWindowObj : null,
	flexalert : function(title, message, fn, width) {
		if(!this.windowObj) {
			this.windowObj = new WindowBox('msgObj');
		}
		this.windowObj.closeBtnHandler(fn);
		this.windowObj.setNoBtnVisible(false);
		this.windowObj.setYesBtnVisible(false);
		this.windowObj.setCloseBtnVisible(true);
		this.windowObj.setNextBtnVisible(false);
		this.windowObj.show(title, message, width, 130);
	},
	alert : function(title, message, fn) {
		if(!this.windowObj) {
			this.windowObj = new WindowBox('msgObj');
		}
		this.windowObj.closeBtnHandler(fn);
		this.windowObj.setNoBtnVisible(false);
		this.windowObj.setYesBtnVisible(false);
		this.windowObj.setCloseBtnVisible(true);
		this.windowObj.setNextBtnVisible(false);
		this.windowObj.show(title, message, 350, 130);
	},
	alertNext : function(title, message, fn) {
		if(!this.windowObj) {
			this.windowObj = new WindowBox('msgObj');
		}
		this.windowObj.nextBtnHandler(fn);
		this.windowObj.setNoBtnVisible(false);
		this.windowObj.setYesBtnVisible(false);
		this.windowObj.setCloseBtnVisible(false);		
		this.windowObj.setNextBtnVisible(true);
		this.windowObj.show(title, message, 350, 130);
	},
	internalAlert : function(title, message, fn) {
		if(!this.innerWindowObj) {
			this.innerWindowObj = new WindowBox('innerMsgObj');
		}
		this.innerWindowObj.closeBtnHandler(fn);
		this.innerWindowObj.setNoBtnVisible(false);
		this.innerWindowObj.setYesBtnVisible(false);
		this.innerWindowObj.setCloseBtnVisible(true);
		this.innerWindowObj.setNextBtnVisible(false);
		this.innerWindowObj.show(title, message, 350, 140);
	},
	showPasswdChange : function(title, finishText) {
		if(!this.windowObj) {
			this.windowObj = new WindowBox('msgObj');
		}
		var message = '<p>Bitte vergeben Sie zunächst Ihr persönliches Passwort, mit dem Sie sich jederzeit wieder auf &quot;meinEBERLE&quot; anmelden können.<BR>&nbsp;</p><table border="0" cellspacing="0" cellpadding="0"><colgroup><col class="caption" /><col class="formfield" /></colgroup>' + 
		'<tr><td width="175">Passwort*</td><td width="170"><input id="passwd" name="passwd" class="formfield" type="password" value=""></td></tr><tr><td>Passwort bestätigen*</td><td><input id="passwdRepeat" name="passwdRepeat" class="formfield" type="password" value=""></td></tr></table>';
		this.windowObj.yesBtnHandler(function() {
			var pass1 = $('passwd');
			var pass2 = $('passwdRepeat');
			var r = 0;
			r = validate('empty', pass1.value, 'passwd', 'formfield');
			r += validate('empty', pass2.value, 'passwdRepeat', 'formfield');
			if(r == 0) {
				if(pass1.value != pass2.value) {
					r += 1;
					pass2.className = 'formfieldError';
				}
			}
			if(r > 0) {
				MsgBox.internalAlert('Hinweis','Bitte ergänzen/korrigieren Sie Ihre Angaben in den rot markierten Feldern.');
				return;
			}	
			var ajax = new AJAX();
			var params = 'passwd=' + pass1.value;
			ajax.callPage('/ajax/change_passwd.asp?' + params, function(respText) {
				if(trim(respText) == 'ok') {
					var msg = finishText ? finishText : '';
					MsgBox.internalAlert('Hinweis', msg);
					MsgBox.hide();
				}
			});
		});
		this.windowObj.setNoBtnVisible(false);
		this.windowObj.setYesBtnVisible(true);
		this.windowObj.setCloseBtnVisible(false);
		this.windowObj.setNextBtnVisible(false);
		this.windowObj.show(title, message, 350, 130);
	},
	showCodeBox : function(title, wrongCodeText, noCodeText) {
		if(!this.codeWindowObj) {
			this.codeWindowObj = new WindowBox('msgObj');
		}
		var message = '<table width=366 border=0 cellspacing=0 cellpadding=0 class="simplebox"><tr><td><p>Geben Sie hier Ihren persönlichen Code ein, der auf der Postkarte angegeben ist, und folgen Sie den weiteren Schritten:</p><br><br></td></tr><tr><td><table border=0 cellspacing=0 cellpadding=0 id="regtable"><colgroup><col width=96 class="caption" /><col width=250 class="formfield" /></colgroup><tr><td>Katalog-Code</td><td><input id="EVENTCODE" name="EVENTCODE" class="formfield" value="" onkeydown="onCodeIn(event);"></td></tr></table></td></tr><tr><td align="right" style="padding-right:10px;padding-top:10px;padding-bottom:10px;"><img src="/MLSupport/ger/button/btn_cnext.gif" style="cursor:pointer;" onclick="codeBoxNextButtonHandler();" /></td></tr><tr><td><strong>Sie haben keinen Code erhalten?</strong><br>Dann klicken Sie "schließen" und füllen Sie bitte das Bestellformular aus.</p></td></tr><tr><td align="right" style="padding-right:10px;padding-top:10px;"><img src="/MLSupport/ger/button/btn_cclose.gif" style="cursor:pointer;" onclick="codeBoxCloseButtonHandler(this);"></td></tr></table>';
		this.codeWindowObj.nextBtnHandler(function() {
			var code = $('EVENTCODE');
			var r = 0;
			r = validate('empty', code.value, 'EVENTCODE', 'formfield');
			if(r > 0) {
				MsgBox.internalAlert('Hinweis', noCodeText);
				return;
			}
			var ajax = new AJAX();
			var params = 'r=' + Math.random() + '&code=' + code.value;
			ajax.callPage('/ajax/code_validator.asp?' + params, function(respText) {
				if(trim(respText) == 'SUCCESS') {
					MsgBox.hide();
					document.location.href= "/campaigns/ev20101118125556817.asp";
				} else {
					if (trim(respText) == 'FAILED') {
						var msg = wrongCodeText ? wrongCodeText : '';
						MsgBox.internalAlert('Hinweis', msg);
						return;
					} else {
						if (trim(respText) == 'NOCODE') {
							var msg = noCodeText ? noCodeText : '';
							MsgBox.internalAlert('Hinweis', msg);
							return;
						}
					}
				}
			});
		});
		this.codeWindowObj.setNoBtnVisible(false);
		this.codeWindowObj.setYesBtnVisible(false);
		this.codeWindowObj.setCloseBtnVisible(false);
		this.codeWindowObj.setNextBtnVisible(false);
		this.codeWindowObj.show(title, message, 350, 130);
	},
	showLgPwBox : function(title, validationErrText, validationEmptyText) {
		if(!this.lgpwWindowObj) {
			this.lgpwWindowObj = new WindowBox('msgObj');
		}
		var message = '<table width=366 border=0 cellspacing=0 cellpadding=0 class="simplebox"><tr><td><p>Geben Sie hier bitte Ihren persönlichen Login ein, und folgen Sie den weiteren Schritten:</p><br></td></tr><tr><td><table border=0 cellspacing=0 cellpadding=0 id="regtable"><colgroup><col width=96 class="caption" /><col width=250 class="formfield" /></colgroup><tr><td colspan=2><br /><br />Login:</td></tr><tr><td>E-Mail</td><td><input id="LG" name="LG" class="formfield" value=""></td></tr><tr><td>Passwort</td><td><input id="PW" type="password" name="PW" class="formfield" value=""></td></tr></table></td></tr><tr><td align="right" style="padding-right:10px;padding-top:10px;padding-bottom:10px;"><img src="/MLSupport/ger/button/btn_cnext.gif" style="cursor:pointer;" onclick="lgpwBoxNextButtonHandler();" /></td></tr><tr><td><strong>Login vergessen?</strong><br /><a href="/base/forgotten.asp" style="color:#666666;">Hier können Sie Ihren persönlichen Login anfordern</a>.<br /><br /><strong>Neu hier?</strong><br /><a href="/base/registration.asp" style="color:#666666;">Hier können Sie sich registrieren</a>.<br /><br /><strong>Sie möchten ohne Login fortfahren?</strong><br />Dann klicken Sie "schließen" und füllen Sie bitte das Bestellformular aus.</p></td></tr><tr><td align="right" style="padding-right:10px;padding-top:10px;"><img src="/MLSupport/ger/button/btn_cclose.gif" style="cursor:pointer;" onclick="lgpwBoxCloseButtonHandler(this);"></td></tr></table>';
		this.lgpwWindowObj.nextBtnHandler(function() {
			var lg = $('LG');
			var pw = $('PW');
			var r = 0;
			r = validate('empty', lg.value, 'LG', 'formfield');
			if (r==0) {
				r = validate('email', lg.value, 'LG', 'formfield');
			}
			r = r + validate('empty', pw.value, 'PW', 'formfield');
			if(r > 0) {
				MsgBox.internalAlert('Hinweis', validationEmptyText);
				return;
			}
			var ajax = new AJAX();
			var params = 'r=' + Math.random() + '&lg=' + lg.value + '&pw=' + pw.value;
			ajax.callPage('/ajax/lgpw_validator.asp?' + params, function(respText) {
				if(trim(respText) == 'SUCCESS') {
					MsgBox.hide();
					document.location.href= "/campaigns/ev20111122132741783.asp";
				} else {
					if (trim(respText) == 'FAILED') {
						var msg = validationErrText ? validationErrText : '';
						MsgBox.internalAlert('Hinweis', msg);
						return;
					} else {
						if (trim(respText) == 'NOCODE') {
							var msg = validationEmptyText ? validationEmptyText : '';
							MsgBox.internalAlert('Hinweis', msg);
							return;
						}
					}
				}
			});
		});
		this.lgpwWindowObj.setNoBtnVisible(false);
		this.lgpwWindowObj.setYesBtnVisible(false);
		this.lgpwWindowObj.setCloseBtnVisible(false);
		this.lgpwWindowObj.setNextBtnVisible(false);
		this.lgpwWindowObj.show(title, message, 350, 230);
	},
	showFaxBox : function(title, noSelectionText, wrongNumberText, errorText, f1, f2, f3) {
		if(!this.faxWindowObj) {
			this.faxWindowObj = new WindowBox('msgObj');
		}
		var message = '<table width="366" border=0 cellspacing=0 cellpadding=0 class="simplebox"><tr><td width="26" valign="top" style="padding-top:5px;padding-left:5px;"><input id="faxOrder" name="faxOrder" class="checkbox" type="checkbox" value="checked"></td><td width="340" valign="top">Ja, ich möchte über die neue Ausgabe der EBERLE Bildpreisliste zukünftig gerne per Fax informiert werden und diese dann gleich per Fax bestellen!</td></tr><tr><td colspan="2"><br><table border="0" cellspacing="0" cellpadding="0" id="regtable" width="366"><tr><td width="146">Meine Fax-Nummer lautet:</td><td width="220"><input id="FAX_LVW" name="FAX_LVW" class="formlvw" value="' + f1 + '" size="3"><input id="FAX_VW" name="FAX_VW" class="formvorw" value="' + f2 + '" size="5"><input id="FAX" name="FAX" class="formnbr" value="' + f3 + '" size="21"></td></tr></table></td></tr></table>';
		this.faxWindowObj.nextBtnHandler(function() {
			var ff1 = $('FAX_LVW');
			var ff2 = $('FAX_VW');
			var ff3 = $('FAX');
			var order = $('faxOrder');
			var t;
			var b = 0;
			if (order.checked) {
				t = ff1.value + ' ' + ff2.value + ' ' + ff3.value;
				b = b + validate('phone', t, 'FAX_LVW', 'formlvw');
				b = b + validate('phone', t, 'FAX_VW', 'formvorw');
				b = b + validate('phone', t, 'FAX', 'formnbr');
				if (b == 0) {
					var ajax = new AJAX();
					var params = 'r=' + Math.random() + '&fax=' + encodeURIComponent(t);
					ajax.callPage('/ajax/fax_updater.asp?' + params, function(respText) {
						if (trim(respText) == 'SUCCESS') {
							MsgBox.hide();
							document.location.href= "/campaigns/ev20101118125556817.2.asp";
						} else {
							MsgBox.internalAlert('Hinweis', errorText);
							return;
						}
					});
				} else {
					MsgBox.internalAlert('Hinweis', wrongNumberText);
					return;
				}
			} else {
				MsgBox.internalAlert('Hinweis', noSelectionText);
				return;
			}
		});
		this.faxWindowObj.setNoBtnVisible(false);
		this.faxWindowObj.setYesBtnVisible(false);
		this.faxWindowObj.setCloseBtnVisible(true);
		this.faxWindowObj.setNextBtnVisible(true);
		this.faxWindowObj.show(title, message, 350, 130);
	},
	confirm : function(message, fn) {
		if(!this.windowObj) {
			this.windowObj = new WindowBox('msgObj');
		}		
		this.windowObj.yesBtnHandler(fn);
		this.windowObj.setNoBtnVisible(true);
		this.windowObj.setYesBtnVisible(true);
		this.windowObj.setCloseBtnVisible(false);
		this.windowObj.setNextBtnVisible(false);
		this.windowObj.show('', message, 350, 110);
	},
	hide : function() {
		try {
			this.windowObj.hide();
			this.innerWindowObj.hide();
			this.codeWindowObj.hide();
			this.faxWindowObj.hide();
			this.lgpwWindowObj.hide();
		} catch(e) {}
	}
};
 
function WindowBox(id) {
	var topZindex = 20000;	
	var id = id;
    var obj;
	var mask;
    var iframe;
    var header;
	var contents;           
    var x, y;
    var left = 0, top = 0;
    var center = true; //show window with center align
    var storeLastPosition = true; //store last window position
    var firstShow = true; //check this if ceter==true and storeLastPosition, then center only first time
	var mouseMove, mouseUp;
	var yesBtnHandler;
	var yesBtnVisible;
	var noBtnHandler;
	var noBtnVisible;
	var closeBtnVisible;
	var closeBtnHandler;
	var nextBtnVisible;
	var nextBtnHandler;
		   
	return {
		$ : function(id) {
			return document.getElementById(id);
		},		
		setYesBtnVisible : function(visible) {
			yesBtnVisible = visible;
		},
		yesBtnHandler : function(fn) {
			yesBtnHandler = fn;
		},
		setNoBtnVisible : function(visible) {
			noBtnVisible = visible;
		},
		noBtnHandler : function(fn) {
			noBtnHandler = fn;
		},
		setCloseBtnVisible : function(visible) {
			closeBtnVisible = visible;
		},		
		closeBtnHandler : function(fn) {
			closeBtnHandler = fn;
		},
		setNextBtnVisible : function(visible) {
			nextBtnVisible = visible;
		},
		nextBtnHandler : function(fn) {
			nextBtnHandler = fn;
		},
		zIndex : function(value) {
			topZindex = value;
		},
		mouseDown : function(event) {
			if(!event) {
				event = window.event;
			}
			y = event.clientY;
			x = event.clientX;
			mouseMove = this.mouseMove.createDelegate(this);		
			this.addEvent(document, "mousemove", mouseMove);
			
			mouseUp = this.mouseUp.createDelegate(this);
			this.addEvent(document, "mouseup", mouseUp);
		},
		
		mouseUp : function (event) {
			if(!event) {
				event = window.event;
			}
			this.removeEvent(document, "mousemove", mouseMove);
			this.removeEvent(document, "mouseup", mouseUp);
		},
	            
		mouseMove : function(event) {
			if(!event) {
				event = window.event;
			}
			var el = this.getObj();
			el.style.left = (parseInt(el.style.left) - (parseInt(x) - parseInt(event.clientX))) + 'px';
			el.style.top = (parseInt(el.style.top) - (parseInt(y) - parseInt(event.clientY))) + 'px';				
					
			y = event.clientY;
			x = event.clientX;
			if (storeLastPosition) {
			    left = el.style.left;
			    top = el.style.top;
			}
			return false;
		},

	    addEvent : function(obj, evType, fn) {
			try {
				if (obj.addEventListener) {
	                obj.addEventListener(evType, fn, false);
	                return true;
	            } else if (obj.attachEvent){
	                var r = obj.attachEvent("on" + evType, fn);
	                return r;
	            } else {
	                return false;
	            }
	        } catch(e) {
	            this.LOG(e.description);				
	        }
	    },

	    removeEvent : function (obj, evType, fn, useCapture) {
	        try{
				if (obj.removeEventListener){
	                obj.removeEventListener(evType, fn, useCapture);
	                return true;
	            } else if (obj.detachEvent){
	                var r = obj.detachEvent("on" + evType, fn);
	                return r;
	            } else {
	                this.LOG("Handler could not be removed");
	            }
	        } catch(e) {
	            this.LOG(e.description);
	        }
	    },
	            
	    LOG : function(msg){
	        window.status = msg;
	    },
		
		show : function(title, message, width, height, xPos, yPos) {			
			this.showMask();
            var el = this.getObj(width, height);
			$(id + '_title').innerHTML = title ? title : '&nbsp;';			
			$(id + '_msg').innerHTML = message ? message : '&nbsp;';
			if($(id + '_yes_btn')) {
				$(id + '_yes_btn').style.display = yesBtnVisible ? 'inline' : 'none';
				$(id + '_yes_btn').onclick = yesBtnHandler ? yesBtnHandler : this.hide.createDelegate(this);
			}
			if($(id + '_no_btn')) {
				$(id + '_no_btn').onclick = noBtnHandler ? noBtnHandler : this.hide.createDelegate(this);
				$(id + '_no_btn').style.display = noBtnVisible ? 'inline' : 'none';
			}
			if($(id + '_close_btn')) {
				$(id + '_close_btn').onclick = closeBtnHandler ? closeBtnHandler : this.hide.createDelegate(this);
				$(id + '_close_btn').style.display = closeBtnVisible ? 'inline' : 'none';
			}
			if($(id + '_next_btn')) {
				$(id + '_next_btn').onclick = nextBtnHandler ? nextBtnHandler : this.hide.createDelegate(this);
				$(id + '_next_btn').style.display = nextBtnVisible ? 'inline' : 'none';
			}
            if (firstShow && center){
				if (xPos == null || yPos == null) {
					x = (Ext.getViewWidth(true) - width) / 2;
					y = ((Ext.getViewHeight(false) - height) / 2) + Ext.getScrollTop() ;
				}
                el.style.left = x + 'px';
                el.style.top = y + 'px';
                left = el.style.left;                          
                top = el.style.top;
            } else {
                el.style.left = left;
                el.style.top = top;             
            }			
			
			var c = this.getContents();
			var header = this.getHeader();		
			
            el.style.zIndex = topZindex;
            el.style.display = "block";			
			
            this.firstShow = false;
		},
		
		showMask : function() {
			if(!mask || !$(id + '_mask')) {
				mask = document.createElement('div');
				mask.id = id + '_mask';
				mask.style.position = 'absolute';
				mask.style.top = '0';
				mask.style.left = '0';
				mask.style.overflow = 'hidden';
				mask.style.zIndex = topZindex - 1;
				mask.style.zoom = '1';
				mask.style.backgroundColor = '#CCC';
				mask.style.filter = 'Alpha(opacity=50)';
				mask.style.opacity =  '0.5';
				mask.style.MozOpacity = '0.5';
				document.body.appendChild(mask);
			}
			mask.style.width = Ext.getViewWidth(true) + 'px';
			mask.style.height = Ext.getViewHeight(true) + 'px';
			mask.style.display = 'block';			
			if(Ext.isIE && !Ext.isIE7) {
				this.showHideCombos(false);
			}
			var obj = document.getElementById('flashDiagramDiv');
			if(obj) {
				obj.style.visibility = 'hidden';
			}
		},
		
		hideMask : function() {
			if(mask) {
				mask.style.display = 'none';
				if(Ext.isIE && !Ext.isIE7) {
					this.showHideCombos(true);
				}
			}
			var obj = document.getElementById('flashDiagramDiv');
			if(obj) {
				obj.style.visibility = 'visible';
			}
		},
		
        getIframe : function () {
            if (!iframe) {
				iframe = $(id + '_iframe');
			}
            return iframe;
        },
		
        getObj : function (width, height) {
            if (!obj) {
				obj = this.$(id);
				if(!obj) {
					var el = document.createElement('div');
					el.id = id;
					el.style.position = 'absolute';
					el.style.left = '0';
					el.style.top = '0';
					el.style.display = 'none';
					document.body.appendChild(el);					
					obj = this.$(id);
					obj.innerHTML = this.getInnerHTML(id, width, height);
				}
			}			
            return obj;
        },

        getHeader : function () {
            if (!header && this.$(id + '_header')) {				
				header = this.$(id + '_header');
				header.onmousedown = this.mouseDown.createDelegate(this);
				header.onmouseup = this.mouseUp.createDelegate(this);
				if(this.$(id + '_closer')) {
					this.$(id + '_closer').onclick = this.hide.createDelegate(this);
				}
			}
            return header;
        },
           
		getContents : function () {
		    if (!contents) {
				contents = this.$(id + '_cont');
			}
			return contents;
		},
		   
        syncIframe : function () {
             var _obj = this.getObj();
			 var c = this.getContents();
			 var header = this.getHeader();
        },
                      
        hide : function () {
            this.getObj().style.display = 'none';
			this.hideMask();			
        },
		
		showHideCombos : function(show) {
			var el = document.getElementsByTagName('select');			
			for(var i = 0, len = el.length; i < len; i++) {
				el[i].style.visibility = show ? 'visible' : 'hidden';				
			}
		},
		
		getHTML : function(id) {
			return '<div id="' + id + '" style="position:absolute;left:0;top:0;display:none;"></div>';
		},
		
		getInnerHTML : function(id, width, height) {
			if(!width) {
				width = 250;
			}
			return '<table id="' + id + '_cont" width="' + width + '" height="' + height + '" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:12px;">' +
				'<tr>' + 
		            '<td width="5"><img src="/images/box_csides.gif" alt="" width="5" height="34" /></td>' +
		            '<td width="290" id="' + id + '_title" style="height:34px;line-height:34px;vertical-align:middle;font-size:14px;color:#333333;background:url(/images/box_ctop.gif) repeat-x top left;padding:0 12px;">&nbsp;</td>' +
		            '<td width="5"><img src="/images/box_csides.gif" alt="" width="5" height="34" /></td>' +
	            '</tr>' +
				'<tr>' +
					'<td bgcolor="#f8dede">&nbsp;</td>' +
					'<td class="boxcontent" bgcolor="#ffffff">' + 
						'<table border="0" cellspacing="0" cellpadding="0" id="simplebox">' +
							'<tr><td>' +
								'<table border="0" cellspacing="0" cellpadding="0" id="regtable">' +								
									'<tr><td td id="' + id + '_msg"></td></tr>' +
								'</table>' +
								'<table width="' + width + '" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:12px;">' +
										'<tr>' +
											'<td align="left" style="padding-left:20px;"></td>' +
											'<td align="right">' +
											'<img id="' + id + '_yes_btn" src="/MLSupport/' + lngDir + '/button/btn_cok.gif" style="cursor:pointer" border="0">' + 
											'<img id="' + id + '_close_btn" src="/MLSupport/' + lngDir + '/button/btn_cclose.gif" style="cursor:pointer" border="0">' +
											'<img id="' + id + '_next_btn" src="/MLSupport/' + lngDir + '/button/btn_cnext.gif" style="cursor:pointer" border="0"></td>' +
										'</tr>' +
								'</table>' +				
							'</td></tr>' +
						'</table>' +
					'</td>' +
					'<td bgcolor="#f8dede">&nbsp;</td>' +
				'</tr>' +
				'<tr>' +
					'<td style="background:url(/images/box_cbottom.gif) repeat-x top left;" colspan="3"><img src="/images/spacer.gif" alt="" width="1" height="6" /></td>'
				'</tr>' +
			'</table>';						
		}
	}
}
