
/*----------------------------------------------------------------------------\
|                            Misc Aergo JS Helpers                            |
|-----------------------------------------------------------------------------|
|                                               							  |
|-----------------------------------------------------------------------------|
| Useful functions used by Aergo                                              |
|-----------------------------------------------------------------------------|
|                  Copyright (c) 2004 e-travel                   			  |
|-----------------------------------------------------------------------------|
| 2004-03-01 | First version                                                  |
|-----------------------------------------------------------------------------|
| Created 2004-03-01 | By Roland Pellegrin  				 				  | 
\----------------------------------------------------------------------------*/


/****f* MiscHelpers/openBrWindow
* NAME
* openBrWindow: function to open a popupwindow (was included in BEA's original portal.jsp).
* USAGE
* openBrWindow(theURL,winName,features)
* FUNCTION
* This function opens a popup window with the URL given as parameter.
* PARAMETERS
* theURL - URL corresponding to the content of the popup window.
* winName - name of the popup window that will be opened.
* features - parameters of the popup window (position, dimensions,...)
* RETURN VALUE
* void
***
*/
var openerURL="";
var popupWindow;
window.popupPointer=null;
function openBrWindow(theURL,winName,features, externalContent)
{ //v2.0
		// CR 1634569 ESC JavaScript Inline Popup
	if(isInlinePopUp!='Y'){
	    if( features.indexOf("left=") < 0 ) {
	        features += ",left=100,top=50";
	    }
	    if( features.indexOf("resizable=") < 0 ) {
	        features += ",resizable=yes";
	    }
	    
	    if((externalContent != null) && (externalContent == true) ){
	    	popupURL=theURL;
	    }
	    else{
	    	//popupURL is set before in portal.jsp
	    	openerURL=makeRelativeURL(theURL);
	    }
	    
	    if((popupWindow!=null) && (!popupWindow.closed)) {
	        popupWindow.close();
	    }
	    popupWindow = window.open(popupURL,winName,features);
	    window.popupPointer=popupWindow;
	    popupWindow.focus();
	}
	else{
					// CR 1634569 ESC JavaScript Inline Popup
				openerURL=makeRelativeURL(theURL);
				displayInlinePopup(openerURL,winName,features);	
	}
}

/****f* MiscHelpers/makeRelativeURL
* NAME
* makeRelativeURL: function to convert url to a relative one.
* USAGE
* makeRelativeURL(theURL)
* FUNCTION
* This function converts the url given as parameter to a relative one (used for http/https).
* PARAMETERS
* theURL - URL that will be changed to a relative one.
* RETURN VALUE
* string : the relative URL.
***
*/
function makeRelativeURL(theURL)
{ //v2.0
    var webAppName = '/portalApp/';
    var webAppIndex = theURL.indexOf(webAppName);
    
    // If we find the web application name in the URL, we remove it and everything prior to it
    if (webAppIndex!=-1) {
        return theURL.substring(webAppIndex+webAppName.length);
    }
    
    // else we return the original URL
    return theURL;
}

/****f* MiscHelpers/makeWebAppURL
* NAME
* makeWebAppURL: function to extract the web app URL from a URL.
* USAGE
* makeWebAppURL(theURL)
* FUNCTION
* This function extracts from the url given as parameter the web app URL.
* PARAMETERS
* theURL - URL from which we extract the web app URL.
* EXAMPLE
* theURL = http://book.e-travel.com/portalApp/application?origin=hnav_bar.jsp
* returns : http://book.e-travel.com/portalApp/
* RETURN VALUE
* string : the extracted web app URL.
***
*/
function makeWebAppURL(theURL)
{
    var webAppName = '/portalApp/';
    var webAppIndex = theURL.indexOf(webAppName);
    
    // If we find the web application name in the URL, we return it and everything prior to it
    if (webAppIndex!=-1) {
        return theURL.substring(0, webAppIndex+webAppName.length);
    }
    
    // else we return the original URL
    return theURL;
}

