/* $Id$ */

//***************************************************************************************************
// JavaScript Version 1.2 
// © Yellowspace smart solutions
// includes generell independent functions 
//***************************************************************************************************

/*******************************************************
 *******************************************************
 
	STARTUP
 
 *******************************************************
 */ function ____StartUp________() {} /*
 *******************************************************/	

//alert('generic_lib is loading');

var page_loaded = 'no';
OnLoadFunctions = new Array();
function OnLoadExec() {
	for (cux=0;cux< OnLoadFunctions.length;cux++) {
		my_eval = OnLoadFunctions[cux];
		eval(my_eval);
		
	}
	page_loaded = "yes";
}




/*****************************************************
*/ function __P___Language() {}
/******************************************************/
 
if(typeof lang == 'undefined') lang = 'de';
lang_show_failed_keys = '';

if(typeof INT != 'object') INT = new Object();
/*INT['firstname'] = new Object();
INT['firstname']['de'] = 'Vorname';
INT['firstname']['en'] = 'First Name';*/

function $L(key,o) {
	
	this.lang = lang;
	this.def_lang = 'en';
	
	if(!INT[key]) {
		return key+lang_show_failed_keys;
	} else if(INT[key]) { // key found
		
		var found_str = '';
		
		if(INT[key][this.lang]) found_str = INT[key][this.lang];
		else if(INT[key][this.def_lang]) found_str = INT[key][this.def_lang];
		else found_str = key+lang_show_failed_keys;
		
		if(typeof o == 'object') {
			var oidx=0;
			for(okey in o) {
				found_str = str_replace('$$'+okey,o[okey], found_str);
				oidx++;
			}
		} 

		return found_str;
		
	} else return key+lang_show_failed_keys;
}


/*******************************************************
 *******************************************************
 
	Ajax
 
 *******************************************************
 */ function ____AJAX________() {} /*
 *******************************************************/	

/*
    * 0: The request is uninitialized (before you've called open()).
    * 1: The request is set up, but not sent (before you've called send()).
    * 2: The request was sent and is in process (you can usually get content headers from the response at this point).
    * 3: The request is in process; often some partial data is available from the response, but the server isn't finished with its response.
    * 4: The response is complete; you can get the server's response and use it.

*/

function ajax() {
	
	//---------------------------------------------------------------------------------------
	this.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);
	}
	
	//---------------------------------------------------------------------------------------
	this.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');
			//this.transport.setRequestHeader('Content-type', 'multipart/form-data');
			if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
		}
		this.transport.send(this.postBody);
	}
	
	//---------------------------------------------------------------------------------------
	this.onStateChange = function(){
		if (this.transport.readyState == 4 && this.transport.status == 200) {
			if (this.onComplete) 
				setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10);//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(){};
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.getTransport = function() {
		if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
		else if (window.XMLHttpRequest) return new XMLHttpRequest();
		else return false;
	}
}



