<!--
/* DHTML functions */
var d = document;
var l = (d.layers)?1:0;
var op = navigator.userAgent.toLowerCase().indexOf('opera') != -1;

/* Get Element */
function gE(e,f){
	if(l){
		f=(f)?f:self;
		V=f.document.layers;
		if(V[e])return V[e];
			for(W=0;i<W.length;W++)
				return(gE(e,V[W]));
		}
	if(d.all)return d.all[e];
		return d.getElementById(e);
}


/**********************/
function getByTagName(tag) {
		
		tag = tag.toUpperCase();
		/*---------------------------------------------
		Creiamo un nuovo array relativo all'elemento
		che chiama il metodo, qualora non sia gi
		presente
		---------------------------------------------*/
		if(!this["lista"+tag]) {
		this["lista"+tag] = new Array()
		/*---------------------------------------------
		A questo punto scandiamo la collezione all
		alla ricerca di quegli elementi caratterizzati
		dall'avere il tag voluto (quello passato come
		parametro della funzione), e li sistemiamo
		nell'array appena creato.
		---------------------------------------------*/
		for(jtag=0,itag=0; jtag<this.all.length; jtag++) {
		if(this.all[jtag].tagName == tag)
		this["lista"+tag][itag++] = this.all[jtag]
		}
		}
		/*---------------------------------------------
		Restituiamo infine l'array
		---------------------------------------------*/
		return(this["lista"+tag])
}

if(document.all && !document.getElementsByTagName){
	document.getElementsByTagName = getByTagName

for(ind=0; ind<document.all.length; ind++){
		if(!document.all[ind].getElementsByTagName)
			document.all[ind].getElementsByTagName = getByTagName
}
}
/**********************/

function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;

//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += "    ";

if(typeof(arr) == 'object') { //Array/Hashes/Objects
 for(var item in arr) {
  var value = arr[item];
 
  if(typeof(value) == 'object') { //If it is an array,
   dumped_text += level_padding + "'" + item + "' ...\n";
   dumped_text += dump(value,level+1);
  } else {
   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
  }
 }
} else { //Stings/Chars/Numbers etc.
 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
} 

function SetLinkLocalita(IDL){
  	  gE('LinkLocalita').href = 'ModifyLocalita.php?IDLocalita='+IDL
	  gE('LinkUltimora').href = 'AddNews.php?IDNewsType=1&IDLocalita='+IDL
	  gE('LinkEventiCalendarizzati').href = 'AddNews.php?IDNewsType=2&IDLocalita='+IDL
	  gE('LinkViabilita').href = 'Viabilita.php?IDLocalita='+IDL
	  sendReq('Request', 'SetSessionLocalita.php', 'IDLocalita', IDL);
	}
	
function SetCronLinkLocalita(IDL){
	gE('CronoLista').href = 'CronoLista.php?IDLocalita='+IDL
	gE('CronoListaEventi').href = 'CronoListaEventi.php?IDLocalita='+IDL
	gE('CronoListaViabilita').href = 'CronoListaViabilita.php?IDLocalita='+IDL
	}
		
function ShowSelect(IDSelect){
 	if(IDSelect >= 4){
		gE("AccountPerms").style.display = 'block';
		}else{
			gE("AccountPerms").style.display = 'none';
	}
}
	
function ShowSelectAna(IDSelect){
	if(IDSelect == 7){
		gE("TRGestore").style.display = 'none';
		gE("TRLocalita").style.display = 'none';
		gE("TREvidenzia").style.display = 'block';				
	}else if(IDSelect == 1){
		gE("TRLocalita").style.display = 'block';
		gE("TRGestore").style.display = 'none';
		gE("TREvidenzia").style.display = 'none';			
	}else{
		gE("TRGestore").style.display = 'none';
		gE("TRLocalita").style.display = 'none';
		gE("TREvidenzia").style.display = 'none';		
	}
}
	
	
function RowColor(element){
	var e = gE(element);
	var chk = gE(element.replace('tr','ID_C'));
	
	if (chk != null && chk.checked){
		e.style.color = '#008000';
		}else{
			e.style.color == '#008000' ? e.style.color = '#666666' : e.style.color = '#008000';
		}
}
function Clear(field){
gE(field).value = '';
gE('ID_'+field).value = '';
return false;
}
function AddToList(valore, key, _ID){

var Lista_ID = gE('List_ID');

	var srcData = Lista_ID.value.split(/,/);
	var IsUni = true;
	
	for (var i=0; i < srcData.length; i++){
		if (key == srcData[i]){
		Lista_ID.value = Lista_ID.value.replace(key+"," ,"");
		Lista_ID.value = Lista_ID.value.replace(key ,"");
		IsUni = false;
		}
	}
	
	//if (srcData.length >= <?=$Max?>) IsUni = false;

	if (IsUni != false){
		if (Lista_ID.value.length != 0 && Lista_ID.value.charAt(Lista_ID.value.length - 1) != ","){
			Lista_ID.value += ",";
			}
			Lista_ID.value += key;
		}
}

