
// ===================================================================
// Author: Vito Di Nunzio
// ===================================================================

	function showdiv(eDiv, eShow) {
		var s="block";
		if (!eShow){s="none";}
		if (eDiv != "" && eDiv != null && eDiv != " " && eDiv != null) 
		{ 
			if (document.getElementById) { // DOM3 = IE5, NS6
				document.getElementById(eDiv).style.display=s;
			}
			else {
				var eID = GetElemento(eDiv); 
				if (document.layers) { // Netscape 4
					document.eID.display=s;
				}
				else { // IE 4
					document.all.eID.style.display=s;
				}
			}
		}
	}

	function showhide(eDiv, eShow) {
		var eID = GetElemento(eDiv); 
		if (eDiv != "" && eDiv != null && eDiv != " " && eDiv != null) 
		{ 
			if (document.getElementById) {  // DOM3 = IE5, NS6, Opera 
				if(!eShow){s="hidden";}else{s="visible";};
				document.getElementById(eDiv).style.visibility=s;
			} 
			else if (document.layers){ //NN4 
				if(!eShow){s="hide";}else{s="show";};
				document.eID.visibility=s;
			} 
			else if (document.all) {// IE 4 
				if(!eShow){s="hidden";}else{s="visible";};
				document.all.eID.style.visibility=s;
			} 
		} 
	}
	

	 function SetPopUp(apri, w, h) 
		{
		var sPop = "top=100, left=100, width=" + w + ", height=" + h;
		sPop += "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes"
		window.open(apri, "", sPop);
		}


	function Ck_Ven_Pro(divCk)
		{
			var CAT_MNU		= document.ff.CAT_MNU.value
			var P_NOME		= document.ff.P_NOME.value
			var P_CONF		= document.ff.P_CONF.value
			var P_PREZZO	= document.ff.P_PREZZO.value
			var P_PESO		= document.ff.P_PESO.value

			if (CAT_MNU 	== null)	{CAT_MNU 	= "";}
			if (P_NOME 		== null)	{P_NOME 	= "";}
			if (P_CONF 		== null)	{P_CONF 	= "";}
			if (P_PREZZO	== null)	{P_PREZZO 	= "";}
			if (P_PREZZO 	== "0,00")	{P_PREZZO 	= "";}
			if (P_PESO		== null)	{P_PESO 	= "";}
			if (P_PESO 		== "0,00")	{P_PESO 	= "";}

			if (P_NOME != "" && P_CONF != "" && CAT_MNU != ""){
			//alert(P_NOME + " - " + P_CONF + " - " + P_PREZZO);
			//alert(divCk + ": true - " + P_NOME + " - " + P_CONF + " - " + CAT_MNU);
			showhide(divCk, true);
			}
			else{
			//alert(P_NOME + " - " + P_CONF + " - " + P_PREZZO);
			//alert(divCk + ": false - " + P_NOME + " - " + P_CONF + " - " + CAT_MNU);
			showhide(divCk, false);
			}
		}	

		function getStrFormGet(form){
		var f=form.length;
		var r="";
		f = parseInt(f,10);
		//alert(f);
		while(f--){
			if(form[f].type=="checkbox"){
			r = r + "&" + form[f].name + "=" + form[f].checked;
			} else
				/*
				var myStr=new String(form[f].value);
				if (myStr.length>1000) {
					myStr = myStr.slice(0,1000);
				}
				*/
				if(navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1){
					r = r + "&" + form[f].name + "=" + escape(form[f].value);
				} else
					r = r + "&" + form[f].name + "=" + form[f].value;
		}
		return r;
		} 
	

		function historyChange(newLocation, historyData) {
			if(newLocation != "" && newLocation != null && historyData != "" && historyData != null)
			{
				var iUrl = historyData.substr(0, historyData.indexOf("|"));
				var iDiv = historyData.substr(historyData.indexOf("|")+1);
				if(iUrl != "" && iUrl != null && iDiv != "" && iDiv != null){carica(iUrl, iDiv);};
			};
		};

		addHistoryEvent = function(iUrl, iDiv, iNum) {
			if(iUrl != "" && iUrl != null && iDiv != "" && iDiv != null)
			{
				if(iNum != "" && iNum != null)
				{
					var chiaveHistory = iUrl.substr(0, iUrl.indexOf("."))+"_"+iNum;
				}
				else
				{
					var chiaveHistory = iUrl.substr(0, iUrl.indexOf("."));
				}
				var valoreHistory = iUrl+"|"+iDiv;
				dhtmlHistory.add(chiaveHistory.toLowerCase(), valoreHistory);
			}
		}
	
		function caricaBis(urlFilePrimo, divPrimo, urlFileSecondo, divSecondo) {
				var eID;
				eID = GetElemento(divPrimo); 
				AjaxRequest.get(
					{
						'url': urlFilePrimo 
						,'onSuccess':function(req){ 
										eID.innerHTML=req.responseText; 
										carica(urlFileSecondo, divSecondo);
												  }
						,'onError':function(req){ 
								eID.innerHTML = "Status: " + req.statusText + "<br><br>" + req.responseText;
												}
					}
				);
		}

		function carica(urlFile, divDestinazione) {
				var eID;
				//alert(urlFile + " --- " + divDestinazione);
				eID = GetElemento(divDestinazione); 
				if (urlFile != "" && urlFile != null && urlFile != " ") 
				{ 
					AjaxRequest.get(
						{
							'url': urlFile 
							,'onSuccess':function(req){ 
											eID.innerHTML=req.responseText; 
													  }
							,'onError':function(req){ 
								eID.innerHTML = "Status: " + req.statusText + "<br><br>" + req.responseText;
													}
						}
					);
				} 
				else				
				{           
					eID.innerHTML = urlFile;
				} 
		}



		function caricaBisForGallery(urlFilePrimo, divPrimo, urlFileSecondo, divSecondo) {
				var eID;
				eID = GetElemento(divPrimo); 
				AjaxRequest.get(
					{
						'url': urlFilePrimo 
						,'onSuccess':function(req){ 
										eID.innerHTML=req.responseText; 
										caricaForGallery(urlFileSecondo, divSecondo);
												  }
						,'onError':function(req){ 
								eID.innerHTML = "Status: " + req.statusText + "<br><br>" + req.responseText;
												}
					}
				);
		}
		
		function caricaForGallery(urlFile, divDestinazione) {
				var eID;
				//alert(urlFile + " --- " + divDestinazione);
				//zoomHide();
				eID = GetElemento(divDestinazione); 
				if (urlFile != "" && urlFile != null && urlFile != " ") 
				{ 
					AjaxRequest.get(
						{
							'url': urlFile 
							,'onSuccess':function(req){ 
											eID.innerHTML=req.responseText; 
											//setupZoom();
													  }
							,'onError':function(req){ 
								eID.innerHTML = "Status: " + req.statusText + "<br><br>" + req.responseText;
													}
						}
					);
				} 
		}

		


		// ===========================================================

		// funzione per prendere un elemento con id univoco
		function GetElemento(id_elemento) {
			var elemento;
			if(document.getElementById)
				elemento = document.getElementById(id_elemento);
			else
				elemento = document.all[id_elemento];
			return elemento;
		};


		// ===========================================================
		
		function getCookie(NameOfCookie)
		{
			if (document.cookie.length > 0) 
			{
				begin = document.cookie.indexOf(NameOfCookie+"=");       
					if (begin != -1) 
					{           
					  begin += NameOfCookie.length+1;       
					  end = document.cookie.indexOf(";", begin);
					  if (end == -1) end = document.cookie.length;
						return unescape(document.cookie.substring(begin, end));
					} 
			}
			return null;
		}


		// ===========================================================

		function setCookie(NameOfCookie, value, expiredays) 
		{
			var ExpireDate = new Date ();
			ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
			//alert(NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires="+ ExpireDate.toGMTString()));
			document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires="+ ExpireDate.toGMTString());
		}


		// ===========================================================

		function delCookie(NameOfCookie) 
		{
		  if (getCookie(NameOfCookie)) 
		  {
			document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
		  }
		}
		

