// JavaScript Document
var last_one=null
function show_div(new_one){
	if (last_one!=null && last_one!="nothing")	{
		document.getElementById(last_one).style.visibility='hidden';
	}
	if (new_one!=null && new_one!="nothing")	{
		document.getElementById(new_one).style.visibility='visible';
	}
	last_one=new_one;
}

function change_continent(){
	var continent_sel = document.getElementById("continent").value;
	document.getElementById('country').length=0;
	document.getElementById('country').options[0] = new Option('Select Country', '#');
	i=1;
	if(continent_sel!='#'){
		//only countries of these continent
		for( var country in arrCountries ) {
			if(arrCountries[country]['continent_id'] == continent_sel){
				document.getElementById('country').options[i] = new Option(arrCountries[country]['country_name'], country);
				i++;
			}
		}
	}else{
		//all countries
		arrCountries.sort(cmd); 
		for( var country in arrCountries ) {
			document.getElementById('country').options[i] = new Option(arrCountries[country]['country_name'], country);
			i++;
		}
	}
}

function cmd(x,y) {
	if ( x['country_name'] < y['country_name'] ) return -1; 
	if ( x['country_name'] > y['country_name'] ) return 1; 
	return 0; 
}

function  change_country(){
	var continent_sel 	= document.getElementById("continent").value;
	var country_sel		= document.getElementById("country").value;
/*	var namecont = arrContinents[continent_sel]['cont_name'];
	namecont = namecont.toLowerCase();
	namecont = namecont.replace(' ','');
	show_div(namecont);
	document.getElementById(namecont).style.top="200px";
*/	
	var styleClass = "position:absolute; left:122; top:-150px;visibility:visible;";
	var titleName = arrContinents[continent_sel]['cont_name'];
	var div_to_show ="<div id=divshow  style=\""+styleClass+"\"  " + 
             			 " onmouseover=\"document.getElementById('divshow').style.visibility='visible'\" " +
            			  "onmouseout=\"document.getElementById('divshow').style.visibility='hidden'\">" +
						"<table cellpadding=1 cellspacing=0 border=0 bordercolor=\"#DB7201\" bgcolor=\"#96B2F6\" width=400px >" +
							"<tr bgcolor=\"#96B2F6\" > " +
							"<td align=\"left\" class=\"text\" style=\"color:##000D6B;font-weight:bold;\" height=17>" +
								titleName + "</td></tr></table>";
					
					div_to_show +="<table class=\"DivBorder\" cellpadding=1 cellspacing=0 bgcolor=\"#FEF8E1\" width=\"400px \" > "+
								"<tr>"+
									"<td valign=\"top\"  width=\"100%\" style=\"border-right:none;\" > "+
										"<table width = \"100%\" cellpadding=1 cellspacing=0 border=0 >"+
											"<tr bgcolor=\"#96B2F6\" > "+
												"<td align=\"center\" class=\"tableheader\" height=\"17\" style=\"font-weight:bold;padding-left:3px\" width=\"80px\" > Country </td> "+
												"<td align=\"center\" class=\"tableheader\" height=\"17\" style=\"font-weight:bold;padding-left:3px\" width=\"120px\"> Lottery </td>"+
												"<td align=\"center\" class=\"tableheader\" height=\"17\" style=\"font-weight:bold;\" > Jackpot </td>"+
												" </tr></table>" ;
						div_to_show += "<table id=\"tbl1\" tabindex=1 cellspacing=1 cellpadding=0 width=400 border=0 class=\"body\">"+
										  "<tbody>";
	for( var draw in arrLottosInfo){
			if(arrLottosInfo[draw]['country_id'] == country_sel){
				//alert(arrLotteries[arrLottosInfo[draw]['lot_id']]['lot_name']);
				 div_to_show += "<tr onMouseOver=\"this.style.cursor='pointer';this.style.backgroundColor='#FFEEA6'\" style=\"BACKGROUND-COLOR: #f4f6fb\" onClick=\"location.href ='playlotto.php?draw_id="+draw+"'\"  onMouseOut=\"this.style.backgroundColor='#F4F6FB'\">"+
									"<td class=textsmaller id=countryname style=\"padding-left: 5px\" align=left width=100 height=17>"+arrRegions[arrLottosInfo[draw]['reg_id']]['reg_name']+"</td>"+
									"<td class=textsmaller id=namesite style=\"padding-left: 5px\"	align=left width=150 height=17>"+arrLotteries[arrLottosInfo[draw]['lot_id']]['lot_name']+"</td>"+
									"<td width=\"117\" height=17 align=right id=jackpot style=\"padding-right: 4px; width: 110px\">"+arrLottosInfo[draw]['jackpot']+"</td>"+
								"</tr>";
			}
	
	}
	div_to_show += "					</tbody></table></tr> </table></div>";
	//alert(div_to_show);
	document.getElementById("lottery").innerHTML = div_to_show;
	//document.getElementById("lottery").style.visibility='visible';
	if (last_one!=null && last_one!='divshow'){
		document.getElementById(last_one).style.visibility='hidden';
	}
	last_one='divshow';
}