function Respond(documentFragment) { 
	
	this.fragment = documentFragment;
	
	//---------------------------------------------------------------------------------------
	// interpretResponse can be called by the documentFragment response
	// use: <evaluatetype type="this.updateFields"> as XML-wrapper
	// the function in type will be called. it gets the documentFragment evaluatetype
	this.interpretResponse = function() {
		this.response = this.fragment.getElementsByTagName("response")[0];
		
		this.evalutions = this.response.getElementsByTagName("evaluatetype");
		evl = this.evalutions.length;
		
		for(evlidx=0; evlidx<evl; evlidx++) {
			
			att_response = this.parseAttributes(this.evalutions[evlidx]);

			if(att_response
			&& att_response['type']
			&& att_response['type'].indexOf("(") >= 0) {
				try { 
					eval(att_response['type']);
				} catch(error) {
					alert("class Respond - evaluation of "+att_response['type']+" failed, because: "+error);
				}			
			} else if(att_response
			&& att_response['type']) {
				e = att_response['type']+'(this.evalutions[evlidx])'; //'this.'+
				//return 
				try { 
					eval(e);
				} catch(error) {
					alert("class Respond - evaluation of "+att_response['type']+" failed, because: "+error);
				}
			} else {
				alert("no type of response specified");
			}
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.updateFields = function(node) {
		
	
		this.fields = node.getElementsByTagName("fields");
		var fl = this.fields.length;
		
		fields = new Array();
		
		for(i=0;i<fl;i++) {
			

			var nodes = this.fields[i].childNodes;
			nl = nodes.length;
			
			//for(var ch in nodes) { // go through childs of fields 
			for(var fidx=0;fidx<nl;fidx++) {
				if(!nodes[fidx].nodeType) continue;
				switch(nodes[fidx].nodeType) {
					case  1:

						update_field = false;
						tagName = nodes[fidx].tagName;
						fields[i] = new Array();
						fields[i][tagName] = new Array();
						fields[i][tagName]['name'] = tagName;
						fields[i][tagName]['attr'] = this.parseAttributes(nodes[fidx]);

						// get element
						if(fields[i][tagName]['attr']
						&& (fields[i][tagName]['attr']['id'])
						&& (document.getElementById(fields[i][tagName]['attr']['id']))) {
							el = document.getElementById(fields[i][tagName]['attr']['id']);
							fields[i][tagName]['el'] = el;
							update_field = true;
						}
						
						// get value
						if(nodes[fidx].firstChild // of data
						//&& (nodes[fidx].firstChild.nodeType == 3)
						&& (nodes[fidx].firstChild.data)
						&& (nodes[fidx].firstChild.data.length>0)) { // text
							fields[i][tagName]['value'] = nodes[fidx].firstChild.data; //unescape(nodes[fidx].firstChild.data);
						} else if(fields[i][tagName]['attr']  // of attribute value
						&& (fields[i][tagName]['attr']['value'])
						&& (fields[i][tagName]['attr']['value'].length > 0)) {
							fields[i][tagName]['value'] = fields[i][tagName]['attr']['value'];
						} else {
							fields[i][tagName]['value'] = '';
						}
						
						if(update_field) this.updateField(fields[i][tagName]);
						
						break;
				}
			}
		
		}
		//return fields;
	}
	
	this.updateField = function(field) {	
		
		// set atrributes
		for(key in field['attr']) {
			field['el'].setAttribute(key, field['attr'][key]);
		}
		
		// get nodes tagName
		switch(field['el'].tagName) {
			default:
				field['el'].innerHTML = field['value'];
			break;
		}
		
	}
	
	//---------------------------------------------------------------------------------------
	this.parseAttributes = function(node) {

		var parsedAttributeSet = new Array();
		var atts = node.attributes;
		for(var i=0; i<atts.length; i++) {
			var attnode = atts.item(i);
			if(!attnode){ continue; }
			if(	(typeof attnode == "object")&&
				(typeof attnode.nodeValue == 'undefined')||
				(attnode.nodeValue == null)||
				(attnode.nodeValue == '')) { 
				continue; 
			}

			parsedAttributeSet[attnode.nodeName] = attnode.nodeValue;
		}
		return parsedAttributeSet;
	}
}


/*******************************************************
 *******************************************************
 
	Globals
 
 *******************************************************
 */ function ____GLOBALS________() {} /*
 *******************************************************/	

//---------------------------------------------------------------------------------------
Loader = function() {
 	
 	// this will just work while page is loaded - not afterwards
	this.require = function(libraryName) {
		// inserting via DOM fails in Safari 2.0, so brute force approach
		document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
	}
  
	this.load = function() {
		$A(document.getElementsByTagName("script")).findAll( function(s) {
		  return (s.src && s.src.match(/load_libs\.js(\?.*)?$/))
		}).each( function(s) {
		  var path = s.src.replace(/load_libs\.js(\?.*)?$/,'');
		  var includes = s.src.match(/\?.*load=([a-z,]*)/);
		  (includes ? includes[1] : 'dom,effect,editor,debug,ajax').split(',').each(
		   function(include) { this.require(path+include+'.js') });
		});
	}

	this.include_once = function(libraryName) {
		scripts = document.getElementsByTagName("script");
		var loaded = false;
		for(i=0;i<scripts.length;i++) {
			if(scripts[i].src.indexOf(libraryName) >= 0) loaded = true;
		}
		
		if(!loaded) this.require(libraryName);
		return loaded;
	}
  
}



//---------------------------------------------------------------------------------------
Function.prototype.bind = function(object) {
  var __method = this;
  return function() {
  	// apply:
  	// 1 parameter = object auf das die function angewendet wird
  	// 2 parameter = object mit argumenten oder ein array mit argumenten
	return __method.apply(object, arguments);
  }
}
//---------------------------------------------------------------------------------------
Function.prototype.bindArguments = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}
//---------------------------------------------------------------------------------------
Function.prototype.bindAsEventListener = function(object) {
  var __method = this;
  return function(event) {
    return __method.call(object, event || window.event);
  }
}
//---------------------------------------------------------------------------------------
//execMethod(DOM,'test','PAGE',{a:'huhu',b:'huhu1'});
function execMethod(classname,method,obj,args) {
	// create object and initilize class
	if(typeof obj != 'object') {
		try {
			if(!typeof eval(obj) == 'object') obj = new classname();
		} catch(e) {
			obj = new classname();
		}
	}
	setTimeout(function(){  obj[method](args);   }.bind(obj), 10);
}
//---------------------------------------------------------------------------------------
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
	var element = arguments[i];
	if (typeof element == 'string')
	  element = document.getElementById(element);

	if (arguments.length == 1) 
	  return element;

	elements.push(element);
  }

  return elements;
}
//---------------------------------------------------------------------------------------
var $A = Array.from = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}

//---------------------------------------------------------------------------------------
document.getElementsByTagAndClassName = function(tagName, className) {
  if ( tagName == null )
     tagName = '*';

  var children = document.getElementsByTagName(tagName) || document.all;
  var elements = new Array();

  if ( className == null )
    return children;

  for (var i = 0; i < children.length; i++) {
    var child = children[i];
    var classNames = child.className.split(' ');
    for (var j = 0; j < classNames.length; j++) {
      if (classNames[j] == className) {
        elements.push(child);
        break;
      }
    }
  }

  return elements;
}

//---------------------------------------------------------------------------------------
function CookieManager(cookiename) { // safari doesn´t like to call this class Cookie...

	this.name = cookiename;

	//---------------------------------------------------------------------------------------
	this.save = function(cookiename,value,days_valid,path,domain,secure) {

		if (!cookiename) {
			cookiename = this.name;
		}
		
		var d = new Date();
		var d = new Date(d.getTime() +1000*60*60*24*days_valid); 
		//document.cookie = cookiename + '=' + escape(value) + ";expires=" + d.toGMTString()+';';

		document.cookie = cookiename + "=" + escape(value) +
			(";expires=" + d.toGMTString()) +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");

	}

	//---------------------------------------------------------------------------------------
	this.getValue = function(cookiename) {
		
		//Get cookie code by Shelley Powers
		
		if (!cookiename) {
			cookiename = this.name;
		}
		
		var search = cookiename + "=";
		
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			// if cookie exists
			if (offset != -1) { 
				offset += search.length;
				// set index of beginning of value
				end = document.cookie.indexOf(";", offset);
				// set index of end of cookie value
				if (end == -1) end = document.cookie.length;
				return parseInt(unescape(document.cookie.substring(offset, end)));
			}
		}
		return null;
	}	

	this.del = function(cookiename,path,domain) {

		if (!cookiename) {
			cookiename = this.name;
		}
		
		if(this.getValue(cookiename)) {
			document.cookie = cookiename + "=" +
			  ((path) ? "; path=" + path : "") +
			  ((domain) ? "; domain=" + domain : "") +
			  "; expires=Thu, 01-Jan-70 00:00:01 GMT";		
		}
		
	}

}

function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

