
var old,head,scrNum=0;

function rpc(Url, Action, ElementId){
	head=document.getElementsByTagName('head').item(0);
	script=document.createElement('script');
	script.id='RPC_Javascript'+scrNum;
	script.src=Url+'&RPC_SCRIPTID='+script.id+'&RPC_SCRIPTACTION='+Action+'&RPC_ELEMENTID='+ElementId;
	script.type='text/javascript';
	script.defer=true;
	scrNum++;
	void(head.appendChild(script));
}

function removeScript(scriptid){
	old=document.getElementById(scriptid);
	if(old)head.removeChild(old);
}
        var Tooltips = {

			disappeardelay : 0,
			verticaloffset : 5,
			ie : document.all,
			ns6 : document.getElementById&&!document.all,
			SupportedTags : Array("a", "input", "select", "b", "i", "div", "span", "p", "u", "td", "img"),

			iecompattest : function () { return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body; },
			showhide : function (obj, e) { dropmenuobj.style.left=dropmenuobj.style.top="-500px"; if (e.type=="mouseover") obj.visibility="visible"; },
			clearhidemenu : function () { if (typeof delayhide!="undefined") clearTimeout(delayhide); },
			delayhidemenu : function () { delayhide=setTimeout("dropmenuobj.style.visibility='hidden'; dropmenuobj.style.left=0;",Tooltips.disappeardelay); },
			reltoelement : function (linkobj) { var relvalue=linkobj.getAttribute("rel"); return (relvalue!=null && relvalue!="" && document.getElementById(relvalue)!=null && document.getElementById(relvalue).className=="BalloonTipsStyle")? true : false; },

			getposOffset : function (what, offsettype) {
				var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
				var parentEl=what.offsetParent;
				while (parentEl!=null){
					totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
					parentEl=parentEl.offsetParent;
				}
				return totaloffset;
			},

			clearbrowseredge : function (obj, whichedge) {
				if (whichedge=="rightedge"){
					edgeoffsetx=0;
					var windowedge=Tooltips.ie && !window.opera? Tooltips.iecompattest().scrollLeft+Tooltips.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15;
					dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;
					if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure) edgeoffsetx=dropmenuobj.contentmeasure-obj.offsetWidth;
					return edgeoffsetx;
				}
				else{
					edgeoffsety=0;
					var topedge=Tooltips.ie && !window.opera? Tooltips.iecompattest().scrollTop : window.pageYOffset;
					var windowedge=Tooltips.ie && !window.opera? Tooltips.iecompattest().scrollTop+Tooltips.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
					dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;
					if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure) edgeoffsety=dropmenuobj.contentmeasure+obj.offsetHeight+(Tooltips.verticaloffset*2);
					return edgeoffsety;
				}
			},

			displaytooltip : function (obj, e) {
				if (window.event) event.cancelBubble=true;
				else if (e.stopPropagation) e.stopPropagation();
				if (typeof dropmenuobj!="undefined") dropmenuobj.style.visibility="hidden";
				Tooltips.clearhidemenu();
				dropmenuobj=document.getElementById(obj.getAttribute("rel"));
				Tooltips.showhide(dropmenuobj.style, e);
				dropmenuobj.x=Tooltips.getposOffset(obj, "left");
				dropmenuobj.y=Tooltips.getposOffset(obj, "top")+Tooltips.verticaloffset;
				dropmenuobj.style.left=dropmenuobj.x-Tooltips.clearbrowseredge(obj, "rightedge")+"px";
				dropmenuobj.style.top=dropmenuobj.y-Tooltips.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";
				if (typeof dropmenuobj!="undefined") dropmenuobj.style.visibility="visible";
			},

			initalizetooltips : function () {
				for (var j=0; j<Tooltips.SupportedTags.length; j++){
					var all_links=document.getElementsByTagName(Tooltips.SupportedTags[j]);
					for (var i=0; i<all_links.length; i++){
						if (Tooltips.reltoelement(all_links[i])){
							all_links[i].onmouseover=function(e){
								var evtobj=window.event? window.event : e;
								Tooltips.displaytooltip(this, evtobj); }
							all_links[i].onmouseout=function(){ Tooltips.delayhidemenu(); }
						}
					}
				}
			}

		}

		if (window.addEventListener) window.addEventListener("load", Tooltips.initalizetooltips, false);
		else if (window.attachEvent) window.attachEvent("onload", Tooltips.initalizetooltips);
		else if (document.getElementById) window.onload=Tooltips.initalizetooltips;
		var PopupWindow;
