Event.observe(window, 'load', function() {
  $$('a[href^=#]:not([href=#])').each(function(element) {
    element.observe('click', function(event) {
      new Effect.ScrollTo(this.hash.substr(1));
      Event.stop(event);
    }.bindAsEventListener(element))
  })
})

function fav() {
	title = "Poker770.com - Mon Casino"; 
	url = "http://www.poker770.com";

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title);
	}
	else if(window.opera && window.print) { // Opera Hotlist
		return true;
	} 
}

function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}


function highlightAvatar(id, value, total) {
	for(var i = 1; i <= total ; i++ ) {
		$('avatar_pick_'+i).parentNode.className = 'clear';
	}
	//document.getElementById('avatar_pick').className = 'clear';
	document.getElementById(id).parentNode.parentNode.className = 'highlight';
}

/*
addLoadEvent(collapseMenu);
addLoadEvent(prepareMenu);
*/
addLoadEvent(prepareMenu);

function collapseMenu(node) {
	if (!document.getElementById) return false;
	if (!document.getElementById("menu")) return false;
	if (!node) node = document.getElementById("menu");

	if (node.childNodes.length > 0) {
		for (var i=0; i<node.childNodes.length; i++) {
			var child = node.childNodes[i];
			if (child.nodeName == "UL" && child.className != 'open') {
				child.style.display = "none";
			}
			collapseMenu(child);
		}
	}

}

function prepareMenu() {
	if (!document.getElementById || !document.getElementsByTagName) return false;
	if (!document.getElementById("menu")) return false;

	var links = document.getElementById("menu").getElementsByTagName("a");
	for (var i=0; i<links.length; i++) {		
		links[i].onclick = function() {
			toggleMenu(this.parentNode.getElementsByTagName("UL")[0], this.href);
			return false;
		}
		/*
		links[i].onmouseover = function() {
			isNode(this.parentNode.getElementsByTagName("UL")[0], this.id, true);
			return false;
		}
		links[i].onmouseout = function() {
			isNode(this.parentNode.getElementsByTagName("UL")[0], this.id, false);
			return false;
		}
		*/
	}
}

function isNode(node, id, expand) {
	if(node && document.getElementById(id)) {
		//document.getElementById(id).style.background = "url(/beta/css/images/arrow2-plus.gif) no-repeat 0px 6px;";
		if (expand == true)
			document.getElementById(id).className = 'expand';
		else
			document.getElementById(id).className = '';
	}
}

function toggleMenu(node, link) {
	if(node) {
		if (!document.getElementById) return false;
		if (!link) return false;
		if (!node){ document.location.href = link.href; }

		// Collapse all nodes, and only show clicked node (when clicking top level of menu)
		if (node.parentNode.parentNode.id == "menu") {
			hideTopLevels();
		}
		
		if (node.style.display == "") {
			node.style.display = "none";
		} else {
			node.style.display = "";
		}
	}
	else {
		document.location.href = link;
	}

}

if ( typeof(ipoker_start) == "function"  )
  start_func(ipoker_start);

