﻿function GoSearch()
{
QuerySearch=document.SearchEngine.Userid.value;
if(chkEmpty(QuerySearch)==false)
{
 document.SearchEngine.Userid.select();
 document.SearchEngine.Userid.focus();
 return false;
} 
else document.SearchEngine.submit();
}
function ApriChat()
{
window.open('/usweb/Chat/Welcome.asp', '', 'width=740,height=588,scrollbars=no, top=50, left=20')
}
function EntraInOra()
{
window.open('http://www.detodo.masde50.net/modules/envotime_ora_cal.swf', 'Ora_Esatta', 'width=300,height=300, scrollbars=no, resizable=yes, top=50, left=20')
}
function Home()
{ 
document.GestioneAccesso.submit();
}
function chkEmpty(field)
{
 if(field == "")
 {
 alert("必要なフィールドを入力します");
 return false;
 }
 return true;
} 
function toggleDiv(divid){ 
 if (document.getElementById(divid).style.display == 'none') { 
 // document.getElementById(divid).style.display = 'block'; 
 // agnaa
 
 JQ("#" + divid ).slideDown();
 
 } else { 
 JQ("#" + divid ).slideUp();
 // document.getElementById(divid).style.display = 'none'; 
 } 
}
(function() {
var f = document.getElementById('SearchEngine');
if (!f) {
f = document.getElementById('SearchEngine');
}
if (f && f.Userid) {
var Userid = f.Userid;
var n = navigator;
var l = location;
if (n.platform == 'Win32') {
Userid.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;';
}
var b = function() {
if (Userid.value == '') {
Userid.style.background = '#FFFFFF url(/ImmaginiSito/HomePage/ricercaBox.png) left no-repeat';
}
};
var f = function() {
Userid.style.background = '#ffffff';
};
Userid.onfocus = f;
Userid.onblur = b;
if (!/[&?]Userid=[^&]/.test(l.search)) {
b();
}
}
})();
function campoVuoto(field)
{
if(field==null || field==""||field==" "||field==" "||field==" "||field==" "||field==" "||field==" "||field==" "||field==" ")
{
 return true;
}
return false;
}
function senzaEmail(field)
{
if(campoVuoto(field) || (field.indexOf("@",0)==-1 || field.indexOf(".",0)==-1) )
{
 return true;
}
return false;
}
//Se trova piu' di 4 numeri desume che c'e' un telefono dentro
function CercaTelefono(testo)
{
if (campoVuoto(testo)==false)
{
 var num=0;
 for(var i=0;i<testo.length;i++)
 {
 var chr=testo.substring(i,i+1);
 if( chr>="0" && chr<="9" )
 {
 num++;
 if (num>4) return true
 }
 else if (chr!=" " && chr!=".")
 num=0;
 }
}
return false;
}
function TestoMaiuscole(testo,perc)
{
if (campoVuoto(testo)==false)
{
 var tot=0;
 var mai=0;
 for(var i=0;((i<testo.length)&&(i<40));i++)
 {
 tot++;
 var chr=testo.substring(i,i+1);
 if( chr>="A" && chr<="Z" )
 {
 mai++;
 }
 }
 //alert("caratteri totali --> "+tot);
 //alert("caratteri maiuscoli --> "+mai);
 if ( (tot > 0) && ( (mai/tot) > perc ) ) 
 {
 return true;
 }
 else
 {
 return false;
 }
}
return false;
}
function ChkAlloggiDescAnnuncio(testo)
{
if(testo!="")
{
 if(testo.indexOf(" alloggi",0)!=-1||testo.indexOf(" stanz",0)!=-1||testo.indexOf(" camer",0)!=-1||testo.indexOf("monolocale",0)!=-1||testo.indexOf("bilocale",0)!=-1||testo.indexOf("trilocale",0)!=-1||testo.indexOf("appartament",0)!=-1||testo.indexOf(" casa",0)!=-1||testo.indexOf("ospitare",0)!=-1||testo.indexOf("posto letto",0)!=-1||testo.indexOf(" affitt",0)!=-1||testo.indexOf("mansard",0)!=-1)
 {
 alert("Inserisci l'annuncio nell'apposita sezione Alloggi: la puoi raggiungere dalla Bacheca Annunci");
 return false;
 }
}
return true;
}
function ChkLinkDesc(testo)
{
if(testo!="")
{
 if(testo.indexOf("www",0)!=-1 || testo.indexOf("http",0)!=-1 || testo.indexOf("ww",0)!=-1 || testo.indexOf("htpt:",0)!=-1)
 {
 return false;
 }
}
return true;
}
function ChkAppuntiDescAnnuncio(testo)
{
if(testo!="")
{
 if(testo.indexOf(" appunti",0)!=-1||testo.indexOf(" dispense",0)!=-1)
 {
 alert("Inserisci l'annuncio nella apposita sezione Appunti: la puoi raggiungere dalla Bacheca Annunci");
 return false;
 }
}
return true;
}
/*Segnala se ci sono in una stringa caratteri non ammessi per Userid/Password*/
function VerificaCaratteriAnomali(testo)
{
if (campoVuoto(testo)==false)
{
var Esito=0;
for(var i=0;i<testo.length;i++)
{
 var chr=testo.substring(i,i+1);
 switch (chr) 
 {
 case "?" : 
 Esito=1; 
 break; 
 case "'" : 
 Esito=1; 
 break; 
 case "&" : 
 Esito=1; 
 break; 
 case "%" : 
 Esito=1; 
 break; 
 } 
}
}
if (Esito==1) 
 return false;
else
 return true;
}
function GetXmlHttpObject(handler){ 
 var objXMLHttp=null ;
 if (window.XMLHttpRequest) { 
 objXMLHttp=new XMLHttpRequest() 
 } 
 else if (window.ActiveXObject) { 
 objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP") 
 }
 return objXMLHttp
 }
 
 function stateChanged(){ 
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.getElementById("txtResult").innerHTML=xmlHttp.responseText; 
 } 
 else { //alert(xmlHttp.status); 
 }
 }// Will populate data based on input
 