// Modified from Jesse Chisholm or Scott Andrew Lepera ?
// (found at both www.dansteinman.com/dynapi/ and www.scottandrew.com/junkyard/js/)
function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}

// from Bill Dortch's Cookie Functions (hidaho.com) 
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}



/*******************************************************
 *******************************************************
 
	FORM
 
 *******************************************************
 */ function ____Form________() {} /*
 *******************************************************/	

// <form onkeypress="check4Return(event)" > // <-- Important, use onkeypress!
function check4Return(event) {
	
   	if(typeof event == 'undefined' || !event) return true;

    var obj = event.target || event.srcElement;
     
    if (obj.type == "submit")
        return true;
        
    if ( obj.type != "textarea" && event && event.keyCode == 13 ){
        
        if ( event.preventDefault )
            event.preventDefault()
        else event.returnValue = false;
    };
    
    return true;
}; 


function URLEncode(clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ') {
        output += '+';
      } else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        if(charCode < 16 && hexVal.length == 1) hexVal = '0'+hexVal;
        output += '%' + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}


function URLDecode(encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}


function str_pad (input, pad_length, pad_string, pad_type) {
  input = String (input);
  pad_string = pad_string != null ? pad_string : " ";
  if (pad_string.length > 0)
  {
    var padi = 0;
    pad_type = pad_type != null ? pad_type : "STR_PAD_RIGHT";
    pad_length = parseInt (pad_length);
    switch (pad_type)
    {
      case "STR_PAD_BOTH":
        input = str_pad (input
                       , input.length + Math.ceil ((pad_length - input.length) / 2.0)
                       , pad_string, "STR_PAD_RIGHT");
     // break;  // kein break!
      case "STR_PAD_LEFT":
        var buffer = "";
        for (var i = 0, z = pad_length - input.length; i < z; ++i)
        {
          buffer += pad_string.charAt(padi); // [padi] IE 6.x bug
          if (++padi == pad_string.length)
            padi = 0;
        }
        input = buffer + input;
        break;
      default:
        for (var i = 0, z = pad_length - input.length; i < z; ++i)
        {
          input += pad_string.charAt(padi);
          if (++padi == pad_string.length)
            padi = 0;
        }
        break;
    }
  }
  return input;
}

function str_replace (search, replace, subject) {
  var result = "";
  var  oldi = 0;
  for (i = subject.indexOf (search)
     ; i > -1
     ; i = subject.indexOf (search, i))
  {
    result += subject.substring (oldi, i);
    result += replace;
    i += search.length;
    oldi = i;
  }
  return result + subject.substring (oldi, subject.length);
}