/**
  * Checks/unchecks all options of a <select> element
  *
  * @param   string   the form name
  * @param   string   the element name
  * @param   boolean  whether to check or to uncheck the element
  *
  * @return  boolean  always true
  */
function setSelectOptions(the_select, do_check)
{
    var selectObject = gE(the_select);
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    } // end for

    return true;
} // end of the 'setSelectOptions()' function

function setCheckbox(input, chk) {

	for (var i = 0; i <= x.length; i++) {
		var element = 'ID_C-' + i;
		var e = gE(element);
		var row = gE('tr-' + i);
		var valore = gE('Valore-' + i);
		if (e != null && row != null){
		
			if((chk == true && e.checked) || (chk == false && !e.checked)){
				continue;
				}else if (chk == true){
					e.checked = false;
				}else if(chk == false){
					e.checked = true;
					}
					
			setCheckboxColumn(element,valore.value);
			RowColor('tr-' + i);
			
			}// End of if (e != null && row != null)
	}// End of for (i = 0; i <= Item; i++) 
}// End offunction setCheckbox(input, chk)

function setCheckboxColumn(element){
	var e = gE(element);
	if (e != null && !e.disabled){
		var valore = gE(element.replace('ID_C','Valore'));
	 	!e.checked? e.checked = true : e.checked = false;
		AddToList(valore.value, e.value);
	}
}

function setChecked(){
	for(var i = 0; i <= x.length; i++){
		var e = gE('ID_C-' + i);	
		var row = gE('tr-' + i);
		if(e != null && row != null && e.checked) RowColor('tr-' + i);
	}// End of for (i = 0; i <= Item; i++) 
}// End offunction setCheckbox(input, chk)

function openDemo(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  var win = window.open(mypage,myname,settings);
  win.window.focus();
}

function Check_Leng(){
	if(document.Search.search_str.value.length < 3){
		alert('<?=SERCH_MIN_WORD?>."');
			return false;
		}
}

function ShowHide(Element){
	gE(Element).style.display = gE(Element).style.display=='block' ? 'none':'block';
}

function Hide(Element){
	gE(Element).style.display = 'none';
}

function Show(Element){
	gE(Element).style.display = 'block';
}

// Calcola Prezzo

function Cvalue()
{
  // missing relevant digits
  
  var Costo, Margine, resultV, nVal;
  var frm = document.Insert;
  Costo = frm.Costo.value;
  Margine = frm.Margine.value;
  IVA = frm.IVA.value;
  
  if ( IsNumeric(IVA) == false || IsNumeric(Costo) == false || IsNumeric(Margine) == false) {
    alert("I campi devono essere numerici separati dal punto per i decimali");
  }
  
  if (Margine < 10) Margine = "1.0" + (Margine*100); else if (Margine >= 10) Margine = "1." + (Margine*100);
  if (IVA < 10) IVA = "1.0" + (IVA*100); else if (IVA >= 10) IVA = "1." + (IVA*100);
  resultV = Costo * Margine * IVA ;

  // 6 relevant digits only, or integer 
  if ( (resultV == parseInt(resultV)) || (resultV > 999999) )
  {
    // mostly integer
    resultV = parseInt( resultV );
  }
  else
  {
    if (resultV > 1)
    {
	resultV = resultV.toString();
	resultV = resultV.substring(0,5);
    } else {
	resultV = resultV.toString();
	resultV = resultV.substring(0,8);
    }
  }

 //document.write(resultV);
  frm.Prezzo.value = "   " + comma(resultV);
}

function comma(num)
{
 var n = Math.floor(num);
 var myNum = num + "";
 var myDec = ""
 
 if (myNum.indexOf('.',0) > -1){
  myDec = myNum.substring(myNum.indexOf('.',0),myNum.length);
 }
 var arr=new Array('0'), i=0; 
 while (n>0) 
   {arr[i]=''+n%1000; n=Math.floor(n/1000); i++;}
 arr=arr.reverse();
 
 for ( i in arr) if (i>0) //padding zeros
   while (arr[i].length<3) arr[i]='0'+arr[i];
 return arr.join() + myDec;
}

