// FUNZIONI PER IMMAGINI ROLLOVER E FINEASTRE

function MM_swapImgRestore() { //v3.0
  var i,x,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,j=d.MM_p.length,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 MM_swapImage() { //v3.0
  var i,j=0,x,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];}
}
// ---------------------------------------------------------------

// FUNZIONI PER POPUP
function PopupPic(sPicURL) { 
	window.open( "immagine.htm?"+sPicURL,"aaa","resizable=1,scrollbars=1,HEIGHT=200,WIDTH=200"); 
}
// ---------------------------------------------------------------



// FUNZIONI PER STAMPA DIV
function stampa(ident) {
var testo = "<html><head><title>"+document.title+"</title><link rel=\"stylesheet\" href=\"http://www.6acasa.it/style.css\" type=\"text/css\"></head>";
testo += "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">";
testo += "<table width=\"100%\" border=\"0\"><tr><td>";
testo += document.getElementById('stampa').innerHTML+"</td></tr></table>";
testo += "</body></html>";
var ident_finestra = window.open("","finestra_stampa","height=500,width=600,left=5000");
ident_finestra.document.open();
ident_finestra.document.write(testo);
ident_finestra.document.close();
if(ident) {
ident_finestra.print();
ident_finestra.close();  
}
}
// ---------------------------------------------------------------



// FUNZIONI PER SCELTA CATEGORIA - TIPOLOGIA
var categories = new Object()
categories["residenziale"] = [
{value:"appartamento_o_monolocale", text:"appartamento o monolocale"},
{value:"appartamento_1_camera", text:"appartamento 1 camera"},
{value:"appartamento_2_camere", text:"appartamento 2 camere"},
{value:"appartamento_3_camere", text:"appartamento 3 camere"},
{value:"casa_singola", text:"casa singola"},
{value:"casa_semi_indipendente", text:"casa semi indipendente"},
{value:"casa_a_schiera", text:"casa a schiera"},
{value:"villa_singola", text:"villa singola"},
{value:"villa_bifamiliare", text:"villa bifamiliare"},
{value:"villa_trifamiliare", text:"villa trifamiliare"},
{value:"rustico_singolo", text:"rustico singolo"},
{value:"rustico_affiancato", text:"rustico affiancato"}];


categories["commerciale"] = [
{value:"ufficio", text:"uffici"},
{value:"attivitą_commerciali", text:"attivitą commerciali"},
{value:"negozio_vetrato_piano_terra", text:"negozio vetrato piano terra"}];

categories["artigianale_industriale"] = [
{value:"capannone", text:"capannone"},
{value:"capannone_primo_piano", text:"capannone primo piano"}];

categories["case_vacanze"] = [
{value:"appartamento_o_monolocale", text:"appartamento o monolocale"},
{value:"appartamento_1_camera", text:"appartamento 1 camera"},
{value:"appartamento_2_camere", text:"appartamento 2 camere"},
{value:"appartamento_3_camere", text:"appartamento 3 camere"},
{value:"casa_singola", text:"casa singola"},
{value:"casa_semi_indipendente", text:"casa semi indipendente"},
{value:"casa_a_schiera", text:"casa a schiera"},
{value:"villa_singola", text:"villa singola"},
{value:"villa_bifamiliare", text:"villa bifamiliare"},
{value:"villa_trifamiliare", text:"villa trifamiliare"},
{value:"rustico_singolo", text:"rustico singolo"},
{value:"rustico_affiancato", text:"rustico affiancato"}];

categories["terreno"] = [
{value:"edificabile", text:"edificabile"},
{value:"agricolo", text:"agricolo"}];



function setTypes(chooser) {
var newElem;
var where = (navigator.appName == "Microsoft Internet Explorer") ? -1 : 
null; var typeChooser = chooser.form.elements["tipologia"];
while (typeChooser.options.length) {
typeChooser.remove(0);
}
var choice = chooser.options[chooser.selectedIndex].value;
var db = categories[choice];
newElem = document.createElement("option");
newElem.text = "Seleziona una tipologia";
newElem.value = "";
typeChooser.add(newElem, where);
if (choice != "") {
for (var i = 0; i < db.length; i++) {
newElem = document.createElement("option");
newElem.text = db[i].text;
newElem.value = db[i].value;
typeChooser.add(newElem, where);
}
}
}
// ---------------------------------------------------------------


// FUNZIONI PER SELECT DINAMICHE AH-AH REGIONI-PROVINCE-COMUNI


url			= "http://www.6acasa.it/";
d			= document;
preloadText = "Generazione lista...";
function caricaPagina(pagina,idLayer) 
{
	if (d.getElementById) {var x=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();}
	if (x) 
  	{
		d.getElementById(idLayer).innerHTML = preloadText;
    	x.onreadystatechange = function() 
							   {
							   	 if (x.readyState == 4 && x.status == 200) 
							   	 {
							   		el=d.getElementById(idLayer);el.innerHTML = x.responseText;
								 }
							   }
 		x.open("GET", url + pagina, true);
    	x.send(null);
  	}
}
// ---------------------------------------------------------------


// FUNZIONI PER BANNER ROTATOR

/****
* Banner Ad Rotater v3.02
* Anarchos > anarchos3@hotmail.com
* http://anarchos.xs.mw/bannerad.phtml
**/

function Banner(refreshTime, width, height, altText, start, random){
	this.objName = "bannerAd" + (Banner.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (!width) this.width = 460; else this.width = width;
	if (!height) this.height = 68; else this.height = height;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.ads = [];
	if (start) this.currentAd = start-1; else start = null;
	this.mySize = 0;

	this.Ad = function(src, href, target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.ads[this.mySize] = new Object();
		var ad = this.ads[this.mySize];
		ad.src = src;
		if (typeof(target) == "undefined" || target == null) ad.target = "_self"; else ad.target = target;
		ad.href = href;
		ad.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	ad = this.ads[this.currentAd];
		if (ad.target == "_self"){
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new"){
			open(ad.href,this.objName + "Win");
		}
		else top.frames[ad.target].location.href = ad.href;
	}

	this.showStatus = function(){
		var ad = this.ads[this.currentAd];
		if (ad.mouseover) status = ad.mouseover;
		else status = ad.href;
	}

	this.randomAd = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentAd);
		this.currentAd = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentAd == null) this.randomAd();
			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;
			tempCode = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onMouseOut="status=\'\';return true">';
			tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
			tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
			if (this.altText) tempCode += 'alt="'+this.altText + '" ';
			tempCode += 'border="0" /></a>';
			document.write(tempCode);
			this.nextAd();
		} else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newAd = function(){
		if (!this.random){	
			this.currentAd++;
			if (this.currentAd >= this.mySize)
			   this.currentAd = 0;
		}
		else {
			this.randomAd();
		}
		this.nextAd();
	}

	this.nextAd = function(){
		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src;
		setTimeout(this.objName+'.newAd()',this.refreshTime)
	}
}
Banner.count = 0;

// ---------------------------------------------------------------

// stampa

function open_detail(imageType,imageName,imageWidth,imageHeight,alt) {  // v4.01
posLeft=(screen.availWidth-imageWidth)/2
posTop=(screen.availHeight-imageHeight)/2

	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,resizable=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<table border="0"  height="100%" width="100%" cellpadding="0" cellspacing="0" align="center"><tr align="center"><td><img src=\"'+imageName+'\" align="center" alt=\"'+alt+'\"></td></tr></table>'); 	
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

//aggiungi ai preferiti
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}