//window.onload = chat_general;
var general_chat_timer;
function chat_general(){	
	general_chat_timer = setTimeout(chat_g_send_mess,5000);
}


function rightToggle(id){
	$(id).toggle();
	$('link_'+id).toggle();
}

function confirm_delete(text, p_url){
	if(confirm(text)){
		document.location = p_url;
	}
}

function leftToggle(id){
	$(id).toggle();
}

function toggleStatus(id, obj){
	var objImg = Element.extend(obj);
	objImg = objImg.childElements();
	objImg = objImg[0];
	//objImg.src = (objImg.src.indexOf("add") > 0)?"images/remove.png":"images/add.png";
	objImg.src = (objImg.src.indexOf("1") > 0)?"images/sageata2.jpg":"images/sageata1.jpg";
	$(id).toggle();
	
}


function formatValue(value, format){
	if(format == "")
		format = "$ ###.###.###.###";
	var fV = "";
	var v = value.toString();
	var ln = v.length;
	var k = format.length - 1;
	var app = "";
	for(i=ln-1; i>=0;){
		if(format.charAt(k) == '#'){
			fV = v.charAt(i--).toString() + fV;
		} else {
			fV = format.charAt(k) + fV;
		}
		k--;
	}
	for(k=0; k<format.length; k++)
		if(format.charAt(k) == '#') break;
		else app = app + format.charAt(k);
	fV = app + fV;
	return fV;
}

function setCountyFor(obj){
	var objSelect = Element.extend(obj);
	var countryValue = objSelect.options[objSelect.selectedIndex].value;
	objSelect = $('state');
	$('stateLoader').show();
	new Ajax.Request("ajax/getGeoData.php", {
		parameters: {country: countryValue},
		onSuccess: function(obj){
			counties = eval(obj.responseText);
			var i;
			var childs = objSelect.childElements();
			i = childs.length - 1;
			while(i > 0){
				childs[i--].remove();
			}
			//alert("Got " + counties.length);
			for(i=0; i<counties.length; i++){
				var option = Element.extend(document.createElement('option'));
				option.value = counties[i];
				option.update(counties[i]);
				objSelect.appendChild(option);
			}			
			$('stateLoader').hide();
		},
		onFailure: function(obj){
			alert("Problems on ...");
		}
	});
}

var gotOKC = 0;
var mTimer;
var mTimerM;
function setCountry(){
	var objSelect = $('country');
	if(!objSelect || gotOKC) return;
	gotOKC = 1;
	clearInterval(mTimer);
	new Ajax.Request("ajax/getGeoData.php", {
		onSuccess: function(obj){
			//alert("Success: " + obj.responseText);
			countries = eval(obj.responseText);
			var i;
			for(i=0; i<countries.length; i++){
				var option = Element.extend(document.createElement('option'));
				option.value = countries[i];
				option.update(countries[i]);
				objSelect.appendChild(option);
			}
			
			//alert("Got " + countries.length);
		},
		onFailure: function(obj){
			alert("Problems on ...");
		}
	});
	// display loading
}
var gotOKS = 0;
var s_county;
var s_country;
function setValues(){
	var objSelectA = $('country');
	var objSelectB = $('state');
	var i;
	if(!objSelectA || !objSelectB) return;
	if(objSelectA.options.length < 2) return;
	if(objSelectA.selectedIndex == 0){
	for(i=1; i<objSelectA.options.length; i++)
		if(objSelectA.options[i].value == s_country){
			objSelectA.selectedIndex = i;
			break;
		}
	}
	if(objSelectB.options.length < 2 && gotOKS) return;
	else if(!gotOKS) {setCountyFor(objSelectA); gotOKS = 1; return;}
	
	clearInterval(mTimerM);
	for(i=1; i<objSelectB.options.length; i++)
		if(objSelectB.options[i].value == s_county){
			objSelectB.selectedIndex = i;
			break;
		}
	
}
var prePayment = 'rooms';
function displayPayment(id){
	if(id == prePayment) return;
	$(prePayment).style.display = 'none';
	prePayment = id;
	$(prePayment).style.display = 'block';
}
var show_top_mem = 1;

