//Nifty
/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? true : false);
}

function Nifty(selector,options){
if(niftyOk==false) return;
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#FFFFFF";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

function rgb2hex(value){
var hex="",v,h,i;
var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
var h=regexp.exec(value);
for(i=1;i<4;i++){
    v=parseInt(h[i]).toString(16);
    if(v.length==1) hex+="0"+v;
    else hex+=v;
    }
return("#"+hex);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    r[i]=r[i].toString(16);
    if(r[i].length==1) r[i]="0"+r[i];
    }
return("#"+r[0]+r[1]+r[2]);
}


function FormatTables(div) {
	var conDiv = document.getElementById(div);
	var wdt = document.body.offsetWidth-200;
	var ht = document.body.offsetHeight-50;
	var tblColl = conDiv.getElementsByTagName("TABLE");
	for (var t=0;t<tblColl.length;t++) {
		var tblObj = tblColl[t];
		var tblPar = tblObj.parentNode;
		tblPar.style.overflow = "auto";
		var currWidth = (tblPar.style.width)?parseInt(tblPar.style.width.replace("px","")):tblPar.offsetWidth;
		if (wdt < (currWidth+100)) {
			tblPar.style.height = Math.min(300,Math.max(tblPar.offsetHeight,150))+"px";
		} else {
			tblPar.style.height = "auto";
		}
		tblPar.style.width = wdt;
	}
}

var validStr = new Object();
	validStr["currency"] = /(^\$\d{1,3}(,\d{3})*\.\d{2}$)|(^\(\$\d{1,3}(,\d{3})*\.\d{2}\)$)/;
	validStr["email"]  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	validStr["numeric"]  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 
	validStr["integer"]  = /(^-?\d\d*$)/;
	validStr["time"] = /^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;
	validStr["date"] = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;

function ValidateForm(frmObj) {
	var x = frmObj.elements.length;
	var message = "";
	frmSubmit = 1;
	var more_message = "";
  	for (var i = 0; i < x; i++) {
		fldObj = frmObj.elements[i];
		req = fldObj.getAttribute('required');
		val = fldObj.getAttribute('vtype');
		more_message = "";
	    	if (req > 0) {
	      		more_message += frmValidRequired(frmObj,fldObj,strFrm.reqMsg);
	      	} 
			var msg_addition = "";
			var objRegExp = eval(validStr[val]);
			form_field_value = trimAll(fldObj.value);
			if (form_field_value != "" && (!objRegExp.test(form_field_value))) {
				msg_addition = fldObj.getAttribute('vlabel')+' '+msg;
				changeColor(frmObj,fldObj,1);
			}
			if (more_message != "" && (message == "")) {
				message = more_message;
				more_message="";
			} else if (more_message != "") {
				message = message + "\n" + more_message;
				more_message="";
			}
    }
	if (message > "") {
		alert(strFrm.formBeginMessage+":\n\n" + message + "\n\n"+strFrm.formEndMessage+".")
   		return false;
  	} else {
   		if (file_attached == 1 && flPth.length > 0) showProgress(flPth);//loadFileCopy(abRoot);
		return true;
   	}
	if (file_attached == 1 && flPth.length > 0) showProgress(flPth);//loadFileCopy(abRoot);
	return true;
}

var isWorking = false;
var http = createRequestObject();
var glossArr = new Object;
function showGlossary(term,obj) {
	if (!isWorking && http) {
		if (glossArr[term]) {
			coolTip(obj,glossArr[term], 300);
			return;
		}
		coolTip(obj,'<em><b>Please wait...</b><br>Retrieving description...</em>', 300);
		http.open('get', '_glossary.cfm?term='+term);
		http.onreadystatechange = function(){handleResponse(term,obj);};
		isWorking = true;
		http.send(null);
	}
}
function handleResponse(term,obj) {
	if(http.readyState == 4) {
		if (http.responseText.indexOf('invalid') == -1) {
			var response = http.responseText;
			glossArr[term] = response;
			coolTip(obj,response, 300);
			isWorking = false;
		}
	}
}

function getObjectPosition(elObj) {
	var objRealPos = Position.get(elObj);
	var posArr = new Array();
	posArr["x"] = objRealPos["left"];
	posArr["y"] = objRealPos["top"];
	return posArr;
}


