$(document).ready(function () {
    BrowserDetect.init();

//    if (BrowserDetect.browser == "Chrome" && document.readyState != "complete") {
//        //console.info('ready...'); 
//        setTimeout(arguments.callee, 100);
//        return;
//    }

    // Attivazione slider immagini
    $("div#divImgFader").attr('class', "ImageFader1");
    $.ImageBox.init
            (
                {
                    loaderSRC: 'jquery/imagebox/loading.gif',
                    closeHTML: '<img src="jquery/imagebox/close.jpg" />'
                }
            );
    ajaxGalleryUpdater('hotel');
    InitDatePicker();
    InitAudioPlayer();
});

jQuery(function($) {
        $("div.ImageFader1").imageFadingSlider({ item_width: 800, item_height: 250, dist: 100, total_time: 10000, fading_time: 2000, easing: "0" });
});

function InitDatePicker()
{
	try
	{
		var datarr = $('input#dataarrivo');
		var datpar = $('input#datapartenza');
		datarr.datepicker({ dateFormat: 'yy-mm-dd', minDate: new Date(2012, 05 - 1, 15), maxDate: new Date(2012, 09 - 1, 25)});
		datpar.datepicker({ dateFormat: 'yy-mm-dd', minDate: new Date(2012, 05 - 1, 15), maxDate: new Date(2012, 09 - 1, 25) });
	}
	catch (e) {
		alert('InitDatePicker raised an exception 2');
	}
}

