/*window.onload = function() {
	doMenu();
}*/
YAHOO.util.Event.on(window,'load',doMenu,"",true);

function pass_link_tabs(site, page_type, site_name, promo){
	//Get cookie
	var cookie_src = getCookie("src_cd");
	
	// If cookie is NULL, fill it woth nothing so we don't get "/index.shtml?undefined", else add a "?"
	var cookie_src=(cookie_src)? cookie_src : "";
	
	if (cookie_src) {
		// We need to make sure we are only passing in affiliates
		// If pipe is found, we need to split to get src_cd
		if (cookie_src.indexOf("|")!= -1) {
			all_cookie = cookie_src.split("|");
			//If length of src cd is < 6, make src code null
			cookie_src = (all_cookie[0].length < 6) ? "" : cookie_src;
		}
		// No pipe - just test length of src_cd
		else if (cookie_src.length < 6){
			cookie_src="";
		}
		// Add "?" if redirecting with source code 
		cookie_src = (cookie_src != "") ? "?" + cookie_src : cookie_src;
	}
	//And then redirect =
	window.location.href = "http://" + site + "/index." + page_type + cookie_src;

}

function getCookie(Name) {   	

	var search = Name + "="   

	if (document.cookie.length > 0) { 
	
	// if there are any cookies      
	offset = document.cookie.indexOf(search)       

	if (offset != -1) { 
		// if cookie exists          
		offset += search.length          
		// set index of beginning of value         
		end = document.cookie.indexOf(";", offset)          
		// set index of end of cookie value         
		if (end == -1)             
			end = document.cookie.length         
			return unescape(document.cookie.substring(offset, end))      
		}    
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//depending upon the page, highlight the correct sub menu item
//each page has a hiMenuID which matches the sub menu id.
function doMenu()
{
	var Menu = document.getElementById ? document.getElementById(MenuID) : document.all ? document.all[MenuID] : null;
	if(Menu) Menu.className = 'currentnav';
	
	var subMenu = document.getElementById ? document.getElementById(subMenuID) : document.all ? document.all[subMenuID] : null;
	if(subMenu) subMenu.className = 'currentsubnav';
}

/*
//////////////////////////////////////////
//      Random Images on Home Page		//
//////////////////////////////////////////

//image path
var path = "/images/logos/home/"; 

var goodies = new Array();

//Array containing file addresses & links. Outside function!
goodies [0] = "<a href='/cgi-bin/member.pl'><img src='" + path + "10sorbetter.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [1] = "<a href='/cgi-bin/member.pl'><img src='" + path + "a_roulette.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [2] = "<a href='/cgi-bin/member.pl'><img src='" + path + "aladdin.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [3] = "<a href='/cgi-bin/member.pl'><img src='" + path + "allamerican.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [4] = "<a href='/cgi-bin/member.pl'><img src='" + path + "baccarat.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [5] = "<a href='/cgi-bin/member.pl'><img src='" + path + "blackjack.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [6] = "<a href='/cgi-bin/member.pl'><img src='" + path + "bucaneer.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [7] = "<a href='/cgi-bin/member.pl'><img src='" + path + "deuceswild.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [8] = "<a href='/cgi-bin/member.pl'><img src='" + path + "doublebonus.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [9] = "<a href='/cgi-bin/member.pl'><img src='" + path + "e_roulette.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [10] = "<a href='/cgi-bin/member.pl'><img src='" + path + "flowerpower.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [11] = "<a href='/cgi-bin/member.pl'><img src='" + path + "forbiddenfruits.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [12] = "<a href='/cgi-bin/member.pl'><img src='" + path + "galactic.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [13] = "<a href='/cgi-bin/member.pl'><img src='" + path + "highnoon.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [14] = "<a href='/cgi-bin/member.pl'><img src='" + path + "jacksorbetter.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [15] = "<a href='/cgi-bin/member.pl'><img src='" + path + "jokerpoker.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [16] = "<a href='/cgi-bin/member.pl'><img src='" + path + "lucky7s.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [17] = "<a href='/cgi-bin/member.pl'><img src='" + path + "reelinthecash.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [18] = "<a href='/cgi-bin/member.pl'><img src='" + path + "safecracker.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [19] = "<a href='/cgi-bin/member.pl'><img src='" + path + "shootorama.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [20] = "<a href='/cgi-bin/member.pl'><img src='" + path + "sphinzhijinx.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [21] = "<a href='/cgi-bin/member.pl'><img src='" + path + "sphinzhijinx.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [22] = "<a href='/cgi-bin/member.pl'><img src='" + path + "superjackpot.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [23] = "<a href='/cgi-bin/member.pl'><img src='" + path + "superjackpot_25c.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [24] = "<a href='/cgi-bin/member.pl'><img src='" + path + "tripleoloves.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";
goodies [25] = "<a href='/cgi-bin/member.pl'><img src='" + path + "tripleoloves_25c.gif' border='0' alt='Click Here to play over 20 of the best casino games on the internet, for FREE!' /></a>";




function mod_write (number_of_mods, page_id) {
	
//	Function writes InterBingo Modules to the screen based on the number
//	passed in when the function is called
 
		
	//Stop request for too many modules 
	if (number_of_mods > goodies.length) {
		number_of_mods = 1;
	}
	
	var rand;
	
	//Begin loop 
	for (b=1; b<=number_of_mods; b++) {
		
		//generate a random No. for splicing
		rand = Math.floor(Math.random() * goodies.length);
		
		//Use below code template for page specific code
		
		//if (page_id == "home") {
		//	while (goodies[rand].indexOf("match") != -1) {  
			//	rand = Math.floor(Math.random() * goodies.length);
			//}
		//}
		//write random image to screen
		//alert(goodies[rand]);
		document.write (goodies[rand]);// + align 
		
		//delete random iomage from array so cannot be repeated
		goodies.splice(rand, 1);
	}
}

/////////////////////////////////////////////////////////////
*/

/* This function takes in a game id and gametype param (flash /java)
and determines if the user is logged in. If they are, it writes a game link, otherwise
it writes a link to the register page */

function play_or_reg (gametype, gameid) {
	if (document.cookie.indexOf("logged_in") != -1) {
		// LOGGED IN
		var cookie= document.cookie;
		//get name and email from cookie to put into game URL
		var username = cookie.substr(cookie.indexOf("username=")+9,cookie.indexOf("logged_in")-11);
		var email = cookie.substr(cookie.indexOf("email=")+6);
		
		//Write game url to page, with gameid, gametype, email and username
		document.write("<a href=\"http://www.datablade.com/cgi-bin/software.html/82262/InterCasinoDeutschlandInstall.exe\">Zum Spielen</a>");
		//alert("<a href=\"#\" onclick=\"MM_openBrWindow('http://practice.ifunds.com/C2/00/instant_" + gametype + ".ehtml?Alias=" + username + "&Email=" + email + "&GameID=" + gameid + "&BrandID=C2','','width=600,height=500')\">Zum Spielen anklicken</a>");

	}
	else {
		//NOT LOGGED IN
		document.write("<a href='/cgi-bin/member.pl'>Zum Spielen</a>");
	}
}

// Same as above but for images. We dont want the txt...
function play_or_reg_img (gametype, gameid) {
	if (document.cookie.indexOf("logged_in") != -1) {
		// LOGGED IN
		var cookie = document.cookie;
		//get name and email from cookie to put into game URL
		var username = cookie.substr(cookie.indexOf("username=")+9,cookie.indexOf("logged_in")-11);
		var email = cookie.substr(cookie.indexOf("email=")+6);
		
		//Write game url to page, with gameid, gametype, email and username
		document.write("<a href=\"http://www.datablade.com/cgi-bin/software.html/82262/InterCasinoDeutschlandInstall.exe\">");
		//alert("<a href=\"#\" onclick=\"MM_openBrWindow('http://practice.ifunds.com/C2/00/instant_" + gametype + ".ehtml?Alias=" + username + "&Email=" + email + "&GameID=" + gameid + "&BrandID=C2','','width=600,height=500')\">Zum Spielen anklicken</a>");
	}
	else {
		//NOT LOGGED IN
		document.write("<a href='/cgi-bin/member.pl'>");
	}
}

//Close A tag for image. Messy but neccessary....
function img_close() {
	document.write("</a>");
}

function write_image(url) {
	var input = new String(url);
	var rExp = /intercasino\.tv/;

	var matchResultat = input.match(rExp);
	if (matchResultat != null) {
		// THIS IS .TV
		document.write('<a href="/cgi-bin/member.pl"><img src="/images/dottv_home_header.jpg" border="0" width="619" height="137" alt="InterCasino - Play for Fun Casino"></a>');
	}
	else {
		//THIS IS .NET
		document.write('<a href="/cgi-bin/member.pl"><img src="/images/home_middle2.jpg" border="0" alt="Interasino - Play for Fun Casino"></a>');
	}
}
function write_image_internal(url) {
	var input = new String(url);
	var rExp = /intercasino\.tv/;

	var matchResultat = input.match(rExp);
	if (matchResultat != null) {
		// THIS IS .TV
		document.write('<img src="/images/dottv_int_header.jpg" width="408" height="47">');
	}
	else {
		//THIS IS .NET
		document.write('<img src="/images/internal_head_right.jpg" width="408" height="47">');
	}
}


function write_me(html) {
	document.write(html);	
}

function write_me_check_flash(html,alternate) {
	if (flash.version >= "6") {
			document.write(html);
	} else {
			document.write(alternate);
	}
}

/* FLASH DETECTION */
var versions = 10;

var flash = new Object();
flash.installed=false;
flash.version='0.0';



// FOR IE
if (window.ActiveXObject) {
	for (i = 2; i <= versions; i++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + i + "');");
			if(oFlash) {
				flash.installed = true;
				flash.version = i + '.0';
			}
		}
		catch(e) {}
	}
}

//FOR NETSCAPE
else if (navigator.plugins && navigator.plugins.length) {
	for (i=0; i < navigator.plugins.length; i++) {
		if (navigator.plugins[i].name.indexOf('Shockwave Flash') != -1) {
			flash.version = navigator.plugins[i].description.split('Shockwave Flash ')[1];
			flash.installed = true;
			break;
		}
	}
}