function popup(Url, Width, Height, Scrollbars)
{
	moveToX = (screen.width/2) - (Width/2);
	moveToY = (screen.height/2) - (Height/2) - 55;
	if (PopupWindow) PopupWindow.close();
	PopupWindow = window.open(Url,'newWin','toolbar=no,location=yes,directories=no,status=yes, menubar=no,scrollbars='+Scrollbars+',resizable=no,copyhistory=yes,width='+Width+',height='+Height);
	PopupWindow.moveTo(moveToX,moveToY);
}
function FontSelect(TheField, TheSample) {
	var TheField = document.getElementById(TheField).value;
	var TheDiv = document.getElementById(TheSample);
	TheDiv.style.fontFamily = TheField;
}
function ToggleDiv(ObjId) {
	var Obj = document.getElementById(ObjId);
	if (Obj.style.display == 'none') Obj.style.display = '';
	else Obj.style.display = 'none';
}//ToggleDiv
function Toggle(ObjId) { ToggleDiv(ObjId); }
var Base64 = {

	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	encode : function (input) {

		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {
			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) { enc3 = enc4 = 64; }
			else if (isNaN(chr3)) { enc4 = 64; }

			output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
		}
		return output;
	},

	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {
			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);
			if (enc3 != 64) { output = output + String.fromCharCode(chr2); }
			if (enc4 != 64) { output = output + String.fromCharCode(chr3); }
		}
		output = Base64._utf8_decode(output);
		return output;
	},

	_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;
	},

	_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;
	}
}

var Fader = {

	BlendTime : 300,
	BlendInTime : 300,
	BlendOutTime : 150,

	SetOpacity : function (Opacity, id) {
	    var object = document.getElementById(id).style;
	    object.opacity = (Opacity / 100);
	    object.MozOpacity = (Opacity / 100);
	    object.KhtmlOpacity = (Opacity / 100);
	    object.filter = "alpha(opacity=" + Opacity + ")";
	},

	ShiftOpacity : function (id, Start, End) {
	    var speed = Math.round(Fader.BlendTime / 100);
	    var timer = 0;

	    if(Start > End) {
	    	var speed = Math.round(Fader.BlendOutTime / 100);
	        for(i = Start; i >= End; i--) {
	            setTimeout("Fader.SetOpacity(" + i + ",'" + id + "')",(timer * speed));
	            timer++; }
	    } else if(Start < End) {
	    	var speed = Math.round(Fader.BlendInTime / 100);
	        for(i = Start; i <= End; i++) {
	            setTimeout("Fader.SetOpacity(" + i + ",'" + id + "')",(timer * speed));
	            timer++; }
	    }
	},

	Toggle : function (id) {
	    if(document.getElementById(id).style.opacity == 0) {
	        Fader.ShiftOpacity(id, 0, 100); }
		else {
	        Fader.ShiftOpacity(id, 100, 0); }
	},

	Blend : function (id, di) {
	    Fader.ShiftOpacity(id, 100, 0);
		document.getElementById(id).style.display = 'none';
		Fader.SetOpacity(0, di);
		document.getElementById(di).style.display = '';
		Fader.ShiftOpacity(di, 0, 100);
	}

}


document.write('<style type="text/css">.colorpicker301{text-align:center;visibility:hidden;display:none;position:absolute;background-color:#FFF;border:solid 1px #CCC;padding:4px;z-index:999;}.o5582brd{padding:0;width:10px;height:10px;}a.o5582n66,.o5582n66,.o5582n66a{width:10px;height:10px;text-decoration:underline;color:#666;border:none;}.o5582n66,.o5582n66a{text-align:center;text-decoration:none;}a:hover.o5582n66{text-decoration:none;color:#FFA500;cursor:pointer;}.a01p3{width:100%;}</style>');