/*

function toggleMenu(node, link) {
	if(node) {
		alert(1);
	}
	if (!document.getElementById) return false;
	if (!link) return false;
	if (!node){ document.location.href = link.href; }

	// Collapse all nodes, and only show clicked node (when clicking top level of menu)
	if (node.parentNode.parentNode.id == "menu") {
		hideTopLevels();
	}
	
	if (node.style.display == "") {
		node.style.display = "none";
	} else {
		node.style.display = "";
	}
	
}
*/
function hideTopLevels() {
	if (!document.getElementById) return false;
	if (!(node = document.getElementById("menu"))) return false;	
	
	if (node.childNodes.length > 0) {
		for (var i=0; i<node.childNodes.length; i++) {
			var child = node.childNodes[i];
			for(var j=0; j<child.childNodes.length; j++) {
				var grandchild = child.childNodes[j];
				if (grandchild.nodeName == "UL") {
					if (grandchild.style.display == '') {
						grandchild.style.display = "none";
					}
				}
			}
		}		
	}
}
/*
function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++){
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			if(inputs[i].id == 'gender') {
			}
			else {
				// the span exists!  on focus, show the hint
				inputs[i].onfocus = function () {
					this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
					this.parentNode.className = 'hover';
				}
				// when the cursor moves away from the field, hide the hint
				inputs[i].onblur = function () {
					this.parentNode.getElementsByTagName("span")[0].style.display = "none";
					if(this.id == 'confirm_password') {
						confirmPassword();
					}
					else {
						checkfield(this.id, this.value);
					}
					this.parentNode.className = 'clear';
				}
			}
		}
	}
}
addLoadEvent(prepareInputsForHints);
*/
function focusSpan(id) {
	document.getElementById(id).parentNode.getElementsByTagName("span")[0].style.display = "inline";
	document.getElementById(id).parentNode.className = 'hover';
	if(document.getElementById(id).type == 'textarea')
		document.getElementById(id).parentNode.getElementsByTagName("span")[0].style.margin = '150px 0px 0px 0px';
}
function blurSpan(id) {
	document.getElementById(id).parentNode.getElementsByTagName("span")[0].style.display = "none";
	document.getElementById(id).parentNode.className = 'clear';
}
function toggleField()	{
	
	var reg_select_room = document.getElementById('reg_select_room'); 
	var reg_other_room = document.getElementById('reg_other_room'); 
	
	if (reg_select_room.value == "other") {
		Effect.SlideDown('reg_other_roomp');
		Element.hide('pseudotablep');
		Element.hide('psrp');
		reg_other_room.disabled=false;
	}
	else if (reg_select_room.value == "Poker770.com") {
		Element.hide('reg_other_roomp');
		Effect.SlideDown('pseudotablep');
		Effect.SlideDown('psrp');
		reg_other_room.disabled=false;
	}
	else {
		Element.hide('reg_other_roomp');
		Element.hide('pseudotablep');
		Element.hide('psrp');
		reg_other_room.disabled=true;
	}

}

function lemur_focus(id) {
	//document.getElementById(id).parentNode.getElementsByTagName("div")[0].style.display = "inline";
	document.getElementById('message_box').className = 'hover';
}
function lemur_blur(id) {
	//document.getElementById(id).parentNode.getElementsByTagName("div")[0].style.display = "none";
	document.getElementById('message_box').className = 'clear';
}

/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=500 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) //if scroller hasn't reached the end of its height
	cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px" //move scroller upwards
else //else, reset to original position
	cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
	if(document.getElementById("marqueecontainer")) {
	cross_marquee=document.getElementById("vmarquee")
	cross_marquee.style.top=0
	marqueeheight=document.getElementById("marqueecontainer").offsetHeight
	actualheight=cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
	if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
		cross_marquee.style.height=marqueeheight+"px"
		cross_marquee.style.overflow="scroll"
		return
	}
	setTimeout('lefttime=setInterval("scrollmarquee()",40)', delayb4scroll)
	}
}

if (window.addEventListener)
	window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
	window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
	window.onload=initializemarquee

/*
#####################
FLOATING ARROW TO TOP
#####################
*/



// height of footer
var margin_from_bottom = 500;

// for deriving total height of page
var page_body = document.getElementsByTagName("body");

// width of sidebar
var x1 = 230;
//var y1 = 500;   // change the # on the left to adjuct the Y co-ordinate

var window_innerwidth = 0;
var window_innerheight = 0;

//retrieves width/height of browser to dynamically adjust placement of arrow
if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	window_innerwidth = window.innerWidth;
	window_innerheight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	window_innerwidth = document.documentElement.clientWidth;
	window_innerheight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	window_innerwidth = document.body.clientWidth;
	window_innerheight = document.body.clientHeight;
}

(document.getElementById && !document.all) ? dom = true : dom = false;

//called whenever user scrolls page
function scroll()
{
	//alert(window_innerheight + window.pageYOffset);
	//alert(page_body[0].clientHeight);
	if (dom) {
		if(window.pageYOffset <= 100){
			document.getElementById("backToTop").style.visibility = "hidden";
		}
		else if((window_innerheight + window.pageYOffset) > (page_body[0].clientHeight - margin_from_bottom)){
			placeIt();
    	}
		else if (window.pageYOffset > 300) {
			document.getElementById("backToTop").style.visibility = "visible";
		}
	}
	if (document.all) {
		if(document.documentElement.scrollTop <= 100){
			document.getElementById("backToTop").style.visibility = "hidden";
		}
		else if((window_innerheight + document.documentElement.scrollTop) > (page_body[0].clientHeight - margin_from_bottom)){
			placeIt();
    	}
		else if (document.documentElement.scrollTop > 300 ) {
			document.getElementById("backToTop").style.visibility = "visible";
		}
	}
}

