


/**
 *  AJAX functions 
 **/


var AJAX =[];
var ajcounter=-1;

function ajaxObject() {
 
     var element;   
     var req;
     var myWidth;
     var myHeight;
     this.callAjaxFunction=function(param,elementid,script) {
   
      if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
     } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
      } 
      
      
     var x_Pos = myWidth /3;
     var y_Pos = myHeight/2;
     
    
   
    try {
          this.element = document.getElementById(elementid);
    	this.element.innerHTML+=" <div style=\'float:left;position:absolute; top:0px;left:0px; width:99%;height:99%\'><div style=\'filter:alpha(opacity=99);-moz-opacity:.9;position:absolute;left:"+x_Pos+"px;top:"+y_Pos+"px; width:250px;height:25px; border:1px solid; background-color:white;text-align:center; \' ><strong> Loading ... </strong> <img align=center src=\'../../documents/ajax-loader.gif\'></div></div>";
      }
      catch (e){
          
          
      }
	 
     
  //for safari,opera, fierfox, IE..
     if(window.XMLHttpRequest){
       
         this.req = new XMLHttpRequest();
     } else if(window.ActiveXObject) {
        
         this.req = new ActiveXObject("Microsoft.XMLHTTP");
     } else {
      
        alert('Problem creating the XMLHttpRequest object');
        //this could happaend only due to old browser or the incopampatabilty 
        
     }
    

	 

}


}
    

     
 //var http = createRequestObject(); 
 //var element;
 //var page = 0;
 
function popUp(URL, height, width, resize, scrollable ) {
    day = new Date();
    id = Math.floor(1000000 * (Math.random() % 1));
    eval("page" + " = window.open(URL, 'page"+id+"', 'toolbar=0,scrollbars="+scrollable+",location=0,statusbar=0,menubar=0,resizable="+resize+",width="+width+",height="+height+",left = 540,top = 362');");
   
}

  
 /**
 * create http request for ajax callback
 *
 */
 
 function createRequestObject() {
     var req;
     //for safari,opera, fierfox, IE..
     if(window.XMLHttpRequest){
       
        req = new XMLHttpRequest();
     } else if(window.ActiveXObject) {
        
        req = new ActiveXObject("Microsoft.XMLHTTP");
     } else {
      
        alert('Problem creating the XMLHttpRequest object');
        //this could happaend only due to old browser or the incopampatabilty 
        
     }
     return req;
  
  }
  

 
/**
* Ajax callback function.
* 
* param        - the list of parameters, ie a string like 'Search&ID=12'
* element id   - id of are to populate on callback
* script       - url of script to call
*/


function callAjaxFunction(param,elementid,script,sync) {
       
    if(!sync){
      sync = true;  
        
    }
   
    ajcounter++;
     
    AJAX[ajcounter] = new ajaxObject();
    
    AJAX[ajcounter].callAjaxFunction(param,elementid,script);
    
	AJAX[ajcounter].req.onreadystatechange = processReqChange;
	
    AJAX[ajcounter].req.open("GET", script + "&" + param, true);
	
   
    AJAX[ajcounter].req.send(null);
 
    

} 

function processReqChange(){
    
    // only if req shows "loaded"
     
    while (ajcounter>=0){
     try {    
    if ( AJAX[ajcounter].req.readyState == 4) {
        
        // only if "OK"
        if ( AJAX[ajcounter].req.status == 200) {
               response =  AJAX[ajcounter].req.responseText;
	           AJAX[ajcounter].element.innerHTML = response;
	          
	           ajcounter--;
	           
        } else {
            alert("There was a problem retrieving the data:\n" +
                 AJAX[ajcounter].req.statusText);
                    
                 ajcounter--;
        }
    }else{
       // ajcounter--;
       return ;
        //ajcounter--;
    }
     }
    catch (e){
           ajcounter--;
         //alert ("error");
     }
   }
}
/*******
  * Clears the stuffin the ajax tags
  **/
 
function clearAjaxElement(divtag) {
   
	document.getElementById(divtag).innerHTML ="";
} 




