
var lastX = 0;
var lastY = 0;

// START - FAQ script
// expandable articles (FAQ)
function expandCollapse(element){
	image = element.firstChild;
	if(!image.src){
		image = image.nextSibling;
	}
	
	div = element.nextSibling;
	if(div.style == undefined){
		div = div.nextSibling;
	}

	if (div.style.display == 'none') {
		div.style.display = 'block';
		image.src = '/bin_images/oben.gif';
	} else {
		div.style.display = 'none';
		image.src = '/bin_images/rechts.gif';
	}
}

// make them clickable
// call via: addEvent(window, 'load', function() { collapseableDivs('FAQuestion', 'FAQAnswer') });
function collapseableDivs(sClickDiv, sCollapseDiv) {
	if (sClickDiv == undefined || sClickDiv == '') sClickDiv = 'FAQuestion';
	if (sCollapseDiv == undefined || sClickDiv == '') sCollapseDiv = 'FAQAnswer';

	a = $$('div.'+sClickDiv);
	for (i = 0; i < a.length; i++) {
		a[i].onclick = function() { expandCollapse(this);  };
	}

	b = $$('div.'+sCollapseDiv);
	for (i = 0; i < b.length; i++) {
		b[i].style.display = "none";
	}
}

// END - FAQ script

// attaches an function to an object when event is called
// cannot have parameters
// example: addEvent(window, 'load', doSomething);
// example: addEvent(window, 'load', function() { doSomething(param, param2); } );
function addEvent( obj, type, fn ) {
   if (obj.addEventListener) {
      obj.addEventListener( type, fn, false );
   } else if (obj.attachEvent) {
      obj["e"+type+fn] = fn;
      obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
      obj.attachEvent( "on"+type, obj[type+fn] );
   }
}

// closes popup
function closeMessage() {
	if(myiframe = document.getElementById('myIframe')) myiframe.parentNode.removeChild(myiframe);
	nd();
	nd();
}
  
// generates HTML code for Buttons
function makeButton(button_text, button_action, classnumber, tablealign, submit, button_title){
	if (tablealign == undefined)
		tablealign = 'right';
	if (button_title == undefined)
		button_title = '';

	var action = '';
	var text = '';

	if (submit != undefined && submit != false) {
		action = '<input class="button_main'+classnumber+'_submit" style="border:none;" type="submit" name="'+button_title+'" width="100%" value="'+button_text+'" />';
		submit = '_submit';
		button_action = '';
	} else {
		action = '<div nowrap="nowrap" valign="middle" alt="'+button_title+'" title="'+button_title+'">&nbsp;&nbsp;'+button_text+'&nbsp;&nbsp;</div>';
		if (button_action.search('/javascript/') == -1)
			button_action = 'onclick="javascript:document.location.href=\''+button_action+'\';"';
		else
			button_action = 'onclick="'+button_action+'"';
		submit = '';
	}

	text=text+'<table class="button_'+classnumber+'" style="border:none; padding:0px; margin:0px;" border="0" cellpadding="0" cellspacing="0" align="'+tablealign+'">';
	text=text+'<tr>';
	text=text+'	<td class="button_left'+classnumber+'" nowrap="nowrap" style="cursor:pointer;" '+button_action+'>&nbsp;</td>';
	text=text+'	<td class="button_main'+classnumber+submit+'" nowrap="nowrap" valign="middle" style="cursor:pointer;" '+ button_action +'>'+action+'</td>';
	text=text+'	<td class="button_right'+classnumber+'" nowrap="nowrap" style="cursor:pointer;" '+button_action+'>&nbsp;</td>';
	text=text+'</tr>';
	text=text+'</table>';

	return text;
}

// trigger an event like onclick from anywhere
// example fireEvent(this, 'click')
// example fireEvent(document.getElementById('test'), 'click')
function  fireEvent(element,event){
    if (document.createEventObject){
        // dispatch for IE
        var evt = document.createEventObject();
        return element.fireEvent('on'+event,evt)
    }
    else{
        // dispatch for firefox + others
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
        return !element.dispatchEvent(evt);
    }
}


