
		/* 
		  IframeWindow_Open:
			 url: the location of the content
			 windowName: the name of the outerdiv used to control visibility
			 windowOptions: a style string for windowName div
			 subWindowName: the name of the div that content is inserted
			 subWindowOptions: a style string for subWindowName div
			 titleBarName: the name of the div used to display title
			 titleText: the text that goes in the titleBarName div
			 backgroundProtect: if true turns on background greyness
    */
    function IframeWindow_Open(url, windowName, windowOptions, subWindowName, subWindowOptions, titleBarName, titleText, backgroundProtect){
      //should we close all open windows ... we can
			closeAllWindows();
			if (backgroundProtect == true) {
				document.getElementById("BlackFrost").style.height="3000px";
				showHideLayers('BlackFrost', '', 'show');
			}
     
			setTitle(titleBarName,titleText);  
 
     
      if(!testWindowCacheIdentifier(windowName,url)){
        var iframeHtml = "";
 iframeHtml = "<iframe id=\"iframe_id_0504\" src=\""+url+"\" style=\""+subWindowOptions+"\" frameborder=\"0\"></iframe>";
        document.getElementById(subWindowName).innerHTML=iframeHtml;
	  document.getElementById("iframe_id_0504").src=url;
        saveWindowCacheIdentifier(windowName, url);

      }
      
      showDiv(windowName);
      applyStyle(windowName, windowOptions);
      
      return false;
    }
    
    /* 
			AjaxWindow_Open:
			 url: the location of the content
			 windowName: the name of the outerdiv used to control visibility
			 windowOptions: a style string for windowName div
			 subWindowName: the name of the div that content is inserted
			 titleBarName: the name of the div used to display title
			 titleText: the text that goes in the titleBarName div
			 backgroundProtect: if true turns on background greyness
    */
    function AjaxWindow_Open(url, windowName, windowOptions, subWindowName, titleBarName, titleText, backgroundProtect){
			//should we close all open windows ... we can
			closeAllWindows();
			if(backgroundProtect==true) showHideLayers('BlackFrost','','show');
			setTitle(titleBarName,titleText);
			 
			if(!testWindowCacheIdentifier(windowName,url)){
				ajaxWindowRequestObject = createRequestObject();
				ajaxWindowRequestObject.open('get', url); 
				ajaxWindowRequestObject.onreadystatechange = handleResponse; //how to handle
				//ajaxWindowRequestObject["subWindowName"] = subWindowName;
				ajaxSubWindowName = subWindowName;
				ajaxWindowRequestObject.send(null); 
				saveWindowCacheIdentifier(windowName, url);
			}
					
			showDiv(windowName);
			applyStyle(windowName, windowOptions);

			return false;
    }
    
     /* 
			InPageWindow_Open:
			 contentName: the name of the div that contains the content
			 windowName: the name of the outerdiv used to control visibility
			 windowOptions: a style string for windowName div
			 subWindowName: the name of the div that content is inserted
			 titleBarName: the name of the div used to display title
			 titleText: the text that goes in the titleBarName div
			 backgroundProtect: if true turns on background greyness
    */
    function InPageWindow_Open(contentName, windowName, windowOptions, subWindowName, titleBarName, titleText, backgroundProtect){
			//should we close all open windows ... we can
			closeAllWindows();
			if(backgroundProtect==true) showHideLayers('BlackFrost','','show');
			
			setTitle(titleBarName,titleText);
			 
			if(!testWindowCacheIdentifier(windowName,contentName)){
				document.getElementById(subWindowName).innerHTML=document.getElementById(contentName).innerHTML;
				//saveWindowCacheIdentifier(windowName, contentName);
			}
					
			showDiv(windowName);
			applyStyle(windowName, windowOptions);

			return false;
    }
    
    
    
    //hides the div specified by divName
    function OverlayWindow_Close(windowName){
      hideDiv(windowName);
      return false;
    }


