1 function grayOut(vis, options) {
2 // Pass true to gray out screen, false to ungray
3 // options are optional. This is a JSON object with the following (optional) properties
4 // opacity:0-100 // Lower number = less grayout higher = more of a blackout
5 // zindex: # // HTML elements with a higher zindex appear on top of the gray out
6 // bgcolor: (#xxxxxx) // Standard RGB Hex color code
7 // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
8 // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
9 // in any order. Pass only the properties you need to set.
10 var options = options || {};
11 var zindex = options.zindex || 50;
12 var opacity = options.opacity || 20;
13 var opaque = (opacity / 100);
14 var bgcolor = options.bgcolor || '#000000';
15 var dark=document.getElementById('darkenScreenObject');
16 //var tbody = document.getElementsByTagName("body")[0];
17 var tbody = document.body;
18 var myAjax = document.getElementById('AjaxLoading');
21 // The dark layer doesn't exist, it's never been created. So we'll
22 // create it here and apply some basic styles.
23 // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
24 var tnode = document.createElement('div'); // Create the layer.
25 tnode.style.position='absolute'; // Position absolutely
26 tnode.style.top='0px'; // In the top
27 tnode.style.left='0px'; // Left corner of the page
28 tnode.style.overflow='hidden'; // Try to avoid making scroll bars
29 tnode.style.display='none'; // Start out Hidden
30 tnode.id='darkenScreenObject'; // Name it so we can find it later
31 tbody.appendChild(tnode); // Add it to the web page
32 dark=document.getElementById('darkenScreenObject'); // Get the object.
35 // Calculate the page width and height
36 if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
37 var pageWidth = document.body.scrollWidth+'px';
38 var pageHeight = document.body.scrollHeight+'px';
39 } else if( document.body.offsetWidth ) {
40 var pageWidth = document.body.offsetWidth+'px';
41 var pageHeight = document.body.offsetHeight+'px';
44 var pageHeight='100%';
46 //set the shader to cover the entire page and make it visible.
47 dark.style.opacity=opaque;
48 dark.style.MozOpacity=opaque;
49 dark.style.filter='alpha(opacity='+opacity+')';
50 dark.style.zIndex=zindex;
51 dark.style.backgroundColor=bgcolor;
52 dark.style.width= pageWidth;
53 dark.style.height= pageHeight;
54 dark.style.display='block';
57 /* Display the "Loading" box */
58 var tnode = document.createElement('div'); // Create the layer.
59 tnode.style.position='absolute'; // Position absolutely
60 tnode.style.top='0px'; // In the top
61 tnode.style.left='0px'; // Left corner of the page
62 tnode.style.overflow='hidden'; // Try to avoid making scroll bars
63 tnode.style.display='none'; // Start out Hidden
64 tnode.id='AjaxLoading'; // Name it so we can find it later
65 tbody.appendChild(tnode); // Add it to the web page
66 myAjax=document.getElementById('AjaxLoading'); // Get the object.
69 // Reset the opacity options. Want this on top
70 var loadingOptions = loadingOptions || {};
71 var zindex = loadingOptions.zindex || 100;
72 var opacity = loadingOptions.opacity || 100;
73 var opaque = (opacity / 100);
74 var bgcolor = loadingOptions.bgcolor || '#FFFFFF';
76 myAjax.style.opacity=opaque;
77 myAjax.style.MozOpacity=opaque;
78 myAjax.style.filter='alpha(opacity='+opacity+')';
79 myAjax.style.zIndex=zindex;
81 myAjax.style.height= '40px';
82 myAjax.style.padding = '3px';
83 myAjax.style.fontSize = '14px';
84 myAjax.style.width = '100px';
85 myAjax.style.textAlign = 'center';
86 myAjax.style.left = '45%';
87 myAjax.style.top = '5%';
88 myAjax.style.position = 'absolute';
89 myAjax.style.border = '2px solid #666';
90 myAjax.style.backgroundColor = bgcolor;
92 myAjax.innerHTML='Loading <img src="static/fusion/raptor/images/progress.gif" id="wait" />';
93 myAjax.style.display='block';
96 if(dark) dark.style.display='none';
97 if(myAjax) myAjax.style.display='none';
100 function checkDate(dateStr, isOptional) {
101 if(dateStr.charAt(0) == '[' && dateStr.charAt(dateStr.length-1) == ']')
106 if((dateStr.length<6)||(dateStr.length>10))
109 if(dateStr.charAt(1)=='/') {
110 dmonth = parseInt(dateStr.substr(0,1));
111 dateStr = dateStr.substr(2,dateStr.length-2);
113 //For some strange reason "08" is parsed as 0, so I remove leading 0-s
114 if(dateStr.charAt(0)=='0')
115 dmonth = parseInt(dateStr.substr(1,1));
117 dmonth = parseInt(dateStr.substr(0,2));
118 dateStr = dateStr.substr(3,dateStr.length-3);
121 if(dateStr.charAt(1)=='/') {
122 dday = parseInt(dateStr.substr(0,1));
123 dateStr = dateStr.substr(2,dateStr.length-2);
125 //For some strange reason "08" is parsed as 0, so I remove leading 0-s
126 if(dateStr.charAt(0)=='0')
127 dday = parseInt(dateStr.substr(1,1));
129 dday = parseInt(dateStr.substr(0,2));
130 dateStr = dateStr.substr(3,dateStr.length-3);
133 if(dateStr.length==2) {
134 if (parseInt(dateStr)>50)
135 dateStr="19"+dateStr;
137 dateStr="20"+dateStr;
139 dyear = parseInt(dateStr);
140 //alert("day: "+dday+", month: "+dmonth+", year: "+dyear);
141 if((dyear<1990)||(dyear>2090)||(dmonth<1)||(dmonth>12)||(dday<1)||
142 (dday>((dmonth==2)?(((dyear % 4 == 0) && ((!(dyear % 100 == 0))||(dyear % 400 == 0)))?29:28):(((dmonth==1)||(dmonth==3)||(dmonth==5)||(dmonth==7)||(dmonth==8)||(dmonth==10)||(dmonth==12))?31:30))))
148 function validateNumber(numValue, mustBeInteger, mustBePositive) {
149 var decimalPointFound = false;
150 for(var i=0; i<numValue.length; i++) {
151 var ch = numValue.charAt(i);
153 if(ch=='0'||ch=='1'||ch=='2'||ch=='3'||ch=='4'||ch=='5'||ch=='6'||ch=='7'||ch=='8'||ch=='9') {
154 // Valid character - do nothing
156 if(mustBePositive||i>0)
159 if(mustBeInteger||decimalPointFound)
162 decimalPointFound = true;
171 function checkInteger(numValue) {
172 return validateNumber(numValue, true, false);
175 function checkNonNegativeInteger(numValue) {
176 return validateNumber(numValue, true, true);
177 } // checkNonNegativeInteger
179 function checkPositiveInteger(numValue) {
180 if(! checkNonNegativeInteger(numValue))
183 if(parseInt(numValue)==0)
187 } // checkPositiveInteger
189 function checkFloat(numValue) {
190 return validateNumber(numValue, false, false);
193 function checkNonNegativeFloat(numValue) {
194 return validateNumber(numValue, false, true);
195 } // checkNonNegativeFloat
197 function checkPositiveFloat(numValue) {
198 if(! checkNonNegativeFloat(numValue))
201 if(parseFloat(numValue)<0.001&&parseFloat(numValue)>-0.001)
205 } // checkPositiveFloat
207 function getDocHeight(doc) {
208 var docHt = 0, sh, oh;
209 if (doc.height) docHt = doc.height;
211 if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
212 if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
213 if (sh && oh) docHt = Math.max(sh, oh);
218 function getDocWidth(doc)
220 var docWd = 0, sh, oh;
225 if (doc.body.scrollWidth)
226 docWd = sh = doc.body.scrollWidth;
227 if (doc.body.offsetWidth)
228 docWd = oh = doc.body.offsetWidth;
230 docWd = Math.max(sh, oh);
236 function setIframeHeight(iframeName)
238 var oldY = document.body.scrollTop;
239 var iframeWin = window.frames[iframeName];
240 var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
241 if ( iframeEl && iframeWin ) {
242 iframeEl.style.height = "auto";
243 // helps resize (for some) if new doc shorter than previous
244 var docHt = getDocHeight(iframeWin.document);
245 var docWd = getDocWidth(iframeWin.document);
246 // need to add to height to be sure it will all show
248 iframeEl.style.height = docHt + 1 + "px";
250 iframeEl.style.width = docWd + 1 + "px";
252 if (oldY != null && oldY != 'undefined')
253 document.body.scrollTop = oldY;
256 function resizeFrames(){
257 var isFolderAllowed = arguments[0];
258 if (isFolderAllowed == null || isFolderAllowed == 'true'){
259 if (document.getElementById('scrollableTable') && document.body.offsetHeight > 195)
260 document.getElementById('scrollableTable').style.height=document.body.offsetHeight - 185;
261 if (document.getElementById('contentDiv') && document.body.offsetHeight > 145)
262 document.getElementById('contentDiv').style.height=document.body.offsetHeight - 135;
263 if (document.getElementById('content_Iframe') && document.body.offsetHeight > 145)
264 document.getElementById('content_Iframe').height=document.body.offsetHeight - 135;
267 setIframeHeight('content_Iframe');
271 function resizeWindow() {
272 var isFolderAllowed = arguments[0];
273 if (isFolderAllowed != null)
274 resizeFrames(isFolderAllowed);
280 * Usage : var myObje = $('theIdOfTheElementYouWantToGet');
281 * Simple gives you the element. Avoids using document.getElementById();
284 if (!$ && document.getElementById) {
286 var elements = new Array();
287 for (var i = 0; i < arguments.length; i++) {
288 var element = arguments[i];
289 if (typeof element == 'string') {
290 element = document.getElementById(element);
292 if (arguments.length == 1) {
295 elements.push(element);
299 } else if (!$ && document.all) {
301 var elements = new Array();
302 for (var i = 0; i < arguments.length; i++) {
303 var element = arguments[i];
304 if (typeof element == 'string') {
305 element = document.all[element];
307 if (arguments.length == 1) {
310 elements.push(element);