
function GetFCDomain() {

// now we are global we will be using this a lot

	this_location = document.location.toString();

	this_host = this_location.substring(this_location.indexOf('http://') + 7);

	this_host = this_host.substring(0,this_host.indexOf('/'));

	this_domain = this_host.substring(this_host.indexOf('.'));

	if(this_domain.indexOf(':') != -1) {		// yeah even works with port numbers

		this_domain = this_domain.substring(0,this_domain.indexOf(':'));
	}

	return(this_domain);	// it's prepended with a period for cookie use btw
}

current_domain = GetFCDomain();

if (current_domain == '.hotgames.com') {current_host = 'http://games.hotgames.com';}
else {current_host = 'http://www' + current_domain;}		// use this all over the place

my_date = new Date();
my_ord = my_date.getTime() % 1000000;


function SetFCRandom(fcrandom) {		// warez-busting cookie

	exp_time = my_date.getTime();
	var my_expiry = new Date(exp_time + 8640000);	// 24 hours

	document.cookie = 'rand=' + fcrandom + '; path=/; domain=' + current_domain + '; expires=' + my_expiry.toGMTString();

}


function DefineDefaultVars() {

// default variables for all sorts of things go here

	fcrandom = 'whatever';
        FCAdTagTarget = 'unclassified';
        GiveMePopups = 0;
	PopupTrellix = '';
        brmvars = '';

// those are global.  now set site-specific defaults.

	if (current_domain == '.fortunecity.com') {FCLanguage = 'en';FCResultsURL = 'English/';link1name = 'Featured Sites';link2href = current_host + '/join/join.html';link2name = '100MB free space';link3href = current_host + '/new/';link3name = 'What\'s New';}
	else if (current_domain == '.hotgames.com') {FCLanguage = 'en';FCResultsURL = 'English/';link1href = current_host;link1name = 'Got Games?';link2href = current_host + '/casino/';link2name = 'Casino';link3href = current_host + '/lotto/';link3name = 'Lotto';}
	else if (current_domain == '.fortunecity.de') {FCLanguage = 'de';FCResultsURL = 'German/';}
	else if (current_domain == '.fortunecity.fr') {FCLanguage = 'fr';FCResultsURL = 'French/';}
	else if (current_domain == '.fortunecity.se') {FCLanguage = 'se';FCResultsURL = 'Swedish/';}
	else if (current_domain == '.fortunecity.es') {FCLanguage = 'es';FCResultsURL = 'Spanish/';}
	else if (current_domain == '.fortunecity.it') {FCLanguage = 'it';FCResultsURL = 'Italian/';}
	else {FCLanguage = 'en';FCResultsURL = 'English/';}
}




