function register(ns)
{
	var nsParts = ns.split(".");
	var root = window;
	for(var i=0; i<nsParts.length; i++)
	{
		if(typeof root[nsParts[i]] == "undefined")
			root[nsParts[i]] = new Object();
		root = root[nsParts[i]];
	}
}
(function()
{
if ( window.SYM)
	var _SYM = window.SYM;
var SYM = window.SYM = function(  ) {
	return new SYM.util.init( );
};
SYM.util = 
{	
	path : "kunder/unio/cms.nsf",
	scripts : "",	
	vars:null,
	browser:"",
	ie:(document.all?true:false),
	loaded:false,
	init : function()
	{
		this.vars = new this.items();
	},
	isArray :function(obj) {
if (obj.constructor ==  null || obj.constructor.toString().indexOf("Array") == -1){return false;}else{return true;}
	},
	isString : function (a) 
	{
		return typeof a == 'string';
	},
	getCookieValue : function(labelName)
	{
		labelName += "=" // append it, so we only find labels not values.
		var cookieData = document.cookie
		cStart = cookieData.indexOf( labelName );
		if ( cStart == -1 )
		{
			return null
		}else{
			cEnd = cookieData.indexOf(";",(cStart+ labelName.length))						
			szvalue = cookieData.substring( (cStart+ labelName.length) , (cEnd!=-1?cEnd:cookieData.length) )		
			return (szvalue ==""?null:unescape(szvalue));
		}	
	},
	/* REMOVES A SCRIPT OR CSS FROM THE HEADER */
	remove:function(script)
	{
		
	},
	/* LOADS A FUNCTION */
	load : function ( name )
	{
	},
	/* ADDS A SCRIPT OR CSS TO THE HEADER */
	add : function ( script , bind )
	{		
		this.appendObject(script);	
	},	
	verifyName:function(type ,src)
	{
		var nodeList = document.getElementsByTagName(type);			
		var node = null;
		for(var i=0;i<nodeList.length;i++)
    		{
			node  = nodeList[i];
			if (type=="script")
			{
				if(node.getAttribute("type") == "text/javascript")
        				{
            					var name = node.getAttribute("src");
					if( name == src )
					{return false;}
				}
			}else{
				if(node.getAttribute("type") == "text/css")
        				{
            					var name = node.getAttribute("href");
					if( name == src )
					{return false;}
				}
			}
		}
		return true;
	},
	appendObject:function(file)	
	{
		if (!document.getElementById)
		return
		var fileref="";
		if (this.scripts.indexOf(file)==-1){
			if (file.indexOf(".js")!=-1){ //If object is a js file
				if (this.verifyName("script" , file))
				{
					fileref=document.createElement('script')
					fileref.setAttribute("type","text/javascript");
					fileref.setAttribute("src", file);
				}
			}else if (file.indexOf(".css")!=-1){ //If object is a css file
				if (this.verifyName("link" , file))
				{
					fileref=document.createElement("link")
					fileref.setAttribute("rel", "stylesheet");
					fileref.setAttribute("type", "text/css");
					fileref.setAttribute("href", file);
				}
			}
		}
		
		if (fileref !="" )
		{
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			this.scripts+=file+"," //Remember this object as being already added to page
		}
	},
			
	/* CAN STORE ITEMS*/	
	items : function ()
	{
		this.myvars=  new Array();
		this.set = function(a, b)
		{
			this.myvars.push( { name:a, value:b} );
		}
		this.get = function(a)
		{			
			for (var i = 0 ; i < this.myvars.length ; i++)
			{
				if (this.myvars[i].name == a)
				{
					var value =  this.myvars[i].value;
					return value;
				}
			}			
		}
		/* CAN STORE THE INFORMATION INSIDE A COOKIE */
		this.serialize = function(serialize , name)
		{
		}
	},
	xhr : function( url ,  callback , szvalues, obj)
	{
		this.timeout = 0;
		this.url = url;
		this.flash = null;
		this.szvalues = szvalues;
		this.status = 0;	
		this.external = false;
		this.data = null;
		this.callbackfunction = callback;	
		this.callbackID = 0;
		this.custom = null;
		this.debug = false;	
		this.callbackobj = obj; // if we are sending a object, this means that an instance is calling us.
		this.cache = true;
		this.init = function init()
		{	
			if (status == 0)
			{	
				if ( this.url.substring(0,4) == "http")
				{
					// look for flash	
					this.flash = ( SYM.util.ie?window['SYM_xhr_fla']: document['SYM_xhr_fla']);					
					
					if (this.flash == null)
					{					
						if (this.iframe)
						{
	
						}else
						{
							/* SET TO USE PASSTHRU ACCESS INSTEAD */	
							this.external = true;
							this.url = "/" + SYM.util.path + "/ajaxpassthru?openagent&url=" + this.url;
						}
					}
				}else
				{
					if ( !this.cache )
					{
						this.url += "&now=" + new Date();
					}
				}	
				this.load();			
			}
		}	
		
		this.getText = function()
		{
			if ( this.flash == null )
			{
				if ( this.xmlhttp.responseText != null )
				{
					return this.xmlhttp.responseText;
				}else
				{
					return null;
				}
			}else
			{
				return this.data;
			}
		}
		
			
		this.inform = function()
		{
			try
			{				
				if (this.debug && this.flash == null)
				{
					alert(this.xmlhttp.responseText);
				}	
				
				if (SYM.util.isString(this.callbackfunction))
				{
					if (this.callbackobj == null)
					{
						eval( this.callbackfunction);
					}else
					{
						eval( "this.callbackobj." + this.callbackfunction )
					}
				}else
				{
					this.callbackfunction();
				}
		}catch(oou){ if(this.debug){alert("error callback" + this.callbackfunction);} }
	}
	
	this.load = function load()
	{
		if (this.flash == null)
		{
			if(navigator.appName == "Microsoft Internet Explorer"){
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}else{ 
				this.xmlhttp = new XMLHttpRequest(); 
			}
			if (this.xmlhttp)
			{		
				var oThis = SYM.bind(this.callback , this);
				if (this.debug) { alert( this.url ); }
				this.xmlhttp.onreadystatechange = function() { oThis() }
				if (this.szvalues == null)
				{
					this.xmlhttp.open("GET",this.url,true)
					this.xmlhttp.setRequestHeader("Connection", "close");
					this.xmlhttp.send(null);
				}else
				{
					if (this.external)
					{
						this.xmlhttp.open("GET",this.url,true)
						this.xmlhttp.setRequestHeader("Connection", "close");
						this.xmlhttp.send(null);
					}else
					{
						this.xmlhttp.open("POST", this.url , true);								
						this.xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
						this.xmlhttp.setRequestHeader("Content-length", this.szvalues.length);
						this.xmlhttp.setRequestHeader("Connection", "close");
						this.xmlhttp.send(this.szvalues);
					}
				}
			}
		}else
		{
			var oThis = SYM.bind(this.flashCallback , this);
			if (this.flash.xhr != null)
			{
				this.callbackID = this.flash.xhr(this.url, "function(id , status,data) { SYM.util.xhr.globalCallback(id,status,data) }" ,this.szvalues);
				if (SYM.util.vars == null){SYM.util.init();}
				SYM.util.vars.set(this.callbackID , this); // save the callback id.
			}
		}
		this.status  = 1;	
	}
	this.callback = function()
	{
		if (this.xmlhttp.readyState==4)
		{
			if (this.xmlhttp.status==200)
	    		{
				this.status = 200;
			}else
			{this.status = 404;}
			this.inform();
		}  
	}
	
	}
		
}
/* BINDS A METHOD TO AN OBJECT. */
SYM.bind = function(method, obj ) { 
	temp = function() { 
		return method.apply(obj, arguments); 
	}; 
	return temp; 
} 
/* WAIT FOR THIS OBJECT, BEFORE CONTINUING. */
SYM.util.waitFor = function( params )
{
      var condition  = params.condition;
      var callback   = params.callback;
      var interval   = params.interval || 100;
      var maxTries   = params.maxTries || 10;
      var currentTry = params._currentTry || 0; // private

      // If condition passes, run the code
      if ( condition() === true )
          return callback();

      // Limit the # of attempts
      if ( currentTry < maxTries )
      {
          // Increment the attempt #
          params._currentTry = currentTry+1;

          // Create the recursive call
          var f = function() { return waitFor( params ); }

          // Wait for one interval and execute
          setTimeout( f, interval );
      }
      else
      {
          // alert( 'Maximum tries used for waitFor()...quitting' );
      }
};
SYM.util.xhr.globalCallback = function( id , status , data )
{
	var obj = SYM.util.vars.get(id);
	if (obj != null)
	{
		obj.status = status;
		obj.data = data;
		obj.inform();
	}
}
SYM.util.clone = function( a )
{
	var temp = new Object();
	for (myvar in a) {
		temp[myvar] = a[myvar];
	}
	return temp;
}
SYM.util.cookie = 
{
	set:function( id , value , days ,reset)
	{
		var oldvalue = "";
		if (reset != null && reset)
		{
			oldvalue = SYM.util.cookie.read(id);
			if(oldvalue == null){oldvalue="";}
		}
 
		var expires = "";
		if (days!= null) 
		{
			var date = new Date();
		 	date.setTime(date.getTime()+(days*24*60*60*1000));
		 	expires = "; expires="+date.toGMTString();
		}
		document.cookie = id +"="+ oldvalue+value+expires+"; path=/";		
	},
	
	remove:function( id, value , multi )
	{
		if (value == null)
		{
			SYM.util.cookie.set( id , "" , -1 );
		}else
		{
			var oldvalue = SYM.util.cookie.read( id )
			if (oldvalue != null)
		 	{			 
				if (multi != null && multi)
				{
					oldvalue = oldvalue.replace( "," + value , "" ); // if multi
				}else
				{
					oldvalue = oldvalue.replace( value , "" );
				}
				
				if (oldvalue == "")
				{
					SYM.util.cookie.set( id , "" , -1 );
				}else
				{
					SYM.util.cookie.set( id , oldvalue );
				}		 		
		 	}
		}
		return true;
	},
	
	read:function(id)
	{
		var nameEQ = id + "=";
		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;	
	}	
}
register("SYM.util.text");
SYM.util.text.isString = function (a) {
    return typeof a == 'string';
}
String.prototype.startsWith = function(s) { return this.indexOf(s)==0; } 
SYM.util.text.trim = function(string)
{
	// Removes leading, trailing, and redundant spaces from string 
	var re = /^ */g
	string = string.replace(re, "")
	var re = /\n/g
	string = string.replace(re, "")
	re = / *$/g
	string = string.replace(re, "")
	re = / {2,}/g
	string = string.replace(re, " ")
	string = string.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
	return string
}
SYM.util.text.replaceString = function(replaceString_s, replaceString_t, replaceString_u) {
	replaceString_s = replaceString_s.toString();
	replaceString_i = replaceString_s.indexOf(replaceString_t);
	replaceString_r = "";
	if (replaceString_i == -1){ return replaceString_s;}
	replaceString_r += replaceString_s.substring(0,replaceString_i) + replaceString_u;
	if ( replaceString_i + replaceString_t.length < replaceString_s.length){
		replaceString_r += replace(replaceString_s.substring(replaceString_i + replaceString_t.length, replaceString_s.length), replaceString_t, replaceString_u);
 	}
	return replaceString_r;
}
SYM.util.text.clean = function(s)
{
	s = s ? s : this;
	return s.replace(/<\/?[^>]+>/gi, '');	
}
SYM.util.date = new Object(); 
SYM.util.date.validDate = function( szdate )
{
	if (szdate == null || szdate == ""){ return true; }
    	var valDate = /^(19|20|21)\d\d[.](0[1-9]|1[012])[.](0[1-9]|[12][0-9]|3[01])?$/;
	return (szdate.match(valDate) == null?false:true);
}
SYM.util.date.validTime = function( sztime )
{
	if (sztime == null || sztime == ""){ return true; }
	var varvalTime = new RegExp("^([0-1][0-9]|[2][0-3]):([0-5][0-9])$");
	return (sztime.match(varvalTime) == null?false:true);
}
SYM.util.date.timeDiff = function( sztime1 , sztime2 )
{
	t1 = new Date();
	t2 = new Date();
	t1.setHours(sztime1.substring(0,2));
	t1.setMinutes(sztime1.substring(3,5));
	t1.setSeconds(0);
	t2.setHours(sztime2.substring(0,2));
	t2.setMinutes(sztime2.substring(3,5));
	t2.setSeconds(0);
	return (t2-t1);
}
register("SYM.ui.Effect")
SYM.ui.Effect.Change = function( elem , properties )
{
	if (properties  == null)
	{properties  = new Object()}
	if ( SYM.util.isString( elem) )
	{ elem= SYM.util.dom.getObject(elem); }
	this.object = elem;
	
	this.startcolor = ( properties.startcolor==null ? [255,255,99] : properties.startcolor);
	this.stopcolor = (properties.stopcolor==null ? [255,255,255] : properties.stopcolor);
	this.endcolor = (properties.endcolor ==null ? "white" : properties.endcolor);
	this.steps = (properties.steps == null ? 25: properties.steps);
	this.intervals = (properties.intervals ==null ? 100 : properties.intervals);	
	this.power = (properties.pwr ==null ? 1: properties.pwr);
	this.callback = (properties.callback ==null ? 1: properties.callback);
	this.doSteps = 0;
	this.ease  = function(minValue,maxValue,totalSteps,actualStep,powr) 
	{ 
		var delta = maxValue - minValue; 
    		var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 		
    		return Math.ceil(stepp) 
	}
	this.fade = function()
	{
		if (this.object.bgFadeInt) window.clearInterval(this.object.bgFadeInt);		
		this.object.bgFadeInt = window.setInterval(
		SYM.bind(function( ) {
			if (this.object != null)
			{
				this.object.style.backgroundColor = "rgb("+
					this.ease(this.startcolor[0],this.stopcolor[0],this.steps,this.doSteps,this.power)+","+
					this.ease(this.startcolor[1],this.stopcolor[1],this.steps,this.doSteps,this.power)+","+
					this.ease(this.startcolor[2],this.stopcolor[2],this.steps,this.doSteps,this.power)+")";
			}
			this.doSteps++;
			if (this.doSteps > this.steps) 
			{				
				this.object.style.backgroundColor = this.endcolor;
				window.clearInterval(this.object.bgFadeInt);
			}
		},this),this.intervals);
	}
	
	this.fade();
}
SYM.ui.Effect.Fade = function( elem , properties )
{
	if ( SYM.util.isString( elem) )
	{ elem= SYM.util.dom.getObject(elem); }
	this.obj = elem;
	if (properties  == null) {properties  = new Object()}
	this.interval =  ( properties.timer==null ? 100 : properties.timer);	
	this.direction =  ( properties.direction==null ? true: properties.direction);	
	this.showing = true;
	this.timer = null;
	this.alpha = 0;
	this.running = false;
	this.intervals = 10;
	this.developersucks = 0;
	this.show = function()
	{	
		SYM.log.debug("start fade");
		if (!this.running)
		{
			this.running = true;
			this.obj.style.display = "";
			if (this.direction)
			{
				this.obj.style.opacity  = 0;
				this.obj.style.filter  = 'alpha(opacity=0)';
				this.alpha = 0;
			}else
			{
				this.obj.style.opacity  = 100;
				this.obj.style.filter  = 'alpha(opacity=100)';
				this.alpha = 100;
			}
		
			this.run();			
		}
	}
	this.stop = function()
	{
		this.running = false;
		clearTimeout(this.obj.timer);
		SYM.log.debug("stop fade");
	}
	this.run = function()
	{			
		if (this.direction)
		{
	 		this.alpha = this.alpha + (this.intervals);
			if ( this.alpha >= 100 )
			{
				this.stop();
			}
		}else
		{
	 		this.alpha = this.alpha - this.intervals;
			if ( this.alpha <= 0)
			{
				this.stop();
			}		
		}
		
		this.obj.style.opacity  = this.alpha * .01;	
		this.obj.style.filter  = 'alpha(opacity='+ this.alpha +')';			
		if (this.running)
		{
			obj = SYM.bind( function(){ this.run()}, this );	
			this.obj.timer =  setTimeout( obj   , this.interval)							
		};
	}
	this.show();
}
SYM.ui.ToolTip = function( szTxt  ,  properties ) 
{
	new SYM.ui.NewToolTip( szTxt  ,  properties  )	
}
SYM.ui.ToolTip.Timer = null;
SYM.ui.NewToolTip = function( szTxt  ,  properties ) 
{	
	this.txt = szTxt;
	if (properties  == null) {properties  = new Object()}
	this.w =  ( properties.width==null ? 200 : properties.width);
	this.delay =  ( properties.delay==null ? 0 : properties.delay);
	this.id =  ( properties.id==null ? "ToolTip"+SYM.ui.ToolTip.Ids : properties.id);
	this.style =  ( properties.style==null ? "" : properties.style);
	this.tooltip = null;
	this.status = 0;
	this.timer = null;
	this.caller =   properties.parent;
	this.remove = function()
	{
		SYM.util.dom.remove(this.tooltip);		
	}
	this.createTooltip = function()
	{		
		this.tooltip = SYM.util.dom.create( 
			{
				type:"div" , szclass:"toolTip"  , id : this.id ,
				items:	
				[
					{
						type:"div" , szclass:"content" ,
						items:
						[
							{type:"div" , szclass:"toolTipTop" , szhtml : "<img src='../toolTipL.gif' alt=''  width='15' height='15' class='corner'  style='display: none' />" },
							{ type:"p" , szhtml : this.txt },
							{type:"div" , szclass:"toolTipBottom" , szhtml : "<img src='../toolTipBL.gif' alt=''  width='15' height='15' class='corner'  style='display: none' />" }
						]
					},
					{
						type:"div" , szclass:"toolTipRight"
					}
				]
			}
		
		);		
		SYM.ui.ToolTip.Ids++;
		document.body.appendChild( this.tooltip );
		if (this.caller != null)
		{	
			var obj = SYM.util.dom.getObject( this.id );
			var pos = SYM.util.dom.findPos(this.caller);
			obj.style.top = pos[1] - 6;
			obj.style.left = (pos[0] - 250);
		}
		this.show();
	}
	this.removeTimer = function()
	{
		this.caller.setAttribute("show" , "false");		
		//SYM.util.dom.removeEvent( document  ,"mousemove" , obj2 )				
	}
	this.check = function()
	{				
		if ( this.caller.getAttribute("show" ) == "true")
		{
			this.caller.setAttribute("show" , false)
			this.createTooltip();
		}			
	}
	this.create = function()
	{
		if (this.delay != 0 && this.caller != null )
		{					
			status = this.caller.getAttribute("show");
			if ( status != "true")
			{
				var obj = SYM.bind( function(){ this.check() } ,this);
				var obj2 = SYM.bind( function(){ this.removeTimer() } ,this);
				setTimeout( obj  , this.delay );
				this.caller.setAttribute("show" , "true");
				SYM.util.dom.addEvent( document  ,"mousemove" , obj2 )				
			}
		}else
		{			
			this.createTooltip();
		}
	}
	this.show = function()
	{	
		// FADE UP
		SYM.ui.Effect.Fade( this.tooltip )
		//this.tooltip.style.display = "";
	}
	
	this.hide = function()
	{
		// THIS FADE DOWN
		if (this.status == 100)
		{
			this.remove();	
		}
	}	
	this.create();			
}
SYM.ui.ToolTip.hide = function( id ) 
{
	var obj = SYM.util.dom.getObject(id)
	if (obj != null){obj.setAttribute("show" , "false");}
	SYM.util.dom.remove(id);			
}
SYM.ui.ToolTip.Ids = 0;
})()
/**
 * Time validation
 * @param timeStr
 */