// Generates HTML code for popup
function makeMessage(msg_title, msg_text, button_text, button_action, classname, scndbutton_text, scndbutton_action){
	// default values
	if (classname == undefined) classname = '';
	if (button_text != undefined || button_action != undefined) {
		if (button_text == undefined)	button_text = 'OK';
		if (button_action == undefined) button_action = "javascript:closeMessage();";
	}
	if (scndbutton_text != undefined || scndbutton_action != undefined) {
		if (scndbutton_text == undefined) {
			if (GLOBAL_CLOSE_TEXT != undefined)
				scndbutton_text = GLOBAL_CLOSE_TEXT;
			else
				scndbutton_text = 'Close';
		}
		if (scndbutton_action == undefined) scndbutton_action = "javascript:closeMessage();";
	}

	if (classname == '' || classname == 'welcome') buttontype = 4;
	else buttontype = 6;

	if (typeof(pagetype) != "undefined" ) { temppt = "affiliate"  } else { temppt = "regular"}

	if ((classname != 'affiliate') && (temppt != "affiliate")) {
		text='';
		text=text+'<table width="400" border="0" cellpadding="0" cellspacing="0" class="default_popup_window '+classname+'_window">';

		text=text+'<tr><td class="default_popup_bar_left '+classname+'_bar_left">&nbsp;</td>';
		text=text+'<td class="default_popup_bar_main '+classname+'_bar_main">';
		text=text+'<img src="/grafik/pixel.gif" onclick="closeMessage();" class="default_popup_closebutton '+classname+'_closebutton" alt="Close" />';
		text=text+'</td>';
		text=text+'<td class="default_popup_bar_right '+classname+'_bar_right">&nbsp;</td></tr>';

		text=text+'<tr><td class="default_popup_main_left '+classname+'_main_left">&nbsp;</td>';
		text=text+'<td class="default_popup_area '+classname+'_area"><p>';
		if (msg_title != undefined && msg_title != '')
			text=text+'<b id="popup_title">'+msg_title+'</b><br/><br/>';
		text=text+msg_text+'</p>';
		text=text+'</td><td class="default_popup_main_right '+classname+'_main_right">&nbsp;</td></tr>';

		text=text+'<tr>';
		text=text+'<td class="default_popup_bottom_left '+classname+'_bottom_left">&nbsp;</td>';
		text=text+'<td class="default_popup_bottom_main '+classname+'_bottom_main" align="center">';
		if (scndbutton_action != undefined && scndbutton_text != undefined ) {
			text=text+makeButton(scndbutton_text, scndbutton_action, 5, 'left');
			text=text+makeButton(button_text, button_action, buttontype, 'right');
		} else if (button_action != undefined && button_text != undefined ) {
			text=text+'<center>'+makeButton(button_text, button_action, buttontype, 'center')+'</center>';
		}
		text=text+'</td><td class="default_popup_bottom_right '+classname+'_bottom_right">&nbsp;</td>';
		text=text+'</tr>';
		text=text+'</table>';
	} else {
		text='';
		text=text+'<table border="0" cellspacing="0" cellpadding="10" width="100%" class="alertwindow">';
	    text=text+'<tr><td class="adbar" align="right"><a href="javascript:closeMessage();">';
		text=text+'<img src="/bin_images/912" border="0" style="position:relative; top:2px;" /></a>&nbsp;';
		text=text+'</td></tr>';

		text=text+'<tr><td class="alertarea '+classname+'_area"><p>';
		if (msg_title != undefined && msg_title != '')
			text=text+'<b id="popup_title">'+msg_title+'</b><br /><br />';
		text=text+msg_text+'</p>';
		text=text+'</td></tr>';

		text=text+'<tr><td class="alertbutton '+classname+'_bottom_main" align="center">';
		text=text+'<center>'+makeButton(button_text, button_action, 2, 'center')+'</center>';
		text=text+'</td></tr>';

		text=text+'</table>';
		text=text+'<iframe id="myIframe" src="empty.html" width="100%" height="100%" frameborder="0" border="0" style="float:left; border:none; background-color:black; z-index:-1; position:absolute; top:0px; left:0px;"></iframe>';
		return text;
	}
	return text;
}

// array check
function isArray(obj) {
   if (obj == undefined || typeof(obj) != 'object' || obj.constructor.toString().indexOf("Array") == -1)
      return false;
   else
      return true;
}

// START - gallery
var image_gallery_index;
var image_gallery_text;
var image_gallery_pics;

