/*
   Milonic JavaScript API webplugs.js version 1.0 - July 15 2008
   Copyright 2008 (c) Milonic Solutions Limited. All Rights Reserved.
   This is a commercial software product, please visit http://www.milonic.com/ for more information.
   Open Source and Non-Profit Licenses are available on request.
*/

function wp(v){
	return this instanceof wp?wp.init(v):new wp(v)
}

wp.extend=function(d,s){
	if(!s)s=this;
	for(var i in d)s[i]=d[i]
}

//window.$=wp // Can use $ in place of wp if you enable this line of code

wp.extend({
	version:"1.0",
	defaultTheme:"Office2003",
	zindex:1000,
	inc:[],
	dep:{},
	fire:{},
	uId:0,
	/*@cc_on
		msie:navigator.appVersion.match(/MSIE (\d\.\d)/)[1],
	@*/
	init:function(v)
	{
		wp.v=wp.seek(v);
		wp.V=[]
		if(wp.v.length)wp.V=wp.v; else wp.V[0]=wp.v
		return wp
	},
	ini:function(o,t)
	{
		var O,v=wp.get_Obj(o,t);
		if(!o)o={};
		if(!o.theme)o.theme=wp.defaultTheme;
		if(!v)return t;
		if(v.length)
		for(O in v){
			if(typeof(v[O])==="object")
				t.init(o,t,v[O]);
			}
			else t.init(o,t,v)
	},
	get_Obj:function(o,t)
	{
		if(o&&o.object)wp.v=o.object;
		for(var C in o)if(C!="object")t[C]=o[C];
		return wp.v
	},
	seek:function(v,L)
	{
		var output=[],i,c,e,s,I,a,A,R=[],O,o,S,objects;
		if(typeof(v)=="string"){
			s=v.split(".");
			i=s[0];
			c=s[1];
			s=i.split("+");
			i=s[0];
			e=s[1]?s[1]:"*";
			I=wp.get(i);
			if(c){
				if(!I)I=document;
				if(L)I=L;

				objects=I.getElementsByTagName(e);
				if(!objects.length)output.push(I);
				for(a=0;a<objects.length;a++){
					var found=0;
					if(objects[a].className){
						wp.each(objects[a].className.split(" "),function(a,i){
							if(a[i]==c)found=1;
						})
					}
					if(O&&e!=objects[a].id)found=0;
					if(found)output.push(objects[a]);
				}
			}
			else{
				if(i&&e=="*")return I?[I]:[];
				else{
					output=document.getElementsByTagName(e);
				}
			}
			if(output.length==0)output=null
			return output;
		}
		else{
			return v
		}
	},
	all:function(o,f)
	{
		var v=wp.get_Obj(o,this);
		if(v.length){
			for(O in v)f.call(this,v[O],O)
		}
		else{
			f.call(this,v)
		}
	},
	each:function(o,f,a) // a parameter forces each to scan through all elements in an object
	{
		if(a||o.length){
			for(var O in o){
				f.call(this,o,O)
			}
		}
		else{
			f.call(this,o)
		}
	},
	loadFunc:[],
	onload:function(f)
	{
		wp.loadFunc.push(function(){return f.apply(f)})
	},
	setready:function()
	{
		for(var x=0;x<wp.loadFunc.length;x++)wp.loadFunc[x].apply();
		wp.docState="complete";
		//setInterval("wp.intv()",0)
		try{document.execCommand("BackgroundImageCache",false,true)}catch(err){}
	},
	ready:function()
	{
		var d=document;
		if(d.addEventListener){
			d.addEventListener('DOMContentLoaded',wp.setready,false);
		}
		else if(wp.msie){
			try{d.documentElement.doScroll("left")}catch(error){
				setTimeout("wp.ready()",50);
				return;
			}
			wp.setready()
		}
		else wp.event.add(window,"load",wp.setready())
	},	
	fileDetail:function(f)
	{
		f=f.split("/");
		return{file:f[f.length-1]}
	},
	getPath:function()
	{
		var S,a,s,V;
		S=document.getElementsByTagName("script");
		for(a=0;a<S.length;a++){
			V=S[a].src;
			s=V.split("\/");
			if(s[s.length-1]=="webplugs.js")return V.substr(0,V.length-11)
		}
	},
	include:function(f)
	{
		var S,oF=function(){wp.addToFire(f)}
		wp.dep[f]=0
		if(!wp.inc[f]){
			if(!wp.docState){
				document.write('<scr'+'ipt type="text/javascript" src="'+wp.getPath()+f+'.js"></scr'+'ipt>');
				wp.inc[f]=1
			}
			else{
				S=document.createElement('script');
				S.type='text/javascript';
				S.src=wp.getPath()+f+".js"
				if(!wp.msie)S.onload=oF; else S.onreadystatechange=function(){if(S.readyState=="loaded"||S.readyState=="complete")wp.addToFire(f)}
				document.getElementsByTagName("head")[0].appendChild(S);
			}
		}
		else{
			if(wp.docState)oF();
		}
		return wp;
	},
	into:function(v)
	{
		wp.include(v)
		return wp;
	},
	icTO:function()
	{
		clearTimeout(wp.DEP);
		wp.DEP=setTimeout("wp.intv()",1);
	},
	addToFire:function(f)
	{
		wp.inc[f]=1
		wp.fire[f]=function(){
			wp.each(wp.v,function(a,i)
			{
				var A=a
				if(i)A=a[i]
				if(wp[f]&&wp[f].exec)wp[f].exec(A)
			})
		}
		wp.icTO();
	},
	intv:function()
	{
		for(var a in wp.dep)
		{
			if(!wp.inc[a]){
				wp.icTO();
				return
			}
		}

		for(var a in wp.dep){
			if(wp.fire[a])wp.fire[a]();
			wp.dep[a]=1
			delete wp.fire[a]
		}
	},	
	dependencies:function(v)
	{
		var D=v.split(",");
		wp.each(D,function(a,i){
			//alert(a+ " -  " + i)
			wp.include(a[i])
		})
		//alert(v)
	},
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	get:function(v,w)
	{
		if(!w)w=window;
		if(!v)return null;
		if(typeof(v)=="string")v=w.document.getElementById(v);
		return v
	},
	getAll:function(v)
	{
		if(wp.msie<6) return v.all; else return v.getElementsByTagName("*")
	},
	node:
	{
		clone:function(i) // wp.cloneNode(OBJ:object,BOOL:before/after(default is after),BOOL:do NOT include children)
		{
			var N=i.cloneNode(true),
			li=i.getElementsByTagName('*'),
			li2=N.getElementsByTagName('*');
		
		/*
		for(var a in i)
		{
			if(typeof(i[a])!=typeof(N[a]))
			{
				N[a]=i[a]
			}
		}
		*/
		
		
			if(!wp.msie){
				wp.each(li,
					function(V,ii){
						
						/*
						//alert(ii + " - " + V[ii].tagName)
						for(var a in V[ii])
						{

							if(typeof(V[ii][a])!=typeof(li2[ii][a]) && a!="wpEvents")
							{
								
			//					if(a=="subMenu")alert(a)
								li2[a]=V[ii][a]
							}							
						}
						*/
						if(ii)
						{
							if(V[ii].nodeType==1 && V[ii].wpEvents){
								for(var a in V[ii].wpEvents){
									wp.event.add(li2[ii],a.split("_")[0],V[ii].wpEvents[a])
									
									//li2[ii].subMenu=wp.get("andy11")
									//li2[ii].subMenu2="ANDY11"
								}
							}
						}
					}
				)
			}
			
			
			return N
		},
		insert:function(N,i,p)
		{
			i.parentNode.insertBefore(N,p?i:i.nextSibling);
		},
		swap:function(n1,n2)
		{
			var N=wp.msie?n2:n2.nextSibling;
			n1.parentNode.replaceChild(n2,n1);
			n2.parentNode.insertBefore(n1,N);			
		},
		remove:function(f)  // Currently named node.remove instead of node.remove because of a bug in Opera 9
		{
			if(f)wp.v=f // This allows for both wp(OBJ).node.remove() as well as wp.removeNode(OBJ)
			wp.each(wp.v,function(V){			
				
				if(V.length>-1){ // This will only remove the first Node in a collecion - Do we need to remove multiple nodes?
					if(!V[0].parentNode||V.length==0)return wp;
					//alert(V[0].tagName + " - " + V.length)
					V[0].parentNode.removeChild(V[0]);
					
				}
				else V.parentNode.removeChild(V);
			})
			return wp			
		},
		
		add:function(d,e,p){
		// d object adding to
		// e element to add
		// p flag for including object as first object
			var O=document.createElement(e);
			if(p){
				if(d.firstChild)d.insertBefore(O,d.firstChild);
			}
			else{
				d.appendChild(O);
			}
			return O
		},
		getParent:function(v,t,c)
		{
			if(!c)c=1;
			var found=0
			var count=1;
			/*
			var count=0;
			if(!c)c=1;
			while((v.tagName!=t)&&(count<c))
			{
				v=v.parentNode;

				if(v.tagName==t)count++
				alert(v.tagName + " - " + t + " - " + c + " - " + count)

			}
			alert(count)
			return v;
			*/
			while(!found&&v.tagName)
			{
				v=v.parentNode;
				if(v.tagName==t)
				{
					//alert(count + " - " + c)
					if(count==c)
					{
						found=1
						
					}
					count++
				}
			}
			if(!v.tagName)v=undefined
			return v
			
		}
	},
	event:
	{
		add:function(o,t,f)
		{
			if(!o.wpEvents)o.wpEvents={};
			//alert(o.tagName)
			var N=t+"_wpEvent"+wp.uId++;
			if(wp.msie){
				o[N]=f;
				o.wpEvents[N]=function(){o[N](window.event)}
			}
			else 
			o.wpEvents[N]=f;
			
			//alert(o.innerHTML)
			
			if(o.attachEvent)o.attachEvent("on"+t,o.wpEvents[N]);else o.addEventListener(t,o.wpEvents[N],false)			
		},
		remove:function(o,t,f)
		{
			var O,C,E=o.wpEvents;
			for(C in E){
				var S=E[C];
				if(wp.msie)S=o[C];
				if(S.toString()==f.toString())O=C;
			}
			if(!O)return;
			f=E[O];
			delete E[O];
			if(wp.msie)delete S
			if(o.detachEvent)o.detachEvent("on"+t,f);else o.removeEventListener(t,f,false)
		},
		exec:function(o,eType)
		{
			for(a in o.wpEvents){
				if(a.split("_")[0]==eType){
					o.wpEvents[a].call(o)
				}
			}
		},
		cancel:function(e)
		{
			if(!e)return false;
			e.returnValue=false;
			e.cancelBubble=true;
			if(e.preventDefault){
				e.preventDefault();
				e.stopPropagation&&e.stopPropagation()
			}
			return false
		}	
	},
	makeMovable:function(v)
	{
		v.style.position="absolute";
	},
	show:function(v)
	{
		//v.style.display="none";
		v.style.visibility="visible"
	},	
	hide:function(v)
	{
		//v.style.display="block";
		v.style.visibility="hidden"
	},
	outerHtml:function(v)
	{
		if(v.outerHTML)return v.outerHTML;
		else
		{
			var E={"IMG":1,"BR":1,"INPUT":1,"META":1,"LINK":1,"PARAM":1,"HR":1},
			A=v.attributes,S="<"+v.tagName,x;
			for(x=0;x<A.length;x++)S+=" "+A[x].name+"=\""+A[x].value+"\"";
			if(E[v.tagName])return S+" />";
			return S+">"+v.innerHTML+"</"+v.tagName+">";			
		}
	},
	IsWS:function(n)
	{
		return !(/[^\t\n\r ]/.test(n.data));
	},
	WsIgnore:function(n)
	{
		return(n.nodeType==8)||((n.nodeType==3)&&wp.IsWS(n));
	},
	previous:function(o)
	{
		while((o=o.previousSibling))if(!wp.WsIgnore(o))return o;
	
	},
	next:function(o)
	{
		while((o=o.nextSibling))if(!wp.WsIgnore(o))return o;
	},
/*
last_child:function ( par )
{
	var res=par.lastChild;
	while (res) {
	if (!wp.WsIgnore(res)) return res;
	res = res.previousSibling;
	}
	return null;
},
first_child:function ( par )
{
	var res=par.firstChild;
	while (res) {
	if (!wp.WsIgnore(res)) return res;
	res = res.nextSibling;
	}
	return null;
},
*/
	tofront:function(v)
	{
		v.style.zIndex=wp.zindex++
	},
	getMouseCoords:function(e)
	{
		if(window.event)e=event;
		return{x:e.clientX,y:e.clientY}
	},
	S:function(v) // same as: var tempVar="";if(val)tempVar=val;
	{
		return v?v:"";
	},
	wpAction:function(v,a)
	{
		a="on"+a
		if(v.wpObject[a])v.wpObject[a]()
	},
	fixZI:function(v)
	{
		var e,p;
		if(wp.msie){
			try{
				if(v.filters)
				{
					e=wp.node.add(v,"iframe",true);
					e.style.filter="Alpha(Opacity=0)"
					e.style.position="absolute"
					//e.style.display="block"
					e.style.top="-1px";
					
					e.style.left="-1px";
					e.className="wpMenuMask"
					v.iframe=e
					p=this.getDimension(v)
					wp(e).setDimension({height:p.height,width:p.width})
					e.style.visibility="visible"
					e.style.zIndex=-1			
				}
			}
			catch(e){}
		}
	},
	progUpdate:function()
	{
			var andy=wp.get("_WP_pBar")
			
			if(!andy)
			{
				//alert("")
				//document.write("<div id=_WP_pBar style='border:1px solid black'><br></div>")
				
				alert(document.getElementsByTagName('HEAD').item(0))
				

				andy=wp.node.add(document.getElementsByTagName('HEAD').item(0),"DIV")
				andy.id="_WP_pBar"
				andy.style.border="1px solid black"
				andy.style.position="absolute"
				andy.style.top="100px"
				andy.style.left="100px"

			}
			
			andy.innerHTML=andy.innerHTML+"loading: "
			andy.innerHTML=andy.innerHTML+".......done<br>"
				
	}
})