var v;
var v2;
function ctr(objform, nomecampo, descrizione, tipo, obbligatorio) 
{
	v = "";
	v2 = "";
	switch (tipo) 
	{
		case "text":
			// controllo che il campo non sia vuoto
			eval("v = objform." + nomecampo + ".value;");
			if (v == "")
			{
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			break;
			
		case "num":
			eval("v = objform." + nomecampo + ".value;");
			
			if (v == "")
			{
				// -1 = True\Vero\E' proprio cosė
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			else
			{
				if (!IsNumeric(v)) 
				{
					alert("Il campo \'" + descrizione + "\' deve essere numerico ");
					eval("objform." + nomecampo + ".focus();");
					eval("objform." + nomecampo + ".value = null;");
					return(false);
				}
			}
			break;

		case "int":
			eval("v = objform." + nomecampo + ".value;");
			
			if (v == "")
			{
				// -1 = True\Vero\E' proprio cosė
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			else
			{
				if (isNaN(parseInt(v, 10)) || (v!=parseInt(v, 10))) 
				{
					alert("Il campo \'" + descrizione + "\' deve essere numerico ");
					eval("objform." + nomecampo + ".focus();");
					eval("objform." + nomecampo + ".value = null;");
					return(false);
				}
			}
			break;
			
		case "email":
			eval("v = objform." + nomecampo + ".value;");
			
			if (v == "")
			{
				// -1 = True\Vero\E' proprio cosė
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			else
			{
				var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\-])+\.)+([a-zA-Z0-9]){2,4}$/;
				if (!filter.test(v)) 
				{
					alert("Il formato del campo \'" + descrizione + "\' non č corretto");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			break;
			
		case "cap":
			eval("v = objform." + nomecampo + ".value;");
			
			if (v == "")
			{
				// -1 = True\Vero\E' proprio cosė
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			else
			{
				lung=5;
				if (isNaN(parseInt(v, 10)) || (v!=parseInt(v, 10))) 
				{
					alert("Il campo \'" + descrizione + "\' deve essere numerico ");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
				if (v.length!= lung) 
				{
					alert("Il campo \'" + descrizione + "\' deve essere lungo " + lung);
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			break;
			
		case "cciaa":
			eval("v = objform." + nomecampo + ".value;");
			
			if (v == "")
			{
				// -1 = True\Vero\E' proprio cosė
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			else
			{
				lung=2;
				if (v.length!= lung) 
				{
					alert("Il campo \'" + descrizione + "\' deve essere lungo " + lung);
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			break;
			
		case "data":
			break;
		
		case "piva":
			break;
		
		case "select":
			if (obbligatorio == -1)  
			{
				eval("v = objform." + nomecampo + ".selectedIndex;");
				if (v == 0)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			break;
		
		case "checkbox":
			if (obbligatorio == -1)
			{
				eval("v = objform." + nomecampo + ".length;");
				for (var i=0; i<v; i++)
				{
					eval("b = objform." + nomecampo + ".item(i).checked;");
					if (b) return(true)
				}
				alert("Selezionare almeno un elemento dal gruppo \'" + descrizione + "\'!");
				return(false)
			}
			break;
			
		//Copiato da case "checkbox":
		case "radio":
			if (obbligatorio == -1)
			{
				eval("v = objform." + nomecampo + ".length;");
				for (var i=0; i<v; i++)
				{
					eval("b = objform." + nomecampo + ".item(i).checked;");
					if (b) return(true)
				}
				alert("Selezionare almeno un elemento dal gruppo \'" + descrizione + "\'!");
				return(false)
			}
			break;
		case "password":
			// controllo che il campo non sia vuoto
			eval("v = objform." + nomecampo + ".value;");
			eval("v2 = objform." + nomecampo + "_Conf" + ".value;");
	
			if (v == "")
			{
				// -1 = True\Vero\E' proprio cosė
				if (obbligatorio == -1)
				{
					alert("Il campo \'" + descrizione + "\' č obbligatorio!");
					eval("objform." + nomecampo + ".focus();");
					return(false);
				}
			}
			else
			{
				if (v == v2){ return(true) }
				alert("Il campo \'" + descrizione + "\' non corrisponde al campo \'Conferma " + descrizione + "\'!");
				return(false)	
			}
			break;
	}
return(true);
}


function IsNumeric(sText)

{
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


/*
Simple Image Trail script- By JavaScriptKit.com
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/


var u_a = navigator.userAgent.toLowerCase();
var div_w=0;
var div_h=0;
var x_to;


if (document.getElementById || document.all)
	document.write('<div id="imgtrailer" style="position:absolute;visibility:hidden;"></div>')
	

function gettrailobject()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer")
	else if (document.all)
		return document.all.imgtrailer
	}

function gettrailobj()
	{
	if (document.getElementById)
		return document.getElementById("imgtrailer").style
	else if (document.all)
		return document.all.imgtrailer.style
	}

function truebody()
	{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

function trailOff()
	{
		if (x_to && x_to > 0)
		{
			clearTimeout(x_to);
		}

		document.onmousemove='';
		gettrailobj().visibility="hidden";
	}

function trailOn(imgFile,imgTit,imgOwn,imgR1,imgR2,_w,_h,smallmedium){


//#####################################################################
		// IMPOSTAZIONI
		//#####################################################################
		
		var siteOwn 	= "Egnam.it";
		var imgLoad 	= "/img/loadingnew.gif";
		var bgImage  	= "/img/sep.gif";
		var bgColor  	= "#b2a99d";
		var borderColor = "#808080";
		var bgColor2  	= "#FFFFFF";

		//alert((imgTit)+" - "+(imgOwn)+" - "+imgR1+" - "+imgR2);

		//#####################################################################
		// FINE IMPOSTAZIONI
		//#####################################################################
		
		var smallmedium = (smallmedium == null) ? 0 : smallmedium;
		iImg= new Image();
		iImg.src=(imgFile);
		if (_w == "" || _w == null || _w == 0){_w = 0;}
		if (_h == "" || _h == null || _h == 0){_h = 0;}
		if (_w == 0 && _h == 0){_w = iImg.width; _h = iImg.height;}
		if (_w == 0 && _h != 0){_w = parseInt(_h*iImg.width/iImg.height);}
		if (_w != 0 && _h == 0){_h = parseInt(_w*iImg.height/iImg.width);}
		
		switch(smallmedium)
		{
			case 1:
				var imgFileprev = imgFile.replace(/thumb_/, "imgFile_");
				break;
			case 0:
				var imgFileprev = imgFile.replace(/thumb_/, "thumbsmall_");
				break;
			case 2:
				var imgFileprev = imgFile.replace(/big/, "small");
				break;
		}
		if (imgR1 == "" && imgR1 == null && imgR1 == " "){imgR1 = "";}
		if (imgR2 == "" && imgR2 == null && imgR2 == " "){imgR2 = "";}
		if (imgOwn == "" && imgOwn == null && imgOwn == " "){imgOwn = "";}
		gettrailobj().left="-500px";
		div_w = parseInt(_w) + 2;
		sm_w = parseInt(_w) + 2;
		half_h = 50;
		half_h = Math.ceil(parseInt(_h)/2);
		topx = half_h - 9;
		sm_h = parseInt(_h) + 2;
		if (navigator.userAgent.indexOf("Opera")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: '+bgColor+'; layer-background-color: '+bgColor+'; border: 1px none '+borderColor+'; padding:10px; width:'+div_w+'px;height:100%;z-index:51"><div style="background-color: '+bgColor2+'; layer-background-color: '+bgColor2+';width:'+_w+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: '+bgColor2+'; layer-background-color: '+bgColor2+';z-index:51;position:absolute;width:'+_w+'px;height:'+sm_h+'px;text-align:center"><img  src="'+imgFileprev+'"  width="'+sm_w+'" height="'+sm_h+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+_w+'px;top:'+topx+'px;text-align: center;"><img src="'+imgLoad+'"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+_w+'px;"><div style="border: 1px solid '+borderColor+';width:'+_w+'px;"><img name="btcontainer" id="btcontainer" src="'+bgImage+'" border="0" width="'+_w+'" height="'+_h+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: '+bgColor2+';background-color:'+bgColor2+';padding:3px;">'+imgTit+'<br>'+(_w>=233?'<nobr>':'')+'&copy; '+siteOwn+(imgOwn==""?'':' | ')+imgOwn+(_w>=233?'</nobr>':'')+'<br></div></div><div class="h2" style="z-index:53;background-color: '+bgColor+'; layer-background-color: '+bgColor+';width:'+_w+'px; border: 1px none '+borderColor+'; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(_w>=233?'<nobr>':'')+imgR1+(_w>=233?'</nobr>':'')+'<br>'+imgR2+'</div></div></div><div style="visibility:hidden"><div style="height:'+_h+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgTit+'<br>'+(_w>=233?'<nobr>':'')+'&copy; '+siteOwn+(imgOwn==""?'':' | ')+imgOwn+(_w>=233?'</nobr>':'')+'<br></div><div class="h2" style="background-color: '+bgColor+'; layer-background-color: '+bgColor+';width:'+_w+'px; border: 1px none '+borderColor+'; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(_w>=233?'<nobr>':'')+imgR1+(_w>=233?'</nobr>':'')+'<br>'+imgR2+'</div></div></div>';
		if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Safari")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: '+bgColor+'; layer-background-color: '+bgColor+'; border: 1px none '+borderColor+'; padding:10px; width:'+div_w+'px;height:100%;z-index:51"><div style="background-color: '+bgColor2+'; layer-background-color: '+bgColor2+';width:'+_w+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: '+bgColor2+'; layer-background-color: '+bgColor2+';z-index:51;position:absolute;width:'+_w+'px;height:'+sm_h+'px;text-align:center"><img  src="'+imgFileprev+'"  width="'+sm_w+'" height="'+sm_h+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+_w+'px;top:'+topx+'px;text-align: center;"><img src="'+imgLoad+'"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:53;position:absolute;width:'+_w+'px;"><div style="border: 1px solid '+borderColor+';width:'+_w+'px;"><img name="btcontainer" id="btcontainer" src="'+bgImage+'" border="0" width="'+_w+'" height="'+_h+'" ><div id="div_2" style="border-width:0px;margin:0px;z-index:53;layer-background-color: '+bgColor2+';background-color:'+bgColor2+';padding:3px;">'+imgTit+'<br>'+(_w>=233?'<nobr>':'')+'&copy; '+siteOwn+(imgOwn==""?'':' | ')+imgOwn+(_w>=233?'</nobr>':'')+'<br></div></div><div class="h2" style="z-index:53;background-color: '+bgColor+'; layer-background-color: '+bgColor+';width:'+_w+'px; border: 1px none '+borderColor+'; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(_w>=233?'<nobr>':'')+imgR1+(_w>=233?'</nobr>':'')+'<br>'+imgR2+'</div></div></div><div style="visibility:hidden"><div style="height:'+_h+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgTit+'<br>'+(_w>=233?'<nobr>':'')+'&copy; '+siteOwn+(imgOwn==""?'':' | ')+imgOwn+(_w>=233?'</nobr>':'')+'<br></div><div class="h2" style="background-color: '+bgColor+'; layer-background-color: '+bgColor+';width:'+_w+'px; border: 1px none '+borderColor+'; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(_w>=233?'<nobr>':'')+imgR1+(_w>=233?'</nobr>':'')+'<br>'+imgR2+'</div></div></div>';
		if (navigator.userAgent.indexOf("MSIE")!=-1)
			gettrailobject().innerHTML = '<div style="background-color: '+bgColor+'; layer-background-color: '+bgColor+'; border: 1px none '+borderColor+'; padding:10px; width:'+div_w+'px;height:100%;z-index:51"><div style="background-color: '+bgColor2+'; layer-background-color: '+bgColor2+';width:'+_w+'px;z-index:51">'+'<div style="border-width:0px;margin:0px;padding:0px;background-color: '+bgColor2+'; layer-background-color: '+bgColor2+';z-index:51;position:absolute;width:'+_w+'px;height:'+sm_h+'px;text-align:center"><img  src="'+imgFileprev+'"  width="'+sm_w+'" height="'+sm_h+'" border="0"></div><div style="border-width:0px;margin:0px;padding:0px;z-index:52;position:absolute;width:'+_w+'px;top:'+topx+'px;text-align: center;"><img src="'+imgLoad+'"></div><div style="margin:0px;padding:0px;z-index:53;position:absolute;width:'+_w+'px;"><div style="border: 1px solid '+borderColor+';width:'+_w+'px;"><img name="btcontainer" id="btcontainer" src="'+bgImage+'" border="0" width="'+_w+'" height="'+_h+'"  ><div id="div_2" style="margin:0px;width:'+_w+'px;z-index:53;layer-background-color: '+bgColor2+';background-color:'+bgColor2+';padding:3px;">'+imgTit+'<br>'+(_w>=233?'<nobr>':'')+'&copy; '+siteOwn+(imgOwn==""?'':' | ')+imgOwn+(_w>=233?'</nobr>':'')+'<br></div></div><div class="h2" style="z-index:53;background-color: '+bgColor+'; layer-background-color: '+bgColor+';width:'+_w+'px; border: 1px none '+borderColor+'; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(_w>=233?'<nobr>':'')+imgR1+(_w>=233?'</nobr>':'')+'<br>'+imgR2+'</div></div></div><div style="visibility:hidden"><div style="height:'+_h+'px">&nbsp;</div><div id="div_2" style="padding:3px;">'+imgTit+'<br>'+(_w>=233?'<nobr>':'')+'&copy; '+siteOwn+(imgOwn==""?'':' | ')+imgOwn+(_w>=233?'</nobr>':'')+'<br></div><div class="h2" style="background-color: '+bgColor+'; layer-background-color: '+bgColor+';width:'+_w+'px; border: 1px none '+borderColor+'; padding:10px;padding:1px;z-index:51;" id="div_3" >'+(_w>=233?'<nobr>':'')+imgR1+(_w>=233?'</nobr>':'')+'<br>'+imgR2+'</div></div></div>';


		//alert(gettrailobject().innerHTML);
		//document.write(gettrailobject().innerHTML);
		//setTimeOut
		x_to = setTimeout("xtimeOut('"+imgFile+"')",100);
		gettrailobj().visibility="visible";
		div_w = parseInt(_w)+25;
		div_h = parseInt(_h)+130;
		document.onmousemove=followmouse;

}

function xtimeOut(thumbimgg){
	if (document.getElementById)
		document.getElementById('btcontainer').src = thumbimgg;
	else if (document.all)
		document.all.btcontainer.src = thumbimgg;

}
function followmouse(e)
	{
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
if(typeof e != "undefined")
	{
	if(docwidth < 15+e.pageX+div_w)
		xcoord = e.pageX-div_w-5;
	else
		xcoord = 15+e.pageX;
	if(docheight < 15+e.pageY+div_h)
		ycoord = 15+e.pageY-Math.max(0,(div_h + e.pageY - docheight - truebody().scrollTop - 30));
	else
		ycoord = 15+e.pageY;
	}
else if (typeof window.event != "undefined")
	{
	if(docwidth < 15+truebody().scrollLeft+event.clientX+div_w)
		xcoord = truebody().scrollLeft-5+event.clientX-div_w;
	else
		xcoord = truebody().scrollLeft+15+event.clientX;

	if(docheight < 15+truebody().scrollTop+event.clientY+div_h)
		ycoord = 15+truebody().scrollTop+event.clientY-Math.max(0,(div_h + event.clientY - docheight - 30));
	else
		ycoord = truebody().scrollTop+15+event.clientY;
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
	}


// ===================================================================
// ===================================================================




// ===================================================================
// Author: Matt Kruse <matt@ajaxtoolbox.com>
// WWW: http://www.AjaxToolbox.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

/**
 * The AjaxRequest class is a wrapper for the XMLHttpRequest objects which 
 * are available in most modern browsers. It simplifies the interfaces for
 * making Ajax requests, adds commonly-used convenience methods, and makes 
 * the process of handling state changes more intuitive.
 * An object may be instantiated and used, or the Class methods may be used 
 * which internally create an AjaxRequest object.
 */
function AjaxRequest() {
	var req = new Object();
	
	// -------------------
	// Instance properties
	// -------------------

	/**
	 * Timeout period (in ms) until an async request will be aborted, and
	 * the onTimeout function will be called
	 */
	req.timeout = null;
	
	/**
	 *	Since some browsers cache GET requests via XMLHttpRequest, an
	 * additional parameter called AjaxRequestUniqueId will be added to
	 * the request URI with a unique numeric value appended so that the requested
	 * URL will not be cached.
	 */
	req.generateUniqueUrl = true;
	
	/**
	 * The url that the request will be made to, which defaults to the current 
	 * url of the window
	 */
	req.url = window.location.href;
	
	/**
	 * The method of the request, either GET (default), POST, or HEAD
	 */
	req.method = "GET";
	
	/**
	 * Whether or not the request will be asynchronous. In general, synchronous 
	 * requests should not be used so this should rarely be changed from true
	 */
	req.async = true;
	
	/**
	 * The username used to access the URL
	 */
	req.username = null;
	
	/**
	 * The password used to access the URL
	 */
	req.password = null;
	
	/**
	 * The parameters is an object holding name/value pairs which will be 
	 * added to the url for a GET request or the request content for a POST request
	 */
	req.parameters = new Object();
	
	/**
	 * The sequential index number of this request, updated internally
	 */
	req.requestIndex = AjaxRequest.numAjaxRequests++;
	
	/**
	 * Indicates whether a response has been received yet from the server
	 */
	req.responseReceived = false;
	
	/**
	 * The name of the group that this request belongs to, for activity 
	 * monitoring purposes
	 */
	req.groupName = null;
	
	/**
	 * The query string to be added to the end of a GET request, in proper 
	 * URIEncoded format
	 */
	req.queryString = "";
	
	/**
	 * After a response has been received, this will hold the text contents of 
	 * the response - even in case of error
	 */
	req.responseText = null;
	
	/**
	 * After a response has been received, this will hold the XML content
	 */
	req.responseXML = null;
	
	/**
	 * After a response has been received, this will hold the status code of 
	 * the response as returned by the server.
	 */
	req.status = null;
	
	/**
	 * After a response has been received, this will hold the text description 
	 * of the response code
	 */
	req.statusText = null;

	/**
	 * An internal flag to indicate whether the request has been aborted
	 */
	req.aborted = false;
	

	/**
	 * The XMLHttpRequest object used internally
	 */
	req.xmlHttpRequest = null;

	// --------------
	// Event handlers
	// --------------
	
	/**
	 * If a timeout period is set, and it is reached before a response is 
	 * received, a function reference assigned to onTimeout will be called
	 */
	req.onTimeout = null; 
	
	/**
	 * A function reference assigned will be called when readyState=1
	 */
	req.onLoading = null;

	/**
	 * A function reference assigned will be called when readyState=2
	 */
	req.onLoaded = null;

	/**
	 * A function reference assigned will be called when readyState=3
	 */
	req.onInteractive = null;

	/**
	 * A function reference assigned will be called when readyState=4
	 */
	req.onComplete = null;

	/**
	 * A function reference assigned will be called after onComplete, if 
	 * the statusCode=200
	 */
	req.onSuccess = null;

	/**
	 * A function reference assigned will be called after onComplete, if 
	 * the statusCode != 200
	 */
	req.onError = null;
	
	/**
	 * If this request has a group name, this function reference will be called 
	 * and passed the group name if this is the first request in the group to 
	 * become active
	 */
	req.onGroupBegin = null;

	/**
	 * If this request has a group name, and this request is the last request 
	 * in the group to complete, this function reference will be called
	 */
	req.onGroupEnd = null;

	// Get the XMLHttpRequest object itself
	req.xmlHttpRequest = AjaxRequest.getXmlHttpRequest();
	if (req.xmlHttpRequest==null) { return null; }
	
	// -------------------------------------------------------
	// Attach the event handlers for the XMLHttpRequest object
	// -------------------------------------------------------
	req.xmlHttpRequest.onreadystatechange = 
	function() {
		if (req==null || req.xmlHttpRequest==null) { return; }
		if (req.xmlHttpRequest.readyState==1) { req.onLoadingInternal(req); }
		if (req.xmlHttpRequest.readyState==2) { req.onLoadedInternal(req); }
		if (req.xmlHttpRequest.readyState==3) { req.onInteractiveInternal(req); }
		if (req.xmlHttpRequest.readyState==4) { req.onCompleteInternal(req); }
	};
	
	// ---------------------------------------------------------------------------
	// Internal event handlers that fire, and in turn fire the user event handlers
	// ---------------------------------------------------------------------------
	// Flags to keep track if each event has been handled, in case of 
	// multiple calls (some browsers may call the onreadystatechange 
	// multiple times for the same state)
	req.onLoadingInternalHandled = false;
	req.onLoadedInternalHandled = false;
	req.onInteractiveInternalHandled = false;
	req.onCompleteInternalHandled = false;
	req.onLoadingInternal = 
		function() {
			if (req.onLoadingInternalHandled) { return; }
			AjaxRequest.numActiveAjaxRequests++;
			if (AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function") {
				AjaxRequestBegin();
			}
			if (req.groupName!=null) {
				if (typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined") {
					AjaxRequest.numActiveAjaxGroupRequests[req.groupName] = 0;
				}
				AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
				if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function") {
					req.onGroupBegin(req.groupName);
				}
			}
			if (typeof(req.onLoading)=="function") {
				req.onLoading(req);
			}
			req.onLoadingInternalHandled = true;
		};
	req.onLoadedInternal = 
		function() {
			if (req.onLoadedInternalHandled) { return; }
			if (typeof(req.onLoaded)=="function") {
				req.onLoaded(req);
			}
			req.onLoadedInternalHandled = true;
		};
	req.onInteractiveInternal = 
		function() {
			if (req.onInteractiveInternalHandled) { return; }
			if (typeof(req.onInteractive)=="function") {
				req.onInteractive(req);
			}
			req.onInteractiveInternalHandled = true;
		};
	req.onCompleteInternal = 
		function() {
			if (req.onCompleteInternalHandled || req.aborted) { return; }
			req.onCompleteInternalHandled = true;
			AjaxRequest.numActiveAjaxRequests--;
			if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
				AjaxRequestEnd(req.groupName);
			}
			if (req.groupName!=null) {
				AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
				if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
					req.onGroupEnd(req.groupName);
				}
			}
			req.responseReceived = true;
			req.status = req.xmlHttpRequest.status;
			req.statusText = req.xmlHttpRequest.statusText;
			req.responseText = req.xmlHttpRequest.responseText;
			req.responseXML = req.xmlHttpRequest.responseXML;
			if (typeof(req.onComplete)=="function") {
				req.onComplete(req);
			}
			if (req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function") {
				req.onSuccess(req);
			}
			else if (typeof(req.onError)=="function") {
				req.onError(req);
			}

			// Clean up so IE doesn't leak memory
			delete req.xmlHttpRequest['onreadystatechange'];
			req.xmlHttpRequest = null;
		};
	req.onTimeoutInternal = 
		function() {
			if (req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled) {
				req.aborted = true;
				req.xmlHttpRequest.abort();
				AjaxRequest.numActiveAjaxRequests--;
				if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
					AjaxRequestEnd(req.groupName);
				}
				if (req.groupName!=null) {
					AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
					if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
						req.onGroupEnd(req.groupName);
					}
				}
				if (typeof(req.onTimeout)=="function") {
					req.onTimeout(req);
				}
			// Opera won't fire onreadystatechange after abort, but other browsers do. 
			// So we can't rely on the onreadystate function getting called. Clean up here!
			delete req.xmlHttpRequest['onreadystatechange'];
			req.xmlHttpRequest = null;
			}
		};

	// ----------------
	// Instance methods
	// ----------------
	/**
	 * The process method is called to actually make the request. It builds the
	 * querystring for GET requests (the content for POST requests), sets the
	 * appropriate headers if necessary, and calls the 
	 * XMLHttpRequest.send() method
	*/
	req.process = 
		function() {
			if (req.xmlHttpRequest!=null) {
				// Some logic to get the real request URL
				if (req.generateUniqueUrl && req.method=="GET") {
					req.parameters["AjaxRequestUniqueId"] = new Date().getTime() + "" + req.requestIndex;
				}
				var content = null; // For POST requests, to hold query string
				for (var i in req.parameters) {
					if (i != "toJSONString") {
						if (req.queryString.length>0) { req.queryString += "&"; }
						req.queryString += encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);
					};
				}
				if (req.method=="GET") {
					if (req.queryString.length>0) {
						req.url += ((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;
					}
				}
				/*
				var myStr=new String(req.url);
				if (myStr.length>2048) {
					//req.url = myStr.slice(0,2047);
				}
				*/
				req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
				if (req.method=="POST") {
					if (typeof(req.xmlHttpRequest.setRequestHeader)!="undefined") {
						req.xmlHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
					}
					content = req.queryString;
				}
				if (req.timeout>0) {
					setTimeout(req.onTimeoutInternal,req.timeout);
				}
				req.xmlHttpRequest.send(content);
			}
		};

	/**
	 * An internal function to handle an Object argument, which may contain
	 * either AjaxRequest field values or parameter name/values
	 */
	req.handleArguments = 
		function(args) {
			for (var i in args) {
				// If the AjaxRequest object doesn't have a property which was passed, treat it as a url parameter
				if (typeof(req[i])=="undefined") {
					req.parameters[i] = args[i];
				}
				else {
					req[i] = args[i];
				}
			}
		};

	/**
	 * Returns the results of XMLHttpRequest.getAllResponseHeaders().
	 * Only available after a response has been returned
	 */
	req.getAllResponseHeaders =
		function() {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getAllResponseHeaders();
				}
				alert("Cannot getAllResponseHeaders because a response has not yet been received");
			}
		};

	/**
	 * Returns the the value of a response header as returned by 
	 * XMLHttpRequest,getResponseHeader().
	 * Only available after a response has been returned
	 */
	req.getResponseHeader =
		function(headerName) {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getResponseHeader(headerName);
				}
				alert("Cannot getResponseHeader because a response has not yet been received");
			}
		};

	return req;
}

// ---------------------------------------
// Static methods of the AjaxRequest class
// ---------------------------------------

/**
 * Returns an XMLHttpRequest object, either as a core object or an ActiveX 
 * implementation. If an object cannot be instantiated, it will return null;
 */
AjaxRequest.getXmlHttpRequest = function() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		// Based on http://jibbering.com/2002/4/httprequest.html
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				return null;
			}
		}
		@end @*/
	}
	else {
		return null;
	}
};