var Position =(function(){function resolveObject(s){if(document.getElementById && document.getElementById(s)!=null){return document.getElementById(s);}else if(document.all && document.all[s]!=null){return document.all[s];}else if(document.anchors && document.anchors.length && document.anchors.length>0 && document.anchors[0].x){for(var i=0;i<document.anchors.length;i++){if(document.anchors[i].name==s){return document.anchors[i]}}}}var pos ={};
pos.set = function(o,left,top){if(typeof(o)=="string"){o = resolveObject(o);}if(o==null || !o.style){return false;}o.style.position = "absolute";if(typeof(left)=="object"){var pos = left;left = pos.left;top = pos.top;}o.style.left = left + "px";o.style.top = top + "px";return true;};
pos.get = function(o){var fixBrowserQuirks = true;if(typeof(o)=="string"){o = resolveObject(o);}if(o==null){return null;}var left = 0;var top = 0;var width = 0;var height = 0;var parentNode = null;var offsetParent = null;offsetParent = o.offsetParent;var originalObject = o;var el = o;while(el.parentNode!=null){el = el.parentNode;if(el.offsetParent==null){}else{var considerScroll = true;if(fixBrowserQuirks && window.opera){if(el==originalObject.parentNode || el.nodeName=="TR"){considerScroll = false;}}if(considerScroll){if(el.scrollTop && el.scrollTop>0){top -= el.scrollTop;}if(el.scrollLeft && el.scrollLeft>0){left -= el.scrollLeft;}}}if(el == offsetParent){left += o.offsetLeft;if(el.clientLeft && el.nodeName!="TABLE"){left += el.clientLeft;}top += o.offsetTop;if(el.clientTop && el.nodeName!="TABLE"){top += el.clientTop;}o = el;if(o.offsetParent==null){if(o.offsetLeft){left += o.offsetLeft;}if(o.offsetTop){top += o.offsetTop;}}offsetParent = o.offsetParent;}}if(originalObject.offsetWidth){width = originalObject.offsetWidth;}if(originalObject.offsetHeight){height = originalObject.offsetHeight;}return{'left':left, 'top':top, 'width':width, 'height':height};};
pos.getCenter = function(o){var c = this.get(o);if(c==null){return null;}c.left = c.left +(c.width/2);c.top = c.top +(c.height/2);return c;};return pos;})();

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var enabletip=false
var tipobj=null;
var pointerobj=null;

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function coolTip(obj,thetext, thewidth, thecolor){
	if (tipobj == null) {
		tipobj = document.createElement("DIV");
		tipobj.id = "dhtmltooltip";
		document.body.appendChild(tipobj);
	}
	if (pointerobj == null) {
		pointerobj = document.createElement("DIV");
		pointerobj.id = "dhtmlpointer";
		pointerobj.innerHTML = "<img src=\"/graphics/arrow_tip_up.gif\">";
		document.body.appendChild(pointerobj);
	}
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
	tipobj.innerHTML=thetext;
	enabletip=true;
	positiontip(obj);
	return false;
}

function positiontip(obj){
	if (enabletip){
		document.onclick=hidecoolTip;
		document.body.onscroll=hidecoolTip;
		var offsetfromcursorX=12 //Customize x offset of tooltip
		var offsetfromcursorY=10 //Customize y offset of tooltip
		
		var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
		var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).
		
		var offsetX = 0;
		var offsetY = 0;
		var nondefaultpos=false;

		var objPos = getObjectPosition(obj);
		var curX=objPos["x"]-offsetX;
		var curY=objPos["y"]-offsetY;

		//Let's see if the tooltip will be too wide;
		if ((curX+tipobj.offsetWidth) > document.body.scrollWidth) {
			curX = objPos["x"]-offsetX-tipobj.offsetWidth+40;
			offsetfromcursorX = tipobj.offsetWidth-30;
		} else if (curY+tipobj.offsetHeight > document.body.offsetHeight) { //If the tooltip will be too tall for the page
			//curX = objPos["y"]-offsetY-tipobj.offsetHeight+40;
			//offsetfromcursorY = tipobj.offsetHeight-30;
			//alert(0);
		}
		//window.status = offsetfromcursorX+" "+curX;
		var tooltipX = curX;
		var tooltipY = curY+offsetfromcursorY+offsetdivfrompointerY;
		var pointerX = curX+offsetfromcursorX;
		var pointerY = curY+offsetfromcursorY;
		
		tipobj.style.left = tooltipX+"px";
		tipobj.style.top=tooltipY+"px";
		pointerobj.style.left = pointerX+"px";
		pointerobj.style.top=pointerY+"px";

		tipobj.style.visibility="visible"
		pointerobj.style.visibility=(!nondefaultpos)?"visible":"hidden";
	}
}

function hidecoolTip(){
	enabletip=false
	tipobj.style.visibility="hidden"
	pointerobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
}

function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		ro = new XMLHttpRequest();
	}
	return ro;
}

// document.getElementsByAttribute([string attributeName],[string attributeValue],[boolean isCommaSeparatedList:false])
document.getElementsByAttribute=function(attrN,attrV,multi){
    attrV=attrV.replace(/\|/g,'\\|').replace(/\[/g,'\\[').replace(/\(/g,'\\(').replace(/\+/g,'\\+').replace(/\./g,'\\.').replace(/\*/g,'\\*').replace(/\?/g,'\\?').replace(/\//g,'\\/');
    var multi=typeof multi!='undefined'?multi:false,
        cIterate=typeof document.all!='undefined'?document.all:document.getElementsByTagName('*'),aResponse=[],re=new RegExp(multi?'\\b'+attrV+'\\b':'^'+attrV+'$'),i=0,elm;
    while((elm=cIterate.item(i++))){
        if(re.test(elm.getAttribute(attrN)||''))
            aResponse[aResponse.length]=elm;
    }
    return aResponse;
}

function globalOnload() {
	//Nifty("div.RoundBox","smooth");
}
if (window.attachEvent) window.attachEvent("onload",function(){globalOnload();});
else if (window.addEventListener) window.addEventListener("load",function(){globalOnload();});