var ColorPicker = {

	nocol1 : "&#78;&#79;&#32;&#67;&#79;&#76;&#79;&#82;",
	clos1 : "&#67;&#76;&#79;&#83;&#69;",
	tt6 : "&#70;&#82;&#69;&#69;&#45;&#67;&#79;&#76;&#79;&#82;&#45;&#80;&#73;&#67;&#75;&#69;&#82;&#46;&#67;&#79;&#77;",
	hm6 : "&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#119;&#119;&#119;&#46;"+this.tt6,

	getScrollY : function(){
		var scrOfX = 0,scrOfY=0;

		if(typeof(window.pageYOffset)=='number'){
			scrOfY=window.pageYOffset;
			scrOfX=window.pageXOffset;}
		else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){
			scrOfY=document.body.scrollTop;
			scrOfX=document.body.scrollLeft;}
		else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){
			scrOfY=document.documentElement.scrollTop;
			scrOfX=document.documentElement.scrollLeft;}

		return scrOfY;
	},

	gett6op6 : function(){
		csBrHt=0;

		if(typeof(window.innerWidth)=='number'){ csBrHt=window.innerHeight; }
		else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){ csBrHt=document.documentElement.clientHeight; }
		else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){ csBrHt=document.body.clientHeight; }

		ctop=((csBrHt/2)-142)+ColorPicker.getScrollY();
		return ctop;
	},

	getLeft6 : function(){
		var csBrWt=0;

		if(typeof(window.innerWidth)=='number'){ csBrWt=window.innerWidth; }
		else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){ csBrWt=document.documentElement.clientWidth; }
		else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){ csBrWt=document.body.clientWidth; }

		cleft=(csBrWt/2)-125;
		return cleft;
	},

	setCCbldID6 : function(objID,val){document.getElementById(objID).value=val;},

	setCCbldSty6 : function(objID,prop,val){
		switch(prop){
			case "bc":if(objID!='none'){document.getElementById(objID).style.backgroundColor=val;}break;
			case "vs":document.getElementById(objID).style.visibility=val;break;
			case "ds":document.getElementById(objID).style.display=val;break;
			case "tp":document.getElementById(objID).style.top=val;break;
			case "lf":document.getElementById(objID).style.left=val;break;
		}
	},

	putOBJxColor6 : function(OBjElem,Samp,pigMent){
		if(pigMent!='x'){
			ColorPicker.setCCbldID6(OBjElem,pigMent);
			ColorPicker.setCCbldSty6(Samp,'bc',pigMent);
		}
		ColorPicker.setCCbldSty6('colorpicker301','vs','hidden');
		ColorPicker.setCCbldSty6('colorpicker301','ds','none');
	},

	showColorGrid3 : function(OBjElem,Sam){
		var objX=new Array('00','22','44','66','88','AA','CC','EE');
		var c=0;
		var z='"'+OBjElem+'","'+Sam+'",""';
		var xl='"'+OBjElem+'","'+Sam+'","x"';
		var mid='';
		mid+='<center><table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0"><tr>';
		mid+="<td colspan='32' align='left' style='background:#6666CC;color:#FFF;'>Pick a color:</td></tr><tr><td colspan='32' align='center'><input type='text' style='width:110px;border:1px solid;' id='o5582n66a' onclick='javascript:alert(\"click on selected swatch below...\");' value=''>&nbsp;<input type='text' size='8' id='o5582n66' value='#FFFFFF'>&nbsp;|&nbsp;<a class='o5582n66' href='javascript:onclick=ColorPicker.putOBJxColor6("+z+")'><span class='a01p3'>"+ColorPicker.nocol1+"</span></a>&nbsp;|&nbsp;<a class='o5582n66' href='javascript:onclick=ColorPicker.putOBJxColor6("+xl+")'><span class='a01p3'>"+ColorPicker.clos1+"</span></a></td></tr><tr><td colspan='32'><hr /></td></tr><tr>";
		var br=1;

		for(o=0;o<8;o++){
			for(y=0;y<8;y++){
				if(y%4==0){ mid+='</tr><tr>'; }
				for(x=0;x<8;x++){
					var grid='';
					grid=objX[y]+objX[o]+objX[x];
					var b="'"+OBjElem+"', '"+Sam+"','#"+grid+"'";
					mid+='<td class="o5582brd" style="background-color:#'+grid+'"><a class="o5582n66"  href="javascript:onclick=ColorPicker.putOBJxColor6('+b+');" onmouseover=javascript:document.getElementById("o5582n66").value="#'+grid+'";javascript:document.getElementById("o5582n66a").style.backgroundColor="#'+grid+'";  title="#'+grid+'"><div class="o5582brd"></div></a></td>';
					c++; }
			}
		}

		mid+='</tr></table>';
		var objX=new Array('0','2','4','6','8','A','C','E');
		var c=0;
		var z='"'+OBjElem+'","'+Sam+'",""';
		var xl='"'+OBjElem+'","'+Sam+'","x"';
		mid+='<br /><table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0"><tr>';
		var br=0;

		for(y=0;y<8;y++){
			for(x=0;x<8;x++){
				if(br==32){
					br=0;
					mid+='</tr><tr>';
				}
				br++;
				var grid='';
				grid=objX[y]+objX[x]+objX[y]+objX[x]+objX[y]+objX[x];
				var b="'"+OBjElem+"', '"+Sam+"','#"+grid+"'";
				mid+='<td class="o5582brd" style="background-color:#'+grid+'"><a class="o5582n66"  href="javascript:onclick=ColorPicker.putOBJxColor6('+b+');" onmouseover=javascript:document.getElementById("o5582n66").value="#'+grid+'";javascript:document.getElementById("o5582n66a").style.backgroundColor="#'+grid+'";  title="#'+grid+'"><div class="o5582brd"></div></a></td>';
				c++;
			}
		}
		mid+='</tr></table></center>';
		ColorPicker.setCCbldSty6('colorpicker301','tp','200px');
		document.getElementById('colorpicker301').style.top=ColorPicker.gett6op6();
		document.getElementById('colorpicker301').style.left=ColorPicker.getLeft6();
		ColorPicker.setCCbldSty6('colorpicker301','vs','visible');
		ColorPicker.setCCbldSty6('colorpicker301','ds','block');
		document.getElementById('colorpicker301').innerHTML=mid;
	}

}