function number_format (number, decimals, dec_point, thousands_sep) {
  var exponent = "";
  var numberstr = number.toString ();
  var eindex = numberstr.indexOf ("e");
  if (eindex > -1)
  {
    exponent = numberstr.substring (eindex);
    number = parseFloat (numberstr.substring (0, eindex));
  }
  
  if (decimals != null)
  {
    var temp = Math.pow (10, decimals);
    number = Math.round (number * temp) / temp;
  }
  var sign = number < 0 ? "-" : "";
  var integer = (number > 0 ? 
      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
  
  var fractional = number.toString ().substring (integer.length + sign.length);
  dec_point = dec_point != null ? dec_point : ".";
  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
               (dec_point + fractional.substring (1)) : "";
  if (decimals != null && decimals > 0)
  {
    for (i = fractional.length - 1, z = decimals; i < z; ++i)
      fractional += "0";
  }
  
  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
                  thousands_sep : null;
  if (thousands_sep != null && thousands_sep != "")
  {
	for (i = integer.length - 3; i > 0; i -= 3)
      integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
  }
  
  return sign + integer + fractional + exponent;
}

function kaufm(x) {
  var k = (Math.round(x * 100) / 100).toString();
  k += (k.indexOf('.') == -1)? '.00' : '00';
  var p = k.indexOf('.');
  return k.substring(0, p) + ',' + k.substring(p+1, p+3);
}

function runde(x, n) {
  if (n < 1 || n > 14) return false;
  var e = Math.pow(10, n);
  var k = (Math.round(x * e) / e).toString();
  if (k.indexOf('.') == -1) k += '.';
  k += e.toString().substring(1);
  return k.substring(0, k.indexOf('.') + n+1);
}

function getRandom(min, max) {
    return Math.floor(min+(max-min+1)*(Math.random()));
}

function hideFormfields() {
	 for(i=0; i<document.forms[0].elements.length; i++) {
  		switch(document.forms[0].elements[i].type) {
			case"select-one":
			case"radio":
			case"checkbox":
			case"text":
			case"password":
			case"textarea":
			default:
				document.forms[0].elements[i].style.visibility = 'hidden';
				//document.forms[0].elements[i].style.display = 'none';
				break;
  		}
	}
}

function hideLayers(layerid) {
	
	if(!document.getElementsByTagName) return;
	var layers = document.getElementsByTagName('div');
	for(i=0; i<layers.length; i++) {
		if(layerid) {
			if(layers[i].id != layerid) layers[i].style.display = 'none';
		} else layers[i].style.display = 'none';
	}
}

running_action = false;
function donotInterruptSubmits() {
	if(!document.getElementById('freelayer')) return;
	running_action = true;
	window.scrollTo(0,0);

	//hideLoginfields();

	switch (SmartAgent){
	case "Netscape4":
		break;
	case "Netscape6":
	case "MSIE5":
	case "Khtml":
	case "Opera5":
		hideLayers('freelayer');
	break;
	case "MSIE5.5":
	case "MSIE6":
		hideFormfields();
	break;
	}
	
	var img_left = 45;
	var img_top = 35;	
	loading_text = '<img style="width:28px;height:28px;margin:'+img_top+'px 0px 0px '+img_left+'px" src="/images/interface/spinning_wheel.gif">';
	WriteToLayer('freelayer',loading_text);
	
	el_l = document.getElementById('freelayer');
	el_l.style.backgroundColor = '#FAFAFA';
	//el_l.style.backgroundColor = '#ffffff';
	el_l.style.width = '5000px';
	el_l.style.height = '5000px';
	el_l.style.zIndex = 300;
	ManageLayer(el_l.id,true,-20,-20,false,false,300);	
}


function setActionAndSubmit(my_action,my_target) {

	if(running_action == true) return;
	
	var r_target = document.forms[0].target;
	var r_action = document.forms[0].action;
	
	document.forms[0].target = my_target;
	document.forms[0].action = my_action;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
	
	if(my_target != '_self') running_action = false;
	document.forms[0].target = r_target;
	document.forms[0].action = r_action;	
}

function setHidden(hidden_value,hidden_id) {
	document.getElementById(hidden_id).value = hidden_value;
}

function setHiddenAndSubmit(hidden_value,hidden_id) {
	if(running_action == true) return;
	document.getElementById(hidden_id).value = hidden_value;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
}

function justSubmit() {
	if(running_action == true) return;
	document.forms[0].onsubmit(); // workaround browser bugs.
	document.forms[0].submit();
}

function confirmHidden(hidden_value,hidden_id,question) {
	if (confirm(question)) {
		document.getElementById(hidden_id).value = hidden_value;
	} else { 
		if(document.getElementById('triggers')) document.getElementById('triggers').value = ''; // unset triggers
		return false;
	}
}

function confirmOperation(operation,question) {
	if (confirm(question)) {
		eval(operation);
	} else return false;
}

function justConfirm(question) {
	if (confirm(question)) {
		return true;
	} else return false;
}


function confirmHiddenAndSubmit(hidden_value,hidden_id,question) {
	if(running_action == true) return;
	if (confirm(question)) {
		document.getElementById(hidden_id).value = hidden_value;
		document.forms[0].onsubmit(); // workaround browser bugs.
		document.forms[0].submit();	
	} else { 
		if(document.getElementById('triggers')) document.getElementById('triggers').value = ''; // unset triggers
		return false;
	}
}


/*******************************************************
 *******************************************************
 
	EVENTS
 
 *******************************************************
 */ function ____Events________() {} /*
 *******************************************************/	


function addSmartEvent(el,evname,func) {

	if (el.attachEvent) { // IE
		el.attachEvent("on" + evname, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	} else {
		el["on" + evname] = func;
	}
}

function removeSmartEvent(el,evname,func) {

	if (el.detachEvent) { // IE
		el.detachEvent("on" + evname, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(evname, func, true);
	} else {
		el["on" + evname] = null;
	}
}

/*******************************************************
 *******************************************************
 
	Validation
 
 *******************************************************
 */ function ____Events________() {} /*
 *******************************************************/	


function validateEmail( strValue) {
	/************************************************
	DESCRIPTION: Validates that a string contains a
	  valid email pattern.
	
	 PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	
	REMARKS: Accounts for email with country appended
	  does not validate that email contains valid URL
	  type (.com, .gov, etc.) or valid country suffix.
	*************************************************/
	var objRegExp  = /(^[a-z]([a-z_\.]*)@([a-z_\.]*)([.][a-z]{3})$)|(^[a-z]([a-z_\.]*)@([a-z_\.]*)(\.[a-z]{3})(\.[a-z]{2})*$)/i;
	//emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
	//phoneRe = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/
                  	
	  //check for valid email
	  return objRegExp.test(strValue);
}

function validateUSPhone( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains valid
	  US phone pattern.
	  Ex. (999) 999-9999 or (999)999-9999
	
	PARAMETERS:
	   strValue - String to be tested for validity
	
	RETURNS:
	   True if valid, otherwise false.
	*************************************************/
	  var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
	
	  //check for valid us phone with or without space between
	  //area code
	  return objRegExp.test(strValue);
}

function  validateNumeric( strValue ) {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains only valid numbers.
	
	PARAMETERS:
	strValue - String to be tested for validity
	
	RETURNS:
	True if valid, otherwise false.
	******************************************************************/
	var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
	
	//check for numeric characters
	return objRegExp.test(strValue);
}

function validateInteger( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string contains only
	valid integer number.
	
	PARAMETERS:
	strValue - String to be tested for validity
	
	RETURNS:
	True if valid, otherwise false.
	**************************************************/
	var objRegExp  = /(^-?\d\d*$)/;
	
	//check for integer characters
	return objRegExp.test(strValue);
}

function validateNotEmpty( strValue ) {
	/************************************************
	DESCRIPTION: Validates that a string is not all
	blank (whitespace) characters.
	
	PARAMETERS:
	strValue - String to be tested for validity
	
	RETURNS:
	True if valid, otherwise false.
	*************************************************/
	var strTemp = strValue;
	strTemp = trimAll(strTemp);
	if(strTemp.length > 0){
	 return true;
	}
	return false;
}


function validateUSDate( strValue ) {
/************************************************
DESCRIPTION: Validates that a string contains only
    valid dates with 2 digit month, 2 digit day,
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS:
   Avoids some of the limitations of the Date.parse()
   method such as the date separator character.
*************************************************/
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
 
  //check to see if in correct format
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var strSeparator = strValue.substring(2,3) 
    var arrayDate = strValue.split(strSeparator); 
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, 
                        '04' : 30,'05' : 31,
                        '06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,
                        '10' : 31,'11' : 30,'12' : 31}
    var intDay = parseInt(arrayDate[1],10); 

    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    }
    
    //check for February (bugfix 20050322)
    //bugfix  for parseInt kevin
    //bugfix  biss year  O.Jp Voutat
    var intMonth = parseInt(arrayDate[0],10);
    if (intMonth == 2) { 
       var intYear = parseInt(arrayDate[2]);
       if (intDay > 0 && intDay < 29) {
           return true;
       }
       else if (intDay == 29) {
         if ((intYear % 4 == 0) && (intYear % 100 != 0) || 
             (intYear % 400 == 0)) {
              // year div by 4 and ((not div by 100) or div by 400) ->ok
             return true;
         }   
       }
    }
  }  
  return false; //any other values, bad date
}