// next button function within gallery popup
function openpopupnext(step) {
	if (image_gallery_index == undefined)
		image_gallery_index = 0;
	if (step == undefined)
		step = 1;

	image_gallery_index += step;
	if (image_gallery_index >= image_gallery_pics.length)
		image_gallery_index = 0;
	if (image_gallery_index < 0)
		image_gallery_index = image_gallery_pics.length-1;

	document.getElementById('popup_title').innerHTML = image_gallery_text[image_gallery_index];
	document.getElementById('popup_image').src 		 = image_gallery_pics[image_gallery_index];
	document.getElementById('popup_image').lowsrc	 = image_gallery_pics[image_gallery_index]+"&thumb=1";
}

// gallery popup
function openpopup(image, text, idx) {
	if (image != undefined && text != undefined && image != '' && text != '') { // && (isArray(image) && isArray(text)) || (!isArray(image) && !isArray(text))) {
		image_gallery_pics = image;
		image_gallery_text = text;
	} else if (!isArray(image_gallery_pics) || !isArray(image_gallery_text)) {
		image_gallery_pics = new Array('/bin_images/284', '/bin_images/283', '/bin_images/282', '/bin_images/286', '/bin_images/287', '/bin_images/285');
		image_gallery_text  = new Array('Table', 'The Lobby: No Limit', 'The Lobby: Fixed Limit', 'Tournament Lobby', 'Game Statistics', 'Cashier');
	}

	if (idx == undefined)
		idx = 0;
	image_gallery_index = idx;

	var content;

	if (isArray(image_gallery_pics) && isArray(image_gallery_text)) {
		content = '<img src="'+image_gallery_pics[idx]+'" lowsrc="'+image_gallery_pics[idx]+'&thumb=1" id="popup_image" alt="Screenshot" title="Screenshot" />';
		content = makeMessage(image_gallery_text[idx], content, '&nbsp&nbsp;&gt;&gt;&nbsp;&nbsp;', "javascript:openpopupnext(1);", 'imagepopup', '&nbsp;&nbsp;&lt;&lt;&nbsp;&nbsp;', "javascript:openpopupnext(-1);");
	} else {
		content = '<img src="'+image+'" lowsrc="'+image+'&thumb=1" alt="Click to close" title="Click to close" style="cursor:pointer;" onclick="javascript:closeMessage();" /><br />&nbsp;';
		content = makeMessage(text, content, undefined, undefined, 'imagepopup');
	}
	overlib(content,FULLHTML,STICKY,WRAP, RELX, 220, RELY, 20);
}
// END - gallery

// changes action within a form and submits it
function sendAction(form,action){
	document.forms[ form ].elements['action'].value = action;
	document.forms[ form ].submit();
}

// generates a GET query out of an form
function makeQuery(f){
	query = '';
	for (var i = 0; i < f.length ; i++) {
		type = f.elements[i].type;
		name = f.elements[i].name;

		switch(type){
			case "select-multiple":
				for(n=0;n<f.elements[i].length;n++){
					if(f.elements[i].options[n].selected)
						query = query + '&' + name + '=' + f.elements[i].options[n].value;
				}
			break;
			case "select-one":
				if(f.elements[i].options != undefined && f.elements[i].options.length != undefined)
					query = query + '&' + name + '=' + f.elements[i].options[ f.elements[i].selectedIndex ].value;
			break;
			case "checkbox":
				if(f.elements[i].checked)
					query = query + '&' + name + '=' + f.elements[i].value;
			break;
			case "radio":
				if(f.elements[i].checked)
					query = query + '&' + name + '=' + f.elements[i].value;
			break;
			case "submit":
			break;
			default:
				query = query + '&' + name + '=' + escape(f.elements[i].value);
			break;
		}
	}
	return query;
}

