/* Bleach v0.01 - Javascript AJAX, Multiple-Bar Progress Strip and Popup Window Library */
/* Developed by: Greg Frazier */

	function bleach(){
	   this.ajax = {
	        reqObj: 0,
	        dest: 0,
	        type: 0,
	        quiet: true,
	        showLoading: 0,
	        onComplete: function(){ if(this.quiet == false){alert("onComplete Called");}},
	        onSuccess: function(){ if(this.quiet == false){alert("onSuccess Called");}},
	        onAbort: function(){ if(this.quiet == false){alert("onAbort Called");}},
	        onFailure: function(){ if(this.quiet == false){alert("onFailure Called");}},
	        onLoading: function(){ if(this.quiet == false){alert("onLoading Called");}},
	        status: 0,
	        responseText: 0,
	        readyChange: 0,
	        params: 0,
	        about: function(){ alert("Bleach Library v0.01");},
	        createAjaxObj: function(){
		        if (window.XMLHttpRequest) {
			        return new XMLHttpRequest();
		        } else if(window.ActiveXObject) {
			        return new ActiveXObject("Microsoft.XMLHTTP");
		        }
		        return false;
	        },
	        setup: function(reqtype,destiny){
		        this.reqObj = this.createAjaxObj();
		        this.dest = destiny; // File to call
		        this.type = reqtype; // GET or POST
		        try{
		            if(this.reqObj == false){
			            // Something happened, and the ajax object could not be created
			            return false;
		            }
		        }catch(ex){;}
		        if(this.reqObj.readyState == 4 || this.reqObj.readyState == 0){
			        return true;
		        }
		        // Fresh Ajax Variable is NOT ready? Failure.
		        return false;		
	        },
	        responseHandler: function(pobj){
		        try{
		            if(typeof pobj.readyState == 'undefined'){ pobj = this.reqObj;}
		            if(pobj.readyState == 4) {
			            if(pobj.status == 200){
				            // onSuccess
				            var resText = pobj.responseText;
				            this.responseText = resText;
				            if(typeof this.onSuccess != "undefined"){
					            this.onSuccess();
				            }
			            }else if(pobj.status == 0){
				            // onAbort
				            alert("Aborted");
				            if(typeof this.onAbort != "undefined"){
					            this.onAbort();
				            }
			            }else{
				            // onFailure
				            if(typeof this.onFailure != "undefined"){
					            this.onFailure();
				            }
			            }
			            // onComplete
			            if(typeof this.onComplete != "undefined"){
				            this.onComplete();
			            }
		            }else{
			            // onLoading
			            if(typeof this.onLoading != "undefined"){
				            this.onLoading();
			            }
		            }	
		        }catch(ex){
                    var popup = new bleach();
                    popup.popup.alert("error", ex.message || ex.description);
		        } 
	        },        	
	        start: function(reqtype, destiny){
			        var gotime = this.setup(reqtype, destiny);
		            try{
			            if(gotime == false){
				            return false;
			            }
			        }catch(ex){;}
			        this.reqObj.open(this.type, this.dest, true);
			        this.reqObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			        var ths = this;
			        this.reqObj.onreadystatechange = function(){
			            ths.responseHandler(this);
			        }
			        if(typeof this.params == 'undefined'){
				        this.reqObj.send(null);
			        }else{
				        this.reqObj.send(this.params);
			        }
			        return true;
	        },
	        abort: function(){
		        this.reqObj.abort();
		        //this.onAbort();
		        //this.onComplete();
	        }
	   };
	   this.barstrip = {
	        width: 100,
	        size: 0,
	        full: false, // True = Piechart Bar Graphs, False = progress bars
	        total: -1,
	        values: new Array(),
	        colors: new Array(), // Corresponds with the values array. Predetermined Colors Only.
	        create: function(){
	            var rTable = "";
	            var x = 0;
	            var totalVal = 0;
	            /*
                    <table style="color: #3b3f42; width: 101px; line-height: 18pt; font-size: 0.8em; border: 1px solid #cecece;" cellpadding="0" cellspacing="0">
                    <tr><td class="poms_progress_side_green" style="width: 1px;"></td><td class="poms_progress_left_green" style="width: 12px;"></td><td class="poms_progress_side" style="width: 1px;"></td><td class="poms_progress_left" style="width: 20px;"></td><td class="poms_progress_right" style="width: 67px;"></td></tr>
                    </table>
                */
                rTable = '<table style="color: #3b3f42; width: ' + (this.width+2) + 'px; line-height: 18pt; font-size: 0.8em; border: 1px solid #cecece;" cellpadding="0" cellspacing="0">';
                rTable += '<tr>';
                var tempvar = 0;
                var tempiVal = 0;
                if(this.size == 0){ this.size = this.values.length;}
                for(x = 0; x < this.values.length; x++){
                    if(this.values[x] == "NaN"){tempvar = 0;}else{tempvar = Math.round(this.values[x]);}
                    var iW = Math.round(this.width / 100);
                    var iValue = Math.round((((tempvar * 1000) / (100 * 1000) * 100) * iW) - 1); // Integer Division
                    var sColor = this.colors[x];
                    if(tempvar != 0){
                        totalVal += tempvar;
                        tempiVal += (iValue + 1);
                        if(x == (this.values.length - 1) && this.full == true){
                            if(parseInt(tempiVal) < 100){
                                iValue += ((100*iW) - parseInt(tempiVal));
                                tempiVal = 100;
                            }
                        }
                        rTable += '<td class="poms_progress_side_' + sColor + '" style="width: 1px;"></td><td class="poms_progress_left_' + sColor + '" style="width: ' + iValue + 'px;"></td>';
                    }
                }
                //alert(totalVal);
                if(parseInt(tempiVal) < 100 || this.full == false){
                    rTable += '<td class="poms_progress_right" style="width: ' + Math.abs((100*iW)-parseInt(tempiVal)) + 'px;"></td>'
                }
                if(parseInt(totalVal) == 0){
                    // Empty Set
                    rTable = '<table style="color: #3b3f42; width: ' + (this.width+2) + 'px; line-height: 18pt; font-size: 0.8em; border: 1px solid #cecece;" cellpadding="0" cellspacing="0">';
                    rTable += '<tr>';                    
                    rTable += '<td class="poms_progress_right" style="width: 100%;"></td>';
                }
                rTable += '</tr>';
                rTable += '</table>';
                //alert(rTable);
                return rTable;
	        }
	   };
       this.popup = {
	        uid: 0,		    
	        idd: '',
		    kill_Loading: new Array(),
		    kill_tooltip: 0,
		    center: false,
		    wide: false,
		    fade: false,
		    fadein: true,
	        oresize: function(){return;},
		    isIE6: /msie|MSIE 6/.test(navigator.userAgent),
	        uniqueID: function(){
		        var uid = new Date;
		        return uid.getTime();
	        },
	        doClose: function(){
	            var fadedout = function(){return;};
	            
                if(!!this.oresize && typeof this.oresize == 'function'){
                    window.onresize = this.oresize;
                }else{
                    window.onresize = function(){return;};
                }
                    
                if(this.fadein == true){
                    //  Fade the Div in using Opacity.
                    document.getElementById(this.idd).style.filter = "alpha(opacity=100)";
                    document.getElementById(this.idd).style.opacity = "1.0";
                    fadedout = function(obj){
                        var hz = (Math.PI / (2 * 200)),
                            sTime = new Date().getTime();
                        var ff = function(){
                            var dTime = new Date().getTime() - sTime;
		                    if(dTime < 200){
			                    var f = Math.abs(Math.cos(dTime * hz));
			                    var ttttt = Math.round(100 - Math.round(f * -100 + (100)));
			                    //obj.innerHTML = "alpha(opacity=" + ttttt + ")";
			                    obj.style.filter = "alpha(opacity=" + ttttt + ")";
			                    obj.style.opacity = ttttt / 10;
			                    timer = setTimeout(function(){ff();}, 10);
		                    }else{
			                    clearTimeout(timer);
			                    obj.style.filter = "alpha(opacity=0)";
			                    obj.style.opacity = "0";
			                    document.body.removeChild(obj);
			                    document.body.removeChild(document.getElementById(obj.id + "_backdrop"));
		                    }
                        };
                        var timer = setTimeout(function(){ff();}, 10);
                    };
                }
	            fadedout(document.getElementById(this.idd));
	            //document.getElementById(this.idd).style.display='none';
	            //document.body.removeChild(document.getElementById(this.idd));
	            this.onClose();
	        },
	        onClose: function(){	            
	            return;
	        },
	        generate: function(type, inside_info, title, nodim){
		        var newdiv = document.createElement('div');
		        var backdrop = document.createElement('div');
		        var divid = type + this.uniqueID();
		        this.idd = divid;
		        var insi;
		        var width, inner_width, x_left;
		        var y = document.documentElement.clientHeight;
                var x = document.documentElement.clientWidth;
                var doctop = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
                var docleft = (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0);
                
                if(typeof nodim == "undefined"){ nodim = false; }
                
                backdrop.style.top = "0px";
                backdrop.style.left = docleft + "px";
                backdrop.style.width = x + "px";
                var ttttttt = (document.body.parentNode.scrollHeight > document.body.parentNode.offsetHeight ? document.body.parentNode.scrollHeight : document.body.parentNode.offsetHeight);
                backdrop.style.height = (ttttttt > document.body.offsetHeight ? ttttttt : document.body.offsetHeight) + "px";
                backdrop.style.backgroundColor = "#000000";
                backdrop.style.filter = "alpha(opacity=80)";
                backdrop.style.opacity = ".80";
                backdrop.style.zIndex = "499";
                backdrop.style.zoom = "1";
                backdrop.style.position = "absolute";
                backdrop.id = divid + "_backdrop";
                
                var fadedin = function(){return;};               
		        newdiv.id = divid;
		        if(this.wide != true){
		            newdiv.style.width = "621px";
		            width = 621;
		            inner_width = 614;
		            x_left = 595;
		        }else{
		            newdiv.style.width = "850px";
		            width = 850;
		            inner_width = 843;
		            x_left = 824;
		        }
		        newdiv.style.height = "452px";
		        if(this.isIE6 == true){newdiv.style.position = "absolute";}else{
		            newdiv.style.position = "fixed";
		            doctop = 0; docleft = 0;
		        }
		        //newdiv.style.position = "absolute";
		        
		        if(this.center == false){
		            newdiv.style.top = "50px";
		            newdiv.style.left = "50px";
		        }else{		        
		            newdiv.style.top = ((y/2 - 226) + doctop) + "px";
		            newdiv.style.left = ((x/2 - (width/2)) + docleft) + "px";
		        }		        
		        newdiv.style.display = "block";
		        if (type == "pm_forecast_popup") { newdiv.style.backgroundImage = "url('/POMS/images/popupWindow_pm.gif')"; }
		        if (type == "cmis_lite_popup") { newdiv.style.backgroundImage = "url('/POMS/images/popupWindow.gif')";}
		        if (type == "pm_forecast") { newdiv.style.backgroundImage = "url('/POMS/images/popupWindow_Widepm.gif')"; }
		        if (type == "om_popup" ) { newdiv.style.backgroundImage = "url('/POMS/images/popupWindow_om.gif')"; }
		        if (type == "site_count_popup" ) { newdiv.style.backgroundImage = "url('/POMS/images/popupWindow_om.gif')"; }
		        if (type != "pm_forecast_popup" && type != "om_popup" && type != "pm_forecast") { 
		            if(this.wide == true){newdiv.style.backgroundImage = "url('/POMS/images/pomsv3/wide_window.jpg')";}else{newdiv.style.backgroundImage = "url('/POMS/images/pomsv3/floatwindow.gif')";} }
		        newdiv.style.zIndex = "500";
		        newdiv.style.fontSize = "8pt";
		        //newdiv.innerHTML = "Tom Selleck Rules.";
		        //newdiv.innerHTML = "Thats your opinion.";
		        insi =  "<div tty=\"window_head\" class=\"dragclass\" style=\"position: absolute; width: 95%; height: 25px; cursor:pointer; line-height: 25px; font-weight: bold; color: #ffffff; padding-right: 5px; padding-left: 5px;\">" + title + "</div>";
		        insi += "<div id=\"" + divid + "_close\"style=\"position: absolute; left: " + x_left + "px; cursor:pointer; width: 25px; height 25px; line-height: 25px;\">&nbsp;</div>";
		        if (type == "pm_forecast"){
		            insi += "<div id=\"mainPortion\" style=\"position: relative; overflow-y: scroll; width: 848px; overflow-x: auto; height: 424px; margin: 1px; top: 27px; padding-right: 0px;\" onclick=\"javascript:getScrollHeight(this.scrollTop)\">";
		            insi += inside_info;
		            insi += "</div>";
		            //insi += "<div id=\"pageFooter\" style=\"font: 8pt/10pt verdana; overflow: hidden; width 619px; height: 18px;\" align=\"center\"><span onclick=\"window.open('http://www.pkmj.com/');\" style=\"cursor: pointer\">&copy; Copyright 2006-09 PKMJ All Rights Reserved.</span></div>";
		        }else{
		            insi += "<div id=\"bleachpopupclose\" style=\"display:none; cursor:pointer;\" closebtn=\"" + divid + "_close\"></div>";
		            insi += "<div id=\"inside_" + divid + "\" style=\"position: relative; overflow-y: auto; width: " + eval(inner_width+5) + "px; overflow-x: auto; height: 424px; margin: 1px; top: 27px;\">";
		            insi += inside_info;
		            insi += "</div>";
		        }
		        //alert(insi);
		        newdiv.innerHTML = insi;
		        
		        if(this.fadein == true){
		            //  Fade the Div in using Opacity.
		            newdiv.style.filter = "alpha(opacity=0)";
		            newdiv.style.opacity = "0";
		            fadedin = function(obj){
		                var hz = (Math.PI / (2 * 150)),
		                    sTime = new Date().getTime();
		                var ff = function(){
		                    var dTime = new Date().getTime() - sTime;
							if(dTime < 150){
								var f = Math.abs(Math.cos(dTime * hz));
								obj.style.filter = "alpha(opacity=" + Math.round(f * -100 + (100)) + ")";
								obj.style.opacity = Math.round(f * -100 + (100)) / 10;
								timer = setTimeout(function(){ff();}, 10);
							}else{
								clearTimeout(timer);
								obj.style.filter = "alpha(opacity=100)";
								obj.style.opacity = "1.0";
							}
		                };
		                var timer = setTimeout(function(){ff();}, 10);
		            };
		        }
		        
		        document.body.appendChild(newdiv);
		        var oldresize = function(){return;};
		        if(nodim == false){document.body.appendChild(backdrop);
                    if (typeof window.onresize == 'function'){
                        oldresize = window.onresize;
                    }
        	        window.onresize = function(){ 
                        var y1 = document.documentElement.clientHeight;
                        var x1 = document.documentElement.clientWidth;
                        backdrop.style.width = x1 + "px";
                        var ttttttt = (document.body.parentNode.scrollHeight > document.body.parentNode.offsetHeight ? document.body.parentNode.scrollHeight : document.body.parentNode.offsetHeight);
                        backdrop.style.height = (ttttttt > document.body.offsetHeight ? ttttttt : document.body.offsetHeight) + "px";
                        oldresize();
                    };
		        }
		        
		        var ttt = setTimeout(
		            function(){
                        fadedin(newdiv);
                    },5);
		        document.getElementById(divid + '_close').onClick = this.doClose;
		        document.getElementById(divid + '_close').onclick = this.doClose;
		        document.getElementById(divid + '_close').idd = this.idd;
		        document.getElementById(divid + '_close').oresize = oldresize;
		        document.getElementById(divid + '_close').onClose = this.onClose;
		        document.getElementById(divid + '_close').fadein = this.fadein;
		        return divid;
	        },        
	        tip: function(x, y, bodyText, titleText){
	            var newdiv = document.createElement('div');
	            var divid = "tooltip" + this.uniqueID();
	            var titleDiv;
	            newdiv.id = divid;
	            //newdiv.style.width = "200px";
	            //newdiv.style.height = "100px";
	            newdiv.style.position = "absolute";
	            newdiv.style.top = (parseInt(y+0)-10) + "px";
	            newdiv.style.left = (parseInt(x+0) + 20) + "px";
	            newdiv.style.display = "block";
	            newdiv.style.zIndex = "501";
	            newdiv.style.fontSize = "8pt";
	            newdiv.style.color = "#ffffff";
	            //newdiv.style.backgroundColor = "#192227";
	            newdiv.style.backgroundColor = "#1e376a";
	            newdiv.style.padding = "3px";
	            if(typeof titleText != "undefined"){
	                titleDiv = "<div style=\"width: 199px;\">" + titleText + "</div>";
                }else{ titleDiv = "";}
                newdiv.innerHTML = titleDiv + " " + bodyText;
                document.body.appendChild(newdiv);
                this.kill_tooltip = newdiv;
	        },
	        tipmove: function(e){
	            if (!e) e = window.event;
                var newdiv = this.kill_tooltip;
			    var doctop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
			    var docleft = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
			    var top1  = (e.clientY + doctop);
			    var left1 = (e.clientX + docleft);
	            newdiv.style.top = (parseInt(top1+0)-10) + "px";
	            newdiv.style.left = (parseInt(left1+0) + 20) + "px";
	        },	        
            tipdie: function(){
	            try{
                    document.body.removeChild(this.kill_tooltip);
                    this.kill_tooltip = 0;
                }catch(ex){
                    ;
                }
	        },	        
	        killLoading: function(){
                try{
                    var fadedout = function(){return;};
                    if(!!this.kill_Loading[3] && typeof this.kill_Loading[3] == 'function'){
                        window.onresize = this.kill_Loading[3];
                    }else{
                        window.onresize = function(){return;};
                    }
                    if(this.fadein == true){
                        //  Fade the Div in using Opacity.
                        this.kill_Loading[1].style.filter = "alpha(opacity=100)";
                        this.kill_Loading[1].style.opacity = "1.0";
                        fadedout = function(obj){
                            var hz = (Math.PI / (2 * 300)),
                                sTime = new Date().getTime();
                            var ff = function(){
                                var dTime = new Date().getTime() - sTime;
			                    if(dTime < 300){
				                    var f = Math.abs(Math.cos(dTime * hz));
				                    var ttttt = Math.round(100 - Math.round(f * -100 + (100)));
				                    //obj.innerHTML = "alpha(opacity=" + ttttt + ")";
				                    obj.style.filter = "alpha(opacity=" + ttttt + ")";
				                    obj.style.opacity = ttttt / 10;
				                    timer = setTimeout(function(){ff();}, 10);
			                    }else{
				                    clearTimeout(timer);
				                    obj.style.filter = "alpha(opacity=0)";
				                    obj.style.opacity = "0";
				                    document.body.removeChild(obj);                
			                    }
                            };
                            var timer = setTimeout(function(){ff();}, 10);
                        };
                    }
		            fadedout(this.kill_Loading[1]);
		            document.body.removeChild(this.kill_Loading[0]);
		            document.body.removeChild(this.kill_Loading[2]);
                    this.kill_Loading = new Array();
                }catch(ex){
                    ;
                }
	        },
	        alert: function(type,title,exeAfter){
	            // These divs are the reverse of their variable name
		        var infopop = document.createElement('div');
		        var objArr = new Array();		
		        var divid = type + this.uniqueID();
		        //type; //+ this.uid;
		        var insi;
		        var y = document.documentElement.clientHeight;
		        var x = document.documentElement.clientWidth;
		        var doctop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
                var docleft = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;  
                var fadedin = function(){return;};
        		
		        infopop.id = divid;
		        infopop.style.width = (x/2) + "px"; //"280px";
		        infopop.style.height = "100px";
		        if(this.isIE6 == true){infopop.style.position = "absolute";}else{
		            infopop.style.position = "fixed";
		            doctop = 0; docleft = 0;
		        }
		        infopop.style.top = ((y/2 - 50) + doctop) + "px";
		        infopop.style.left = ((x/2 - (x/4)) + docleft) + "px";
		        infopop.style.display = "block";
		        infopop.style.fontSize = "8pt";
		        infopop.style.backgroundColor = "#ffffff";
		        infopop.style.zIndex = "502";
		        infopop.style.border = "5px solid #000000";
		        /*if(title == undefined || title == "Loading..."){
			        infopop.innerHTML = "<div class='poms_loading_atom' style='height: 100px;'>Loading...</div>";
		        }else{*/
			    
			    var pop_image = "";
			    switch(type)
			    {
			        case "error": pop_image = "/POMS/images/pomsv3/error.png"; break;
			        case "exclamation": pop_image = "/POMS/images/pomsv3/exclamation.png"; break;
			        case "good": pop_image = "/POMS/images/greenFlag.png"; break;
			        case "obsolete": pop_image = "/POMS/images/redFlag.png"; break;
			        case "oird": pop_image = "/POMS/images/pomsv3/poms_oird.png"; break;
			        default: pop_image = "/POMS/images/pomsv3/accept.gif"; break;
			    }
			    var tt = "<div style=\"float: left; margin: 5px; height: 100%;\"><img src=\"" + pop_image + "\"></div>";
			    tt += "<div style=\"float: left; overflow: auto; height: 55px;\">" + title + "</div><div style=\"clear: both;\"></div>";
			    tt += "<div id=\"" + divid + "_close\" style=\"margin: 0px auto; margin-top: -40px; border: 1px solid #000000; text-align: center; width: 60px; cursor: pointer;\">Close</div>";
			    if(type == "error"){
			        tt += "<div style=\"color: #980909; font-size: 0.8em; padding-left: 3px;\">If this problem persists, please contact PKMJ Technical Services.</div>";
			    }else{
			        tt += "<div style=\"color: #006a9b; font-size: 0.8em; padding-left: 3px;\">Need Help? Try our Live Chat.</div>";
			    }
			    
			    infopop.innerHTML = tt;
		        
		        //}
		        
		        if(this.fadein == true){
		            //  Fade the Div in using Opacity.
		            infopop.style.filter = "alpha(opacity=0)";
		            infopop.style.opacity = "0";
		            fadedin = function(obj){
		                var hz = (Math.PI / (2 * 100)),
		                    sTime = new Date().getTime();
		                var ff = function(){
		                    var dTime = new Date().getTime() - sTime;
							if(dTime < 100){
								var f = Math.abs(Math.cos(dTime * hz));
								obj.style.filter = "alpha(opacity=" + Math.round(f * -100 + (100)) + ")";
								obj.style.opacity = Math.round(f * -100 + (100)) / 10;
								timer = setTimeout(function(){ff();}, 10);
							}else{
								clearTimeout(timer);
								obj.style.filter = "alpha(opacity=100)";
								obj.style.opacity = "1.0";
							}
		                };
		                var timer = setTimeout(function(){ff();}, 10);
		            };
		        }
	            document.body.appendChild(infopop);
	            var ttt = setTimeout(
	                function(){
	                    fadedin(infopop);
	                },5);
		        document.getElementById(divid + '_close').onClick = this.popClose;
		        document.getElementById(divid + '_close').onclick = this.popClose;
		        document.getElementById(divid + '_close').idd = divid;
		        if(!!exeAfter){
		            document.getElementById(divid + '_close').exeAfter = exeAfter;
		        }
		        //document.getElementById(divid + '_close').onClose = this.onClose;
		        document.getElementById(divid + '_close').fadein = this.fadein;
		        return divid;	                
		        return;
	        },
            popClose: function(){
	            var fadedout = function(){return;};
                    
                if(this.fadein == true){
                    //  Fade the Div in using Opacity.
                    document.getElementById(this.idd).style.filter = "alpha(opacity=100)";
                    document.getElementById(this.idd).style.opacity = "1.0";
                    fadedout = function(obj, exeAfter){
                        var hz = (Math.PI / (2 * 200)),
                            sTime = new Date().getTime();
                        var ff = function(){
                            var dTime = new Date().getTime() - sTime;
		                    if(dTime < 200){
			                    var f = Math.abs(Math.cos(dTime * hz));
			                    var ttttt = Math.round(100 - Math.round(f * -100 + (100)));
			                    obj.style.filter = "alpha(opacity=" + ttttt + ")";
			                    obj.style.opacity = ttttt / 10;
			                    timer = setTimeout(function(){ff();}, 10);
		                    }else{
			                    clearTimeout(timer);
			                    obj.style.filter = "alpha(opacity=0)";
			                    obj.style.opacity = "0";
			                    if(!!exeAfter){exeAfter();}
			                    document.body.removeChild(obj);
		                    }
                        };
                        var timer = setTimeout(function(){ff();}, 10);
                    };
                }
	            fadedout(document.getElementById(this.idd), this.exeAfter);
	            return;
	        },	        
	        loading: function(type,title,nodim){
	            // These divs are the reverse of their variable name
		        try{
	                var newdiv = document.createElement('div');
	                var newdivshadow = document.createElement('div');
    		        
	                var backdrop = document.createElement('div');
    		        
	                var objArr = new Array();		
	                var divid = type; //+ this.uid;
	                var insi;
	                var y = document.documentElement.clientHeight;
	                var x = document.documentElement.clientWidth;
	                var doctop = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
                    var docleft = (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0);
                    var fadedin = function(){return;};
                    
                    backdrop.style.top = "0px";
                    backdrop.style.left = docleft + "px";
                    backdrop.style.width = x + "px";
                    var ttttttt = (document.body.parentNode.scrollHeight > document.body.parentNode.offsetHeight ? document.body.parentNode.scrollHeight : document.body.parentNode.offsetHeight);
                    backdrop.style.height = (ttttttt > document.body.offsetHeight ? ttttttt : document.body.offsetHeight) + "px";
                    backdrop.style.backgroundColor = "#000000";
                    backdrop.style.filter = "alpha(opacity=80)";
                    backdrop.style.opacity = ".80";
                    backdrop.style.zIndex = "499";
                    backdrop.style.zoom = "1";
                    backdrop.style.position = "absolute";
    		        
	                if(this.fade == true){
	                    newdiv.id = divid;
	                    newdiv.style.width = document.getElementsByTagName('HTML')[0].scrollWidth + "px"; //"300px";
	                    newdiv.style.height = document.getElementsByTagName('HTML')[0].scrollHeight + "px";// "120px";
	                    newdiv.style.position = "absolute";
                		
	                    newdiv.style.top = "131px"; //((y/2 - 60) + doctop) + "px";
	                    newdiv.style.left = "0px"; //((x/2 - 150) + docleft) + "px";
                		
	                    newdiv.style.display = "block";
	                    newdiv.style.zIndex = "501";
	                    newdiv.style.backgroundColor = "white";
	                    newdiv.style.opacity = ".90";
	                    newdiv.style.filter = "alpha(opacity=90)";
	                }
            		
	                newdivshadow.style.width = "280px";
	                newdivshadow.style.height = "100px";
	                //newdivshadow.style.position = "absolute";
	                if(this.isIE6 == true){newdivshadow.style.position = "absolute";}else{
	                    newdivshadow.style.position = "fixed";
	                    doctop = 0; docleft = 0;
	                }		        
	                newdivshadow.style.top = ((y/2 - 50) + doctop) + "px";
	                newdivshadow.style.left = ((x/2 - 140) + docleft) + "px";
	                newdivshadow.style.display = "block";
	                newdivshadow.style.fontSize = "12pt";
	                newdivshadow.style.backgroundColor = "#ffffff";
	                newdivshadow.style.zIndex = "502";
	                newdivshadow.style.border = "3px solid #000000";
	                newdivshadow.idd = divid;
	                if(typeof title == 'undefined' || title == "Loading..." || type == "load"){
		                newdivshadow.innerHTML = "<div class='poms_loading_atom' style='height: 100px;'>" + title + "</div>";
	                }else{
		                newdivshadow.innerHTML = title;
	                }
    		        
	                if(this.fadein == true){
	                    //  Fade the Div in using Opacity.
	                    newdivshadow.style.filter = "alpha(opacity=0)";
	                    newdivshadow.style.opacity = "0";
	                    fadedin = function(obj){
	                        var hz = (Math.PI / (2 * 500)),
	                            sTime = new Date().getTime();
	                        var ff = function(){
	                            var dTime = new Date().getTime() - sTime;
						        if(dTime < 500){
							        var f = Math.abs(Math.cos(dTime * hz));
							        obj.style.filter = "alpha(opacity=" + Math.round(f * -100 + (100)) + ")";
							        obj.style.opacity = Math.round(f * -100 + (100)) / 10;
							        timer = setTimeout(function(){ff();}, 10);
						        }else{
							        clearTimeout(timer);
							        obj.style.filter = "alpha(opacity=100)";
							        obj.style.opacity = "1.0";
						        }
	                        };
	                        var timer = setTimeout(function(){ff();}, 10);
	                    };
	                }
    		        if(typeof nodim == "undefined"){ nodim = false; }    
	                if(!this.kill_Loading[0]){
	                    document.body.appendChild(newdiv);
	                    document.body.appendChild(newdivshadow);
	                    var oldresize = function(){return;};
	                    if(nodim == false){ 
	                        document.body.appendChild(backdrop);
                            var oldresize = function(){return;};
                            if (typeof window.onresize == 'function'){
                                oldresize = window.onresize;
                            }		        	                        
	                        window.onresize = function(){ 
                                var y1 = document.documentElement.clientHeight;
                                var x1 = document.documentElement.clientWidth;
                                backdrop.style.width = x1 + "px";
                                var ttttttt = (document.body.parentNode.scrollHeight > document.body.parentNode.offsetHeight ? document.body.parentNode.scrollHeight : document.body.parentNode.offsetHeight);
                                backdrop.style.height = (ttttttt > document.body.offsetHeight ? ttttttt : document.body.offsetHeight) + "px";
                                oldresize();
                            };
	                    }
	                    var ttt = setTimeout(
	                        function(){
	                            fadedin(newdivshadow);
	                        },5);
	                    this.kill_Loading[0] = newdiv;
	                    this.kill_Loading[1] = newdivshadow;
	                    this.kill_Loading[2] = backdrop;
	                    this.kill_Loading[3] = oldresize;
	                }
	            }catch(ex){
	                alert((ex.message || ex.description || "unknown error"));
	            }
		        return;
	        }
	    };
	};
	
	if  (document.getElementById){
		(function(){

			if (window.opera){
				document.write("<input type='hidden' id='Q' value=' '>");
			}

			var n = 500;
			var dragok = false;
			var sizeok = false;
			var y,x,d,dy,dx,MAX_X,MAX_Y,sx,sy;
			
			function move(e){
				if (!e) e = window.event;
				if (dragok){
						d.style.left = dx + e.clientX - x + "px";
						d.style.top  = dy + e.clientY - y + "px";
					return false;
				}
			}
			
			function addEvent(func, obj) {
	            var oldonload = obj.onmouseout;
	            if (typeof obj.onmouseout != 'function') {
	            obj.onmouseout = func;
	            } else {
	            obj.onmouseout = function() {
		            if (oldonload) {
		            oldonload();
		            }
		            func();
	            }
	            }
            }
			
			function overit(e){				
				if(!e){ e = window.event; }
				var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
				if(temp == null || typeof temp == 'undefined'){return;}
				var tempr;
				if ((temp.tagName == "DIV"  || temp.tagName == "SPAN") && temp.className.indexOf("forceTip") == -1){
				    try{
				        tempr = temp.attributes['tiptext'].nodeValue
				    }catch(ex){
				        tempr = temp.tiptext;
				    }
					if(typeof tempr != "undefined"){
					    var doctop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
					    var docleft = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
					    var top1  = (e.clientY + doctop) + "px";
					    var left1 = (e.clientX + docleft) + "px";
					    if(temp.offsetWidth < temp.scrollWidth && temp.innerText.substring(0,18) != "Advanced Search - "){
					        var f = new bleach();
                            f.popup.tip(left1, top1, tempr);
                            temp.onmouseout = function(){f.popup.tipdie(); this.onmousemove = ""; f = undefined; this.onmouseout = "";};
                            temp.onmousemove = function(){f.popup.tipmove();};
                        }
					}
				}else if(temp.className.indexOf("forceTip") > -1){
				    try{
				        tempr = temp.attributes['tiptext'].nodeValue
				    }catch(ex){
				        tempr = temp.tiptext;
				    }
					if(typeof tempr != "undefined"){
					    var doctop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
					    var docleft = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
					    var top1  = (e.clientY + doctop) + "px", left1 = (e.clientX + docleft) + "px";
				        var f = new bleach();
                        f.popup.tip(left1, top1, tempr);
                        temp.onmouseout = function(){f.popup.tipdie(); this.onmousemove = ""; f = undefined; this.onmouseout = "";};
                        temp.onmousemove = function(){f.popup.tipmove();};
					}
				}
			}			

			function down(e){
				if (!e) e = window.event;
				
				var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
				
				if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass" && temp.className != "sizeclass"){
					temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
				}
				if(temp == null || typeof temp == 'undefined'){return;}
	            
				if (temp.className == "dragclass"){
						temp = temp.parentNode;
						temp.style.zIndex = parseInt(temp.style.zIndex) + 1;
						if(temp.style.top == ""){ temp.style.top = "50px";}
						if(temp.style.left == ""){ temp.style.left = "50px";}
					if (window.opera){
						document.getElementById("Q").focus();
					}
					dragok = true;
					d = temp;
					dx = parseInt(temp.style.left+0);
					dy = parseInt(temp.style.top+0);
					x = e.clientX;
					y = e.clientY;
					document.onmousemove = move;
					return false;
				}
			}

			function up(e){
				if (!e) e = window.event;
				
				var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
				
				if (temp.tagName != "HTML"|"BODY" && temp.className != "dragclass" && temp.className != "sizeclass"){
					temp = (typeof temp.parentNode != "undefined")?temp.parentNode:temp.parentElement;
				}
				if(temp == null || temp == undefined){return;}
				if (temp.className == "dragclass"){
						//temp = temp.parentNode;
						//temp.style.zIndex = parseInt(temp.style.zIndex) - 1;
				}			
				dragok = false;
				document.onmousemove = null;
			}

			document.onmousedown = down;
			document.onmouseup = up;
			document.onmouseover = overit;

		})();
	}