/****f* MiscHelpers/makeAbsoluteURL
* NAME
* makeAbsoluteURL: function to build dynamically a URL to a non-static resource
* USAGE
* makeAbsoluteURL(theURL, resourcePath)
* FUNCTION
* This function builds a URL to a non-static resource based on the url given as parameter.
* PARAMETERS
* theURL - URL from which we build the URL to a non-static resouce.
* resourcePath - relative path to the non-static resource.
* EXAMPLE
* theURL = http://book.e-travel.com/portalApp/application?origin=hnav_bar.jsp
* resourcePath = pages/business/rail/LightRailRedirect.jsp
* returns : http://book.e-travel.com/portalApp/APF/pages/business/rail/LightRailRedirect.jsp
* RETURN VALUE
* string : The absolute path to the non-static resource given as parameter.
***
*/
function makeAbsoluteURL(theURL, resourcePath)
{
    var webAppURL = makeWebAppURL(theURL);
    
    // If resourcePath starts with a /, remove it
    if (resourcePath.charAt(0) == '/') {
        resourcePath = resourcePath.substring(1, resourcePath.length);
    }
    
    return webAppURL + resourcePath;
}


/**
** variables and methods used for browser Back support
**/
var aFnLoad=new Array();
var aFnResize=new Array();
var isBrowserRefresh=false;

/****f* MiscHelpers/subscribeOnLoad
* NAME
* subscribeOnLoad: used to add a function to a list that must be called at loading time
* USAGE
* subscribeOnLoad(fn)
* FUNCTION
* This function adds a function to an array. This array contains functions that have
* to be called at the loading of the page.
* PARAMETERS
* fn - function to add in the array.
* RETURN VALUE
* void
***
*/
function subscribeOnLoad(fn){
	aFnLoad.push(fn);
}

/****f* MiscHelpers/subscribeOnResize
* NAME
* subscribeOnResize: used to add a function to a list that must be called at the time
* the page is resized.
* USAGE
* subscribeOnResize(fn)
* FUNCTION
* This function adds a function to an array. This array contains functions that have
* to be called at the resizing of the page.
* PARAMETERS
* fn - function to add in the array.
* RETURN VALUE
* void
***
*/
function subscribeOnResize(fn){
	aFnResize.push(fn);
}

/****f* MiscHelpers/propagateOnLoad
* NAME
* propagateOnLoad: used to call the functions registered to be called at the loading of the page.
* USAGE
* propagateOnLoad()
* FUNCTION
* This function goes through the array containing the functions that have
* to be called at the loading of the page, and calls these functions.
* PARAMETERS
* no parameter.
* RETURN VALUE
* void
***
*/
function propagateOnLoad()
{	
	// set a variable indicating browser refresh or not
	var o = document.getElementById("idBrowserRefreshFlag");
	isBrowserRefresh = (o.value!=0);
	o.value=1; 
	
	for(var i=0;i<aFnLoad.length;i++)
		aFnLoad[i]();
}

/****f* MiscHelpers/propagateOnResize
* NAME
* propagateOnResize: used to call the functions registered to be called at the resizing of the page.
* USAGE
* propagateOnResize()
* FUNCTION
* This function goes through the array containing the functions that have
* to be called at the resizing of the page, and calls these functions.
* PARAMETERS
* no parameter.
* RETURN VALUE
* void
***
*/
function propagateOnResize(){
	for(var i=0;i<aFnResize.length;i++)
		aFnResize[i]();
}

/****f* MiscHelpers/reloadPage
* NAME
* reloadPage: Method used to load an URL in the current browser.
* USAGE
* reloadPage(URL)
* FUNCTION
* This function reload the page with the URL given as parameter.
* PARAMETERS
* URL - the redirection URL.
* RETURN VALUE
* void
***
*/
function reloadPage(URL){
	document.location=URL;
}