function showObjProps(v,back){
	var h=""
	

//v=i[a].slice(q+1);


h+="<a href='javascript:showObjProps(wp.sopObj[0],2)'>BACK</a><br />";

	

	if(back)
	{
		//if(back==1)
		
		wp.sopBack.push(v)
		if(back==2)
		{
			v=wp.sopBack[wp.sopBack.length-1]
			wp.sopBack.pop()
			alert(wp.sopBack)
		}

		//var tmp=wp.sopObj.slice(0,1)[0]
		//wp.sopObj=[]
		//wp.sopObj.push(tmp)
		
		//alert(wp.sopObj)
		//wp.sopObj.push(wp.sopObj.slice(0,1)[0])


		

		//alert(wp.sopBack)


		
	}
	else
	{
		wp.sopBack=[]
		wp.sopBack.push(v)
	}


	wp.sopObj=[]
	wp.sopObj.push(v)
		


	
	if(back)
	{
		//wp.sopObj.push(back)
		//alert(back.scrollHeight)
//		h+="<a href='javascript:showObjProps(wp.sopObj[0],wp.sopObj[0])'>BACK</a>";
	}
	
	
	
	for(var c in v){
		if(c!="outerHTML")
		{
			var out=v[c]
			if(typeof(v[c])==="object")
			{
				wp.sopObj.push(v[c])
				out="<a href='javascript:showObjProps(wp.sopObj["+(wp.sopObj.length-1)+"],1)'>"+out+"</a>";
			}
			
			h+=c+" - '" +out+"'<br />";
		}
	}
	h.replace(/ /g,"&nbsp;") 
	
	var a=document.getElementById("objProps");
	if(!a){
		

		
		//if(!wp.docState)return
		
		var a=document.createElement("div");
		document.body.appendChild(a);
		a.id="objProps";
		a.style.position="absolute";
			a.style.top="200px";
			a.style.left="100px";
			a.style.height="350px";
			a.style.width="650px";
			a.style.fontFamily="verdana";
			a.style.fontSize="10px";
		
		a.innerHTML=h
		
		//alert(h)
		
		/*	
		if(document.body.appendChild){
			document.body.appendChild(a);
			a.style.position="absolute";
			a.style.border="1px solid gray";
			a.style.padding=4;
			a.style.top="200px";
			a.style.left="100px";
			a.style.height="350px";
			a.style.width="850px";
			a.style.fontFamily="verdana";
			a.style.fontSize="10px";
			a.style.overflow="scroll";
			a.style.color="black";
			a.style.background="white";
		}
		*/
		wp(a).into("window");
		
	}
	else
	{
		//a.innerHTML=h;
		//alert(h)
		wp(a).window.change(h)
	}
	
	//alert(wp.get("objProps").innerHTML)
	
}




	wp.extend({
		toarray:function(v){return this.split('')}
	},String.prototype)

	if(wp.msie<5.5){
	wp.extend({
		push:function(v){this[this.length]=v}
	},Array.prototype)
	
	wp.extend({
		getElementsByTagName:function(str){return(str=='*')?document.all:document.all.tags(str)}
	},document)
}


wp.ready()



function OLDshowObjProps(_w){
	var a=document.getElementById("OLDobjProps");
	if(!a){
		//wp.include("window")
		var a=document.createElement("div");
		a.id="OLDobjProps";
		if(document.body.appendChild){
			document.body.appendChild(a);
			a.style.position="absolute";
			a.style.border="1px solid gray";
			a.style.padding=4;
			a.style.top="200px";
			a.style.left="100px";
			a.style.height="350px";
			a.style.width="850px";
			a.style.fontFamily="verdana";
			a.style.fontSize="10px";
			a.style.overflow="scroll";
			a.style.color="black";
			a.style.background="white";
		}}	
	var h=""
	for(var _cO in _w){
		h+=_cO+" - '" +_w[_cO]+"'<br />";
	}
	h.replace(/ /g,"&nbsp;") 
	a.innerHTML=h;
}







/*
	wp.extend({
		inArray:function(v){
			//for(var i in this)
			//{
				//if(this[i]===v)
				//return i
			//}
			//return -1
		}
	},Array.prototype)
*/