SYM.ui.DateUtils = {
   isValidTime:function(timeStr){
    // Checks if time is in HH:MM:SS AM/PM format.
    // The seconds and AM/PM are optional.
    var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
    var matchArray = timeStr.match(timePat);
    if (matchArray == null) {
        alert("Time is not in a valid format.");
        return false;
    }
    var hour = matchArray[1];
    var minute = matchArray[2];
    var second = matchArray[4];
    var ampm = matchArray[6];
    if (second == "") {
        second = null;
    }
    if (ampm == "") {
        ampm = null
    }
    if (hour < 0 || hour > 23) {
        alert("Hour must be between 1 and 23");
        return false;
    }
    if (minute < 0 || minute > 59) {
        alert("Minute must be between 0 and 59.");
        return false;
    }
    if (second != null && (second < 0 || second > 59)) {
        alert("Second must be between 0 and 59.");
        return false;
    }
    return true;
    },
    /**
     * Parse date time to Date object
     *
     * @param dateTime - string of date in "yyyy.mm.dd hh:mm" format
     */
    parseDateTime:function(dateTime) {
        var dateTimeObj = new Date();
        var date_time = dateTime.split(" ");
        var dateArr = date_time[0].split(".");
        var y = dateArr[0],m = dateArr[1],d = dateArr[2];
        var month = parseInt(m) - 1;
        dateTimeObj.setYear(y);
        dateTimeObj.setDate(d);
        dateTimeObj.setMonth(month);
        dateTimeObj.setMinutes(0);
        dateTimeObj.setHours(0);
        dateTimeObj.setSeconds(0);
        if (date_time.length > 1) {
            var timeArr = date_time[1].split(":");
            var h = timeArr[0], mm = timeArr[1];
            dateTimeObj.setHours(h);
            dateTimeObj.setMinutes(mm);
        } else {
            dateTimeObj.setHours(0);
            dateTimeObj.setMinutes(0);
        }
        return dateTimeObj;
    }
  
}
/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Url = {
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},
	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},
	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = ""; 
		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n); 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	},
	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
		while ( i < utftext.length ) {
			c = utftext.charCodeAt(i);
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
}
String.prototype.left = function( sz ){if (this.indexOf(sz) == -1) {return "";}return this.substring(0,this.indexOf( sz ))}
String.prototype.right = function( sz){if (this.indexOf(sz) == -1){return "";}return this.substring(this.indexOf( sz ) + sz.length, this.length);}