/****f* MiscHelpers/makeCssUrl
* NAME
* makeCssUrl: Method used to load an URL in the current browser.
* USAGE
* makeCssUrl()
* FUNCTION
* This function reload the page with the URL given as parameter.
* PARAMETERS
* URL - the redirection URL.
* RETURN VALUE
* void
***
*/
function makeCssUrl() {

var webAppName = '\/\/';
var webAppName2 = '/css/';
var tagCol = document.getElementsByTagName("LINK");	
i = 0;
var urlRet='';
var base='';        	

	while((i<tagCol.length) && ((urlRet = tagCol[i].getAttribute("href")).indexOf(webAppName2)== -1))
		{
			i+=1;  		
		};
	if (i<tagCol.length){							
		var webAppIndex = urlRet.indexOf("http");
		webAppIndex2 = urlRet.indexOf(webAppName2);
		if (webAppIndex !=-1) {			
			return urlRet.substring(0,webAppIndex2+webAppName2.length);
		} else {
			base = document.URL;
			webAppIndex = base.indexOf(webAppName);
			webAppIndex = base.indexOf("\/",webAppIndex+webAppName.length);
    
		    // If we find the web application name in the URL, we remove it and everything prior to it
    		if (webAppIndex!=-1) {     
    				base = base.substring(0,webAppIndex);  
					return base+urlRet.substring(0,webAppIndex2+webAppName2.length);
			}
		}				
	}
	// else we return the original URL
    return base;   
}

/*----------------------------------------------------------------------------\
|                            Browser Detection Utilities	                  |
|-----------------------------------------------------------------------------|
|                                               							  |
|-----------------------------------------------------------------------------|
| Utilities to detect browser versions                                        |
|-----------------------------------------------------------------------------|
|                  Copyright (c) 2003 e-travel                   			  |
|-----------------------------------------------------------------------------|
| 2003-10-08 | First version                                                  |
|-----------------------------------------------------------------------------|
| Created 2003-10-08 | By Roland Pellegrin						 			  |
\----------------------------------------------------------------------------*/

// Browser Detect Lite  v2.1.4
// http://www.dithered.com/javascript/browser_detect/index.html


/****f* MiscHelpers/BrowserDetectLite
* NAME
* BrowserDetectLite: Method used to test the browser's parameters.
* USAGE
* BrowserDetectLite()
* FUNCTION
* This function retrieves all the navigator's parameters.
* PARAMETERS
* no parameter.
* RETURN VALUE
* void
***
*/
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) && (ua.indexOf('safari') == - 1));
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   this.isFirefox   = (ua.indexOf('firefox') != -1);
      
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   else if (this.isFirefox) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('firefox/') + 8 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
	 this.isIE7x = (this.isIE && this.versionMajor == 7);
	 this.isIE7up = (this.isIE && this.versionMajor >= 7);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();



/****f* MiscHelpers/isNumeric
* NAME
* isNumeric: Method used to test if a variable is numeric or not.
* USAGE
* isNumeric(myNumber)
* FUNCTION
* This function tests if the parameter myNumber is a number or not.
* PARAMETERS
* myNumber - variable to test.
* RETURN VALUE
* boolean
***
*/
function isNumeric(myNumber){
  cmp = "0123456789";
  for(var i = 0; i < myNumber.length; i++){
    if(cmp.indexOf(myNumber.substring(i, i + 1)) < 0)
      return false;
  }
  return true;
}

/****f* MiscHelpers/hide
* NAME
* hide: Method used to hide an object.
* USAGE
* hide(divObj)
* FUNCTION
* This function retrieves the object which id is passed as a parameter, and hides it.
* PARAMETERS
* divObj - object to hide.
* RETURN VALUE
* void
***
*/
function hide(divObj)
{
	  DOM = (document.getElementById); // IE 5+ et NS 6+ 
	  IE4 = (document.all); // IE 4 
	  NS4 = (document.layers); // NS 4
	  var state = ""; 

	  if (DOM) { 
	    	if(document.getElementById(divObj)) {
	    		document.getElementById(divObj).style.display = "none";
	    	}
	  } 
	  else if (IE4) { 
	  	if(document.all.divObj) {
	    		document.all.divObj.style.display = "none";
	    	}
	  } 
	  else if (NS4) { 
		if(document.layers[divObj]) {
	    		document.layers[divObj].style.display = "none";
		}
	  } 
}

/****f* MiscHelpers/show
* NAME
* show: Method used to show an object.
* USAGE
* show(divObj)
* FUNCTION
* This function retrieves the object which id is passed as a parameter, and shows it.
* PARAMETERS
* divObj - object to show.
* RETURN VALUE
* void
***
*/
function show(divObj)
{
	  DOM = (document.getElementById); // IE 5+ et NS 6+ 
	  IE4 = (document.all); // IE 4 
	  NS4 = (document.layers); // NS 4
	  var state = ""; 

	  if (DOM) { 
	     	if(document.getElementById(divObj)) {
	     		document.getElementById(divObj).style.display = "";
	     	}
	  } 
	  else if (IE4) { 
	  	if(document.all.divObj) {
	     		document.all.divObj.style.display = "";
	     	}
	  } 
	  else if (NS4) { 
	      	if(document.layers[divObj]) {
	      		document.layers[divObj].style.display = "";
	      	}
	  } 
}

