var WSU = {
	jspath: 'http://www.wichita.edu/thisis/js/',
	csspath: 'http://www.wichita.edu/thisis/css/',
	imagespath: 'http://www.wichita.edu/thisis/images/',
	verticalNavCookieName: 'VertNavCookie',
	debugflag: 'false',
	
	ls: function(s){
		document.write('<script src="'+s+'" type="text/javascript"></script>');
	},
	
	isObject: function(o) {
		return (o && typeof o == 'object') || this.isFunction(o);
	},

	isFunction: function(o) {
	    return typeof o == 'function';
	},	

	toggle: function (o) {
		var el = document.getElementById(o);
		if ( el.style.display != 'none' ) {
			el.style.display = 'none';
		}
		else {
			el.style.display = '';
		}
	},
	RemoveAttribute: function(htmltag,att) {
		var o = document.getElementsByTagName(htmltag);
		att = att.split(",");
		for (var i=0;i<o.length;i++) {
			for (j=0;j<att.length;j++)
				o[i].removeAttribute(att[j]);
		}
	},	
	debug: function(i){
		if(i || WSU.debugflag) alert(i);
	},
	replaceContentsofDiv: function(elName,newContent){
		var el = document.getElementById(elName)
		if (el)
			el.innerHTML = newContent;
	},	
	addEvent: function(elm, evType, fn, useCapture) {
		if (elm.addEventListener) {
			elm.addEventListener(evType, fn, useCapture);
			return true;
		}
		else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		}
		else {
			elm['on' + evType] = fn;
			return null;
		}
	},	
	insertAfter: function(parent, node, referenceNode) {
		parent.insertBefore(node, referenceNode.nextSibling);
	},
	ngo: function(o,t) {
		window.open(o.href,'OpenedWSUWindow').focus();		
		return false;
	},
	analytics: function(){
		_uacct = "UA-272026-1";
		urchinTracker();
	}
	};
	
	var DT = {
		DTCookie: '',
		DTPrefix: 'dttog_'		
	};
	
	Array.prototype.inArray = function (value) {
		var i;
		for (i=0; i < this.length; i++) {
			if (this[i] === value) {
				return true;
			}
		}
		return false;
	};

	var Cookie = function(){
		var domain = '.wichita.edu';
		var path = '/';
		this.Domain = domain;
		this.Path = path;
	};

	Cookie.prototype.getCookie = function( name ) {
			var start = document.cookie.indexOf( name + "=" );
			var len = start + name.length + 1;
			if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
				return null;
			}
			if ( start == -1 ) return null;
			var end = document.cookie.indexOf( ';', len );
			if ( end == -1 ) end = document.cookie.length;
			return unescape( document.cookie.substring( len, end ) );
		};

	Cookie.prototype.setCookie = function( name, value, expires, secure ) {
			var today = new Date();
			today.setTime( today.getTime() );
			if ( expires ) {
				expires = expires * 1000 * 60 * 60 * 24;
			}
			var expires_date = new Date( today.getTime() + (expires) );
			document.cookie = name+'='+escape( value ) +
				( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) +
				( ( this.path ) ? ';path=' + this.path : '' ) +
				( ( this.domain ) ? ';domain=' + this.domain : '' ) +
				( ( secure ) ? ';secure' : '' );
		};

	Cookie.prototype.deleteCookie = function( name ) {
			if ( getCookie( name ) ) document.cookie = name + '=' +
					( ( this.path ) ? ';path=' + this.path : '') +
					( ( this.domain ) ? ';domain=' + this.domain : '' ) +
					';expires=Thu, 01-Jan-1970 00:00:01 GMT';
		};
		
	Cookie.prototype.view = function( name ){
		alert(name +': '+ this.getCookie( name ));
	};
	
	 var ViewElementState = {
		ViewStateCookie: new Cookie(),
		d: document,
		FuncCheck: document.getElementById ? true : false,
		FormattedID: function(id){return '|' + id + '|';},
		AppendCookie: function(id,cookieName){
			var cur_cookie = ViewElementState.ViewStateCookie.getCookie(cookieName);
			var n_id = ViewElementState.FormattedID(id);
			if (!cur_cookie) cur_cookie = '';
			cur_cookie += n_id;
			ViewElementState.ViewStateCookie.setCookie(cookieName,cur_cookie);
		},
		RemoveCookie: function(id,cookieName){
			var n_id = ViewElementState.FormattedID(id);
			var cur_cookie = ViewElementState.ViewStateCookie.getCookie(cookieName);
			if (cur_cookie) {
				var t_loc;
				var t_len = cur_cookie.length;
				var n_id_len = n_id.length;
				var i = 0;
				for (i=0; i < t_len; i++){
					t_loc = cur_cookie.indexOf(n_id);
					if (t_loc != -1) {
						cur_cookie = cur_cookie.slice(0,t_loc) + cur_cookie.slice(t_loc + n_id_len,t_len);
						t_len = cur_cookie;
					}
				}
				ViewElementState.ViewStateCookie.setCookie(cookieName,cur_cookie);
			}
		},
		Toggle: function(o,cookieName,displaytype) {
			if (ViewElementState.FuncCheck) {
				var el = ViewElementState.d.getElementById(o);
				if (el.style.display == '') {
					ViewElementState._close(el,cookieName);
				}
				else {
					ViewElementState._open(el,cookieName,displaytype);
				}
			}
		},
		Open: function(o,cookieName,displaytype) {
			if (ViewElementState.FuncCheck) {
				var el = ViewElementState.d.getElementById(o);
				ViewElementState._open(el,cookieName,displaytype);
			}
		},
		Close: function(o,cookieName) {
			if (ViewElementState.FuncCheck) {
				var el = ViewElementState.d.getElementById(o);
				ViewElementState._close(el,cookieName);
			}
		},
		_close: function(el,cookieName){
			el.style.display = 'none';
			if (cookieName)
				ViewElementState.RemoveCookie(el.id,cookieName);
		},
		_open: function(el,cookieName,dtype){
			if (!dtype) dtype = '';
			el.style.display = dtype;
			if (cookieName)
				ViewElementState.AppendCookie(el.id,cookieName);
		},
		Initialize: function(container,el,prefix,cookieName){
			var i;
			if (ViewElementState.d.getElementsByTagName && ViewElementState.d.getElementById(container)){
				if(cookieName)
				var cur_cookie = ViewElementState.ViewStateCookie.getCookie(cookieName);
				if (!cur_cookie) cur_cookie = '';
				var htmltags = ViewElementState.d.getElementById(container).getElementsByTagName(el);
				if (htmltags){
				for (i = 0 ; i < htmltags.length ; i++)
					if (htmltags[i].id.indexOf(prefix) != -1){
						htmltags[i].style.display = 'none';
					}
				if (cookieName){
					for (i = 0 ; i < htmltags.length ; i++){
						if (cur_cookie.indexOf(ViewElementState.FormattedID(htmltags[i].id)) != -1)
							htmltags[i].style.display = '';
						}
					}
				}
			}
			
		}
	};
		
	var ImageSwap = function(){};
	ImageSwap.prototype.ImageList = {};
	ImageSwap.prototype.AlwaysOn = '';
	ImageSwap.prototype.AddImageSet = function(el,a,b,preload){
		var x = new this.ImageSet(a,b,el);
		this.ImageList[el]=x;
		if (preload){
			var img = new Image();
			img.src= a;
			img.src= b;
		}
	};
	ImageSwap.prototype.ImageSet = function(a,b,el){
		this.on = a;
		this.off = b;
		this.el = el;
	};	
	ImageSwap.prototype.On = function(el,elname){
		el.src = this.ImageList[elname].on;
	};
	ImageSwap.prototype.Off = function(el,elname){
		el.src = this.ImageList[elname].off;
	};
	ImageSwap.prototype.AttachEventsSelf = function(el){
		if (this.AlwaysOn != el){
			var x = document.getElementById(el);
			var _this = this;
			var y = function(){_this.On(x,el);};
			var z = function(){_this.Off(x,el);};
			WSU.addEvent(x,'mouseout',z, false);
			WSU.addEvent(x,'mouseover',y, false);	
		}	
	};
	ImageSwap.prototype.AttachImages = function(){
		for (var el in this.ImageList) {
		  this.AttachEventsSelf(el);	
		}
	};
	
	
	
	
	