function cambiaImp(){
            myForm=document.formlogon;
            var imp= myForm.Importo.value;
            var impFormat = puntiInVirgole(imp);
            if(imp==0){
              alert("Inserisci l'importo");
              focus();
              }
            if(imp==impFormat && parseInt(impFormat,10)==impFormat)
              myForm.Importo.value=imp+",00";
            else
              myForm.Importo.value = impFormat;
    }
	
function IsNumeric(strString)
{
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
   }
   
   return blnResult;
}

// ====================================================================
//       URLEncode and URLDecode functions
//
// Copyright Albion Research Ltd. 2002
// http://www.albionresearch.com/
//
// You may copy these functions providing that 
// (a) you leave this copyright notice intact, and 
// (b) if you use these functions on a publicly accessible
//     web site you include a credit somewhere on the web site 
//     with a link back to http://www.albionresarch.com/
//
// If you find or fix any bugs, please let us know at albionresearch.com
//
// SpecialThanks to Neelesh Thakur for being the first to
// report a bug in URLDecode() - now fixed 2003-02-19.
// ====================================================================
function URLEncode(Stringa)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = Stringa;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function URLDecode(Stringa)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = Stringa;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext ;
};

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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImage() { //v3.0
  var i; var j=0; var x; var a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i; var x; var a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i;
	var j=d.MM_p.length;
	var a=MM_preloadImages.arguments;
	for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('I campi sottoelencati sono incompleti o contengono degli errori:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}
function trim(chestring){
	chestring = chestring.split(" ");
	chestring = chestring.join();
		return chestring;
	}
function octalchange()
    {
        var val = document.chmod_form.t_total.value;
        var stickybin = parseInt(val.charAt(0)).toString(2);
        var ownerbin = parseInt(val.charAt(1)).toString(2);
        while (ownerbin.length<3) { ownerbin="0"+ownerbin; };
        var groupbin = parseInt(val.charAt(2)).toString(2);
        while (groupbin.length<3) { groupbin="0"+groupbin; };
        var otherbin = parseInt(val.charAt(3)).toString(2);
        while (otherbin.length<3) { otherbin="0"+otherbin; };
        document.chmod_form.sticky.checked = parseInt(stickybin.charAt(0));
        document.chmod_form.owner4.checked = parseInt(ownerbin.charAt(0));
        document.chmod_form.owner2.checked = parseInt(ownerbin.charAt(1));
        document.chmod_form.owner1.checked = parseInt(ownerbin.charAt(2));
        document.chmod_form.group4.checked = parseInt(groupbin.charAt(0));
        document.chmod_form.group2.checked = parseInt(groupbin.charAt(1));
        document.chmod_form.group1.checked = parseInt(groupbin.charAt(2));
        document.chmod_form.other4.checked = parseInt(otherbin.charAt(0));
        document.chmod_form.other2.checked = parseInt(otherbin.charAt(1));
        document.chmod_form.other1.checked = parseInt(otherbin.charAt(2));
        calc_chmod(1);
    };

    function calc_chmod(nototals)
    {
      var users = new Array("owner", "group", "other");
      var totals = new Array("","","");
      var syms = new Array("","","");

        for (var i=0; i<users.length; i++)
        {
            var user=users[i];
            var field4 = user + "4";
            var field2 = user + "2";
            var field1 = user + "1";
            var symbolic = "sym_" + user;
            var number = 0;
            var sym_string = "";
            var sticky = "0";
            var sticky_sym = " ";
            if (document.chmod_form.sticky.checked){
                sticky = "1";
                sticky_sym = "t";
            }
            if (document.chmod_form[field4].checked == true) { number += 4; }
            if (document.chmod_form[field2].checked == true) { number += 2; }
            if (document.chmod_form[field1].checked == true) { number += 1; }

            if (document.chmod_form[field4].checked == true) {
                sym_string += "r";
            } else {
                sym_string += "-";
            }
            if (document.chmod_form[field2].checked == true) {
                sym_string += "w";
            } else {
                sym_string += "-";
            }
            if (document.chmod_form[field1].checked == true) {
                sym_string += "x";
            } else {
                sym_string += "-";
            }

            totals[i] = totals[i]+number;
            syms[i] =  syms[i]+sym_string;

      };
        if (!nototals) document.chmod_form.t_total.value = sticky + totals[0] + totals[1] + totals[2];
        document.chmod_form.sym_total.value = syms[0] + syms[1] + syms[2] + sticky_sym;
    }
function cutHex(h){
	return (h.charAt(0)=="#") ? h.substring(1,7) : h
	}
function HexToRGB(Hex){
	var R = parseInt((cutHex(Hex)).substring(0,2),16);
	var G = parseInt((cutHex(Hex)).substring(2,4),16);
	var B = parseInt((cutHex(Hex)).substring(4,6),16);
	return R+', '+G+', '+B;
	}
function BgColorRow(Row, Color, MarkColor){
	var TDList = Row.getElementsByTagName('TD');
	var TDBgColor = TDList.item(1).style.backgroundColor.toLowerCase();	
	if(arguments.length>2){
		var MkColor = MarkColor.toLowerCase();		
		if(TDBgColor.substring(0,3) == 'rgb') MkColor = 'rgb('+HexToRGB(MarkColor)+')';
		if(TDBgColor == MkColor) Color = MkColor;
	}
	for(var X=0; X<TDList.length; X++){
		TDList.item(X).style.backgroundColor = Color;
		}
	}

function SetBgColorRow(Row, BgColor, MarkColor){
	var TDList = Row.getElementsByTagName('TD');
	var Color = MarkColor;
	var TDBgColor = TDList.item(1).style.backgroundColor.toLowerCase();
	var MkColor = MarkColor.toLowerCase();
	if(TDBgColor.substring(0,3) == 'rgb') MkColor = 'rgb(' + HexToRGB(MarkColor) + ')';
	if(TDBgColor == MkColor) Color = BgColor;
	for(var X=0; X<TDList.length; X++){
		TDList.item(X).style.backgroundColor = Color;
		}
	}
	
function CleanWord( html,bIgnoreFont ){
	

	html = html.replace(/<o:p>\s*<\/o:p>/g, "") ;
	html = html.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
	
	// Remove mso-xxx styles.
	html = html.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;

	// Remove margin styles.
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
	html = html.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;

	html = html.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
	html = html.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;

	html = html.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;

	html = html.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
	html = html.replace( /\s*tab-stops:[^"]*/gi, "" ) ;

	// Remove FONT face attributes.
	
	if ( bIgnoreFont )
	{
		html = html.replace( /\s*face="[^"]*"/gi, "" ) ;
		html = html.replace( /\s*face=[^ >]*/gi, "" ) ;

		html = html.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;
	}
	
	// Remove Class attributes
	html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;

	// Remove styles.
	/*if ( bRemoveStyles )
		html = html.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
		*/
	// Remove empty styles.
	html =  html.replace( /\s*style="\s*"/gi, '' ) ;
	
	html = html.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
	
	html = html.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
	
	// Remove Lang attributes
	html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	
	html = html.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
	
	html = html.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;

	// Remove XML elements and declarations
	html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
	
	// Remove Tags with XML namespace declarations: <o:p><\/o:p>
	html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
	
	html = html.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;

	html = html.replace( /<H1([^>]*)>/gi, '<div$1><b><font size="6">' ) ;
	html = html.replace( /<H2([^>]*)>/gi, '<div$1><b><font size="5">' ) ;
	html = html.replace( /<H3([^>]*)>/gi, '<div$1><b><font size="4">' ) ;
	html = html.replace( /<H4([^>]*)>/gi, '<div$1><b><font size="3">' ) ;
	html = html.replace( /<H5([^>]*)>/gi, '<div$1><b><font size="2">' ) ;
	html = html.replace( /<H6([^>]*)>/gi, '<div$1><b><font size="1">' ) ;

	html = html.replace( /<\/H\d>/gi, '<\/font><\/b><\/div>' ) ;
	
	html = html.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;

	// Remove empty tags (three times, just to be sure).
	html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	html = html.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;

	// Transform <P> to <DIV>
	var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;	// Different because of a IE 5.0 error
	html = html.replace( re, "<div$2<\/div>" ) ;

	return html ;
}

function divCenter(IDDiv){
var BrowserSize = getBrowserSize();
var BWidth = BrowserSize[0];
var BHeight = BrowserSize[1];

var DivObj = gE(IDDiv);
	
var DivWidth = DivObj.offsetWidth;
var DivHeight = DivObj.offsetHeight;

var DivXPos = (BWidth - DivWidth)/2;
var DivYPos = (BHeight - DivHeight)/2;
DivObj.style.position = 'absolute';
DivObj.style.left = DivXPos+'px';
DivObj.style.top = DivYPos+'px';
	}
	
function getBrowserSize() {
 var myHeight = 0;
 var myWidth = 0; 
 this["size"] = new Array()
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
	myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
	myWidth = document.body.clientWidth;
  }
  this["size"][0] = myWidth;
  this["size"][1] = myHeight;
return this["size"];
}

function CenterPositionElement(){
var IDElement = arguments[0];
if(IDElement == "[object Event]") IDElement = IDIFrame;
	if (gE(IDElement) != null) {
		var EObj = gE(IDElement);
		var EWidth = EObj.offsetWidth;
		var EHeight = EObj.offsetHeight;
		var Position = TB_position(EWidth, EHeight);
		EObj.style.position = 'absolute';
		EObj.style.left = Position[0]+'px';
		EObj.style.top = Position[1]+'px';
	}
}

function TB_position(TB_WIDTH, TB_HEIGHT) {
  var pagesize = TB_getPageSize();
  var arrayPageScroll = TB_getPageScrollTop();    
  arrayPosition = new Array((arrayPageScroll[0] + (pagesize[0] - TB_WIDTH)/2),
															(arrayPageScroll[1] + (pagesize[1]-TB_HEIGHT)/2))
  return arrayPosition
}

function TB_getPageScrollTop(){
  var yScrolltop;
  var xScrollleft;
  if (self.pageYOffset || self.pageXOffset) {
    yScrolltop = self.pageYOffset;
    xScrollleft = self.pageXOffset;
  } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){   // Explorer 6 Strict
    yScrolltop = document.documentElement.scrollTop;
    xScrollleft = document.documentElement.scrollLeft;
  } else if (document.body) {// all other Explorers
    yScrolltop = document.body.scrollTop;
    xScrollleft = document.body.scrollLeft;
  }
  arrayPageScroll = new Array(xScrollleft,yScrolltop) 
  return arrayPageScroll;
}

function TB_getPageSize(){
  var de = document.documentElement;
  var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
  arrayPageSize = new Array(w,h) 
  return arrayPageSize;
}

function TB_overlaySize(){
	if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) {	
		yScroll = window.innerHeight + window.scrollMaxY;
		xScroll = window.innerWidth + window.scrollMaxX;
		var deff = document.documentElement;
		var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
		var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
		xScroll -= (window.innerWidth - wff);
		yScroll -= (window.innerHeight - hff);
	} else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
		yScroll = document.body.scrollHeight;
		xScroll = document.body.scrollWidth;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		yScroll = document.body.offsetHeight;
		xScroll = document.body.offsetWidth;
  	}
	   return new Array(xScroll,yScroll);
}