// repositions arrow whenever user resize browser
function resize(){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		window_innerwidth = window.innerWidth;
		window_innerheight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		window_innerwidth = document.documentElement.clientWidth;
		window_innerheight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		window_innerwidth = document.body.clientWidth;
		window_innerheight = document.body.clientHeight;
	}
	placeIt();
}

function typeStart() {
	if (dom) {
    	document.write('<div id="backToTop" style="position:absolute; left:' + (window.innerWidth-x1) + 'px; visibility:visible">') }
	if (document.all) {
    	document.write('<div id="backToTop" style="position:absolute; left:' + (document.body.clientWidth-x1) + 'px; visibility:visible">') }
	}

function typeEnd() {
	if (document.all || dom) {
		document.write('</div>')
	}
 }

function placeIt() {
	// ideally should be global constants
	// 50 is the distance from bottom
	// 800 is total width of page

	if (dom) {
		if(window.pageYOffset <= 100)
			document.getElementById("backToTop").style.visibility = "hidden";
    	else if((window_innerheight + window.pageYOffset) > (page_body[0].clientHeight - margin_from_bottom)){
    		// 60 is the positioning offset for IE
    		var bottom_offset = (window_innerheight + window.pageYOffset) - (page_body[0].clientHeight - margin_from_bottom) + 60;
    		document.getElementById("backToTop").style.top = window_innerheight + window.pageYOffset - bottom_offset + "px";
    		document.getElementById("backToTop").style.left = (window_innerwidth-800)/2 + window.pageXOffset + x1 + "px";
    	}
    	else{
    		document.getElementById("backToTop").style.top = window.pageYOffset + window_innerheight-50 + "px";
    		document.getElementById("backToTop").style.left = (window_innerwidth-800)/2 + window.pageXOffset + x1 + "px";
    	}
	}
	if (document.all) {
		if(document.documentElement.scrollTop <= 100)
			document.getElementById("backToTop").style.visibility = "hidden";
		else if((window_innerheight + document.documentElement.scrollTop) > (page_body[0].clientHeight - margin_from_bottom)){
			// 90 is the positioning offset for IE
			var bottom_offset = (window_innerheight + document.documentElement.scrollTop) - (page_body[0].clientHeight - margin_from_bottom) + 90;
    		document.all["backToTop"].style.top = window_innerheight + document.documentElement.scrollTop - bottom_offset + "px";
    		document.all["backToTop"].style.left = (document.documentElement.clientWidth-800)/2 + document.documentElement.scrollLeft + x1 + "px";
		}
    	else{
			document.all["backToTop"].style.top = document.documentElement.scrollTop + document.documentElement.clientHeight-50 + "px";
    		document.all["backToTop"].style.left = (document.documentElement.clientWidth-800)/2 + document.documentElement.scrollLeft + x1 + "px";
    	}
	}
	window.setTimeout("placeIt()", 10);
 }


/**
 * Tidbit : Cookie
 */

var Cookie = {
	set: function(name,value,seconds){
		if(seconds){
			d = new Date();
			d.setTime(d.getTime() + (seconds * 1000));
			expiry = '; expires=' + d.toGMTString();
		}else
			expiry = '';
		document.cookie = name + "=" + value + expiry + "; path=/";
	},
	get: function(name){
		nameEQ = name + "=";
		ca = document.cookie.split(';');
		for(i = 0; i < ca.length; i++){
			c = ca[i];
			while(c.charAt(0) == ' ')
				c = c.substring(1,c.length);
			if(c.indexOf(nameEQ) == 0)
				return c.substring(nameEQ.length,c.length);
		}
		return null
	},
	unset: function(name){
		Cookie.set(name,'',-1);
	}
}