function validateValue( strValue, strMatchPattern ) {
/************************************************
DESCRIPTION: Validates that a string a matches
  a valid regular expression value.

PARAMETERS:
   strValue - String to be tested for validity
   strMatchPattern - String containing a valid
      regular expression match pattern.

RETURNS:
   True if valid, otherwise false.
*************************************************/
var objRegExp = new RegExp( strMatchPattern);

 //check if string matches pattern
 return objRegExp.test(strValue);
}


function rightTrim( strValue ) {
/************************************************
DESCRIPTION: Trims trailing whitespace chars.

PARAMETERS:
   strValue - String to be trimmed.

RETURNS:
   Source string with right whitespaces removed.
*************************************************/
var objRegExp = /^([\w\W]*)(\b\s*)$/;

      if(objRegExp.test(strValue)) {
       //remove trailing a whitespace characters
       strValue = strValue.replace(objRegExp, '$1');
    }
  return strValue;
}

function leftTrim( strValue ) {
/************************************************
DESCRIPTION: Trims leading whitespace chars.

PARAMETERS:
   strValue - String to be trimmed

RETURNS:
   Source string with left whitespaces removed.
*************************************************/
var objRegExp = /^(\s*)(\b[\w\W]*)$/;

      if(objRegExp.test(strValue)) {
       //remove leading a whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function trimAll( strValue ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}


function urlGetExtension(path) {
	var reg = '[\?]'; 
	//var found = path.match(/([\?]+)/); // <-- maybe better...
	var found = path.match(reg);
	if(found) return "&";
	else return "?";
}

function checkUrl(SessionUrl) {

	var urlString;
	var reg = '[&\?]PHPSESSID=[a-z0-9]{32}';
	var found = SessionUrl.match(reg);
	if(found) return SessionUrl; 
	
	var reg = '[\?]';
	var found = SessionUrl.match(reg);
	if(found) wildcard = "&";
	else wildcard = "?";
	
	try {
			var urlString = wildcard + "PHPSESSID="+parent.navigation.useSessionId;
			sessid_found = true; 
	} catch(e) {
		sessid_found = false; 
	}

	if(sessid_found == false && document.forms[0] && document.forms[0].PHPSESSID) var urlString = wildcard + document.forms[0].PHPSESSID.value;
	else return SessionUrl;
	
	var urlString = SessionUrl+urlString;
	return urlString;
}

function FensterOeffnen(path,name,width,height,scroll) {
	path = checkUrl(path);

	window_loaded = false;
	if(parent
	&& (parent.opener)
	&& (parent.opener.FensterOeffnen)
	&& (typeof parent.opener.FensterOeffnen == 'function')) {
		parent.opener.FensterOeffnen(path,name,width,height,scroll);
		window_loaded = true;			
	} else if(opener
	&& (opener.FensterOeffnen)
	&& (typeof opener.FensterOeffnen == 'function')) {
		opener.FensterOeffnen(path,name,width,height,scroll);
		window_loaded = true;		
	}
	
	if(window_loaded === false) {
		mywin = window.open(path,name,"top=20,left=30,width="+width+",height="+height+",dependent=no,scrollbars="+scroll+",status=yes,toolbar=yes,location=yes,menubar=yes,resizable=yes");
		mywin.focus();
	}
}

function openWindow(path,name,width,height,scroll) {
	path = checkUrl(path);
	mywin = window.open(path,name,"top=20,left=30,width="+width+",height="+height+",dependent=no,scrollbars="+scroll+",status=yes,toolbar=yes,location=yes,menubar=yes,resizable=yes");
	mywin.focus();
}


/*******************************************************
 *******************************************************
 
	DOM-ELEMENT-FUNCTIONS
 
 *******************************************************
 */ function ____DOMElementFunctions________() {} /*
	http://developer.apple.com/internet/webcontent/dom2i.html
 *******************************************************/	


function GetWindowWidth() { 
	/*
	VORSICHT: die Abfrage funktioniert nur "onload" der Seite - nicht vorher!
	VORSICHT: Entgegen dem namen der Funktion wird bei Frames die Breite und Hoehe des Frames ausgespuckt.
	*/
	if (self.innerWidth) {
		return self.innerWidth;
	}
	else if(document.documentElement && document.documentElement.clientWidth) {
		return document.documentElement.clientWidth;
	} 
	else if(document.body) {
		return document.body.clientWidth;
	}
	else return 0;
	
}

function GetWindowHeight() { 
	/*
	VORSICHT: die Abfrage funktioniert nur "onload" der Seite - nicht vorher!
	VORSICHT: Entgegen dem namen der Funktion wird bei Frames die Breite und Hoehe des Frames ausgespuckt.
	*/
	if(self.innerHeight) {
		return self.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight) {
		return document.documentElement.clientHeight;
	} 
	else if(document.body) {
		return document.body.clientHeight;
	}
	else return 0;
}


function setStyle(el_id,styleName,styleValue) {
	if(document.getElementById(el_id)) {
		//DebugDump(document.getElementById(el_id).style,'el_style');
		document.getElementById(el_id).style[styleName] = styleValue;
	} else return false;
}

function createNewElement(elRef,eltagName) {
	return elRef.createElement(eltagName);
}

function setElementAttribute(el,attrName,attrValue,force) {
	if(force !== false) el.setAttribute(attrName,attrValue);
	else {
		
		// if force = false, replace attirbute only if it does not exist
		
		if (el.hasAttribute(attrName) === false) {
			el.setAttribute(attrName,attrValue);
		}
	}
}

var el_updated = false;
function updateClassName(el,par) {
	if(el == el_updated) return false;
	if(el.className.length>0) { 
		if(el_updated)  el_updated.className = updatedClassName;
		updatedClassName = el.className;
		el.className = el.className+par;
		el_updated = el;
	} else {
		updateClassName(el.parentNode,par)
	}
}

function FindElementsByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = FindElementsByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }
  return null;
}

