function ddshow(n, type) {
	ddhideAll();
	var name_gif = n + '_gif';
	var name_swf = n + '_swf';
	var e_gif = document.getElementById(name_gif);
	var e_swf = document.getElementById(name_swf);
	if (type == 'gif') {
		e_gif.style.visibility = "visible";
		e_gif.style.display = "block";
		e_swf.style.visibility = "hidden";
		e_swf.style.display = "none";
	} else {
		e_gif.style.visibility = "hidden";
		e_gif.style.display = "none";
		e_swf.style.visibility = "visible";
		e_swf.style.display = "block";
	}
}
function ddhide(n) {
	var e = document.getElementById(n);
	e.style.visibility = "hidden";
	e.style.display = "none";
}
function ddhideAll() {
	all = new Array;
	all[0] = 'banner120x60_gif';
	all[1] = 'banner120x60_swf';
	all[2] = 'banner120x60r_gif';
	all[3] = 'banner120x60r_swf';
	all[4] = 'banner120x120_gif';
	all[5] = 'banner120x120_swf';
	all[6] = 'banner120x120r_gif';
	all[7] = 'banner120x120r_swf';
	all[8] = 'banner125x125_gif';
	all[9] = 'banner125x125_swf';
	all[10] = 'banner125x125r_gif';
	all[11] = 'banner125x125r_swf';
	all[12] = 'banner468x60_gif';
	all[13] = 'banner468x60_swf';
	all[14] = 'banner468x60r_gif';
	all[15] = 'banner468x60r_swf';

	all[16] = 'banner120x60_02_gif';
	all[17] = 'banner120x60_02_swf';
	all[18] = 'banner120x60r_02_gif';
	all[19] = 'banner120x60r_02_swf';
	all[20] = 'banner120x120_02_gif';
	all[21] = 'banner120x120_02_swf';
	all[22] = 'banner120x120r_02_gif';
	all[23] = 'banner120x120r_02_swf';
	all[24] = 'banner125x125_02_gif';
	all[25] = 'banner125x125_02_swf';
	all[26] = 'banner125x125r_02_gif';
	all[27] = 'banner125x125r_02_swf';
	all[28] = 'banner468x60_02_gif';
	all[29] = 'banner468x60_02_swf';
	all[30] = 'banner468x60r_02_gif';
	all[31] = 'banner468x60r_02_swf';

	all[32] = 'banner120x60_03_gif';
	all[33] = 'banner120x60_03_swf';
	all[34] = 'banner120x60r_03_gif';
	all[35] = 'banner120x60r_03_swf';
	all[36] = 'banner120x120_03_gif';
	all[37] = 'banner120x120_03_swf';
	all[38] = 'banner120x120r_03_gif';
	all[39] = 'banner120x120r_03_swf';
	all[40] = 'banner125x125_03_gif';
	all[41] = 'banner125x125_03_swf';
	all[42] = 'banner125x125r_03_gif';
	all[43] = 'banner125x125r_03_swf';
	all[44] = 'banner468x60_03_gif';
	all[45] = 'banner468x60_03_swf';
	all[46] = 'banner468x60r_03_gif';
	all[47] = 'banner468x60r_03_swf';

	// allength = all.length - 1;
	allength = all.length;

	for (i = 0; i < allength; i++) {
		var eall = document.getElementById(all[i]);
		eall.style.visibility = "hidden";
		eall.style.display = "none";
	}
}

/* forms */
function dE(n, s, type) {
	if (!type) {
		type = 'block';
	}
	var e = document.getElementById(n);
	if (!s) {
		s = (e.style.display == '') ? -1 : 1;
	}
	e.style.display = (s == 1) ? type : 'none';
}

function roll_select(n) {
	var e = document.getElementById(n);
	s = e.style.display;
	if (s == 'block') {
		e.style.display = 'none';
	} else {
		e.style.display = 'block';
	}
}

function calculate(frm) {
	if (!frm) {
		return false;
	}
	var players = parseInt(frm.players.value);
	var affiliates = parseInt(frm.affiliates.value);
	var bet = parseFloat(frm.bet.value);
	var affl1 = parseFloat(frm.affilL1.value);
	var affl2 = parseFloat(frm.affilL2.value);
	affl1 = affl1 / 100;
	affl2 = affl2 / 100;

	if (isNaN(players)) {
		alert("Please enter valid players amount");
		frm.players.focus();
		return false;
	}

	if (isNaN(affiliates)) {
		alert("Please enter valid affiliates amount");
		frm.affiliates.focus();
		return false;
	}

	if (isNaN(bet)) {
		alert("Please enter valid average bet");
		frm.bet.focus();
		return false;
	}

	/* players */
	var l1players = players;
	var l2players = l1players * affiliates;
	var total_players = l1players + l2players;
	$('l1players').innerHTML = l1players;
	$('l2players').innerHTML = l2players;
	$('total_players').innerHTML = total_players;

	/* income */
	var l1income = l1players * bet * affl1;
	var l2income = l2players * bet * affl2;
	var total_income = l1income + l2income;
	$('l1income').innerHTML = '$ ' + l1income;
	$('l2income').innerHTML = '$ ' + l2income;
	$('total_income').innerHTML = '$ ' + total_income;

	/* affiliates */
	var l1affiliates = affiliates;
	var l2affiliates = 'N/A';
	var total_affiliates = l1affiliates;
	$('l1affiliates').innerHTML = l1affiliates;
	$('l2affiliates').innerHTML = l2affiliates;
	$('total_affiliates').innerHTML = total_affiliates;
}

change_lang = function(lang_id) {
	document.cookie = 'lang=' + lang_id + '; expires=Mon, 3 Jan 2050 00:00:00 UTC;; path=/ ';
	window.location.reload();
}