/* add/changes or removes a css klass
	a	    defines the action you want the function to perform.
	o	    the object in question.
	c1	    the name of the first class
	c2	    the name of the second class
*/
function jscss(a,o,c1,c2) {
	switch (a){
		case 'swap':
		  o.className=!jscss('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
		break;
		case 'add':
		  if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
		  var rep=o.className.match(' '+c1)?' '+c1:c1;
		  o.className=o.className.replace(rep,'');
		break;
		case 'check':
		  return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}

//
function replaceInput(id, name, css) {
    var newInput = document.createElement("input");
    newInput.setAttribute('type','password');
    newInput.setAttribute('id',id);
    newInput.setAttribute('name',name);

    var pwfield = document.getElementById(id);

	//special code to support ie !
	var temp = document.createAttribute("class");
	temp.nodeValue = css;
	newInput.setAttributeNode(temp);

    pwfield.parentNode.appendChild(newInput);
    pwfield.parentNode.removeChild(pwfield);
    var newElement = document.getElementById(id);
    newElement.focus();
}

function addInputSuggestion(elementID,suggestiontext,className){
	var e = document.getElementById(elementID );
	// Element exists?
	if (!e || "undefined" == e) return false;
	// Set default values
	if (!className || "undefined" == className || "undefined"  == className ) className = "suggestion";
	if (!suggestiontext || "" == suggestiontext  || "undefined" == suggestiontext ) suggestiontext = e.getAttribute("suggestiontext");
	// Preparation
	e.suggestiontext = suggestiontext;
	e.suggestionclassname = className;
	if (e.value == "" ) {
		e.value = suggestiontext;
		e.className = ( e.className == ""  ? className : e.className + " " + className);
	}
	e.onclick = function(event){
		var e = this;
		if (e) {
			if (e.value == e.suggestiontext) e.value = "";
			if (e.className.indexOf(e.suggestionclassname) >= 0 ) {
				e.className = e.className.replace( "" + e.suggestionclassname, "" );
			}
		}

	}
	e.onblur = function(event){
		var e = this;
		if (e) {
			if (e.value == "") {
				e.value = e.suggestiontext;
				if (e.className.indexOf(e.suggestionclassname) < 0 ) {
	            	e.className = ( e.className == ""  ? className : e.className + " " + className);
				}
			}
		}
	}
}

// display or hide a dom element
function setVisible(layer, on) {
	if (layer != undefined) {
		if(typeof(layer) == 'object') {
			if (on) {
				if(layer.style != undefined) {
					layer.style.visibility = 'visible';
					layer.style.display = '';
				} else {
					layer.visibility = 'show';
				}
			} else {
				if(layer.style != undefined) {
					layer.style.visibility = 'hidden';
					layer.style.display = 'none';
				} else {
					layer.visibility = 'hide';
				}
			}
		} else {
			if (on) {
				if (document.getElementById && document.getElementById(layer) != undefined) {
					document.getElementById(layer).style.visibility = 'visible';
					document.getElementById(layer).style.display = '';
				} else if (document.layers && document.layers[layer] != undefined) {
					document.layers[layer].visibility = 'show';
					//document.layers[layer].display = '';
				} else if (document.all && document.all[layer] != undefined) {
					document.all[layer].style.visibility = 'visible';
					document.all[layer].style.display = '';
				}
			} else {
				if (document.getElementById && document.getElementById(layer) != undefined) {
					document.getElementById(layer).style.visibility = 'hidden';
					document.getElementById(layer).style.display = 'none';
				} else if (document.layers && document.layers[layer] != undefined) {
					document.layers[layer].visibility = 'hide';
					//document.layers[layer].display = 'none';
				} else if (document.all && document.all[layer] != undefined) {
					document.all[layer].style.visibility = 'hidden';
					document.all[layer].style.display = 'none';
				}
			}
		}
	}
}

// START - Time Script
// sets the intveral for updating the clock
function setClockInterval() {
	// reset old timer
	if (clock_timer) {
		clearInterval(clock_timer);
		clock_timer = null;
	}

	// only start clock if there is one
	if (document.getElementById("clock") != undefined) {
		clock_timer = setInterval('updateClock('+clock_updates+')', clock_updates );
		updateClock(1);
	}
}

// END - Time Script

/**************************************************
* dom-drag.js
* 09.25.2001
* www.youngpup.net
* Script featured on Dynamic Drive (http://www.dynamicdrive.com) 12.08.2005
**************************************************
* 10.28.2001 - fixed minor bug where events
* sometimes fired off the handle, not the root.
**************************************************/

var Drag = {

obj : null,

init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
{
	o.onmousedown	= Drag.start;

	o.hmode			= bSwapHorzRef ? false : true ;
	o.vmode			= bSwapVertRef ? false : true ;

	o.root = oRoot && oRoot != null ? oRoot : o ;

	if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
	if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
	if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
	if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

	o.minX	= typeof minX != 'undefined' ? minX : null;
	o.minY	= typeof minY != 'undefined' ? minY : null;
	o.maxX	= typeof maxX != 'undefined' ? maxX : null;
	o.maxY	= typeof maxY != 'undefined' ? maxY : null;

	o.xMapper = fXMapper ? fXMapper : null;
	o.yMapper = fYMapper ? fYMapper : null;

	o.root.onDragStart	= new Function();
	o.root.onDragEnd	= new Function();
	o.root.onDrag		= new Function();
},

start : function(e)
{
	var o = Drag.obj = this;
	e = Drag.fixE(e);
	var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
	var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
	o.root.onDragStart(x, y);

	o.lastMouseX	= e.clientX;
	o.lastMouseY	= e.clientY;

	if (o.hmode) {
		if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
		if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
	} else {
		if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
		if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
	}

	if (o.vmode) {
		if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
		if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
	} else {
		if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
		if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
	}

	document.onmousemove	= Drag.drag;
	document.onmouseup		= Drag.end;

	return false;
},

drag : function(e)
{
	e = Drag.fixE(e);
	var o = Drag.obj;

	var ey	= e.clientY;
	var ex	= e.clientX;
	var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
	var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
	var nx, ny;

	if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
	if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
	if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
	if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

	nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
	ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

	if (o.xMapper)		nx = o.xMapper(y)
	else if (o.yMapper)	ny = o.yMapper(x)

	Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
	Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
	Drag.obj.lastMouseX	= ex;
	Drag.obj.lastMouseY	= ey;

	Drag.obj.root.onDrag(nx, ny);
	return false;
},

end : function()
{
	document.onmousemove = null;
	document.onmouseup   = null;
	Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),
								parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
	Drag.obj = null;
},

fixE : function(e)
{
	if (typeof e == 'undefined') e = window.event;
	if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
	if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
	return e;
}
};


/**
var params = makeQuery($(IdOfTheForm);
sendAjaxRequest(params, {fncOnSuccess:FunzNameOnSuccess, URI: 'bla_ajax.php'})
*/
function sendAjaxRequest(parameters,options) {
    if (!options) options = {};
    if (!options.fncOnSuccess) options.fncOnSuccess = processAjaxResponseSuccess;
    if (!options.fncOnFailure) options.fncOnFailure = processAjaxResponseFailure;
    if (!options.asynchronous) options.asynchronous = false;
    if (!options.method) options.method = 'post';
    
    if (!options.URI) {
        if (typeof(ajaxURI) == "undefined" || !ajaxURI || ajaxURI == "undefined") {
 				options.URI = document.location.pathname;
		}
		else {
 				options.URI = ajaxURI;
		}
	}
    var t = new Date().getTime();
    new Ajax.Request(options.URI, {
	    method: options.method,
	    asynchronous: options.asynchronous,
	    parameters: parameters,
	    onComplete: options.fncOnSuccess,
   		onFailure: options.fncOnFailure
	  });
}


function processAjaxResponseSuccess(transport){
    evalRicoAjaxResponse (transport);
}

function processAjaxResponseFailure(transport){
  	alert('AJAX Error!');
}

/**
 * Takes an old-style Rico-Response and works with it.
 * 	 
 */ 
function evalRicoAjaxResponse(transport){
	if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)){
		var nodes = transport.responseXML.documentElement.childNodes;
	}
	else {
		var nodes = transport.responseXML.childNodes[0].childNodes;
	}
	for (var i = 0; i < nodes.length; i++ ) {
		var node = nodes[i];
    	if (node.nodeName == "response") {				
			var type = node.getAttribute("type");
			if (type == "object") {
		    	if (node.firstChild.getAttribute("id")) {
  					var targetElement = $( node.firstChild.getAttribute("id") );
					if (targetElement) {
						targetElement.value = node.firstChild.getAttribute("value");
					}
				}
			} else if (type == "value") {
			    if (node.getAttribute("id")) {
    				var targetElement = $( node.getAttribute("id") );
					if (targetElement) {
						targetElement.value = node.firstChild.nodeValue;
					}
				}
			} else if (type == "element") {
                var targetElement = $( node.getAttribute("id") );
				if (targetElement) {
					// Remove old child nodes
				    while (targetElement.firstChild)
                        targetElement.removeChild(targetElement.firstChild);
                    // Insert the new childs
					for (var j = 0; j < node.childNodes.length; j++) {
						if (node.childNodes[j].nodeType == 4 )
							targetElement.innerHTML = targetElement.innerHTML + node.childNodes[j].nodeValue;  
						else
							targetElement.appendChild(node.childNodes[j]);
					}
				}
			} else if (type == "message") {
				if(node.getAttribute("id"))
			    	alert(node.getAttribute("id") + ': '+ node.firstChild.nodeValue);
			    else
			    	alert(node.firstChild.nodeValue);
			} else if (type == "script") {
				var code = node.firstChild.nodeValue;
				eval(code);
			}
		}
		else if (node.nodeName == "script"){
			var code = node.firstChild.nodeValue;
			eval(code);
		}
	}
}

