"+
"";
div = document.createElement('DIV');
div.innerHTML = tmpl;
div.style.clear = "both";
padre = hiPut.parentNode;
padre.insertBefore(div, hiPut);
// hidden
if(hiPut.value != "") hiPut.value += ";";
hiPut.value += valueHidden;
}
function switchOnOff(idInput,idImg){
idInputOld = document.getElementById(idInput).value;
idInputNew = idInputOld=='0'?"1":"0";
document.getElementById(idInput).value = idInputNew;
img = idInputOld=='0'?"on.gif":"off.gif";
document.getElementById(idImg).src = "img/"+img;
}
function switchOnOffEvent(obj,idInput,idImg){
idInputOld = document.getElementById(idInput).value;
idInputNew = idInputOld=='0'?"1":"0";
document.getElementById(idInput).value = idInputNew;
img = idInputOld=='0'?"on.png":"off.png";
document.getElementById(idImg).src = "img/"+img;
if(obj.getAttribute('onchange')!=""){
eval(obj.getAttribute('onchange'));
}
}
function switchOnf(obj,hid){
obj = document.getElementById(obj);
hid = document.getElementById(hid);
att = hid.value;
if(att===""){
obj.src = "img/on.png";
hid.value = "1";
}else if(att==="1"){
obj.src = "img/off.png";
hid.value = "0";
}else{
obj.src = "img/onf.png";
hid.value = "";
}
}
function changeIdStatus(obj,tab,fld,idName,idVal,val){
viewMex("Modifica in corso...");
myajax.post("?cmd=changeIdStatus","tab="+tab+"&fld="+fld+"&idName="+idName+"&idVal="+idVal+"&val="+val);
myajax.echoFunction=function(aa){
hideMex(aa,0);
eval(aa);
if(resp.status=="ok"){
img = "off.gif";
nVal = 1;
tit = "Attiva";
if(val==1){
img = "on.gif";
tit = "Disattiva";
nVal = 0;
}
obj.onclick = function(){changeIdStatus(obj,tab,fld,idName,idVal,nVal)};
obj.firstChild.src = "img/"+img;
obj.title = tit;
}
}
}
function confirmChangeIdStatus(obj,tab,fld,idName,idVal,val){
if(confirm('Confermi la modifica?')) {
viewMex("Modifica in corso...");
myajax.post("?cmd=changeIdStatus","tab="+tab+"&fld="+fld+"&idName="+idName+"&idVal="+idVal+"&val="+val);
myajax.echoFunction=function(aa){
hideMex(aa,0);
eval(aa);
if(resp.status=="ok"){
img = "off.gif";
nVal = 1;
tit = "Attiva";
if(val==1){
img = "on.gif";
tit = "Disattiva";
nVal = 0;
}
obj.onclick = function(){confirmChangeIdStatus(obj,tab,fld,idName,idVal,nVal)};
obj.firstChild.src = "img/"+img;
obj.title = tit;
}
}
}
}
function selCal(anno,mese,campo){
this.win = document.getElementById("select");
var poststr = "mese="+mese+"&anno="+anno+"&campo="+campo;
myajax.post("?cmd=selCal",poststr);
myajax.echoFunction=function(response){
hideMex("",1);
xx = getPosX(document.getElementById(campo))-5;
yy = getPosY(document.getElementById(campo))+21;
win.style.width = "";
win.style.height = "";
win.style.left = xx+"px";
win.style.top = yy+"px";
win.innerHTML = response;
win.style.display = "block";
}
}
function calcolaSelCal(id,id2,yCorr,mCorr){
data1 = document.getElementById(id).value;
data2 = document.getElementById(id2).value;
if(data1!=""){
dummy = data1.split("-");
y = dummy[2];
m = dummy[1];
}else if(data2!=""){
dummy = data2.split("-");
y = dummy[2];
m = dummy[1];
}else{
y = yCorr;
m = mCorr;
}
selCal(y,m,id);
}
function getForm(obj){
while(obj.nodeName!="FORM"){
if(obj.previousSibling!=null){
obj = obj.previousSibling;
}else{
obj = obj.parentNode;
}
if(obj.nodeName == "BODY"){
alert("FORM NOT FOUND");
break;
}
}
return obj;
}
function clearFields(){
for (var i = 0; i < arguments.length; i++)
document.getElementById(arguments[i]).value = "";
}
function hideSel(){
document.getElementById('select').style.display='none'
document.getElementById('select').innerHTML = "";
document.getElementById('loader').style.display = 'none';
document.getElementById('loader').innerHTML = "";
if(autoSugAr.length >0) hideSuggestions();
}
// fine funzioni globali
//******************************************
function hideAlert(obj,cont,dbg){
if(dbg){
document.getElementById(obj).innerHTML = cont;
}else{
document.getElementById(obj).style.display = "none";
document.getElementById(obj).innerHTML = "";
}
}
function isNumeric(val) {
return val !== "NaN" && (+val)+'' === val + ''
}
function getChar(event) {
if (event.which == null) {
return String.fromCharCode(event.keyCode) // IE
} else if (event.which!=0 && event.charCode!=0) {
return String.fromCharCode(event.which) // the rest
} else {
return null // special key
}
}
function setData(objId,yearR,closeEv) {
$(objId).datepick('destroy');
$(objId).datepick({
dateFormat: 'dd-mm-yyyy',
alignment: 'bottom',
yearRange: yearR,
alignment: 'bottom',
multiSeparator: ', ',
defaultDate: $.datepick.today(),
selectDefaultDate: true,
showOtherMonths: true,
selectOtherMonths: true,
onClose: closeEv,//document.getElementById('messageError').style.display = "none";},
renderer: {
picker: '',
monthRow: '{months}',
month: '' +
'{monthHeader:M yyyy}' +
'
' +
'' +
'{weekHeader}' +
'{weeks}
',
weekHeader: '{days}
',
dayHeader: '{day} | ',
week: '{days}
',
day: '{day} | ',
monthSelector: '.month',
daySelector: 'td',
rtlClass: 'rtl',
multiClass: 'multi',
defaultClass: 'default',
selectedClass: 'selected',
highlightedClass: 'highlight',
todayClass: 'today',
otherMonthClass: 'other-month',
weekendClass: 'week-end',
commandClass: 'calendar',
commandLinkClass: 'button',
disabledClass: 'unavailable'
}
});
}
//********** GOOGLE MAP **********
//******************************************
var map;
var cellX = 0;
var cellY = 0;
var marker = null;
function initMap(x,y) {
cellX = document.getElementById(x);
cellY = document.getElementById(y);
zoom = 14;
if(cellX.value == "") cellX.value = "37.575059";
if(cellY.value == "") {
cellY.value = "13.908691";
zoom=6;
};
var latLng = new google.maps.LatLng(Number(cellX.value),Number(cellY.value));
var iconColor = new google.maps.MarkerImage("http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png");
var geocoder = new google.maps.Geocoder();
var infowindow = new google.maps.InfoWindow({content: ""});
var myOptions = {
zoom: 8,
center: latLng,
mapTypeControl: true,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },
zoomControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var marker = new google.maps.Marker({
position: latLng,
title: 'Sposta',
map: map,
icon: iconColor,
draggable: true
});
function updateMarkerPosition(latLng) {
cellX.value = String(Math.round(latLng.lat() * 1000000) / 1000000);
cellY.value = String(Math.round(latLng.lng() * 1000000) / 1000000);
}
// Update current position info.
updateMarkerPosition(latLng);
google.maps.event.addListener(marker, 'dragend', function() {
updateMarkerPosition(marker.getPosition());
});
google.maps.event.addListener(marker, 'drag', function() {
updateMarkerPosition(marker.getPosition());
});
var googleSeachControlDiv = document.createElement('DIV');
var googleSeachControl = new GoogleSeachControl(googleSeachControlDiv, map);
googleSeachControlDiv.index = 1;
map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(googleSeachControlDiv);
function GoogleSeachControl(controlDiv, map) {
controlDiv.style.margin = '5px';
var controlUI = document.createElement('DIV');
controlUI.style.backgroundColor = 'white';
controlUI.style.cursor = 'pointer';
controlUI.style.textAlign = 'center';
controlUI.title = "Cerca";
controlDiv.appendChild(controlUI);
var controltxtbox = document.createElement('input');
controltxtbox.setAttribute("id", "txt_googleseach");
controltxtbox.setAttribute("type", "text");
controltxtbox.setAttribute("value", "");
controlUI.appendChild(controltxtbox);
var controlbtn = document.createElement('input');
controlbtn.setAttribute("id", "btn_googleseach");
controlbtn.setAttribute("type", "button");
controlbtn.setAttribute("value", "Cerca");
controlUI.appendChild(controlbtn);
controltxtbox.onkeyup = function(){ctrlKey(event,'btn_googleseach')};
google.maps.event.addDomListener(controlbtn, 'click', function() {
GoogleSeachAddress();
});
}
function GoogleSeachAddress() {
var address = document.getElementById("txt_googleseach").value;
if (geocoder) {
geocoder.geocode({ 'address': address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
newLatLng = new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng());
marker.setPosition(newLatLng);
cellY.value = String(Math.round(results[0].geometry.location.lng() * 1000000) / 1000000);
cellX.value = String(Math.round(results[0].geometry.location.lat() * 1000000) / 1000000);
infowindow.setContent("lat "
+ results[0].geometry.location.lat() + "
lng "
+ results[0].geometry.location.lng() + "
hai cercato:"
+ address + "
");
infowindow.open(map, marker);
/*google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});*/
} else {
alert("Indirizzo non trovato, risposta del geocoder: " + status);
}
});
}
}
}
//******************************************
//********** FINE GOOGLE MAP **********
//******************************************
function alertWinScroll(id, duration, mex){
$(window).scrollTop($('#'+id).offset().top-300);
alertWin(mex);
}
//********** Contattaci **********
function contatta(obj){
flag = true;
flag = flag && controlField("E-mail",'blablaCo','','_');
flag = flag && controlField("E-mail",'blablaCo','','@');
flag = flag && controlField("Richiesta",'mexCo','','_');
if(flag){
viewMex("Invio richiesta...");
strUri = buildUri(obj);
$.post('https://www.freaklab.it/contatta',strUri,function(){},'json')
.done(function(resp){
if(resp.s=="ok"){
alertWin("La sua richiesta è stata inoltrata con successo, le risponderemo il più presto possibile, Grazie.");
}else if(resp.s=="noajax"){
alertWin('Permesso negato');
}else{
alertWin("Siamo spiacenti ma si è verificato un errore durante l'invio della richiesta, la preghiamo di riprovare. Grazie.");
}
})
.fail(function(){alertWin("Errore di connessione");})
.always(function(resp){hideMex(resp,0);});
}
}