var TreeMenu = {

	createTree : function(treeid){

		var ultags=document.getElementById(treeid).getElementsByTagName("ul");
		for (var i=0; i<ultags.length; i++) this.buildSubTree(treeid, ultags[i], i);

	},

	buildSubTree : function(treeid, ulelement, index){

		ulelement.parentNode.className="submenu";

		if (ulelement.getAttribute("rel")==null || ulelement.getAttribute("rel")==false) ulelement.setAttribute("rel", "closed");
		else if (ulelement.getAttribute("rel")=="open") this.expandSubTree(treeid, ulelement);

		ulelement.parentNode.onclick=function(e){

			var submenu=this.getElementsByTagName("ul")[0]

			if (submenu.getAttribute("rel")=="closed"){
				submenu.style.display="block";
				submenu.setAttribute("rel", "open");
			}
			else if (submenu.getAttribute("rel")=="open"){
				submenu.style.display="none";
				submenu.setAttribute("rel", "closed");
			}

			TreeMenu.preventpropagate(e);

		}

		ulelement.onclick=function(e){ TreeMenu.preventpropagate(e); }

	},

	expandSubTree : function(treeid, ulelement){

		var rootnode=document.getElementById(treeid);
		var currentnode=ulelement;
		currentnode.style.display="block";

		while (currentnode!=rootnode){

			if (currentnode.tagName=="UL"){ //if parent node is a UL, expand it too
				currentnode.style.display="block";
				currentnode.setAttribute("rel", "open"); //indicate its open
			}

			currentnode=currentnode.parentNode;

		}

	},

	flatten : function(treeid, action){

		var ultags=document.getElementById(treeid).getElementsByTagName("ul");

		for (var i=0; i<ultags.length; i++){
			ultags[i].style.display=(action=="expand")? "block" : "none";
			var relvalue=(action=="expand")? "open" : "closed";
			ultags[i].setAttribute("rel", relvalue);
		}

	},

	searcharray : function(thearray, value){

		var isfound=false;

		for (var i=0; i<thearray.length; i++){
			if (thearray[i]==value){
				isfound=true;
				thearray.shift(); //delete this element from array for efficiency sake
				break;
			}
		}

		return isfound;

	},

	preventpropagate : function(e){
		if (typeof e!="undefined") e.stopPropagation();
		else event.cancelBubble=true;
	},

	dotask : function(target, functionref, tasktype){

		var tasktype=(window.addEventListener)? tasktype : "on"+tasktype;

		if (target.addEventListener) target.addEventListener(tasktype, functionref, false);
		else if (target.attachEvent) target.attachEvent(tasktype, functionref);

	}

}