/****f* MiscHelpers/ShowHide
* NAME
* ShowHide: Method used to show/hide an object.
* USAGE
* ShowHide(divObj)
* FUNCTION
* This function retrieves the object which id is passed as a parameter,
* and shows it if it was hidden, or hides it if it was visible.
* PARAMETERS
* divObj - object to show/hide.
* RETURN VALUE
* void
***
*/
function ShowHide(divObj)
{
  DOM = (document.getElementById); // IE 5+ et NS 6+ 
  IE4 = (document.all); // IE 4 
  NS4 = (document.layers); // NS 4
  var state = ""; 

  if (DOM) { 
    state = document.getElementById(divObj).style.display;
    if(state == "none" && state != null) {
      document.getElementById(divObj).style.display = "";
    } else {
      document.getElementById(divObj).style.display = "none";
    }
  } 
  else if (IE4) { 
    state = document.all.divObj.style.display;
    if(state == "none" && state != null) {
      document.all.divObj.style.display = "";
    } else {
      document.all.divObj.style.display = "none";
    }
  } 
  else if (NS4) { 
    state = document.layers[divObj].style.display;
    if(state == "none" && state != null) {
      document.layers[divObj].style.display = "";
    } else {
      document.layers[divObj].style.display = "none";
    }
  } 
}

/****f* MiscHelpers/calculateOffset
* *****************************************************************************
* FUNCTION
* Calculate the offset of an object. 
*
* USAGE
* calculateOffset(obj,attr)
*
* PARAMETERS
* obj   - The reference object.
* attr - The type of offset to calculate (offsetLeft, offsetRight, offsetTop...).
*
* RETURN VALUE
* The offset value.	
******************************************************************************/		
function calculateOffset(obj,attr,stopAbsolute,scrollTop){
	var kb=0;
	var i=0;
	
  	while(obj){
  		if (stopAbsolute) {
  			if (i>0 && obj.style.position=="absolute") {
  				return kb;
  			}	
  		}
		kb+=obj[attr];
    		obj=obj.offsetParent;
    		i++;
  	}
	if (attr == "offsetTop" && scrollTop != null && scrollTop > 0) {
		if (!browser.isIE)
 	 		kb = kb - scrollTop;
 	 	else
 	 		kb = kb - 130;
	}
  	return kb
}
	
/****c* MiscHelpers/ProtectDiv
* *****************************************************************************
* DESCRIPTION
* HREF_FILE_NAME
* A known bug of Internet Explorer is that when an absolute positioned 
* div is over a dropdown form element, the dropdown is showing on top of the div.
* ProtectDiv is an object used to fix a bug on IE.
*
* Example of usage:
* protectDiv = new ProtectDiv(div);
*
* PARAMETERS
* div - The DIV object to protect.
*
* UNIT TESTS
* href:UNIT_TEST_PATH/ProtectDiv/index.htm
******************************************************************************/