function AjaxGetData(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (req) {
		var encodedUrl = encodeRequest(url);
        req.onreadystatechange = responseHandler;
        req.open('GET', encodedUrl, true);
        req.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        req.send('');
    }
    else {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
}

function encodeRequest(url)
{
	var encodedUrl = url;
	if (url == 'preventivo.php')
	{
		encodedUrl += '?arrdate=';
		encodedUrl += document.getElementById('dataarrivo').value;
		encodedUrl += '&depdate=';
		encodedUrl += document.getElementById('datapartenza').value;
		encodedUrl += '&np=';
		encodedUrl += document.getElementById('selnpers').value;
		encodedUrl += '&ages=';
		var age1 = document.getElementById('selage3').value;
		if (age1>0) encodedUrl += (age1-1);
		var age2 = document.getElementById('selage4').value;
		if (age2>0) encodedUrl += (age2-1);
		var age3 = document.getElementById('selage5').value;
		if (age3>0) encodedUrl += (age3-1);
		encodedUrl += '&rt=';
		encodedUrl += document.getElementById('selopzcam').value;
		encodedUrl += '&fb=';
		var fb = document.getElementById('tsog').value;
		fb = 1-fb;	// pens. completa: indice combo 0, ma valore nella richiesta 1; mezza pens. indice combo 1, valore richiesta 0
		encodedUrl += fb;
		//alert('Original url:' + url);
		//alert('Encoded url:' + encodedUrl);
	}
	return encodedUrl;
}

function preventivoCallback() {
	try {
		//TODO scrivere la risposta (preventivo) nell'elemento contenitore
		if (req.readyState == 4 || req.readyState == 'complete')
		{
			//alert('preventivoCallback1');
			var respTxt = req.responseText;
            document.getElementById('rispostapreventivo').innerHTML = respTxt;
			//alert('preventivoCallback2');
			$("p#rispostapreventivo").attr('class', "AreaPreventivoVisibile");
			$("p#disclaimerpreventivo").attr('class', "AreaPreventivoVisibile");
		}		
	}
	catch (e) {
        alert('Error in Ajax response');
		}
}

function ajaxPageLoader() {
    try {
        //readyState of 4 or 'complete' represents 
        //that data has been returned 
        if (req.readyState == 4 || req.readyState == 'complete') 
        {
            var respTxt = req.responseText;
            var respXml = req.responseXML;
            if ((respXml) && (respTxt.indexOf('pagelistino') <= 0)) {
                xmlMultiContentReader(respXml);
            }
            else {
                document.getElementById('AjaxPageContent').innerHTML = respTxt;
            }

			GUnload();
            // Reperimento del nome della pagina
            var pageName;
            if (respTxt.indexOf('pagehotel') > 0) {
                pageName = 'hotel';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryVisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pageristorante') > 0) {
                pageName = 'ristorante';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryVisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pagecamere') > 0) {
                pageName = 'camere';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryVisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pagelistino') > 0) {
                pageName = 'listino';
				$("p#areapreventivo").attr('class', "AreaPreventivoVisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoVisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryInvisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoVisibile");
				document.getElementById('tdAuxContent').innerHTML = "";
				InitPreventivo();				
            }
            else if (respTxt.indexOf('pagedovesiamo') > 0) {
                pageName = 'hotel';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryInvisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				loadMap();
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pageinformazioni') > 0) {
                pageName = 'hotel';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryInvisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pagegabicce') > 0) {
                pageName = 'gabicce';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryVisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pageescursioni') > 0) {
                pageName = 'escursioni';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryVisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }
            else if (respTxt.indexOf('pageappartamenti') > 0) {
                pageName = 'appartamenti';
				$("p#areapreventivo").attr('class', "AreaPreventivoInvisibile");
				//$("p#imgpreventivo").attr('class', "AreaPreventivoInvisibile");
				$("div#PhotoGallery").attr('class', "PhotoGalleryVisibile");
				//$("p#statopreventivo").attr('class', "AreaPreventivoInvisibile");
				SetStatoPreventivo(0);
            }

			// Aggiornamento della gallery in base alla pagina
            ajaxGalleryUpdater(pageName);
        }
    }
    catch (e) {
        alert('Error in Ajax response');
    }
}

function xmlMultiContentReader(respXml) {

    var multicontentNodeList = respXml.getElementsByTagName("multicontent");



    //var rootNode = respXml.childNodes[0];
    //var nOfChilds=rootNode.childNodes.length;
    var nOfChilds = multicontentNodeList.length;
    for (var i = 0; i < nOfChilds; i++) {
        //var childNode = rootNode.childNodes[i];
        var childNode = multicontentNodeList[i];
        if (childNode) {
            var attributes = childNode.attributes;
            if (attributes) {
                if (attributes.length > 0) {
                    var contentIdNode = attributes.getNamedItem("id");
                    if (contentIdNode) {
                        var content = "";
                        var contentId = contentIdNode.value;
                        var nOfSubChilds = childNode.childNodes.length;
                        for (var j = 0; j < nOfSubChilds; j++) {
                            var nodeContent = childNode.childNodes[j].xml;
                            if (!nodeContent) {
                                var serializer = new XMLSerializer();
                                nodeContent = serializer.serializeToString(childNode.childNodes[j]);
                            }
                            content += nodeContent;
                        }
                        document.getElementById(contentId).innerHTML = content;
                    }
                }
            }
        }
    }
}

function ajaxGalleryUpdater(pageName) {
    try {
        // Identificazione del contenitore delle immagini visibili ...
        var visibleDiv = $('div#PhotoGallery p');
    
        // Identificazione della lista delle immagini visibili ...
        var visibleImages = $('div#PhotoGallery p a');
        
        // ... e del contenitore quello delle immagini invisibili
        var invisibleDiv = $('div#PhotoGalleryInvisibili');

        // Le immagini visibili vengono nascoste (si riferivano alla pagina precedente)
        visibleImages.clone(true).appendTo(invisibleDiv);
        visibleImages.remove();
        var emptyImageVisible = $('div#PhotoGallery p img#imgvuota');
        emptyImageVisible.remove();

        // Identificazione delle immagini della gallery per la pagina corrente ...
        var queryForCurrPageImages = 'div#PhotoGalleryInvisibili a.gallery' + pageName;
        var imagesForCurrPage = $(queryForCurrPageImages);
        // ... e loro spostamento nel contenitore delle immagini visibili
        imagesForCurrPage.clone(true).appendTo(visibleDiv);
        imagesForCurrPage.remove();

        // aggiunta dell'immagine vuota
        var emptyImage = $('div#PhotoGalleryInvisibili img#imgvuota');
        visibleDiv.append(emptyImage.clone(true));
    }
    catch (e) {
        alert('Error in ajaxGalleryUpdater');
    }
}



////////// Gestione preventivo ///////////
function InitPreventivo()
{
	SetStatoPreventivo(10);	
	
	// Definizione funzione di gestione dell'evento selezione n. di persone
	$("select#selnpers").change(
		function() {
			//alert(this.value);
			if (this.value == 0)
			{
				SetStatoPreventivo(10);
			}
			if (this.value == 1)
			{
				SetStatoPreventivo(20);
			}
			else if (this.value == 2)
			{
				SetStatoPreventivo(30);
			}
			else if (this.value == 3)
			{
				SetStatoPreventivo(40);
			}
			else if (this.value == 4)
			{
				SetStatoPreventivo(50);
			}
			else if (this.value == 5)
			{
				SetStatoPreventivo(60);
			}
		}
	);
	
	// Definizione funzione di gestione dell'evento "selezione tipo camera"
	$("select#selopzcam").change(
		function() {
			if (this.value == 0)
			{
				SetStatoPreventivo(20);
			}
			else
			{
				SetStatoPreventivo(21);
			}
		}
	);
	
	// Definizione funzione di gestione dell'evento "selezione età terza persona"
	$("select#selage3").change(
		function() {
			$statoprev = GetStatoPreventivo();
			if (this.value == 0)
			{
				if ($statoprev == 41)
				{
					SetStatoPreventivo(40);
				}
				else if (($statoprev == 51) || ($statoprev == 53) || ($statoprev == 61) || ($statoprev == 63) || ($statoprev == 65) || ($statoprev == 67))
				{
					$statoprev--;
					SetStatoPreventivo($statoprev);
				}
			}
			else
			{
				if ($statoprev == 40)
				{
					SetStatoPreventivo(41);
				}
				else if (($statoprev == 50) || ($statoprev == 52) || ($statoprev == 60) || ($statoprev == 62) || ($statoprev == 64) || ($statoprev == 66))
				{
					$statoprev++;
					SetStatoPreventivo($statoprev);
				}
			}
		}
	);
	
	// Definizione funzione di gestione dell'evento "selezione età quarta persona"
	$("select#selage4").change(
		function() {
			$statoprev = GetStatoPreventivo();
			if (this.value == 0)
			{
				if (($statoprev == 52) || ($statoprev == 53) || ($statoprev == 62) || ($statoprev == 63) || ($statoprev == 66) || ($statoprev == 67))
				{
					$statoprev--; $statoprev--;
					SetStatoPreventivo($statoprev);
				}
			}
			else
			{
				if (($statoprev == 50) || ($statoprev == 51) || ($statoprev == 60) || ($statoprev == 61) || ($statoprev == 64) || ($statoprev == 65))
				{
					$statoprev++; $statoprev++;
					SetStatoPreventivo($statoprev);
				}
			}
		}
	);
	
	// Definizione funzione di gestione dell'evento "selezione età quinta persona"
	$("select#selage5").change(
		function() {
			$statoprev = GetStatoPreventivo();
			if (this.value == 0)
			{
				if (($statoprev == 64) || ($statoprev == 65) || ($statoprev == 66) || ($statoprev == 67))
				{
					$statoprev--; $statoprev--; $statoprev--; $statoprev--;
					SetStatoPreventivo($statoprev);
				}
			}
			else
			{
				if (($statoprev == 60) || ($statoprev == 61) || ($statoprev == 62) || ($statoprev == 63))
				{
					$statoprev++; $statoprev++; $statoprev++; $statoprev++;
					SetStatoPreventivo($statoprev);
				}
			}
		}
	);
	
}

function ResetInputEta()
{
	document.getElementById('selage3').value="0";
	document.getElementById('selage4').value="0";
	document.getElementById('selage5').value="0";
}

function ResetInputTipoCamera()
{
	document.getElementById('selopzcam').value="0";
}

function UpdateStatoPreventivo()
{
	$statepreventivo=GetStatoPreventivo();
	if ($statepreventivo=="0")
	{
		// Stato = siamo in altra pagina (non prezzi)
		$("p#npersone").attr('class', "AreaPreventivoInvisibile");
		$("p#opzcamera").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers3").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers4").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers5").attr('class', "AreaPreventivoInvisibile");
		$("p#tiposogg").attr('class', "AreaPreventivoInvisibile");
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");
		$("p#rispostapreventivo").attr('class', "AreaPreventivoInvisibile");
		$("p#disclaimerpreventivo").attr('class', "AreaPreventivoInvisibile");
		document.getElementById('dataarrivo').value="";
		document.getElementById('datapartenza').value="";
		document.getElementById('selnpers').value="0";
		ResetInputEta();
		document.getElementById('selopzcam').value="0";
		document.getElementById('tsog').value="0";
	}
	else if ($statepreventivo=="10")
	{
		// Stato = primo ingresso in preventivo
		$("p#npersone").attr('class', "AreaPreventivoVisibile");
		$("p#opzcamera").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers3").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers4").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers5").attr('class', "AreaPreventivoInvisibile");
		$("p#tiposogg").attr('class', "AreaPreventivoVisibile");
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");
	}
	else if ($statepreventivo=="20")
	{
		// Stato = è stato selezionato n. di persone = 1
		$("p#opzcamera").attr('class', "AreaPreventivoVisibile");
		$("p#agepers3").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers4").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers5").attr('class', "AreaPreventivoInvisibile");
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");
		ResetInputEta();
		ResetInputTipoCamera();
	}
	else if ($statepreventivo=="21")
	{
		// Stato = con n. persone 1, è stato selezionato un valore valido per il tipo camera
		$("p#oksend").attr('class', "AreaPreventivoVisibile");		
	}
	else if ($statepreventivo=="30")
	{
		// Stato = è stato selezionato n. di persone = 2
		$("p#opzcamera").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers3").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers4").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers5").attr('class', "AreaPreventivoInvisibile");
		$("p#oksend").attr('class', "AreaPreventivoVisibile");
		ResetInputEta();
		ResetInputTipoCamera();
	}
	else if ($statepreventivo=="40")
	{
		// Stato = è stato selezionato n. di persone = 3
		$("p#opzcamera").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers3").attr('class', "AreaPreventivoVisibile");
		$("p#agepers4").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers5").attr('class', "AreaPreventivoInvisibile");
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");
		ResetInputEta();
		ResetInputTipoCamera();
	}
	else if ($statepreventivo=="41")
	{
		// Stato = con n. persone 3, è stato selezionato un valore valido per l'età della terza persona
		$("p#oksend").attr('class', "AreaPreventivoVisibile");		
	}
	else if ($statepreventivo=="50")
	{
		// Stato = è stato selezionato n. di persone = 4
		$("p#opzcamera").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers3").attr('class', "AreaPreventivoVisibile");
		$("p#agepers4").attr('class', "AreaPreventivoVisibile");
		$("p#agepers5").attr('class', "AreaPreventivoInvisibile");
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");
		ResetInputEta();
		ResetInputTipoCamera();
	}
	else if (($statepreventivo=="51") || ($statepreventivo=="52"))
	{
		// Stato = con n. persone 4, non è stato selezionato un valore valido per le età sia della terza che della quarta persona
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");		
	}
	else if ($statepreventivo=="53")
	{
		// Stato = con n. persone 4, è stato selezionato un valore valido per le età della terza e quarta persona
		$("p#oksend").attr('class', "AreaPreventivoVisibile");		
	}
	else if ($statepreventivo=="60")
	{
		// Stato = è stato selezionato n. di persone = 5
		$("p#opzcamera").attr('class', "AreaPreventivoInvisibile");
		$("p#agepers3").attr('class', "AreaPreventivoVisibile");
		$("p#agepers4").attr('class', "AreaPreventivoVisibile");
		$("p#agepers5").attr('class', "AreaPreventivoVisibile");
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");
		ResetInputEta();
		ResetInputTipoCamera();
	}
	else if (($statepreventivo=="61") || ($statepreventivo=="62") || ($statepreventivo=="63") || ($statepreventivo=="64") || ($statepreventivo=="65") || ($statepreventivo=="66"))
	{
		// Stato = con n. persone 5, non è stato selezionato un valore valido per le età sia della terza che della quarta e quintapersona
		$("p#oksend").attr('class', "AreaPreventivoInvisibile");		
	}
	else if ($statepreventivo=="67")
	{
		// Stato = con n. persone 5, è stato selezionato un valore valido per le età della terza, quarta e quinta persona
		$("p#oksend").attr('class', "AreaPreventivoVisibile");		
	}
}