function FindElementsByTagName(el, tagName) {

  var i, tmp;

  if (el.tagName == tagName)
    return el;

  // Search for a descendant element assigned the given tagname.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = FindElementsByTagName(el.childNodes[i], tagName);
    if (tmp != null)
      return tmp;
  }
  return null;
}

function getContainerWith(node, tagName, className) {

  	// Starting with the given node, find the nearest containing element
	// with the specified tag name and style class.

	while (node != null) {
		if (node.tagName != null && node.tagName == tagName && hasClassName(node, className))
		return node;
		node = node.parentNode;
	}
	
	return node;
}

function getContainerWithTag(node, tagName) {

  	// Starting with the given node, find the nearest containing element
	// with the specified tag name and style class.

	while (node != null) {
		if (node.tagName != null && node.tagName == tagName)
		return node;
		node = node.parentNode;
	}
	
	return node;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}


function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}


function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}

function winFindByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = winFindByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }

  return null;
}

function ShowAlert(MyAlert,AlertKind) {
	AlertKind ? AlertKind = AlertKind + " " : AlertKind = "";
	alert(AlertKind+MyAlert);
}


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


var Try = {
  these: function() {
    var returnValue;

    for (var i = 0; i < arguments.length; i++) {
      var lambda = arguments[i];
      try {
        returnValue = lambda();
        break;
      } catch (e) {}
    }

    return returnValue;
  }
}

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

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

Object.inspect = function(object) {
  try {
    if (object == undefined) return 'undefined';
    if (object == null) return 'null';
    return object.inspect ? object.inspect() : object.toString();
  } catch (e) {
    if (e instanceof RangeError) return '...';
    throw e;
  }
}

