
// -------------------------------------------------------------------------------
// Name: Controlli WURFL (wurfl.js, mobile.css, wurfl_js.php, HTML, Jquery)
// Author: Altea Software S.r.l.
// Version: 1.0.0
// Description: Funzioni di controllo programma PERL e database WURFL
//              Controlla tramite lo User Agent se si sta visualizzando il sito con un cellulare
//				e mostra il pulsante per andare al sito mobile.
// Required: La corretta attivazione dei controlli richiede: Javascript, file CSS, HTML, Jquery 1.6
//
// Devel Date: 11/05/2011
// Last Modify: 
// CacheLog: 
//
// -------------------------------------------------------------------------------

// -------------------------------------------------------------------------------
// CONFIG


// -------------------------------------------------------------------------------

// Questo script va a chiamare il programma PERL e mette display block al div che contiene il pulsante
// che suggerisce di andare al sito per cellulare

function check_wurfl() {
	var isMobile = "";
	$.ajax({
  		url: '/wurfl/is_wurfl.php',
		cache: false,
		async: false,
		success: function(msg) {
			isMobile = msg;
			//alert(isMobile);
		}
	});
	
	if ((isMobile == "true")) {
		//alert (isMobile);
		if(!($.cookie("no_mobile"))) {
			window.location = sitoMobile;
		}
	}
}

//javascript:alert(location.host)

var sitoMobile = "http://mobile.fairbz.it/site/";
var regEx = /no_mobile=(.*)/;
if ((location.search.substr(1)) && (regEx.exec(location.search.substr(1)))){
	var expDate = new Date();
	expDate.setTime(expDate.getTime() + (60 * 60 * 1000));	
	$.cookie('no_mobile', 'yes',{expires:expDate});
}

$(document).ready(function() {
	check_wurfl();
});