function htmlData(url, qStr){ 
 if (url.length == 0) { 
 document.getElementById("txtResult").innerHTML = "";
 return; 
 }
 xmlHttp = GetXmlHttpObject(); 
 if (xmlHttp == null) { 
 alert ("Browser does not support HTTP Request"); 
 return; 
 } 
 url=url+"?"+qStr; 
 url=url+"&sid="+Math.random(); 
 //alert(url); 
 xmlHttp.onreadystatechange=stateChanged; 
 xmlHttp.open("GET",url,true) ; 
 xmlHttp.send(null);
 }
 
 
/*******************/
 
function toggle(div_id) {
 var el = document.getElementById(div_id);
 if ( el.style.display == 'none' ) { el.style.display = 'block';}
 else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
 
 
 viewportheight = f_clientHeight()
 
 
 if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
 blanket_height = viewportheight;
 } else {
 if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
 blanket_height = document.body.parentNode.clientHeight;
 } else {
 blanket_height = document.body.parentNode.scrollHeight;
 }
 }
 
 var blanket = document.getElementById('blanket');
 blanket.style.height = blanket_height + 'px';
 var popUpDiv = document.getElementById(popUpDivVar);
 popUpDiv_height = blanket_height/2-150; //150 is half popup's height
 
 //popUpDiv.style.top = popUpDiv_height + 'px';
 
 v = viewportheight - 500; 
 popUpDiv.style.top = v + 'px'; //50
 
 //popUpDiv.style.top = Math.round ((document.documentElement.clientHeight/2)+ document.documentElement.scrollTop)-100 + 'px'; 
}
function window_pos(popUpDivVar) {
 
 viewportwidth = f_clientWidth() 
 
 if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
 window_width = viewportwidth;
 } else {
 if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
 window_width = document.body.parentNode.clientWidth;
 } else {
 window_width = document.body.parentNode.scrollWidth;
 }
 }
 var popUpDiv = document.getElementById(popUpDivVar);
 window_width = window_width/2-150;//150 is half popup's width
 //popUpDiv.style.left = window_width + 'px';
 
 v = viewportwidth - 400; 
 
 popUpDiv.style.left = v + 'px';
 
}
function popup(windowname) {
 scroll(0,0);
 blanket_size(windowname);
 window_pos(windowname);
 toggle('blanket');
 toggle(windowname); 
}
function f_clientWidth() {
 return f_filterResults (
 window.innerWidth ? window.innerWidth : 0,
 document.documentElement ? document.documentElement.clientWidth : 0,
 document.body ? document.body.clientWidth : 0
 );
}
function f_clientHeight() {
 return f_filterResults (
 window.innerHeight ? window.innerHeight : 0,
 document.documentElement ? document.documentElement.clientHeight : 0,
 document.body ? document.body.clientHeight : 0
 );
} 
function f_scrollLeft() {
 return f_filterResults (
 window.pageXOffset ? window.pageXOffset : 0,
 document.documentElement ? document.documentElement.scrollLeft : 0,
 document.body ? document.body.scrollLeft : 0
 );
}
function f_scrollTop() {
 return f_filterResults (
 window.pageYOffset ? window.pageYOffset : 0,
 document.documentElement ? document.documentElement.scrollTop : 0,
 document.body ? document.body.scrollTop : 0
 );
}
function f_filterResults(n_win, n_docel, n_body) {
 var n_result = n_win ? n_win : 0;
 if (n_docel && (!n_result || (n_result > n_docel)))
 n_result = n_docel;
 return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function feedbackValidate(v){
 tipo = document.feedback.tipo.value;
 //nemail = document.feedback.nemail.value;
 issue = document.feedback.issue.value; 
 
 
 
 
 if (issue == "") {
 alert("例") 
 return false;
 } 
 
 //alert(issue.length);
 
 if (issue.length < 50) {
 alert("説明以上の'詳細入力") 
 return false;
 }
 
 
 return true; 
}
function createCookie(name,value,days) {
 if (days) {
 var date = new Date();
 date.setTime(date.getTime()+(days*24*60*60*1000));
 var expires = "; expires="+date.toGMTString();
 }
 else var expires = "";
 document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++) {
 var c = ca[i];
 while (c.charAt(0)==' ') c = c.substring(1,c.length);
 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return '';
}
function eraseCookie(name) {
 createCookie(name,"",-1);
}
// createCookie(name,value,days)
// 
function OnLoadToggleMyMenu(){
 mymenuCookie = readCookie("mymenuCookie"); 
 
 //alert( mymenuCookie );
 
 if (mymenuCookie == '' || mymenuCookie == 'chiuso') {
 //createCookie ("mymenuCookie", "chiuso", 2)
 document.getElementById('x_mymenu').style.display = 'none';
 
 document.getElementById('imageMenuToggle').innerHTML = '<img src="/Disegni/plus.gif" border="0"/>';
 
 }
 if (mymenuCookie == 'aperto') {
 //createCookie ("mymenuCookie", "aperto", 2)
 document.getElementById('x_mymenu').style.display = 'hidden';
 
 document.getElementById('imageMenuToggle').innerHTML = '<img src="/Disegni/minus.gif" border="0"/>';
 }
} 
function ToggleMyMenu(){
 
 mymenuCookie = readCookie("mymenuCookie"); 
 //se nn esiste cookie menu lo pongo a chiuso e chiudo il menu
 if (mymenuCookie == '' || mymenuCookie == 'chiuso') {
 createCookie ("mymenuCookie", "aperto", 0)
 document.getElementById('x_mymenu').style.display = '';
 document.getElementById('imageMenuToggle').innerHTML = '<img src="/Disegni/minus.gif" border="0"/>';
 }
 if (mymenuCookie == 'aperto') {
 createCookie ("mymenuCookie", "chiuso", 0)
 document.getElementById('x_mymenu').style.display = 'none';
 document.getElementById('imageMenuToggle').innerHTML = '<img src="/Disegni/plus.gif" border="0"/>';
 }
 
} 
 
//-----------------
function ToggleSection(SectionName, SubText, SetForce){
 //alert (SetForce);
 //mymenuCookie = readCookie(SectionName); 
 //se nn esiste cookie menu lo pongo a chiuso e chiudo il menu
 
 d = document.getElementById('x_' + SectionName).style.display;
 //alert(d);
 
 if (d == 'none' || SetForce=='Open') {
 //createCookie (SectionName, "aperto", 0)
 //
 
 if (SetForce=='')
 {JQ("#" + 'x_' + SectionName ).slideDown();}
 else 
 {document.getElementById('x_' + SectionName).style.display = '';}
 
 document.getElementById('x_' + SectionName + '_no').style.display = 'none';
 
 document.getElementById(SectionName + '_imageMenuToggle').innerHTML = '<img src="/Disegni/minus3.gif" width="17px" border="0"/>';
 if (SetForce=='')
 JQ.ajax({ type: "GET", url: "/usweb/utenza/Preferences.asp?NomePreferenza=" + SectionName + "&Operation=Open", async: false }).responseText;
 }
 if (d == '' || d == 'block' || SetForce=='Close') {
 //createCookie (SectionName, "chiuso", 0)
 //document.getElementById('x_' + SectionName).style.display = 'none';
 
 if (SetForce=='')
 {JQ("#" + 'x_' + SectionName ).slideUp();}
 else 
 {document.getElementById('x_' + SectionName).style.display = 'none';}
 document.getElementById('x_' + SectionName + '_no').style.display = '';
 document.getElementById(SectionName + '_imageMenuToggle').innerHTML = ' <img src="/Disegni/plus3.gif" width="17px" border="0"/>';
 
 
 //document.getElementById('x_' + SectionName).innerHTML = SubText;
 if (SetForce=='')
 JQ.ajax({ type: "GET", url: "/usweb/utenza/Preferences.asp?NomePreferenza=" + SectionName + "&Operation=Close", async: false }).responseText;
 }
 
}
 
//if (mymenuCookie == '') { 
 
