(function (i, s, o, g, r, a, m)
{
    i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function ()
    {
        (i[r].q = i[r].q || []).push(arguments);
    }, i[r].l = 1 * new Date(); a = s.createElement(o),
    m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m);
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-43104796-1', 'the-hotels.info');
ga('send', 'pageview');


var deviceType = GetURLParameter('deviceType');
var providor = GetURLParameter('providor');
var language = GetURLParameter('language');

function LocationBookingLinkUrl()
{
    var suplierLink = "";

    if (providor == 'booking')
    {
        if (deviceType == "phone")
        {
            // suplierLink = "http://m.booking.com/city/" + location.Location.SupplierIdBookingDotCom + ".html?aid=304310&label=" + deviceType;
            suplierLink = "http://www.booking.com/city/" + location.Location.SupplierIdBookingDotCom + ".html?aid=304310&label=" + deviceType;
        } else
        {
            suplierLink = "http://www.booking.com/city/" + location.Location.SupplierIdBookingDotCom + ".html?aid=304310&label=" + deviceType;
        }
    }

    if (providor == 'ean')
    {
        suplierLink = "http://www.travelnow.com/templates/397351/hotels/list?lang=" + language + "&targetId=" + location.Location.SupplierIdEan;
    }

    if (providor == 'easytobook')
    {

        if (deviceType == "phone")
        {
            // http://www.easytobook.com/?lang=en&amu=280828148&location_name=Bangkok+Thailand
            // http://www.easytobook.com/en/netherlands/north-holland/amsterdam-hotels/?amu=280828148
            suplierLink = "http://www.easytobook.com/" + language + "/" + location.Location.SupplierIdEasyToBook + "-hotels/?amu=280828148";
        } else
        {
            suplierLink = "http://www.easytobook.com/" + language + "/" + location.Location.SupplierIdEasyToBook + "-hotels/?amu=280828148";
        }
    }

    if (providor == 'hrs')
    {

        if (deviceType == "phone")
        {
            suplierLink = "http://www.hrs.com/web3ci/?client=" + language + "__greens&customerId=2pl-com&location=" + location.Location.SupplierIdHrs;
        } else
        {
            suplierLink = "http://www.hrs.com/web3ci/?client=" + language + "__greenm&customerId=2pl-com&location=" + location.Location.SupplierIdHrs;
        }
    }
    return suplierLink;
}

function GetURLParameter(sParam) {
    var parameterName = "";
    
    var sPageUrl = window.location.search.substring(1);
    var sUrlVariables = sPageUrl.split('&');
    for (var i = 0; i < sUrlVariables.length; i++) {
        var sParameterName = sUrlVariables[i].split('=');
        if (sParameterName[0] == sParam) {
            parameterName = sParameterName[1];
        }
    }
    return parameterName;
}

$(document).ready(function ()
{
    $(document).attr("title", "Hotels " + self.location.Location.name + " " + providor + " " + deviceType + " " + language);

    // forwarding 
    window.location = LocationBookingLinkUrl();
});

