function handleBarLink() {}
function $(a) {
    return document.getElementById(a)
}
if (window.addEventListener) {
    window.addEventListener("load", __init, false)
} else {
    window.attachEvent("onload", __init)
}
var Days = ['Domenica', 'Lunedi', 'Martedi', 'Mercoledi', 'Giovedi', 'Venerdi', 'Sabato'];
var Months = ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'];

function addLeadingZero(a) {
    if (a < 10) {
        return "0" + a
    } else {
        return a
    }
}

function changelanguage(lang) {
    savecookie('language', lang, 1000);
}

function getAMPM(a) {
    return (a >= 12) ? "PM" : "AM"
}
function cutHoursToAMPM(a) {
    return (a == 12 || a == 0) ? 12 : a % 12
}
function updateDateSpan() {
    var b = $("dateContainer");
    if (b) {
        var a = new Date();
        b.innerHTML = Days[a.getUTCDay()] + ", " + Months[a.getUTCMonth()] + " " + addLeadingZero(a.getUTCDate()) + ", " + addLeadingZero(a.getUTCFullYear()) + " - " + cutHoursToAMPM(a.getUTCHours()) + ":" + addLeadingZero(a.getUTCMinutes()) + " " + getAMPM(a.getUTCHours()) + " GMT"
    }
    setTimeout("updateDateSpan();", 1000)
}
function __init() {
    updateDateSpan();
    if (typeof(document.doonload) != "undefined") {
        document.doonload()
    }
}
var emerpcomp = null;
var counter = 0;
var userGuid = "";
document.EMERPCallbacks = [];

function EMERPCallback(b, a) {
    emerpcomp = b;
    userGuid = b.GetUserID();
    document.shouldsendhphit = doubletracking();
    if (typeof(document.EMERPAdditionalCallback) != "undefined") {
        document.EMERPAdditionalCallback(b, a)
    } else {
        if (a == "DummyEvent") {
            if (typeof(document.shouldsendhphit) != "undfined" && document.shouldsendhphit) {
                emerpcomp.SendEvent("", "hphit", "cp")
            }
        }
    }
    if (typeof(document.EMERPCallbacks) != "undefined" && typeof(document.EMERPCallbacks.length) != "undefined") {
        for (var i=0,ii=document.EMERPCallbacks.length;i<ii;i++) {
            document.EMERPCallbacks[i](b, a);
        }
    }
    if (typeof(document.EMERPToUrchin) != "undefined") {
        document.EMERPToUrchin(b, a)
    }
}
function getDownloadLink() {
    var userGuid = (emerpcomp != null) ? emerpcomp.GetUserID() : "";
    var pixel = (emerpcomp != null) ? emerpcomp.GetPixelID() : "";
    var dp = (emerpcomp != null) ? emerpcomp.GetDPID() : "";
    var banner_click = readcookie('banner_click');
    var creferer = '';
    if ( banner_click !== null ) {
    	banner_click = banner_click.split(',');
	    if ( banner_click[4].length >0 && banner_click[4] !== '*' ) {
	    	creferer = banner_click[4];
	    }
    }
	var cref = new cRefererObj(creferer);
	cref.add('UserGUID', userGuid);
	cref.add('pixelid', pixel);
	cref.add('DP', dp);
    var downloadUrl = "http://banner.mansioncasino.com/cgi-bin/SetupCasino.exe?creferer=" + cref.toString();
    return downloadUrl
}
function getpropertybag() {
	var rs = [];
	rs.push("proposition:"+readcookie("b"));
	return rs.join(";");
}
function trackdownload(b) {
    try { if (readcookie("_km") == "1" && userGuid != "") _kmq.push(['identify', userGuid]); savecookie("_km", "2", 1000);} catch (e) { }
    try { _kmq.push(['record', (b?'Flash':'Client')+' Download Attempt']);} catch (e) {}
    var a = document.createElement("script");
    a.src = "http://stat.mansioncasino.com/stats/track.php?r=" + escape(document.referrer) + ((b) ? "&__f=true" : "") + "&__d=true&__b=mc&pb="+getpropertybag();
    document.body.appendChild(a)
}