function ProtectDiv(div) {
	
	/****f* ProtectDiv/protect
	* *****************************************************************************
	* FUNCTION
	* When IE browser is detected, protect the div against dropdown element.
	* This method is called on initialisation, and each time the div is moving.
	*
	* USAGE
	* protect()
	*
	* RETURN VALUE
	* void
	******************************************************************************/
	ProtectDiv.prototype.protect = function protect() {
		if(browser.isIE && browser.versionMajor<7){
			var iframe = document.getElementById("protectDiv"+this.div.id);
			if(iframe==null){
				iframe = document.createElement("IFRAME");
				iframe.id = "protectDiv"+this.div.id;
				iframe.target = "_blank";
				iframe.src = "/portalApp/APF/pages/include/blank.jsp";
				iframe.style.position = "absolute";
				iframe.style.border = "0"; 
				document.body.appendChild(iframe);
			}
			iframe.style.left = this.div.offsetLeft;
			iframe.style.top = this.div.offsetTop;
			if(this.div.style.width)
				iframe.style.width = this.div.style.width;
			else
				iframe.style.width = this.div.clientWidth;
				
			var height = "";
			if(this.div.style.height){
				height = this.div.style.height;
			}else if(this.div.clientHeight){
				height = this.div.clientHeight;			
			}	
			
			height = height+"";
			if(height!=""){
				if(height.indexOf("px")>0)
					height = height.substring(0, height.indexOf("px"));
				height = (parseInt(height)+2)+'px'
				iframe.style.height = height;
			}
			iframe.style.visibility = this.div.style.visibility;
		}	
	}	
		
	this.div = div;
	div.protectDiv = this;
	if(browser.isIE && browser.versionMajor<7){
		// The Z-index of DIV must be greater than IFRAME
		if(div.style.zIndex == 0)
			div.style.zIndex = 1;
		// When the DIV move, move the IFRAME too.
		div.onmove=function(){
			this.protectDiv.protect();
		}
		
		// When the DIV visibility change, change the IFRAME visibility too.
		div.onpropertychange=function(){
			this.protectDiv.protect();
		}
		
		// Call the protect() method
		this.protect();
	}
}


/**
* 
* str = "<input name="NAME" value="VALUE"/><input name="NAME2" value="VALUE2"/>..."
* returns "NAME=VALUE&NAME2=VALUE2"
*/
function createUrlFromHidden(str){
	
	var start=new RegExp('(<input name=\")', "g");	
	var middle=new RegExp('(\" value=\")', "g");	
	var end=new RegExp('(\"/>)', "g");	
	var blank=new RegExp('(\r)', "g");	
	var submit=new RegExp('(<input type=\"submit=&)', "g");	
	
	str = str.replace(blank,"");
	str = str.replace(start,"");
	str = str.replace(middle,"=");
	str = str.replace(end,"&");
	str = str.replace(submit,"");
	
	return URLencode(str);
}

function URLencode(sStr) {
    return sStr.replace(/\+/g, '%2B').
             replace(new RegExp('( )', "g"), '%20').
             replace(/\"/g,'%22').
             replace(/\'/g, '%27').
             replace(/\//g,'%2F');
  }


/****f* MiscHelpers/escapeSpecialChars
* *****************************************************************************
* NAME
* escapeSpecialChars: Convert special characters to their escape correspondent codes, in order to correctly display strings inside HTML tags.
* USAGE
* escapeSpecialChars(theString)
* FUNCTION
* This function converts special characters to their escape correspondent codes, in order to correctly display strings inside HTML tags.
*    Note: it doesn't work if we want to display with an alert() command         
* PARAMETERS
* theString - string to escape the special characters
* EXAMPLE
* sStr = This is John's community called "SNCF Special"
* returns: This is John&#39;s community called &#34;SNCF Special&#34;
* RETURN VALUE
* string 
***
*/

function escapeSpecialChars(sStr) {	
	return sStr.replace("\'", "&#39;").replace(/\"/gi, "\\\"");
}

/**
* This functions looks for all the <script> tags contained in a div element,
* and it executes them using eval statement.
* It will ignore the "document.write" statements.
*/
function executeScriptTags(divId) {
	
	var oDiv = document.getElementById(divId);
	if (oDiv) {
		var scriptsArray = oDiv.getElementsByTagName('SCRIPT');
		var length = scriptsArray.length;
		for (var i=0; i<length; i++) {
			if (scriptsArray[i].innerHTML!="") {
				try {
					if (scriptsArray[i].innerHTML.indexOf("document.write")==-1 && scriptsArray[i].innerHTML.indexOf("DisplaySeatMapLink")==-1) {
						eval(scriptsArray[i].innerHTML);
					} 
				} catch(ex) {}
			}
		}
	}
	
}


// Builds a form input field.
function addFormF(name, value)
{
	if (value==null || value=='')
		return '';
		
	return '<input name="'+name+'" value="'+value+'"/>';	

}

/**
* Method added to the Array prototype.
* Useful to look for an element in an Array.
*/
Array.prototype.inArray = function inArray(search_term) {
  var i = this.length;
  if (i > 0) {
	 do {
		if (this[i] === search_term) {
		   return true;
		}
	 } while (i--);
  }
  return false;
}