//// AJAX HELPER CODE
		var ajaxWindowRequestObject;
		var ajaxSubWindowName;
		
    function createRequestObject() { 
			 var req; 
			 if(window.XMLHttpRequest){ 
					req = new XMLHttpRequest(); 					// Firefox, Safari, Opera... 
			 } else if(window.ActiveXObject) { 
					req = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 5+ 
			 } else { 
					alert('Problem creating the XMLHttpRequest object'); //SORRY NO LUCK
			 } 
			 return req; 
		} 
				
		function handleResponse() { 
			 if(ajaxWindowRequestObject.readyState == 4 && ajaxWindowRequestObject.status == 200){ 

					var response = ajaxWindowRequestObject.responseText; 
					if(response) { 
						//document.getElementById(ajaxWindowRequestObject["subWindowName"]).innerHTML = response; 
						document.getElementById(ajaxSubWindowName).innerHTML = response;
					} 
				http_done = true;
			 }   
		} 
//// END AJAX HELPER COXE


//// CODE TO KEEP TRACK OF CONTENT
    //windowCacheIdentifier is used to see if the last window loaded for  
    //window name is the same as the current request
		var windowCacheIdentifier = new Array;
		var windowNames = new Array;

    function saveWindowCacheIdentifier(windowName, url){
    		
			windowCacheIdentifier[windowName]=url;
			if(containsValue(windowNames,windowName)==false)
				windowNames[windowNames.length]=windowName;
			
			return false;
    }
    
    function testWindowCacheIdentifier(windowName, url){
    		
			return (windowCacheIdentifier[windowName]==url);
    }

//// END CODE TO KEEP TRACK OF CONTENT        

//// CODE TO HIDE AND DISPLAY AND APPLY STYLES FOR DIVS
    
    function hideDiv(divName){
      eval("document.getElementById(\""+divName+"\").style.position=\"absolute\";");
      eval("document.getElementById(\""+divName+"\").style.display=\"none\";");
      eval("document.getElementById(\""+divName+"\").style.visibility=\"hidden\";");          
    }
    
    function showDiv(divName){
      eval("document.getElementById(\""+divName+"\").style.position=\"absolute\";");
      eval("document.getElementById(\""+divName+"\").style.display=\"block\";");
      eval("document.getElementById(\""+divName+"\").style.visibility=\"visible\";");    
    }
    
    function closeAllWindows(){
			 for(x=0;x<windowNames.length;x++){
        OverlayWindow_Close(windowNames[x]);
       }
       return false;
    }
    
    function applyStyle(divName, options){
      
      options=options.toLowerCase();
      
      var styles = new Array;
      styles = options.split(";");
      for(x=0;x<styles.length;x++){
        if(styles[x]!=""){
          var style = new Array;
          style = styles[x].split(":");
          if(style[1]!="" && style.length==2){
							if(style[0]=="top"||style[0]=="left"){
								style[1] = adjustForScrollOffset(style[0], style[1]);
							}
						
              eval("if(document.getElementById(\""+divName+"\").style."+style[0]+"!=null) " + 
								"document.getElementById(\""+divName+"\").style."+style[0]+"=\""+style[1]+"\";");
          }
        }
      }//end for
    }
    
    //show and hide layers .. from TOM's CODE
    function showHideLayers() { //v9.0
			var i,p,v,obj,args=showHideLayers.arguments;
			for (i=0; i<(args.length-2); i+=3) 
			with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
				if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
				obj.visibility=v; }
		}    
		
		function setTitle(titleBarName, titleText){
			if(titleBarName!=null && titleBarName!=""){
				if(document.getElementById(titleBarName)!=null)
					document.getElementById(titleBarName).innerHTML=titleText;
			}
		}
//// END CODE TO HIDE AND DISPLAY AND APPLY STYLES FOR DIVS
    
//// UTILITY FUNCTIONS
    
		function containsValue(arr, str){

			var testString = arr.join("|");
			testString = "|" + testString + "|";
			str = "|" + str + "|";
			return (testString.indexOf(str)>=0);
			
		}
		
		function adjustForScrollOffset(name, value){
			//String(Number(window.screenTop)+Number(style[1].toString().replace("px","")))+"px";
			var numericValue = Number(value.toString().replace("px",""));
			var scrollOffset = 0;
			var documentRoot;
			if (document.documentElement && document.documentElement.scrollTop){
				documentRoot = document.documentElement;
			}
			else if (document.body){
				documentRoot = document.body;
			}
			if (name=="top"){
				scrollOffset = Number(documentRoot.scrollTop);
			}
			else if(name=="left"){
				scrollOffset = Number(documentRoot.scrollLeft);
			}
			
			return String(numericValue+scrollOffset)+"px";
			//
		}
//// END UTILITY FUNCTIONS
    
    
    