function DisplayFCAdBanner() {

	if (current_domain != '.hotgames.com') {link1href = current_host + '/classification/topsites/'+ FCResultsURL;}

        document.write('<font size=-3><img src="' + current_host + '/banners/track1.gif" height=1 width=1% border="0" name="FCimg11bnr" hspace=0 vspace=0>');
        document.write('<img src="' + current_host + '/banners/foo.gif" height=1% width=1 border="0" name="FCimg12bnr" hspace=0 vspace=0><br clear=all></font>');

if((self.parent==self||((self.length==0)&&
        (document.images.FCimg11bnr.width>4)&&document.images.FCimg12bnr.height>2))) {

                FrameisBigEnough = 1;
        }

        else {FrameisBigEnough = 0;}

        if(FrameisBigEnough == 1) {

                if ((parent.TlxPgNm != null || (top.frames[1] != null && top.frames[1].TlxPgNm != null)) || (document.isTrellix == 1)) {

                        document.write('<font size=-3><img src="' + current_host + '/banners/trackt.gif?' + document.location + '&ord=' + my_ord + '" height=1 width=1% border="0" name="FCimg11bnr" hspace=0 vspace=0>'); 

			FCLanguage = 'tlx';
			PopupTrellix = '?tlx';
                }


                if (GiveMePopups == 0) {


			if (FCLanguage == 'ad') {		// no logos on porno sites

				var fc_brand = '';
			}


			else {

				var fc_brand = '<tr><td colspan=5><table cellpadding=0 cellspacing=0 border=0><tr><td><img src="' + current_host + '/images/spacer.gif" height=2></td><td width=174><a href="' + current_host + '" target="_new"><img src="' + current_host + '/images/fclogo_inline.gif" height=15 width=122 border=0></a></td><td width=140><a href="' + link1href +'" target="_new"><font face="Verdana, Helvetica, Arial, sans-serif" size=2>' + link1name + '</font></a></td><td width=140><a href="' + link2href + '" target="_new"><font face="Verdana, Helvetica, Arial, sans-serif" size=2>' + link2name + '</font></a></td><td width=140><a href="' + link3href + '" target="_new"><font face="Verdana, Helvetica, Arial, sans-serif" size=2>' + link3name + '</font></a></td></tr>';

			}


                        var my_chunk = '<center><table cellpadding=0 cellspacing=0 border=0><tr><td colspan=5><img src="' + current_host + '/images/spacer.gif" height=2></td></tr><tr><td><img src="' + current_host + '/images/spacer.gif" height=60 width=2></td><td><iframe src="http://ads.fortunecity.com/RealMedia/ads/adstream_sx.ads/' + FCLanguage + '/m_' + FCAdTagTarget + '/' + my_ord + '@Top" width="468" height="60" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"><a target="fcadwin" href="http://204.198.135.79/RealMedia/ads/click_nx.cgi/' + FCLanguage + '/m_' + FCAdTagTarget +'/' + my_ord + '@Top"><img src="http://204.198.135.79/RealMedia/ads/adstream_nx.cgi/' + FCLanguage + '/m_' + FCAdTagTarget + '/' + my_ord + '@Top" border=0 height="60" width="468"></a></iframe></td><td><img src="' + current_host + '/images/spacer.gif" height=60 width=4></td><td><iframe src="http://ads.fortunecity.com/RealMedia/ads/adstream_sx.ads/' + FCLanguage + '/m_' + FCAdTagTarget +'/' + my_ord + '@x02" width="120" height="60" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"><a target="fcadwin" href="http://204.198.135.79/RealMedia/ads/click_nx.cgi/' + FCLanguage + '/m_' + FCAdTagTarget +'/' + my_ord + '@x02"><img src="http://204.198.135.79/RealMedia/ads/adstream_nx.cgi/' + FCLanguage + '/m_' + FCAdTagTarget +'/' + my_ord + '@x02" border=0 height="60" width="120"></a></iframe></td><td><img src="' + current_host + '/images/spacer.gif" height=60 width=2></td></tr>' + fc_brand + '</table></td></tr></table></center>';

                        document.write(my_chunk);
                }

                else {

                        window.open(current_host + '/classification/topsites/' + FCResultsURL + 'fcpopup.html' + PopupTrellix,'fcpopup','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=598,height=110,left=0,top=0,screenX=0,screenY=0');

                }

		DisplayBRM(0);		// insert any BRM stuff with a placement of 0 (top-of-page)

        }
}

        

// now let's handle the top5 popup

var showpopup = 0;

if (document.referrer.indexOf(this_domain) == -1 && (!(document.referrer == null))){

        showpopup = 1;
}

if (document.referrer == '') {showpopup = 0;}  // weird kludge for 'view' from File Manager


if (navigator.appVersion.indexOf('MSIE') != -1 && navigator.appVersion.indexOf('Macintosh') != -1) {

                showpopup = 0;         // damn crappy IE/Mac
}



function MyExtendOnClick() {

        if (this.host.indexOf(this_domain) != -1) {

                showpopup = 0;
        }               

        else {

                showpopup = 1;
        }


        if (this.my_onclick != null) {

                this.my_onclick();
        }
}


function setonclickmethods() {

        if (navigator.appVersion.indexOf('MSIE') != -1 && navigator.appVersion.indexOf('Macintosh') != -1) {

                return;         // totally sucky
        }

        for(i = 0; i < document.links.length; i++) {

                document.links[i].my_onclick = document.links[i].onclick;
        
                document.links[i].onclick = MyExtendOnClick;
        }
}