function GetStatoPreventivo()
{
	return document.getElementById('statopreventivo').innerHTML;
}

function SetStatoPreventivo(newState)
{
	try
	{
		//$("p#statopreventivo").innerHTML=newState;
		document.getElementById('statopreventivo').innerHTML = newState;
		UpdateStatoPreventivo();
	}
	    catch (e) 
	{
        alert('Error in SetStatoPreventivo');
    }
}

function InitAudioPlayer() {
    // Su IE il nodo embed non funziona: lo sostituiamo con object
    if (BrowserDetect.browser == "Explorer") {
        var playerTag = "<object id='wmp' width='240' height='45' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' type='application/x-oleobject'><param name='URL' value='musica_hotel_ambra.mp3'><param name='SendPlayStateChangeEvents' value='True'><param name='AutoStart' value='True'><param name='uiMode' value='mini'><param name='PlayCount' value='1'></object>";
        document.getElementById('playercontainer').innerHTML = playerTag;
    }
    else if (BrowserDetect.browser == "Chrome") {
        var playerTag = "<audio controls='controls' autoplay='autoplay' loop=''><source src='musica_hotel_ambra.mp3' type='audio/mpeg' /></audio>";
        document.getElementById('playercontainer').innerHTML = playerTag;
    }
}



var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.userAgent,
		    subString: "Chrome",
		    identity: "Chrome"
		},
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari",
		    versionSearch: "Version"
		},
		{
		    prop: window.opera,
		    identity: "Opera",
		    versionSearch: "Version"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.userAgent,
		    subString: "iPhone",
		    identity: "iPhone/iPod"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};