/**
 * See if any request is active in the background
 */
AjaxRequest.isActive = function() {
	return (AjaxRequest.numActiveAjaxRequests>0);
};

/**
 * Make a GET request. Pass an object containing parameters and arguments as 
 * the second argument.
 * These areguments may be either AjaxRequest properties to set on the request 
 * object or name/values to set in the request querystring.
 */
AjaxRequest.get = function(args) {
	AjaxRequest.doRequest("GET",args);
};

/**
 * Make a POST request. Pass an object containing parameters and arguments as 
 * the second argument.
 * These areguments may be either AjaxRequest properties to set on the request 
 * object or name/values to set in the request querystring.
 */
AjaxRequest.post = function(args) {
	AjaxRequest.doRequest("POST",args);
};

/**
 * The internal method used by the .get() and .post() methods
 */
AjaxRequest.doRequest = function(method,args) {
	if (typeof(args)!="undefined" && args!=null) {
		var myRequest = new AjaxRequest();
		myRequest.method = method;
		myRequest.handleArguments(args);
		myRequest.process();
	}
}	;

/**
 * Submit a form. The requested URL will be the form's ACTION, and the request 
 * method will be the form's METHOD.
 * Returns true if the submittal was handled successfully, else false so it 
 * can easily be used with an onSubmit event for a form, and fallback to 
 * submitting the form normally.
 */