function spawntopfivewindow() {

if (showpopup == 1 && FrameisBigEnough == 1 && IsFCMember() == 0) {

	exit_popup = current_host + '/classification/topsites/' + FCResultsURL + 'top5.html';

	if (document.location.toString().indexOf('members.hotgames.com') != -1) {		// unless it's members.hotgames.com

		exit_popup = 'http://games.hotgames.com/classification/topsites/hotgames.exitpopup.html';
	}

window.open(exit_popup,'top5popup','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=300,height=220,left=0,top=0,screenX=0,screenY=0');

        }
}


// handle the BRM stuff


function DisplayBRM(brmparam) {

	if(brmvars != '' && (document.location.toString().toLowerCase().indexOf('index.htm') != -1 || document.location.toString().substring(document.location.toString().length -1) == '/')) {

//	index.html and index.htm only


		var brmarray = new Array();

		brmcopy = brmvars;

		brmoffsetcount = 0;			// controls placement of popup

		brmarrayloop = 0;

		while (brmcopy.indexOf(';') != -1) {	// keep looping

			brmarray[brmarrayloop] = brmcopy.substring(0,brmcopy.indexOf(';'));
				
			brmarrayloop++;
	
			brmcopy = brmcopy.substring(brmcopy.indexOf(';') + 1);
		}

		for(brmcount = 0; brmcount < brmarrayloop; brmcount++) {

			var brmdata = new Array();

			for(brmsplit = 0; brmsplit < 4; brmsplit++) {

				brmdata[brmsplit] = brmarray[brmcount].substring(0,brmarray[brmcount].indexOf(','));
				brmarray[brmcount] = brmarray[brmcount].substring(brmarray[brmcount].indexOf(',') + 1);
			}

			// see if it's centered

			drawcentered = brmarray[brmcount];

			// now draw the iframes, whatever

			if(brmdata[1] == brmparam && (brmparam == 0 || brmparam == 1)) { 

// intended for this placement and placement is top-of-page or bottom-of-page

				


// add centering if set up in parameter list and browser supports it without bitching

				if(navigator.appVersion.indexOf('MSIE') != -1) {

					var BRMOut = '<iframe width="' + brmdata[2] + '" height="' + brmdata[3] + '" src="' + brmdata[0] + '" frameborder="no"  scrolling="no"></iframe>';

					if(drawcentered == 0) {

						BRMOut = '<td align="left">' + BRMOut;
					}
				
					else if(drawcentered == 1) {

						BRMOut = '<td align="center">' + BRMOut;
					}

					else {

						BRMOut = '<td align="right">' + BRMOut;
					}

					BRMOut = '<p><table width="100%" border="0"><tr>' + BRMOut;
					BRMOut = BRMOut + '</td></tr></table></p>';
				}

				else {		// Netscrape sucks


					var BRMOut = '<p><ilayer width="' + brmdata[2] + '" height="' + brmdata[3] + '" src="' + brmdata[0] + '"></ilayer></p>';

				}

				document.write(BRMOut);
			}

			else if(brmdata[1] == 2 && brmparam == 1) {

// draw the popup placements as part of the DisplayBRM(1) call: therefore only once

// need a unique window name

				brmpopupname = 'brmpopupname' + brmcount.toString();
// cascade the things

				brmoffset = 0 + (100 * brmoffsetcount);
				brmoffstring = brmoffset.toString();
				brmoffsetcount++;

window.open(brmdata[0],brmpopupname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + brmdata[2] + ',height=' + brmdata[3] +',left=' + brmoffstring + ',top=' + brmoffstring + ',screenX=' + brmoffstring + ',screenY=' + brmoffstring);

			}

			else if((brmdata[1] == 3 && brmparam == 0) || (brmdata[1] == 4 && brmparam == 1)) {

// top-of-page and bottom-of-page Javascript embeds

				var BRMOut = '<script language="Javascript" src="' + brmdata[0] + '"></script>';

				document.write(BRMOut);
			}
		}
	}

	return;
}