/**
 * callSendMail
 * sends a form to the massmail function on the affiliate site
 **/
function callSendMail(formname) {	
	if(formname == '' || !formname || typeof formname == "undefined" ) formname = 'myform';
	document.forms[formname].action = '/index.php?do=affiliate/aff_massmail.php';
	document.forms[formname].submit();
}


/**
 * jumpToResultNr
 * for setList type: compact
 **/
function jumpToResultNr(resultNr,elementId,setCounter,setSize){
//document.jumpToResultNr = function(resultNr,elementId) { 
	if (!setSize || typeof (setSize) == "undefined" || setSize <= 0) setSize = 20;
	if (!elementId || typeof (elementId) == "undefined") elementId = "set_now"; 
	
	if (!isNaN(resultNr))
		resultNr = Math.min(Math.max(1,resultNr),setCounter);
	else
		resultNr = 1;
	setNr = Math.ceil(resultNr / setSize);
	return jumpToSet(setNr, elementId);
}

/**
 * jumpToSet
 * for setList type: compact
 **/
function jumpToSet(setNr,elementId){
//document.jumpToSet = function(setNr,elementId) {
	if (!elementId || typeof (elementId) == "undefined") elementId = "set_now"; 
	if (!isNaN(setNr)) setNr = Math.max(0,setNr); else setNr = 1;
	$(elementId).value = setNr;
	window.setTimeout( function () { 
		if(eval("typeof updateSet"+elementId) == "function") {
			eval("updateSet"+elementId+"("+setNr+");");
		} else {
			$(elementId).up("form").submit(); 
		}
	}, 150 );
	return false;
}