try {
	_kmq.push(function(){
			document.downloadmethod = (navigator.userAgent.match(/(msie|firefox)/i)) ? KM.ab("Download Method", ["popup", "iframe"]) : "iframe";
	});
} catch (e) {}

function doDownload() {
    trackdownload();
    var w = null;
    if (typeof(document.downloadmethod) != "undefined" && document.downloadmethod == "popup") {
	try {
		w = window.open(getDownloadLink(), "popDown", "width=1,height=1,top=0,left=0");
	} catch (e) {
		w = null;
	}
	
	if (w != null) {
		if (!redirectafterdownload || document.location.href.match(/\/download\//i)) return;
		document.location.href = "/download.html";
	}
    }
    if (w == null || typeof(document.downloadmethod) == "undefined" || document.downloadmethod == "iframe") {
	    var a = document.getElementById("download_iframe");
	    if (a == null) {
		a = document.createElement("iframe");
		a.width = "1px";
		a.height = "1px";
		a.position = "absolute";
		a.left = "-100px";
		document.body.appendChild(a)
	    }
	    a.src = getDownloadLink();
	    if (!redirectafterdownload || document.location.href.match(/\/download\.html/i)) {
		return
	    }
	    window.setTimeout(function () {
		document.location.href = "/download.html"
	    }, 4000);
    }
}
var senddownload = false;
var downloadattempts = 0;
var redirectafterdownload = true;

function startDownload(d, a) {
    if (a) {
        redirectafterdownload = false
    }
    var b = document.location.href.replace(/^.*\//, "");
    if (typeof(d) != "undefined") {
        b += ((b != "") ? ":" : "") + d
    }
    if (typeof(pageTracker) != "undefined") {
        pageTracker._trackEvent("Download", "click", b);
        pageTracker._trackPageview("/clientdownload.html")
    }
    isLink = true;
    var f = "cd";
    try {
        if (!navigator.userAgent.match(/Windows/)) {
            f = "cf"
        }
    } catch (c) {}
    downloadattempts = 0;
    startActualDownload(f)
}
function startActualDownload(clienttype) {
    if (emerpcomp == null || !synced || !cookiesreloaded) {
        downloadattempts += 1;
        if (downloadattempts < 8) {
            window.setTimeout(function () {
                startActualDownload(clienttype);
            }, 1000);
            return;
        }
    }
    if (clienttype == "cd") doDownload();
	else {
		var ref_info_cookie = readcookie('banner_click');
		var get_ref_info = "?";
		var userGuid = (emerpcomp != null) ? emerpcomp.GetUserID() : "";
	    var pixel = (emerpcomp != null) ? emerpcomp.GetPixelID() : "";
	    var dp = (emerpcomp != null) ? emerpcomp.GetDPID() : "";
	    var creferer = '';

	    if (ref_info_cookie!=null) {
			var ref_info = ref_info_cookie.split(",");
			creferer = ( ref_info[4] == '*' || ref_info[4] == '') ? '' : ref_info[4];
			get_ref_info = "?advertisercode="+ref_info[0]+"&banner="+ref_info[1]+"&profile="+ref_info[2]+"&creferer=";
		} else {
		    get_ref_info = "?creferer=";
		}
		var cref = new cRefererObj(creferer);
		cref.add('UserGUID', userGuid);
		cref.add('pixelid', pixel);
		cref.add('DP', dp);
		window.open("http://cachebanner.mansioncasino.com/flash/20/casino_mansion/launchcasino.html"+get_ref_info+cref.toString()+"&language=it", "newwindow", "width=800, height=600");
	}
    if (emerpcomp != null) {
        if (document.sshhwd) emerpcomp.SendEvents([
            ["", "hphit", "cp"],
            ["", "download", clienttype]
        ], "download");
        else emerpcomp.SendEvent("", "download", clienttype);
    } else senddownload = true;
}
function startDownloadWORedirection(a) {
    startDownload(a, true)
}
function findPosition(b) {
    var c = {
        x: 0,
        y: 0
    };
    try {
        while (b.nodeName.toLowerCase() != "body") {
            c.x += parseInt(b.offsetLeft, 10);
            c.y += parseInt(b.offsetTop, 10);
            b = b.offsetParent
        }
    } catch (a) {}
    return c
}
function findPosX(a) {
    var b = 0;
    if (a.offsetParent) {
        while (1) {
            b += a.offsetLeft;
            if (!a.offsetParent) {
                break
            }
            a = a.offsetParent
        }
    } else {
        if (a.x) {
            b += a.x
        }
    }
    return b
}
function findPosY(b) {
    var a = 0;
    if (b.offsetParent) {
        while (1) {
            a += b.offsetTop;
            if (!b.offsetParent) {
                break
            }
            b = b.offsetParent
        }
    } else {
        if (b.y) {
            a += b.y
        }
    }
    return a
}
function formatNumber(a) {
    a = a.split("").reverse().join("");
    a = a.replace(/([0-9]{3})(?=[0-9])/g, "$1,");
    return a.split("").reverse().join("")
}
function closeme() {
    self.close();
    document.location.href = "htcmd:close"
}
var traceoutput = "";

function trace(a) {
    traceoutput += a + "_"
}
function savecookie(c, d, e) {
    var b = new Date();
    b.setTime(b.getTime() + (((typeof(e) != "undefined") ? e : 3) * 24 * 60 * 60 * 1000));
    var a = "; expires=" + b.toGMTString();
    document.cookie = c + "=" + d + a + "; path=/;domain=.mansioncasino.com"
}
function readcookie(a) {
    a += "=";
    var d = document.cookie.split(";");
    for (var b = 0; b < d.length; b++) {
        var e = d[b];
        while (e.substring(0, 1) == " ") {
            e = e.substring(1, e.length)
        }
        if (e.indexOf(a) == 0) {
            return (e.substring(a.length, e.length) != "null") ? e.substring(a.length, e.length) : null
        }
    }
    return null
}
function deletecookie(a) {
    savecookie(a, "", -1)
}
function syncAffiliate(d, a) {
    var c = readcookie(d);
    for (var b = 0; b < a.length; b++) {
        savecookie(a[b], c)
    }
}
function getParamFromUrl(b) {
    var c = new RegExp("(?:\\?|\\&)" + b + "=([^\\&]*)");
    var a = document.location.search.match(c);
    return (a != null) ? a[1] : ""
}
function setAffiliate(c, d) {
    d = d ? d : "default";
    var e = "." + (document.domain.match(/\./ig).length > 1) ? document.domain.replace(/[^\.]*\./, "") : document.domain;
    var b = new Date();
    b.setTime(b.getTime() + (3 * 24 * 60 * 60 * 1000));
    var a = "; expires=" + b.toGMTString();
    document.cookie = "banner_domainclick=" + c + ",," + d + ",*,*" + a + "; path=/" + ((e != "") ? ";domain=" + e : "");
    document.cookie = "banner_click=" + c + ",," + d + ",*,*" + a + "; path=/" + ((e != "") ? ";domain=" + e : "");
    document.cookie = "banner_download=" + c + ",," + d + ",*,*" + a + "; path=/" + ((e != "") ? ";domain=" + e : "")
}
function getaffiliate() {
    var a = (document.cookie.match(/banner_domainclick/)) ? document.cookie.match(/banner_domainclick=([\d\D]+)/i) : null;
    if (a != null && a[1].replace(/,.*/, "") != "defaultm6") {
        return a[1].replace(/,.*/, "")
    } else {
        return ""
    }
}
function getdownloadaffiliate() {
    var a = (document.cookie.match(/banner_download/)) ? document.cookie.match(/banner_download=([\d\D]+)/i) : null;
    if (a != null && a[1].replace(/,.*/, "") != "defaultm6") {
        return a[1].replace(/,.*/, "")
    } else {
        var b = getParamFromUrl("tracker");
        return (b != "defaultm6") ? b : ""
    }
}
var __segment = "";
var synced = false;
var cookiesreloaded = false;

function doubletracking() {
    if (synced) {
        return false
    }
    var d = true;
    synced = true;
    var l = emerpcomp.GetProperty("aff");
    trace("k1" + l);
    var h = emerpcomp.GetProperty("sid");
    trace("k2" + h);
    var j = getaffiliate();
    var m = getdownloadaffiliate();
    trace("a1" + j);
    trace("da" + m);
    var a = emerpcomp.GetSerialID();
    trace("s" + a);
    var b = (j != "" && j != l && !j.match(/(Convertonet|convertonetC|ConvertonetC)/i));
    if (m != "" && !m.match(/(Convertonet|convertonetC|ConvertonetC)/i) && j != m && !b) {
        b = true;
        j = m;
        syncAffiliate("banner_download", new Array("banner_domainclick", "banner_click"))
    }
    var i = (a != null && a != "" && a != h);
    var k = getReferrer();
    var f = document.location.search.match(/[\?\&]SID=[0-9]+/);
    trace("ia" + b);
    trace("ic" + i);
    trace("is" + k);
    if (!k && j == "" && a == "") {
        trace("tu");
        emerpcomp.DeleteProperty("aff");
        emerpcomp.DeleteProperty("sid");
        emerpcomp.DeleteProperty("seo");
        __segment = "Unknown";
        cookiesreloaded = true
    } else {
        if (b && !f) {
            trace("na");
            emerpcomp.SetProperty("aff", j);
            emerpcomp.SetProperty("seo", 0);
            setAFFILIATE(j);
            syncAffiliate("banner_domainclick", new Array("banner_click", "banner_download"));
            d = false
        } else {
            if (k && !i) {
                trace("sc");
                emerpcomp.SetProperty("aff", "ConvertonetC");
                emerpcomp.SetProperty("seo", 1);
                setAffiliate("ConvertonetC", "seo");
                setSEO(k);
                __segment = "SEO";
                d = false
            } else {
                if (k && i) {
                    trace("smc");
                    emerpcomp.SetProperty("aff", "ConvertonetC");
                    emerpcomp.SetProperty("sid", a);
                    emerpcomp.SetProperty("seo", 0);
                    setAffiliate("ConvertonetC", "sem");
                    __segment = "SEM";
                    d = false;
                    cookiesreloaded = true
                } else {
                    if (i) {
                        trace("ns");
                        emerpcomp.SetProperty("aff", "ConvertonetC");
                        emerpcomp.SetProperty("sid", a);
                        emerpcomp.SetProperty("seo", 0);
                        setAffiliate("ConvertonetC", "media");
                        __segment = "Media/" + a;
                        cookiesreloaded = true
                    } else {
                        if (readcookie("__utmv") == null) {
                            var g = emerpcomp.GetProperty("aff");
                            var e = emerpcomp.GetProperty("sid");
                            var c = emerpcomp.GetProperty("seo");
                            if (g != "" && !g.match(/(Convertonet|convertonetC|ConvertonetC)/i)) {
                                __segment = "Affiliate/" + g
                            } else {
                                if (c == "1") {
                                    __segment = "SEO"
                                } else {
                                    if (e != "") {
                                        __segment = "Media/" + a
                                    } else {
                                        __segment = "Unknown"
                                    }
                                }
                            }
                            cookiesreloaded = true
                        } else {
                            cookiesreloaded = true
                        }
                    }
                }
            }
        }
    }
    return d
}
function getReferrer() {
    return a(document.referrer);

    function a(c) {
        if (!c) {
            return
        }
        var e = [/^http:\/\/[^\/]*?\b(google)(?:\.[^\.]+)*\/.+?[\?&]q=([^&#]*)/i, /^http:\/\/[^\/]*?\b(google\.com)\/.+?[\?&]q=([^&#]*)/i, /^http:\/\/[^\/]*?\b(google\.ca)\/.+?[\?&]q=([^&#]*)/i, /^http:\/\/[^\/]*?\b(google\.co\.uk)\/.+?[\?&]q=([^&#]*)/i, /^http:\/\/[^\/]*?\b(yahoo)\.co(?:m|\.[^\.]+)\/.+?[\?&]p=([^&#]*)/i, /^http:\/\/search\.(yahoo\.com)\/.+?[\?&]p=([^&#]*)/i, /^http:\/\/(uk\.search\.yahoo\.com)\/.+?[\?&]p=([^&#]*)/i, /^http:\/\/(ca\.search\.yahoo\.com)\/.+?[\?&]p=([^&#]*)/i, /^http:\/\/[^\/]*?\b(bing\.com)\/.+?[\?&]q=([^&#]*)/i, ""];
        for (var b, d = e.length - 2; d >= 0; --d) {
            if (b = e[d].exec(c)) {
                return {
                    site: b[1],
                    keyword: decodeURIComponent(b[2])
                }
            }
        }
    }
}
function reloadcookies(a) {
    emerpcomp.SetProperty("aff", a.GetProperty("aff"));
    emerpcomp.SetProperty("sid", a.GetProperty("sid"));
    emerpcomp.SetProperty("seo", a.GetProperty("seo"));
    emerpcomp.SetSerialID(a.GetSerialID());
    cookiesreloaded = true
}
var iframese = null;

function setAFFILIATE(a) {
    iframese = document.createElement("iframe");
    iframese.width = 1;
    iframese.height = 1;
    iframese.src = "/EMERPECp/aff.php?callback=reloadcookies&name=" + a + "&r=" + Math.random() * 100000;
    callse()
}
function setSEO(a) {
    iframese = document.createElement("iframe");
    iframese.width = 1;
    iframese.height = 1;
    iframese.src = "/EMERPECp/se.php?callback=reloadcookies&keyword=" + a.keyword + "&site=" + a.site + "&r=" + Math.random() * 100000;
    callse()
}
function callse() {
    if (document.getElementById("emerpec") == null) {
        window.setTimeout(callse, 100);
        return
    } else {
        document.getElementById("emerpec").parentNode.appendChild(iframese)
    }
}
var isLink = false;

function on_unload() {
    if (document.location.search.match(/(client|nxs)=true/)) {
        document.cookie = "ptclient=true; path=/;domain=.mansioncasino.com"
    }
    if (isLink || readcookie("ptclient") == "true" || readcookie("x") == "true") {
        return false
    } else {
        var a = Math.round(Math.random());
        var b = window.open('http://www.casino.com/xsell/redirect/?SID=152947&t=hp&l=fr' + a, "_new", "width=1024, height=707");
        if (b != null) {
            if (a == 0) {
                b.blur();
                window.focus()
            }
            document.cookie = "x=true; path=/;domain:.mansioncasino.com"
        }
        return true
    }
}
function handleLinks(g) {
    if (window.event) {
        var a = window.event.srcElement
    } else {
        var a = g.target
    }
    var f = false;
    if (a.href) {
        if (a.href.toString().indexOf("#") != -1) {
            var k = a.href.toString().substring(0, a.href.toString().indexOf("#"));
            var b = a.href.toString().substring(a.href.toString().indexOf("#"));
            var i = location.href.toString().substring(0, a.href.toString().indexOf("#"));
            if (i == k) {
                f = true
            }
        }
    }
    var d = false;
    if (!(null == a.getAttribute("onclick"))) {
        if (a.getAttribute("onclick").toString().indexOf("location") != -1) {
            d = true
        }
    }
    if (a.tagName == "A" || d) {
        var h = a
    } else {
        var h = getParent(a)
    }
    var c = false;
    if (!(null == h.getAttribute("href")) && h.getAttribute("href") != "") {
        if (h.getAttribute("href").toString().indexOf("javascript") == -1) {
            c = true
        }
    }
    var j = false;
    if (!(null == h.getAttribute("onclick"))) {
        if (h.getAttribute("onclick").toString().indexOf("location") != -1) {
            j = true
        }
    }
    if ((h.tagName == "A" && c && !f) || j) {
        isLink = true
    }
}
function getParent(c) {
    var b = c;
    try {
        while (true) {
            if (b.tagName.toLowerCase() == "a" || b.getAttribute("onclick") != null) {
                break
            }
            b = b.parentNode
        }
        return b
    } catch (a) {
        alert(a.description)
    }
}
function ff(a) {
    document.write(a)
}
var lastName = -1;

function gotoInfo(a) {
    if (lastName != -1 && a != lastName) {
        $(lastName).style.display = "none";
        $(lastName + "Row").className = "doTableRow";
        $(lastName + "Sep").className = "doTableSep";
        $(lastName + "D").className = $(lastName + "D").className.replace("Open", "");
        $(lastName + "W").className = $(lastName + "W").className.replace("Open", "");
        $(lastName + "Frame").src = ""
    }
    if ($(a).style.display == "none") {
        $(a).style.display = "";
        $(a + "Row").className = "doTableRowOpen";
        $(a + "Sep").className = "doTableSepOpen";
        $(a + "D").className = $(a + "D").className + "Open";
        $(a + "W").className = $(a + "W").className + "Open";
        $(a + "Frame").src = a + "/index.html?showlink=yes";
        document.location.href = "#link_" + a
    } else {
        $(a).style.display = "none";
        $(a + "Row").className = "doTableRow";
        $(a + "Sep").className = "doTableSep";
        $(a + "D").className = $(a + "D").className.replace("Open", "");
        $(a + "W").className = $(a + "W").className.replace("Open", "");
        $(a + "Frame").src = ""
    }
    lastName = a
}
function getParamFromUrl(b) {
    var c = new RegExp("(?:\\?|\\&)" + b + "=([^\\&]*)");
    var a = document.location.search.match(c);
    return (a != null) ? a[1] : ""
}
function launchChat(a) {
    var b = window.open(a, "chatWindow", "width=490,height=400,resizable=0,scrollbars=no,menubar=no,status=no");
    b.focus(true)
}
function launchPlaytech(src) {
	var source = document.location.href.replace(/^.*\//, "");
	if (typeof(src) != "undefined") source += ((source != "") ? ":" : "")+src;

	currentsrc = src;

	if (typeof(funnelstep) != "undefined") {
		funnelstep("b");
		funnelstep("d");
	}

    if (typeof(trackdownload) != "undefined") trackdownload(true);
		var ref_info_cookie = readcookie('banner_click');
		var get_ref_info = "?";
		var userGuid = (emerpcomp != null) ? emerpcomp.GetUserID() : "";
	    var pixel = (emerpcomp != null) ? emerpcomp.GetPixelID() : "";
	    var dp = (emerpcomp != null) ? emerpcomp.GetDPID() : "";
	    var creferer = '';

	    if (ref_info_cookie!=null) {
			var ref_info = ref_info_cookie.split(",");
			creferer = ( ref_info[4] == '*' || ref_info[4] == '') ? '' : ref_info[4];
			get_ref_info = "?advertisercode="+ref_info[0]+"&banner="+ref_info[1]+"&profile="+ref_info[2]+"&creferer=";
		} else {
		    get_ref_info = "?creferer=";
		}
		var cref = new cRefererObj(creferer);
		cref.add('UserGUID', userGuid);
		cref.add('pixelid', pixel);
		cref.add('DP', dp);

	    window.open("http://cachebanner.mansioncasino.com/flash/20/casino_mansion/launchcasino.html"+get_ref_info+cref.toString()+"&language=it", "newwindow", "width=800, height=600");
    if (emerpcomp != null) {
        if (document.sshhwd) emerpcomp.SendEvents([
            ["", "hphit", "cp"],
            ["", "download", "cf"]
        ], "download");
        else emerpcomp.SendEvent("", "download", "cf");
    } else sendflashdownload = true;

	if (typeof(_updatetimestamp) != "undefined") _updatetimestamp();
	_extgaq.push(['_trackEvent', 'Download', 'flash', 'full']);
	_extgaq.push(['_trackPageview', '/flashdownload.html']);
	if (readcookie("_fd") == null) {
		_extgaq.push(['_trackPageview', '/download/flash/first']);
		savecookie("_fd", "1", 1000);
	} else if (readcookie("_fd") == "2") {
		_extgaq.push(['_trackPageview', '/download/flash/second']);
		savecookie("_fd", "3", 1000);
	}
	//Block VSP popup when user start dowwnload 
	try { SwitchedOn = false;} catch(e) {}
}
function getCurrentLanguageParameter(prefix) {
    CONSTANTS.language='it';
	if (CONSTANTS.language == "") {
        var a = document.location.href.match(/mansioncasino.com\/([a-z]{2})\//);
        return (a != null && a.length > 1) ? prefix + a[1] : "";
    } else {
        return (CONSTANTS.language != "") ? prefix + CONSTANTS.language : "";
    }
}
function showCountryNumber(c) {
    for (var a = 0; a <= (c.options.length - 1); a++) {
        var b = document.getElementById("num_" + c.options[a].value);
        b.style.display = "none"
    }
    var b = document.getElementById("num_" + c.value);
    b.style.display = ""
}
function handleStartedSteps(a) {
    if ($("startedStep" + a).style.display == "none") {
        if ($("startedStepImage" + a)) {
            $("startedStepImage" + a).src = "/images/sarrowdown.gif"
        }
        $("startedStep" + a).style.display = ""
    } else {
        if ($("startedStepImage" + a)) {
            $("startedStepImage" + a).src = "/images/sarrowright.gif"
        }
        $("startedStep" + a).style.display = "none"
    }
}
function openLanguages(a) {
    if (document.getElementById("langselector").style.display == "none") {
        document.getElementById("langselector").style.display = "";
        a.style.backgroundPosition = "0 -29px"
    } else {
        document.getElementById("langselector").style.display = "none";
        a.style.backgroundPosition = "0 0"
    }
};

var CONSTANTS = {};
CONSTANTS.xsell_link = 'http://www.casino.com/xsell/redirect/?SID=152947&t=hp&l=it';
CONSTANTS.xsellTitle = 'Perchè non provare uno dei nostri Casino partner ?';
CONSTANTS.xsellOffer = '<div class="for">Per te il</div> 100% Bonus di <div class="bonus"\>benvenuto di  €150</div>';
CONSTANTS.xsellVisitURL = 'Visita il sito it.MansionCasino.com';
CONSTANTS.xsellDownloadLink = 'http://www.casino.com/xsell/redirect/?SID=152947&t=dl&l=it';
CONSTANTS.xsellDownloadTitle = '<div id="download_txt">Scarica il software del Casino</div>';

// New Cross-Sell;	


function initxsell() {
    var Browser = {
        name: "",
        version: 6,
        init: function () {
            navigator.userAgent.replace(/(chrome|safari|opera|firefox|msie)/i, function (a, b) {
                Browser.name = b.toLowerCase();
                try {
                    switch (Browser.name) {
                    case "msie":
                        Browser.version = parseInt(navigator.userAgent.match(/msie ([0-9])/i)[1], 10);
                        break;
                    case "safari":
                        var version = parseInt(navigator.userAgent.match(/version\/([0-9])/i)[1], 10);
                        Browser.version = (version >= 4) ? 8 : (version == 3) ? 7 : 6;
                        break;
                    default:
                        Browser.version = (typeof document.body.style.maxHeight != "undefined") ? 7 : 6;
                    }
                } catch (e) {}
            });
        }
    };

    Browser.init();
    if (Browser.version >= 7) {
        if (document.addEventListener) document.addEventListener("mousemove", mousemove, false);
        else document.attachEvent("onmousemove", mousemove);
//			document.onmousemove = mousemove;
	    }
}

var pos = [];

function flat(arr) {
    var output = [];
    for (var i = 0; i < pos.length; i++) output.push(pos[i].x + "," + pos[i].y);
    return output.join("<br />");
}

var mousecheckinterval = 0;

function mousemove(e) {
    window.clearInterval(mousecheckinterval);
    e = e || event;
    if (pos.length == 0 || pos[pos.length - 1].y > e.clientY) {
        pos.push({
            x: e.clientX,
            y: e.clientY
        });
        mousecheckinterval = window.setTimeout(checkmouseposition, 1500);
    } else pos = [];
}

function checkmouseposition() {
    if (pos.length < 2 || pos[pos.length - 1].y > 150) {
        pos = [];
        return;
    }
    if (pos[pos.length - 1].y > 10) {
        var lastgap = 10000;
        for (var i = pos.length - 1; i >= 1; i--) {
            var gap = pos[i - 1].y - pos[i].y;
            //console.info("gap:"+gap+", lastgap:"+lastgap);
            if (gap >= lastgap) {
                pos = [];
                return;
            }
            lastgap = gap;
        }
    }
    popup.show('xsell');
}

var popup = {}
popup.show = function (popup) {
    var currentHeight = 0;
    containerHeight = (document.all) ? document.documentElement.offsetHeight - 4 : document.documentElement.scrollHeight;
    bodyHeight = window.document.body.offsetHeight;

    if (containerHeight < bodyHeight) {
        currentHeight = bodyHeight;
    } else {
        currentHeight = containerHeight;
    }
    if (document.location.search.match(/(client|nxs)=true/)) document.cookie = "xsell=true; path=/;domain=.mansioncasino.com";
    if (typeof(CONSTANTS.xsell_disabled) != "undefined" && CONSTANTS.xsell_disabled == "true") return false;

    var xSellCookie = readcookie("xsell");
    if (xSellCookie == "true") return;
    else {
        $("blocker").style.height = currentHeight + "px";
        $("blocker").style.display = '';

        if (CONSTANTS.xsell_link == "") {
            CONSTANTS.xsell_link = 'http://www.casino.com/?SID=152947';
        }
        if (CONSTANTS.xsellDownloadLink == "") {
            CONSTANTS.xsellDownloadLink = 'http://www.casino.com/?SID=152947';
        }

        $('xsell_title').innerHTML = CONSTANTS.xsellTitle;
        $('xsell_offer').innerHTML = CONSTANTS.xsellOffer;
        $('xsell_visit').innerHTML = CONSTANTS.xsellVisitURL;
        $('download_button').innerHTML = CONSTANTS.xsellDownloadTitle;

        $(popup).style.display = '';
        document.cookie = "xsell=true";
        $('xsell_iframe').src = "/xsell/gaxsell.html";
    }
}

function hideXsell(popup) {
	var iframe = document.getElementById('xsell_iframe').contentWindow; 
	iframe.sendpageview('exit');

    $("blocker").style.display = 'none';
    $(popup).style.display = 'none';
}

function goTo(target) {
	var iframe = document.getElementById('xsell_iframe').contentWindow; 

	if (target=='main') {
		iframe.sendpageview('main');
		location.href=CONSTANTS.xsell_link;
	}
	else {
		iframe.sendpageview('download');
		location.href=CONSTANTS.xsellDownloadLink;
	}
}

function cRefererObj( creferer ) {
	this.creferer = this.parse(creferer);
}

cRefererObj.prototype.parse = function ( creferer ) {
	var cret = new Object();
	if ( creferer !== '' && creferer !== '*' ) {
		var cref = unescape(creferer).split(';');
		for ( var idx in cref ) {
			var item = cref[idx].split(':',2);
			cret[item[0]] = item[1];
		}
	}
	return cret;
}

cRefererObj.prototype.add = function ( name, value ) {
	this.creferer[name] = value;
}

cRefererObj.prototype.get = function ( name ) {
	return ( typeof( this.creferer[name] ) == "string" ) ? this.creferer[name] : false;
}

cRefererObj.prototype.del = function ( name ) {
	delete this.creferer[name];
}

cRefererObj.prototype.toString = function ( ) {
	var cret = '';
	for ( var idx in this.creferer ) {
		cret = cret + idx + ':' + this.creferer[idx] + ';';
	}
	if ( cret.length > 0 ) {
		cret = cret.substr(0, cret.length - 1);
	}
	return cret;
}