//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
/*
Object.extend(String.prototype, {
  stripTags: function() {
    return this.replace(/<\/?[^>]+>/gi, '');
  },

  stripScripts: function() {
    return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
  },

  extractScripts: function() {
    var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
    var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
    return (this.match(matchAll) || []).map(function(scriptTag) {
      return (scriptTag.match(matchOne) || ['', ''])[1];
    });
  },

  evalScripts: function() {
    return this.extractScripts().map(eval);
  },

  escapeHTML: function() {
    var div = document.createElement('div');
    var text = document.createTextNode(this);
    div.appendChild(text);
    return div.innerHTML;
  },

  unescapeHTML: function() {
    var div = document.createElement('div');
    div.innerHTML = this.stripTags();
    return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
  },

  toQueryParams: function() {
    var pairs = this.match(/^\??(.*)$/)[1].split('&');
    return pairs.inject({}, function(params, pairString) {
      var pair = pairString.split('=');
      params[pair[0]] = pair[1];
      return params;
    });
  },

  toArray: function() {
    return this.split('');
  },

  camelize: function() {
    var oStringList = this.split('-');
    if (oStringList.length == 1) return oStringList[0];

    var camelizedString = this.indexOf('-') == 0
      ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
      : oStringList[0];

    for (var i = 1, len = oStringList.length; i < len; i++) {
      var s = oStringList[i];
      camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
    }

    return camelizedString;
  },

  inspect: function() {
    return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
  }
});
*/
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
/*
Object.extend(Array.prototype, {
  _each: function(iterator) {
    for (var i = 0; i < this.length; i++)
      iterator(this[i]);
  },

  clear: function() {
    this.length = 0;
    return this;
  },

  first: function() {
    return this[0];
  },

  last: function() {
    return this[this.length - 1];
  },

  compact: function() {
    return this.select(function(value) {
      return value != undefined || value != null;
    });
  },

  flatten: function() {
    return this.inject([], function(array, value) {
      return array.concat(value.constructor == Array ?
        value.flatten() : [value]);
    });
  },

  without: function() {
    var values = $A(arguments);
    return this.select(function(value) {
      return !values.include(value);
    });
  },

  indexOf: function(object) {
    for (var i = 0; i < this.length; i++)
      if (this[i] == object) return i;
    return -1;
  },

  reverse: function(inline) {
    return (inline !== false ? this : this.toArray())._reverse();
  },

  shift: function() {
    var result = this[0];
    for (var i = 0; i < this.length - 1; i++)
      this[i] = this[i + 1];
    this.length--;
    return result;
  },

  inspect: function() {
    return '[' + this.map(Object.inspect).join(', ') + ']';
  }
});
*/
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function DOM() {
	
	//---------------------------------------------------------------------------------------
	this.init = function() {
		
	}
	
	//---------------------------------------------------------------------------------------
	this.toggle = function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			this[this.visible(element) ? 'hide' : 'show'](element);
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.hide = function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = 'none';
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.show = function() {
		for (var i = 0; i < arguments.length; i++) {
			var element = $(arguments[i]);
			element.style.display = '';
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.getContainerByTagAndClass = function(node, tagName, className) {

		// Starting with the given node, find the nearest containing element
		// with the specified tag name and style class.
	
		while (node != null) {
			if (node 
			&& node.nodeType
			&& node.nodeType == 1
			&& node.tagName 
			&& node.tagName != null 
			&& node.tagName == tagName 
			&& node.className
			&& this.hasClassName(node, className))
				return node;
			
			/*if(node.parentNode
			&& node.parentNode.nodeType
			&& node.parentNode.nodeType == 1) node = node.parentNode;
			else node = null;*/
			
			node = node.parentNode;
		}
		
		return node;
	}

	//---------------------------------------------------------------------------------------
	this.getContainerByTag = function(node, tagName) {
	
		// Starting with the given node, find the nearest containing element
		// with the specified tag name and style class.
	
		while (node != null) {
			if (node.tagName != null && node.tagName == tagName)
			return node;
			node = node.parentNode;
		}
		
		return node;
	}
	
	//---------------------------------------------------------------------------------------
	this.getContainer = function(node, parent) {
		// Starting with the given node, find the nearest containing element
		// with the specified tag name and style class.
	
		while (node != null) {
			if (node == parent) return node;
			node = node.parentNode;
		}
		
		return node;
		
	}
	
	//---------------------------------------------------------------------------------------
	this.hasClassName = function(node, name) {

		var i, list;
		if(!node.className) return false;
		// Return true if the given element currently has the given class
		// name.
		
		list = node.className.split(" ");
		for (i = 0; i < list.length; i++) {
			if (list[i] == name) return true;
		}
		return false;
	}

	//---------------------------------------------------------------------------------------
	this.removeClassName = function(el, name) {
	
		var i, curList, newList;
		
		if (el.className == null) 	return;
		
		// Remove the given class name from the element's className property.
		
		newList = new Array();
		curList = el.className.split(" ");
		for (i = 0; i < curList.length; i++)
			if (curList[i] != name)
				  newList.push(curList[i]);
		
		el.className = newList.join(" ");
	}
	
	//---------------------------------------------------------------------------------------
	this.removeChildren = function(node){
		var count = node.childNodes.length;
		while(node.hasChildNodes()){ node.removeChild(node.firstChild); }
		return count;
	}
	
	//---------------------------------------------------------------------------------------
	this.getHeight = function(element) {
		element = $(element);
		return element.offsetHeight;
	}
	//---------------------------------------------------------------------------------------
	this.getWidth = function(element) {
		element = $(element);
		return element.offsetWidth;
	}	
	//---------------------------------------------------------------------------------------
	this.removeNode = function(node){
		if(node && node.parentNode){
			return node.parentNode.removeChild(node);
		}
	}
	//---------------------------------------------------------------------------------------
	this.remove = function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	}
  
	//---------------------------------------------------------------------------------------
	this.empty = function(element) {
		return $(element).innerHTML.match(/^\s*$/);
	}
	//---------------------------------------------------------------------------------------
	this.scrollTo = function(element) {
		element = $(element);
		var x = element.x ? element.x : element.offsetLeft,
			y = element.y ? element.y : element.offsetTop;
		window.scrollTo(x, y);
	}
	
	//---------------------------------------------------------------------------------------
	// PAGEdom.getStyle(element, 'opacity'))  
	this.getStyle = function(element, style) {
		element = $(element);
		var value = element.style[this.camelize(style)];
		if (!value) {
			if (document.defaultView && document.defaultView.getComputedStyle) {
				var css = document.defaultView.getComputedStyle(element, null);
				value = css ? css.getPropertyValue(style) : null;
			} else if (element.currentStyle) {
				value = element.currentStyle[this.camelize(style)];
			}
		}
		
		if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
		if (this.getStyle(element, 'position') == 'static') value = 'auto';
		
		return value == 'auto' ? null : value;
	}
	
	//---------------------------------------------------------------------------------------
	// style = new Array(); style['opacity'] = 0;
	// PAGEdom.getStyle(element, style);
	this.setStyle = function(element, style) {
		element = $(element);
		for (name in style)
			element.style[this.camelize(name)] = style[name];
	}
	
	//---------------------------------------------------------------------------------------
	// PAGEdom.getElementsComputedStyle(this.div, 'height')
	this.getElementsComputedStyle = function(htmlElement, cssProperty, mozillaEquivalentCSS) {
		if ( arguments.length == 2 )
			mozillaEquivalentCSS = cssProperty;
		//DebugDump(document.defaultView,'document.defaultView');
		var el = $(htmlElement);
		if (el.currentStyle)
			return el.currentStyle[cssProperty];
		else
			return document.defaultView.getComputedStyle(el, null).getPropertyValue(mozillaEquivalentCSS);
	}
	
	//---------------------------------------------------------------------------------------
	this.getDimensions = function(element) {
		element = $(element);
		if (this.getStyle(element, 'display') != 'none')
		  return {width: element.offsetWidth, height: element.offsetHeight};
		
		// All *Width and *Height properties give 0 on elements with display none,
		// so enable the element temporarily
		var els = element.style;
		var originalVisibility = els.visibility;
		var originalPosition = els.position;
		els.visibility = 'hidden';
		els.position = 'absolute';
		els.display = '';
		if(element.clientWidth && element.clientWidth > 0) {
			var originalWidth = element.clientWidth; 
			var originalHeight = element.clientHeight;
		} else {
			var originalWidth = element.offsetWidth; 
			var originalHeight = element.offsetHeight;		
		}
		els.display = 'none';
		els.position = originalPosition;
		els.visibility = originalVisibility;
		return {width: originalWidth, height: originalHeight};
	}
	
	//---------------------------------------------------------------------------------------
	this.parseAttributes = function(node) {

		var parsedAttributeSet = new Array();
		var atts = node.attributes;
		for(var i=0; i<atts.length; i++) {
			var attnode = atts.item(i);
			if(!attnode){ continue; }
			if(	(typeof attnode == "object")&&
				(typeof attnode.nodeValue == 'undefined')||
				(attnode.nodeValue == null)||
				(attnode.nodeValue == '')) { 
				continue; 
			}

			parsedAttributeSet[attnode.nodeName] = attnode.nodeValue;
		}
		return parsedAttributeSet;
	}

	//---------------------------------------------------------------------------------------
   this.toViewportPosition = function(element) {
      return this._toAbsolute(element,true);
   }

   this.toDocumentPosition = function(element) {
      return this._toAbsolute(element,false);
   }

   /**
    *  Compute the elements position in terms of the window viewport
    *  so that it can be compared to the position of the mouse (dnd)
    *  This is additions of all the offsetTop,offsetLeft values up the
    *  offsetParent hierarchy, ...taking into account any scrollTop,
    *  scrollLeft values along the way...
    *
    * IE has a bug reporting a correct offsetLeft of elements within a
    * a relatively positioned parent!!!
    **/
   this._toAbsolute = function(element,accountForDocScroll) {

      if ( navigator.userAgent.toLowerCase().indexOf("msie") == -1 )
         return this._toAbsoluteMozilla(element,accountForDocScroll);

      var x = 0;
      var y = 0;
      var parent = element;
      while ( parent ) {

         var borderXOffset = 0;
         var borderYOffset = 0;
         if ( parent != element ) {
            var borderXOffset = parseInt(this.getElementsComputedStyle(parent, "borderLeftWidth" ));
            var borderYOffset = parseInt(this.getElementsComputedStyle(parent, "borderTopWidth" ));
            borderXOffset = isNaN(borderXOffset) ? 0 : borderXOffset;
            borderYOffset = isNaN(borderYOffset) ? 0 : borderYOffset;
         }

         x += parent.offsetLeft - parent.scrollLeft + borderXOffset;
         y += parent.offsetTop - parent.scrollTop + borderYOffset;
         parent = parent.offsetParent;
      }

      if ( accountForDocScroll ) {
         x -= this.docScrollLeft();
         y -= this.docScrollTop();
      }

      return { x:x, y:y };
   }

   /**
    *  Mozilla did not report all of the parents up the hierarchy via the
    *  offsetParent property that IE did.  So for the calculation of the
    *  offsets we use the offsetParent property, but for the calculation of
    *  the scrollTop/scrollLeft adjustments we navigate up via the parentNode
    *  property instead so as to get the scroll offsets...
    *
    **/
   this._toAbsoluteMozilla = function(element,accountForDocScroll) {
      var x = 0;
      var y = 0;
      var parent = element;
      while ( parent ) {
         x += parent.offsetLeft;
         y += parent.offsetTop;
         parent = parent.offsetParent;
      }

      parent = element;
      while ( parent &&
              parent != document.body &&
              parent != document.documentElement ) {
         if ( parent.scrollLeft  )
            x -= parent.scrollLeft;
         if ( parent.scrollTop )
            y -= parent.scrollTop;
         parent = parent.parentNode;
      }

      if ( accountForDocScroll ) {
         x -= this.docScrollLeft();
         y -= this.docScrollTop();
      }

      return { x:x, y:y };
   }
	
	//---------------------------------------------------------------------------------------
   this.docScrollLeft = function() {
      if ( window.pageXOffset )
         return window.pageXOffset;
      else if ( document.documentElement && document.documentElement.scrollLeft )
         return document.documentElement.scrollLeft;
      else if ( document.body )
         return document.body.scrollLeft;
      else
         return 0;
   }

	//---------------------------------------------------------------------------------------
    this.docScrollTop = function() {
      if ( window.pageYOffset ) {
         return window.pageYOffset;
      } else if ( document.documentElement && document.documentElement.scrollTop ) {
         return document.documentElement.scrollTop;
      } else if ( document.body ) {
         //alert(document.body.scrollTop);
        return document.body.scrollTop;
      } else {
         return 0;
   		}
   }


	//---------------------------------------------------------------------------------------
	this.getWindowWidth = function() {
		var w;
		
		if(window
			&& window.innerWidth
			&& window.innerWidth > 0
		) {
			w = window.innerWidth;
		} 
		else if(document
			&& document.documentElement
			&& document.documentElement.clientWidth
			&& document.documentElement.clientWidth > 0
		) {
			w = document.documentElement.clientWidth;
		}
		else if(document
			&& document.body
			&& document.body.clientWidth
			&& document.body.clientWidth > 0
		) {
			w = document.body.clientWidth;
		}

		return w;
	}
	
	//---------------------------------------------------------------------------------------
	this.getWindowHeight = function() {
		var h;
		
		if(window
			&& window.innerHeight
			&& window.innerHeight > 0
		) {
			h = window.innerHeight;
		} 
		else if(document
			&& document.documentElement
			&& document.documentElement.clientHeight
			&& document.documentElement.clientHeight > 0
		) {
			h = document.documentElement.clientHeight;
		} else if(document
			&& document.body
			&& document.body.clientHeight
			&& document.body.clientHeight > 0
		) {
			h = document.body.clientHeight;
		} else if(document
			&& document.body
			&& document.body.offsetHeight
			&& document.body.offsetHeight > 0
		) {
			h = document.body.offsetHeight;
		}
		
		return h;
	}

	this.getPageHeight = function() {
		var x,y;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight;
		var test1 = document.documentElement.scrollHeight;
		var test2 = document.documentElement.offsetHeight;
		
		if(document
			&& document.body
			&& document.body.scrollHeight
			&& document.body.scrollHeight > 0
		) {
			return document.body.scrollHeight;
		} else if(document
			&& document.documentElement
			&& document.documentElement.scrollHeight
			&& document.documentElement.scrollHeight > 0
		) {
			return document.documentElement.scrollHeight;
		}
		
		return 0;
	}
	
	//---------------------------------------------------------------------------------------
	this.stripTags = function(t) {
		return t.replace(/<\/?[^>]+>/gi, '');
	}
	//---------------------------------------------------------------------------------------
	this.escapeHTML = function(t) {
		var div = document.createElement('div');
		var text = document.createTextNode(t);
		div.appendChild(text);
		return div.innerHTML;
	}	
	//---------------------------------------------------------------------------------------
	this.UniqueId = function() {
		  var date = new Date();
		  return date.getMilliseconds();
	}

	//---------------------------------------------------------------------------------------	
	this.camelize = function(str) {
		var oStringList = str.split('-');
		if (oStringList.length == 1) return oStringList[0];
		
		var camelizedString = str.indexOf('-') == 0
		  ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
		  : oStringList[0];
		
		for (var i = 1, len = oStringList.length; i < len; i++) {
		  var s = oStringList[i];
		  camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
		}
		
		return camelizedString;
	}
	//---------------------------------------------------------------------------------------
	this.test = function(a,b) {
		 DebugDump(this,'this');
		 DebugDump(a,'a');
		 DebugDump(b,'b');
		//alert(a);
	}
}

//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
PAGEdom = new DOM();
PAGEdom.init();

