   var httpRequest = false;
   function postForm(url, parameters, div) {
		
		printLoading(div);
		
      httpRequest = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         httpRequest = new XMLHttpRequest();
         if (httpRequest.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //httpRequest.overrideMimeType('text/xml');
            httpRequest.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!httpRequest) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }

	  httpRequest.onreadystatechange = function() { 
		document.getElementById(div).innerHTML = httpRequest.responseText;
  	  };
	  
      httpRequest.open("POST", url, true);
	  httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	  httpRequest.send(parameters);
   }

   function alertContents(div) {
      if (httpRequest.readyState == 4) {
         if (httpRequest.status == 200) {
            //alert(httpRequest.responseText);
            result = httpRequest.responseText;
            document.getElementById(div).innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function anotherForm(obj,  div , url) {
      
	  printLoading(div);
	  
	  var getstr = "";
		var i=0;
 		var j=0;
		
      for (i=0; i<obj.length; i++) {
         if (obj[i].tagName == "INPUT") {
		 	//alert(obj[i].type);

            if (obj[i].type == "text") {
               getstr += obj[i].name + "=" + obj[i].value + "&";
            }
			
            if (obj[i].type == "checkbox") {
               if (obj[i].checked) {
                  getstr += obj[i].name + "=" + obj[i].value + "&";
               } else {
                  getstr += obj[i].name + "=&";
               }
            }
			
            if (obj[i].type == "radio") {
               if (obj[i].checked) {
                  getstr += obj[i].name + "=" + obj[i].value + "&";
               }
            }
         }   
		 
         if (obj[i].tagName == "SELECT") {
            var sel = obj[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
		 
		 
		 if (obj[i].type == "hidden") {
             getstr += obj[i].name + "=" + obj[i].value + "&";
         }
		 
      }
		
		
		postForm(url, getstr, div);
		return;
		
		}
		
		
		function processForm(obj,  div , url) {
      
	  printLoading(div);
	  
	  var getstr = "";
		var i=0;
 		var j=0;
		
		var i=0;
 		var j=0;
 		for(i=0;i<document.forms.length;++i) {
  		for(j=0;j<document.forms[i].elements.length;++j) {

		if (document.forms[i].elements[j].type == "text") {
           getstr += document.forms[i].elements[j].name + "=" + document.forms[i].elements[j].value + "&";
        }
				
		if (document.forms[i].elements[j].type == "checkbox") {
         	if (document.forms[i].elements[j].checked) {
               getstr += document.forms[i].elements[j].name + "=" + document.forms[i].elements[j].value + "&";
            } else {
               getstr += document.forms[i].elements[j].name + "=&";
            }
         }
				
		if (document.forms[i].elements[j].type == "radio") {
           if (document.forms[i].elements[j].checked) {
               getstr += document.forms[i].elements[j].name + "=" + document.forms[i].elements[j].value + "&";
           }
        }
		
		if (document.forms[i].elements[j].type == "hidden") {
           getstr += document.forms[i].elements[j].name + "=" + document.forms[i].elements[j].value + "&";
        }

		if (document.forms[i].elements[j].type== "select-one") {
		   //alert(document.forms[i].elements[j].name);
           var sel = document.forms[i].elements[j];
           getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
        }
			
		}
 	}

	postForm(url, getstr, div);
	return;
}




//swf|flv|gif|jpg|png|mov|mpg|wmv|mp3|wav|aiff|zip|pdf|doc|tif
//swf,flv,gif,jpg,mov,mpg,wmv,mp3,wav,aiff
var exts = "swf|flv|gif|jpg|png|mov|mpg|wmv|mp3|wav|aiff|zip|pdf|doc|tif|ics|js|xml";
var UID,NF=0,cx=0;

function openStatusWindow()
{ 
 if(document.F1.popup.checked == true)
 {
   win1 = window.open('/cgi-bin/upload/upload_status.cgi?upload_id='+UID,'win1','width=320,height=240,resizable=1');
   win1.window.focus();
 }
}

function generateSID()
{
 UID = Math.round(10000*Math.random())+'0'+Math.round(10000*Math.random());
 var f1=document.F1;
 f1.action = f1.action.split('?')[0]+'?upload_id='+UID;
}

function StartUpload()
{
    NF=0;
    for (var i=0;i<document.F1.length;i++)
    {
     current = document.F1.elements[i];
     if(current.type=='file' && current.value!='')
      {
         if(!checkExt(current.value))return false;
         NF++;
      }
    }
    if(NF==0){alert('Select at least one file to upload');return false;};
    generateSID();
	//makeRequest(url, div);
    openStatusWindow();
}





function checkExt(value)
{
    if(value=="")return true;
    var re = new RegExp("^.+\.("+exts+")$","i");
    if(!re.test(value))
    {
        alert("Extension not allowed for file: \"" + value + "\"\nOnly these extensions are allowed: "+exts.replace(/\|/g,',')+" \n\n");
        return false;
    }
    return true;
}




function confirmsubmit()
{
var agree=confirm("Think carefully.\n\nAre you sure you wish to obliterate this content?\n\nClick cancel if you are unsure.\n\n");
if (agree)
	return true ;
else
	return false ;
}


function makeRequest(url, div) {
 
  printLoading(div);

  var httpRequest;
	
  if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  httpRequest = new XMLHttpRequest();
  if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); }
  } 
  
  else if (window.ActiveXObject) { // IE
  try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } 
  catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } 
  catch (e) {}
  }
  }
        
  if (!httpRequest) {
  alert('Giving up :( Cannot create an XMLHTTP instance');
  return false;
  }
		
  //call the function that will handle the response we get
  httpRequest.onreadystatechange = function() { 
  	printContent(httpRequest, div, url);
  };
  
  
  httpRequest.open("GET", url, true);
  httpRequest.send(null);
  
 }
 
 function printContent(httpRequest, div, url){
	if (httpRequest.readyState == 4) {
       if (httpRequest.status == 200) {
		document.getElementById(div).innerHTML = httpRequest.responseText;
	   }
	   else {
	   //alert('There was a problem with the request to '+url);
	   document.getElementById(div).innerHTML = '<p>&nbsp;</p><p>Oh dear. There was an error requesting the url'+url+'</p>';
	  }
	}
	return;
}
	
	
function printLoading(div)
{
	document.getElementById(div).innerHTML = '<div class="loading"><img src="/images/loading.gif" width="200" height="150" alt="Processing, please wait" /></div>';
}

function upLoading(div)
{
	document.getElementById(div).innerHTML = '<div class="loading"><img src="/images/loading.gif" width="200" height="150" alt="Uploading, please wait" /></div>';
}





var active_hidden_text = "";

function show_hidden_obj(obj){
	if(document.getElementById(obj).style.display == 'block'){
		document.getElementById(obj).style.display = 'block';
	}
	else{
		document.getElementById(obj).style.display = 'block';
	}
	if(active_hidden_text != "" && active_hidden_text != obj){
		document.getElementById(active_hidden_text).style.display = 'none';
	}	
	active_hidden_text = obj;
}

function hasAnchor(){
	var url = unescape(window.top.location.href);
	if(url.indexOf("#") != -1){
		return true;
	} else {
		return false;	
	}
}