function showdiv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
	    if (document.getElementById(id))
			document.getElementById(id).style.display = 'block';
	}
    else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}
function hidediv(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
	    if (document.getElementById(id))
			document.getElementById(id).style.display = 'none';
	}
    else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function clickclear(thisfield, color){
    if (typeof(thisfield) != undefined && typeof(color) != undefined ) {
        thisfield.style.color = color;
    	if (thisfield.value == thisfield.defaultValue) thisfield.value = "";
    	else thisfield.select();
	}
}

function blurrecall(thisfield, color ){
    if (typeof(thisfield) != undefined && typeof(color) != undefined ) {
		if (thisfield.value == '')
			thisfield.value = thisfield.defaultValue;
		if (thisfield.value == thisfield.defaultValue )
			thisfield.style.color = color ;
    }
}


/********** PART FOR HANDHISTORY ********************/
function openHandHistoryWindow(urlparams){

	var url = '/flashclient/gamehistory.php?' + urlparams;
//      window.open(url,'GAMEPLAYBACK');
	var gwindow = window.open(url,'GAMEPLAYBACK','resizable=yes,menubar=no,location=no,toolbar=no,status=no,width=820,height=610');
	if(gwindow)
		gwindow.focus();
	else
		alert('to see the hand playback you have to disable the popup blocker');

	return false;
}

function getUrlVars(){

	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++){
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	return vars;
}

function openHandhistory(){

	var params = getUrlVars();
	if(params['gnr']>0){
		urlparams='gnr='+params['gnr'];

		if(params['key'])
			urlparams = urlparams + '&key=' + params['key'];
		if(params['nick'])
			urlparams = urlparams + '&nick=' + params['nick'];
		if(params['note'])
			urlparams = urlparams + '&note=' + params['note'];

		openHandHistoryWindow(urlparams);
	}

	return false;
}

function checkHand(){

	var params = getUrlVars();
	if(params['gnr']>0){
		openHandhistory();
		if ($('popupinfo') != undefined)
			$('popupinfo').show();
	}
}

addEvent(window,'load', checkHand);


/****************************************************/