function getIframeId() {
	var iframes = document.getElementsByTagName("IFRAME");
	var win = window.top;
	for (var i=0; i<iframes.length; i++) {
		var o = iframes.item(i);
		var w = null;
	// For IE5.5 and IE6
	if(o.contentWindow) w = o.contentWindow;
	if (window.frames && window.frames[o.id].window) w = window.frames[o.id];
	return o.id;
		}
	return null;
	}

function getInsideIframeID(){
     var myTop;
     if(window.frameElement){
       myTop = window.frameElement;
     } else if (window.top) {
       myTop = window.top;
       var myURL = location.href;
       var iFs = myTop.document.getElementsByTagName('iframe');
       var x, i = iFs.length;
       while (i--){
         x = iFs[i];
         if (x.src && x.src == myURL){
           myTop = x;
           break;
         }
       }
     }
     if (myTop){
       return ((myTop.id)?  myTop.id : false);
     } else {
       return false;
     }
   }

/*Ajax*/
//var http = createRequestObject();
//var objectId = '';

function createRequestObject(htmlObjectId){
    var obj;
    var browser = navigator.appName;
    objectId = htmlObjectId;
    if(browser == "Microsoft Internet Explorer"){
        obj = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        obj = new XMLHttpRequest();
    }
    return obj;    
}

function sendReq(Request, serverFileName, variableNames, variableValues) {
	 http = createRequestObject(Request);
	var paramString = '';
	variableNames = variableNames.split(',');
	variableValues = variableValues.split(',');
	for(var i=0; i<variableNames.length; i++) {
		paramString += variableNames[i]+'='+variableValues[i]+'&';
	}
	paramString = paramString.substring(0, (paramString.length-1));
	if (paramString.length == 0) {
	   	http.open('get', serverFileName);
	}
	else {
		http.open('get', serverFileName+'?'+paramString);
	}
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
	if(http.readyState == 4){
		responseText = http.responseText;
		document.getElementById(objectId).innerHTML = responseText;
    }
}
/*Ajax*/
// End -->