AjaxRequest.submit = function(theform, args) {
	var myRequest = new AjaxRequest();
	if (myRequest==null) { return false; }
	var serializedForm = AjaxRequest.serializeForm(theform);
	myRequest.method = theform.method.toUpperCase();
	myRequest.url = theform.action;
	myRequest.handleArguments(args);
	myRequest.queryString = serializedForm;
	myRequest.process();
	return true;
};

/**
 * Serialize a form into a format which can be sent as a GET string or a POST 
 * content.It correctly ignores disabled fields, maintains order of the fields 
 * as in the elements[] array. The 'file' input type is not supported, as 
 * its content is not available to javascript. This method is used internally
 * by the submit class method.
 */
AjaxRequest.serializeForm = function(theform) {
	var els = theform.elements;
	var len = els.length;
	var queryString = "";
	this.addField = 
		function(name,value) { 
			if (queryString.length>0) { 
				queryString += "&";
			}
			queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
		};
	for (var i=0; i<len; i++) {
		var el = els[i];
		if (!el.disabled) {
			switch(el.type) {
				case 'text': case 'password': case 'hidden': case 'textarea': 
					this.addField(el.name,el.value);
					break;
				case 'select-one':
					if (el.selectedIndex>=0) {
						this.addField(el.name,el.options[el.selectedIndex].value);
					}
					break;
				case 'select-multiple':
					for (var j=0; j<el.options.length; j++) {
						if (el.options[j].selected) {
							this.addField(el.name,el.options[j].value);
						}
					}
					break;
				case 'checkbox': case 'radio':
					if (el.checked) {
						this.addField(el.name,el.value);
					}
					break;
			}
		}
	}
	return queryString;
};

// -----------------------
// Static Class variables
// -----------------------

/**
 * The number of total AjaxRequest objects currently active and running
 */
AjaxRequest.numActiveAjaxRequests = 0;

/**
 * An object holding the number of active requests for each group
 */
AjaxRequest.numActiveAjaxGroupRequests = new Object();

/**
 * The total number of AjaxRequest objects instantiated
 */
AjaxRequest.numAjaxRequests = 0;

