PageSourceSearch

https://www.travelobahrain.com/template/themes/exploringtourism/js/Common.js

js travelobahrain.com collected 2026-10-07 00:42:51 UTC 9,517 bytes, 413 lines download raw bytes

1if (typeof window.event != 'undefined')
2document.onkeydown = function()
3{
4	if (event.srcElement.tagName.toUpperCase() != 'INPUT' && event.srcElement.tagName.toUpperCase() != 'TEXTAREA')
5		return (event.keyCode != 8);
6	else
7	{
8		if(event.srcElement.readOnly || event.srcElement.disabled)
9			return (event.keyCode != 8);
10	}
11}
12else
13document.onkeypress = function(e)
14{
15	if (e.target.nodeName.toUpperCase() != 'INPUT' && e.target.nodeName.toUpperCase() != 'TEXTAREA')
16		return (e.keyCode != 8);
17	else
18	{
19		if(e.target.readOnly || e.target.disabled)
20			return (e.keyCode != 8);
21	}
22}
23	
24function XHConn()
25{
26  var xmlhttp, bComplete = false;
27  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
28  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
29  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
30  catch (e) { xmlhttp = false; }}}
31  if (!xmlhttp) return null;
32  this.connect = function(sURL, sMethod, sVars, fnDone)
33  {
34    if (!xmlhttp) return false;
35    bComplete = false;
36    sMethod = sMethod.toUpperCase();
37    try {
38      if (sMethod == "GET")
39      {
40        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
41        sVars = "";
42      }
43      else
44      {
45        xmlhttp.open(sMethod, sURL, true);
46        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
47        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
48      }
49      xmlhttp.onreadystatechange = function(){
50        if (xmlhttp.readyState == 4 && !bComplete)
51        {
52          bComplete = true;
53          fnDone(xmlhttp);
54        }};
55      xmlhttp.send(sVars);
56    }
57    catch(z) { return false; }
58    return true;
59  };
60  return this;
61}
62
63function getObjCommon(objID) 
64{
65	if (document.getElementById)
66	{
67		if (document.getElementById(objID)==null)
68			return window.parent.document.getElementById(objID);			
69		
70		return document.getElementById(objID)
71	}
72	else if (document.all)
73	{
74		if (document.all(objID)==null)
75			return window.parent.document.all[objID];
76		
77		return document.all[objID];
78	}
79	else if (document.layers)
80	{
81		if (document.layers(objID)==null)
82			return window.parent.document.layers[objID];
83		
84		return document.layers[objID];
85	}
86}
87
88function getObj(objID) 
89{
90	if (document.getElementById)
91	{
92		if (document.getElementById(objID)==null)
93			return window.parent.document.getElementById(objID);			
94		
95		return document.getElementById(objID)
96	}
97	else if (document.all)
98	{
99		if (document.all(objID)==null)
100			return window.parent.document.all[objID];
101		
102		return document.all[objID];
103	}
104	else if (document.layers)
105	{
106		if (document.layers(objID)==null)
107			return window.parent.document.layers[objID];
108		
109		return document.layers[objID];
110	}
111}
112	
113//For Enter Button
114
115function enterSubmit()
116{   
117    var DisableSubmitButtonID = eval("getObjCommon('DisableSubmitButtonID').value");
118  
119    if(DisableSubmitButtonID != '0')
120    {   
121        var id = eval("getObjCommon('SubmitButtonID').value");
122		
123        if(id=="")
124        {
125            return;
126        }
127        else
128        {
129            if(id.indexOf(',') !=-1)
130            {
131                var obtnId = new Array();
132                obtnId = id.split(',');
133                for(i=0; i<obtnId.length;i++)
134                {
135                    if(getObjCommon(obtnId[i]))
136                    {
137                       getObjCommon(obtnId[i]).focus();                     
138                    }
139                } 
140            }
141            else
142            {
143//                getObjCommon(id).onClick=document.login.submit();
144                getObjCommon(id).onclick();
145            } 
146         }
147    }
148}
149
150function disableSubmit()
151{		
152    getObjCommon('DisableSubmitButtonID').value="0";    
153}
154
155function enableSubmit()
156{
157    getObjCommon('DisableSubmitButtonID').value="1";
158}
159
160
161function extractNumber(obj, decimalPlaces, allowNegative)
162{
163	var temp = obj.value;
164
165	// avoid changing things if already formatted correctly
166	var reg0Str = '[0-9]*';
167	if (decimalPlaces > 0) {
168		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
169		
170	} else if (decimalPlaces < 0) {
171		reg0Str += '\\.?[0-9]*';
172	}
173	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
174	reg0Str = reg0Str + '$';
175	var reg0 = new RegExp(reg0Str);
176	if (reg0.test(temp)) return true;
177
178	// first replace all non numbers
179	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
180	var reg1 = new RegExp(reg1Str, 'g');
181	temp = temp.replace(reg1, '');
182
183	if (allowNegative) {
184		// replace extra negative
185		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
186		var reg2 = /-/g;
187		temp = temp.replace(reg2, '');
188		if (hasNegative) temp = '-' + temp;
189	}
190	
191	if (decimalPlaces != 0) {
192		var reg3 = /\./g;
193		var reg3Array = reg3.exec(temp);
194		if (reg3Array != null) {
195			// keep only first occurrence of .
196			//  and the number of places specified by decimalPlaces or the entire str
196ing if decimalPlaces < 0
197			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
198			reg3Right = reg3Right.replace(reg3, '');
199			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
200			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
201		}
202	}
203	
204	obj.value = temp;
205}
206
207function blockNonNumbers(obj, e, allowDecimal, allowNegative, id, ispromo)
208{
209    //alert(obj.id);
210	var key;
211	var isCtrl = false;
212	var keychar;
213	var reg;
214
215	if(window.event) {
216		key = e.keyCode;
217		isCtrl = window.event.ctrlKey
218	}
219	else if(e.which) {
220		key = e.which;
221		isCtrl = e.ctrlKey;
222	}
223	
224	if (isNaN(key)) return true;
225	
226	keychar = String.fromCharCode(key);
227	
228	// check for backspace or delete, or if Ctrl was pressed
229	if (key == 8 || isCtrl|| key == 46)
230	{
231		return true;
232	}
233        
234        
235
236	reg = /\d/;
237	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
238	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
239        
240        if(id!='' && id!=null)
241            if(ispromo && reg.test(keychar))
242                document.getElementById(id).disabled = false;
243            else
244                document.getElementById(id).disabled = true;
245	
246	return isFirstN || isFirstD || reg.test(keychar);
247        
248        
249}
250
251function disablePromotion(obj,id,parray)
252{
253    reg = /\d/;
254    if(obj.value!="" && reg.test(obj.value) && obj.value>0)
255        document.getElementById(id).disabled = false;
256    else
257    {
258        parray = parray.split(",");
259        for(var i=0;i<parray.length;i++)
260            document.getElementById(parray[i]).value = '';
261        document.getElementById(id).checked = false;
262        document.getElementById(id).disabled = true;
263        if(obj.id=='txtroomprice')
264        {
265            document.getElementById('ddlroomtypeProm').value = 0;
266            disableHotalControl();
267        }
268        else
269            displayPromo();
270    }
271        
272        
273    if(obj.id=='txtroomprice')
274        if(document.getElementById('ddlroomtype').value==0)
275            document.getElementById(id).disabled = true;
276}
277function ContactNumbers(obj, e, allowDecimal, allowNegative)
278{
279    var key;
280	var isCtrl = false;
281	var keychar;
282	var reg;
283    if(window.event) {
284		key = e.keyCode;
285		isCtrl = window.event.ctrlKey
286	}
287	else if(e.which) {
288		key = e.which;
289		isCtrl = e.ctrlKey;
290	}
291	
292	if (isNaN(key)) return true;
293	
294	keychar = String.fromCharCode(key);
295	// check for backspace or delete, or if Ctrl was pressed
296	if (key == 8 || isCtrl || key == 43 || key == 45 || key == 44 || key == 32)
297	{
298		return true;
299	}
300    reg = /\d/;
301	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
302	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
303	
304	return  isFirstN || isFirstD || reg.test(keychar);
305}
306
307//To stop right click behaviour in textbox
308var diablepastemessage="";
309function rightClickDisable()
310{
311    if (this.layers)
312    {
313        this.captureEvents(Event.MOUSEDOWN);
314        this.onmousedown=clickNS;
315    }
316    else
317    {
318        this.onmouseup=clickNS;
319        this.oncontextmenu=clickIE;
320    }
321    this.oncontextmenu=new Function("return false");
322
323}
324function clickIE()
325{
326    if (this.all)
327    {
328        (diablepastemessage);
329        return false;
330    }
331}
332 
333function clickNS(e)
334{
335    if(this.layers||(this.getElementById&&!this.all))
336    {
337        if (e.which==2||e.which==3)
338        {
339            (diablepastemessage);
340            return false;
341        }
342    }    
343}
344
345//To enable right click, after blur out from textbox
346function rightClickEnable()
347{
348    if (this.layers)
349    {
350        this.captureEvents(Event.MOUSEDOWN);
351        this.onmousedown=true;
352    }
353    else
354    {
355        this.onmouseup=true;
356        this.oncontextmenu=true;
357    }
358
359    this.oncontextmenu=new Function("return true");
360}
361
362document.onclick = function hideAutoDivCal ()
363{ 
364	try
365	{
366		hideAutoDiv();		
367	}
368	catch (e)
369	{}
370	
371	try
372	{
373		hidecal2();
374	}
375	catch (e)
376	{}
377}
378
379function SplashScreenSeconds(url, msg)
380{
381 var TARG_ID = "spanSplashScreenSeconds";//Span declared in html form
382 var DEF_MSG = "Redirecting...";
383 if(!msg)
384    {
385        msg = DEF_MSG;
386    }
387 if(!url)
388    {
389        throw new Error('You didn\'t include the "url" parameter'); 
390    }
391var e = document.getElementById(TARG_ID);
392
393if(!e)
394{
395   throw new Error('"spanSplashScreenSeconds" element id not found');
396}
397 
398 var cTicks = parseInt(e.innerHTML);
399 var timer = setInterval(function()
400 {
401 if( cTicks )
402  {
403         e.innerHTML = --cTicks;
404  }
405 else
406  {
407         clearInterval(timer);
408         //document.body.innerHTML = msg;
409         window.location = url;	  
410  }
411
412   }, 1000);
413}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.