function Download_Track(btag, ul, offerid, linkid, pageid, pageurl, omnitureid, casinoid) {
    var url = "download.casino?file_name=7Sultans.exe&ul=" + ul + "&offerid=" + offerid + "&linkid=" + linkid + "&pageid=" + pageid + "&pageurl=" + pageurl + "&omnitureid=" + omnitureid + "&casinoid=" + casinoid + "&banner_tag=" + btag;
    window.open(url, '', 'width=10,height=10');
}

function GamePreview(GameType) {
    window.open("/launch_new/?gameid=" + GameType + "", "GamePreview", "scrollbars=yes, resizable=no, width=780, height=570");
    return false;
}
function downloadCasino(btag) {
    parent.window.opener.location.replace("/downloadh");
    window.open('/download/download.asp?banner_tag=' + btag + '&file_name=7Sultans.exe&ul=en', 'download', 'width=5,height=5');
    parent.window.close();
}

function chatpopup(lang) {
    window.open("https://chat.casinodesk.com/webchat/chatform" + lang + ".asp", "Chat", "width=400, height=410, border=2, scrollbars=no, resizable=no");
}

function tournamentpop() {
    window.open("http://www.fortunelounge.eu/tournamentpop.asp?BTag=" + btag + "", "tournament", "width=570,height=399,scrollbars=yes,resizable=no")
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_findObj(n, d) { //v3.0
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function LiveChat() {
    window.open("http://chat.casinodesk.com/chatframe.php?clientid=1&deptid=2", "LiveChat", "width=550,height=300, scrollbars=no, resizable=no");
}

function PreloadContent() {
    if (document.getElementById('theContentLayer') == null) {
    }
    else {
        document.getElementById('theContentLayer').style.visibility = "visible";
    }
}

function closeWin() {
    parent.document.getElementById('theContentLayer').style.visibility = "hidden";
}
function bonus() {
    window.open("/bonus_popup", "Bonus", "width=600,height=200,resizable=yes, scrollbars=no");
}

function SignUpOffers() {
    window.open("/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}
function SignUpOffersDE() {
    window.open("/de/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}
function SignUpOffersES() {
    window.open("/es/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}
function SignUpOffersFR() {
    window.open("/fr/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}
function SignUpOffersEL() {
    window.open("/el/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}
function SignUpOffersIT() {
    window.open("/IT/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}
function SignUpOffersPT() {
    window.open("/PT/termsofferpop", "TermsOffer", "width=480,height=300,scrollbars=yes");
}

function PromoTermsSpecial() {
    window.open("/promotermsspecial", "PromoTermsSpecial", "width=590,height=500, scrollbars=yes, resizable=no");
}

function PromoTermsEco() {
    window.open("/promotermseco", "PromoTermsEco", "width=590,height=500, scrollbars=yes, resizable=no");
}
function PromoTermsEntro() {
    window.open("/promotermsentropay", "PromoTermsEco", "width=590,height=500, scrollbars=yes, resizable=no");
}
function PromoTermsFire() {
    window.open("promotermsfire", "PromoTermsFire", "width=590,height=400, scrollbars=yes, resizable=no");
}

function PromoTermsNet() {
    window.open("/promotermsnet", "PromoTermsNet", "width=590,height=420, scrollbars=yes, resizable=no");
}

function PromoTermsClick() {
    window.open("/promotermsclick", "PromoTermsClick", "width=590,height=400, scrollbars=yes, resizable=no");
}

function pop(btag) {
    window.open("http://www.fortunelounge.eu/cashin1.asp?btag=" + btag + "", "cashin", "width=570,height=390,scrollbars=no,resizable=no")
}


function selfassess() {
    window.open("/selfassesment", "SelfAssess", "width=500,height=550, scrollbars=yes, resizable=no");
}

function check_form(btag) {
    
    var emailaddress = document.getElementById('ctl00_ctl00_maincontent_derivedmaincontent_tbemail');
    if (emailaddress.value.length < 1) {
        alert("Please supply an email address");
        emailaddress.focus();
        return false;
    }
    goodEmail = emailaddress.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
    if (!goodEmail) {
        alert('Please enter a valid e-mail address.')
        emailaddress.focus()
        emailaddress.select()
        return false;
    }
    else {
        window.open('/download/download.asp?banner_tag=' + btag + '&file_name=7sultans.exe&ul=en', 'download', 'width=5,height=5');
        return true;
     }
}

//EMAIL VALIDATION
function emailCheck(emailStr, displaySpan) {
    var emailPat = /^(.+)@(.+)$/;
    var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
    var validChars = "\[^\\s" + specialChars + "\]";
    var quotedUser = "(\"[^\"]*\")";
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$");


    var matchArray = emailStr.match(emailPat);
    if (matchArray == null) {
        displaySpan.innerHTML = 'Please enter a valid e-mail address.';
        return false;
    }

    var user = matchArray[1]
    var domain = matchArray[2]

    if (user.match(userPat) == null) {
        displaySpan.innerHTML = 'Please enter a valid e-mail address.';
        return false;
    }

    var IPArray = domain.match(ipDomainPat)
    if (IPArray != null) {
        for (var i = 1; i <= 4; i++) {
            if (IPArray[i] > 255) {
                displaySpan.innerHTML = 'Please enter a valid e-mail address.';
                return false;
            }
        }
        return true;
    }


    var domainArray = domain.match(domainPat)
    if (domainArray == null) {
        displaySpan.innerHTML = 'Please enter a valid e-mail address.';
        return false;
    }

    var atomPat = new RegExp(atom, "g")
    var domArr = domain.match(atomPat)
    var len = domArr.length
    if (domArr[domArr.length - 1].length < 2 ||
        domArr[domArr.length - 1].length > 6) {
        // the address must end in a two letter or other TLD including museum
        displaySpan.innerHTML = 'Please enter a valid e-mail address.';
        return false;
    }

    // Make sure there's a host name preceding the domain.
    if (len < 2) {
        displaySpan.innerHTML = 'Please enter a valid e-mail address.';
        return false;
    }

    return true;
}

//EMAIL VALIDATION
function emailAlertCheck(emailStr) {
    var emailPat = /^(.+)@(.+)$/;
    var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
    var validChars = "\[^\\s" + specialChars + "\]";
    var quotedUser = "(\"[^\"]*\")";
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$");


    var matchArray = emailStr.match(emailPat);
    if (matchArray == null) {
        alert('Please enter a valid e-mail address.');
        return false;
    }

    var user = matchArray[1]
    var domain = matchArray[2]

    if (user.match(userPat) == null) {
        alert('Please enter a valid e-mail address.');
        return false;
    }

    var IPArray = domain.match(ipDomainPat)
    if (IPArray != null) {
        for (var i = 1; i <= 4; i++) {
            if (IPArray[i] > 255) {
                alert('Please enter a valid e-mail address.');
                return false;
            }
        }
        return true;
    }


    var domainArray = domain.match(domainPat)
    if (domainArray == null) {
        alert('Please enter a valid e-mail address.');
        return false;
    }

    var atomPat = new RegExp(atom, "g")
    var domArr = domain.match(atomPat)
    var len = domArr.length
    if (domArr[domArr.length - 1].length < 2 ||
        domArr[domArr.length - 1].length > 6) {
        // the address must end in a two letter or other TLD including museum
        alert('Please enter a valid e-mail address.');
        return false;
    }

    // Make sure there's a host name preceding the domain.
    if (len < 2) {
        alert('Please enter a valid e-mail address.');
        return false;
    }

    return true;
}

function popup(mylink, windowname)

{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=250,height=350,scrollbars=no');
return false;
}


function openSupportPopupByLanguage(mailtype, lang) {
	if (lang == "en" || lang == "uk") 
	{
		var new_win = window.open("/contactform/?MailType=" + mailtype, "Email_7Sultans", "width=290,height=400,directories=no,toolbar=no,resizable=yes,location=no,menubar=no,status=no,scrollbars=no");
	}
	else
	{
		var new_win = window.open("/"+lang+"/contactform/?MailType=" + mailtype, "Email_7Sultans", "width=290,height=400,directories=no,toolbar=no,resizable=yes,location=no,menubar=no,status=no,scrollbars=no");
	}    
}

function openSupportPopupByLanguageFloor(mailtype, lang)
{
	var new_win = window.open("/"+lang+"/contactformfloormanager/?MailType=" + mailtype, "Email_7Sultans", "width=290,height=400,directories=no,toolbar=no,resizable=yes,location=no,menubar=no,status=no,scrollbars=no");
}

