
function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}
function AJAXInclude(id,url){

	//alert("ajaxinclude");
     new Ajax.Request(url,{
                    method:'get',
                    onSuccess:function(transport){
												/*alert("success");
												alert(id);
												alert(url);
												alert(transport.responseText);*/
												//document.getElementById(id).innerHTML = transport.responseText;
												var txt=document.createTextNode(transport.responseText);
												$(id).appendChild(txt); 
												//$(id).update(transport.responseText);

												//$(id).innerHTML = transport.responseText;
												},
                    onFailure:function(transport){
													new Ajax.Request('../../../' + url,{
																		method:'get',
																		onSuccess:function(transport)
																			{
																			$(id).innerHTML = transport.responseText;
																			},
																		onFailure:function(transport){
																		
																		
																		},
													                    asynchronous: false
																		}
																	);
												},
                    asynchronous: false
                   });
	

}


function AJAXWrite(url){

	//alert("ajaxinclude");
     new Ajax.Request(url,{
                    method:'get',
                    onSuccess:function(transport){

												document.write(transport.responseText);
												},
                    onFailure:function(transport){
													new Ajax.Request('../../../' + url,{
																		method:'get',
																		onSuccess:function(transport)
																			{
																			document.write(transport.responseText);
																			},
																		onFailure:function(transport){
																		
																		
																		},
													                    asynchronous: false
																		}
																	);
												},
                    asynchronous: false
                   });
	

}

//funziona copia di AJAXWrite che pero' verrą renderizzata come "include file" anzichč include virtual
function AJAXWrite_F(url)
{AJAXWrite(url);}
//prova a caricare in un iframe con ID  iframeID il firstURL , in caso di FAILURE carica l'URL secondURL
function SwitchURLOnFailure(iframeID,firstURL,secondURL)
{


 var url = "/sp/94_javascript_include/10_utils/XMLTryPath.asp"
 //var url = "XMLTryPath.asp"
var mypar = "path=" + firstURL;

 new Ajax.Request(url,{
					method:'get',
                    onSuccess:function(transport){
											/*alert("success");
											alert(transport.responseText);*/
											if (transport.responseText != "200")
											{$(iframeID).src=secondURL;
											}
											else
											{
											$(iframeID).src=firstURL;
													}},
                    onFailure:function(transport){
											//alert("onFailure");
											//alert(transport.responseText);
												$(iframeID).src=secondURL;
												},

                    parameters:mypar,
                    asynchronous: false
 
 
				});





}


function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   
   if ((version >= 5.5) && (version < 7 ) && (document.body.filters)&&(navigator.appName =='Microsoft Internet Explorer')) 
   {	
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}