function show_top(){
	if(show_top_mem){
		document.getElementById('top_points_users').style.display='block';
		document.getElementById('show_top').innerHTML = "Hide top 30";
		show_top_mem = 0;	
	}else{
		document.getElementById('top_points_users').style.display='none';
		document.getElementById('show_top').innerHTML = "Show top 30";
		show_top_mem = 1;
	}	
}

var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  } 
    
  
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  //return [ scrOfX, scrOfY ];
 return scrOfY;
}

var mad_text = new Array();
mad_text[1] = '<div class="details_title">Special Madness Gift:  LG22" TFT - Wide Screen</div><br /><br />Tournament Name: eXpert Special Madness<br />Poker Room: Titan Poker<br />Date: 28th February<br />Time: 8.00 PM GMT<br />Buy in: $10+1<br />Tournament Type: NL Holdem Freezeout<br />Starting Chips: 3000<br />Blinds: 10 min<br />Prize pool: standard Titan Poker structure<br />Min players: 20<br />Max players: 500<br /><div style="color:red;">The winner will take home the Special Madness Gift!</div><br />Conditions: <br />Only for all depositors from eXpert Poker Network and restricted to the others . Special gift will be offered, only if it will be minimum 25 players registered.<br /><br />Open an account and <a href="http://www.expertpokerclub.com/index.php?page=vip_bonus&action=details&site=20">make your first deposit</a>. Now you are able to register into our Special Madness and get your new LG22" TFT - Wide Screen for FREE. Do you already have an eXpert poker account on <a href="http://www.expertpokerclub.com/index.php?page=vip_bonus&action=details&site=20">Titan Poker</a>? In this case you already are qualified for "the action". Register and play. Get your gift.<br /><br />';
mad_text[2] = '<div class="details_title">Special Madness Gift: Toshiba - Laptop Satellite L40-17Q, Bag and Mouse</div><br />Tournament Name: eXpert Special<br />Poker Room: Poker Heaven<br />Date: 10th March<br />Time: 8.00 PM GMT<br />Buy in: &euro;10+1<br />Tournament Type: NL Holdem Freezeout<br />Starting Chips: 3000<br />Blinds: 10 min<br />Prize pool: standard Poker Heaven structure<br />Min players: 20<br />Max players: 500<br /><div style="color:red;">The winner will take home the Special Madness Gift!</div><br /><br />Conditions:<br />Only for all depositors from eXpert Poker Network. Special gift will be offer, only if it will be minimum 20 players registered.<br />Players must earn minimum 2.5 XPN points on <a href="http://www.expertpokerclub.com/index.php?page=rakeback&action=details&site=1">Poker Heaven</a> from 15th till 29 February (this mean 250 rake). Here you can see the situation of your XPN points: login to the network and see XPN points. You can <a href="http://www.expertpokernetwork.com/index.php?page=promotions">see here</a> details about the way we give the XPN points.    <br />Open an account and play few hands, register into our Special Madness and get your new Laptop for FREE. Do you already have an eXpert poker account on <a href="http://www.expertpokerclub.com/index.php?page=rakeback&action=details&site=1">Poker Heaven</a>? Deposit again and begin to play. Be sure you will be qualifying for "the action". Get your gift. <br /><br />';
mad_text[3] = '<div class="details_title">Special Madness Gift: Toshiba - Laptop Satellite L40-18Y</div><br />Tournament Name: eXpert Special Madness<br />Poker Room: Dracula Hold\'em<br />Date: 28th March<br />Time: 8.00 PM GMT<br />Buy in: &euro;10+1<br />Tournament Type: NL Holdem Freezeout<br />Starting Chips: 3000<br />Blinds: 10 min<br />Prize pool: standard standard Dracula Hold\'em structure<br />Min players: 20<br />Max players: 500<br /><div style="color:red;">The winner will take home the Special Madness Gift!</div><br />Conditions: <br />Restricted for all players from eXpert Poker Network. The winner will receive the madness gift! <br /><br />Open an account and make your first deposit. Now you are able to register into our Special Madness and get your new Toshiba - Laptop Satellite L40-18Yfor FREE. Do you already have an eXpert poker account on <a href="http://www.expertpokerclub.com/index.php?page=vip_bonus&action=details&site=9027">Dracula Hold\'em</a>? In this case, you already are qualified for "the action". Register and play. Get your gift.<br /><br />';
mad_text[4] = '<div class="details_title">Special Madness Gift: Panasonic Viera TH-42PV7, 42" 106cm</div><br />Tournament Name: eXpert Special<br />Poker Room: Poker Heaven<br />Date: 10th April<br />Time: 8.00 PM GMT<br />Buy in: &euro;10+1<br />Tournament Type: NL Holdem Freezeout<br />Starting Chips: 3000<br />Blinds: 10 min<br />Prize pool: standard Poker Heaven structure<br />Min players: 20<br />Max players: 500<br /><div style="color:red;">The winner will take home the Special Madness Gift!</div><br />Conditions:<br />Only for all depositors from eXpert Poker Network. Special gift will be offer, only if it will be minimum 50 players registered.<br /><br />Players must earn minimum 5 XPN points on <a href="http://www.expertpokerclub.com/index.php?page=rakeback&action=details&site=1">Poker Heaven</a> from 1th till 31 March (this mean 500 rake). Here you can see the situation of your XPN points: login to the network and see XPN points. You can <a href="http://www.expertpokernetwork.com/index.php?page=promotions">see here</a> details about the way we give the XPN points.    <br />Open an account and play few hands, register into our Special Madness and get your new Panasonic Viera for FREE. Do you already have an eXpert poker account on <a href="http://www.expertpokerclub.com/index.php?page=rakeback&action=details&site=1">Poker Heaven</a>? Deposit again and begin to play. Be sure you will be qualifying for "the action". Get your gift. <br /><br />';
mad_text[5] = '<div class="details_title">Special Madness Gift: LG - LCD TV 32" 32LC41</div><br />Tournament Name: eXpert Special Madness<br />Poker Room: Dracula Hold\'em<br />Date: 28th April<br />Time: 8.00 PM GMT<br />Buy in: &euro;10+1<br />Tournament Type: NL Holdem Freezeout<br />Starting Chips: 3000<br />Blinds: 10 min<br />Prize pool: standard standard Dracula Hold\'em structure<br />Min players: 20<br />Max players: 500<br /><div style="color:red;">The winner will take home the Special Madness Gift!</div><br />Conditions: <br />Restricted for all players from eXpert Poker Network. The winner will receive the madness gift!<br /><br />Open an account and make your first deposit. Now you are able to register into our Special Madness and get your new LG - LCD TV for FREE. Do you already have an eXpert poker account on <a href="http://www.expertpokerclub.com/index.php?page=vip_bonus&action=details&site=9027">Dracula Hold\'em</a>? In this case, you already are qualified for "the action". Register and play. Get your gift.<br /><br />';

function mad_details(details_text){
	positionY = getScrollXY();
	$('mad_details').style.left =  250 +"px";
	$('mad_details').style.top =  myHeight/2 -300 + positionY+"px";	
	$('mad_details').style.display = "block";
	$('mad_details_cont').innerHTML = mad_text[details_text];
}

function mad_details_close(){
	$('mad_details').style.display = "none";
}

function go2Online(){
	strHref = window.location.href;
	if(strHref.indexOf("#") > -1){
	var strQueryString = strHref.substr(strHref.indexOf("#")+1).toLowerCase();
	if(strQueryString == "online")
		showOnline();
	}
}