var onload_events=new Array();
var onunload_events=new Array();
var home_url="";
//var home_url="http://www.pokernews.info/";
var action_script="en";
 
function loading(){
m=onload_events;
for(i=0;i<m.length;i++){eval(m[i]);}
}
function unloading(){
m=onunload_events;
for(i=0;i<m.length;i++){eval(m[i]);}
}
function onloading(s){
onload_events[onload_events.length]=s;
}
function pop(url,name,width,height,scrollbars,resisable){
if (url=='') {return;}
if (name=='') name='';
if (!(width>0)) width=300;
if (!(height>0)) height=200;
if (scrollbars==null) scrollbars = 'yes';
if (resisable==null) resisable = 'yes';
//url=home_url+url;
var a=window.open(url,name,"toolbar=no,scrollbars=" + scrollbars + ",titlebar=no,resizable="+resisable+",width="+width+",height="+height+",top=100,left=200");
a.focus();
}

function addbookmark(url,title){
if (document.all) window.external.AddFavorite(url,title)
}

//Function for setting the cookie
function setCookie(name) 
{
var quickexpdate = new Date();
quickexpdate.setTime(quickexpdate.getTime() + 1000*60*10); //10min
document.cookie = name + "=On;expires=" + quickexpdate.toGMTString();
}

//Function to get the cookie
function getCookie(name) 
{
var index = document.cookie.indexOf(name + "=");
if (index == -1) return null;
index = document.cookie.indexOf("=", index) + 1;
var endstr = document.cookie.indexOf(";", index);
if (endstr == -1) endstr = document.cookie.length;
return unescape(document.cookie.substring(index, endstr));
}

//Function for pop under
function goNewWin()
{
//TheNewWin = window.open("http://www.partypoker.com/affiliates/ppm20bonus_s.htm?wm=2021733","","toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1");
TheNewWin = window.open(home_url + action_script + "/2htm.pop/empire", "empp", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=700,height=300");
//TheNewWin = window.open("http://www.empirepoker.com/index.htm?wm=1702025","","toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1");
TheNewWin.blur();
}

//checks for the existance of the cookie
//Requires goNewWin, getCookie, setCookie
function CheckCook(name)
{
if(!getCookie(name)) 
{
setCookie(name);
goNewWin();
}
}

// op buttons
function setBut(pDiv,pOver) {
   if (typeof(pDiv.style) == 'undefined') {
        return false;
   }
  if (pOver) pDiv.className='prb prb2';
  else pDiv.className='prb';
}

// op buttons
function setButUs(pDiv, pOver) {
   if (typeof(pDiv.style) == 'undefined') {
        return false;
   }
  if (pOver) pDiv.style.backgroundColor='#ffffff';
  else pDiv.style.backgroundColor='#f2f2f2';
}

// top menu

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
////-------------------
function setLyr(obj,lyr)
{
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	if (lyr == 'tmenu') newX -= 224;
	var x = new getObj(lyr);
	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
}
function getObj(name) {
	if (document.getElementById) {
	 	obj = document.getElementById(name);
		if (obj) {
			this.obj = obj;
			this.style = obj.style;
		}
	} else if (document.all) {
		obj = document.all[name];
		if (obj) {
			this.obj = obj;
			this.style = obj;
		}
	} else if (document.layers) {
		if (document.layers[name]) {
			this.obj = document.layers[name];
			this.style = document.layers[name];
		} else {
			this.obj = document.layers.testP.layers[name];
			this.style = document.layers.testP.layers[name];
		}
	}
}

function smenu() {
	var x = new getObj('tmenu');
	if (x && x.style) {
    	x.style.visibility = 'visible';
		var obj = new getObj('lang2');
		if (!obj || !obj.obj) {
			obj = new getObj('moreLang');
			jQuery('#tmenu').css('margin-top', (8+jQuery('#moreLang').height())+'px');
			jQuery('#tmenu').css('margin-left', (jQuery('#moreLang').width()-jQuery('#tmenu').width()+224+10)+'px');
			//jQuery('#tmenu').css('border','1px solid red');
		}
		setLyr(obj.obj,'tmenu');
	}
}

function hmenu() {
   var x = new getObj('tmenu');
   if (x && x.style) x.style.visibility = 'hidden';
}

function resize_hdmenu() {
	var obj = new getObj('login-tabs-container');
	var addY = 0;
	if (!obj || !obj.obj) {
		obj = new getObj('pop_menu');
		addY = 1;
	}
	var x = new getObj('subscribe_tab');
	if (x && obj) {
		if (x.style && x.style.display == '') {
			var newX = findPosX(obj.obj) + obj.obj.offsetWidth - x.obj.offsetWidth;
			var newY = findPosY(obj.obj) + obj.obj.offsetHeight + addY;
			x.style.left = newX + 'px';
			x.style.top = newY + 'px';
		}
	}
	var x = new getObj('login_tab');
	if (x && obj) {
		if (x.style && x.style.display == '') {
			var newX = findPosX(obj.obj) + obj.obj.offsetWidth - x.obj.offsetWidth;
			var newY = findPosY(obj.obj) + obj.obj.offsetHeight + addY;
			x.style.left = newX + 'px';
			x.style.top = newY + 'px';
		}
	}
}

window.onresize = resize_hdmenu;

function hdmenu(id) {
	switch (id) {
		case 1 :
            if (jQuery && jQuery('#pop_menu').size()>0) {
				jQuery('#pop_b1').removeClass('active');
				jQuery('#login_tab').hide();
				if (jQuery('#pop_b0').hasClass('active')) {
					jQuery('#pop_menu').removeClass('active');
					jQuery('#pop_b0').removeClass('active');
					jQuery('#subscribe_tab').hide();
				} else {
                    jQuery('#pop_menu').addClass('active');
					jQuery('#pop_b0').addClass('active');
					jQuery('#subscribe_tab').show();
				}
				resize_hdmenu();
				return false;
			}
			var x = new getObj('subm_obj');
			if (x && x.obj) {
				if (x.obj.className != 'ftab1') {
					x.obj.className = 'ftab1';
					var y = new getObj('subscribe_tab');
					if (y && y.obj) {
						x.obj.className = 'ftab1';
						y.obj.style.display = '';
					}
					var x = new getObj('login_tab');
					if (x && x.obj) x.obj.style.display = 'none';
					resize_hdmenu();
					return false;
				} else {
					// Hide TABS
					x.obj.className = '';
					var x = new getObj('subscribe_tab');
					if (x && x.obj) x.obj.style.display = 'none';
					var x = new getObj('login_tab');
					if (x && x.obj) x.obj.style.display = 'none';
					return false;
				}
			} else return true;
			break;
		case 2 :
            if (jQuery && jQuery('#pop_menu').size()>0) {
				jQuery('#pop_b0').removeClass('active');
				jQuery('#subscribe_tab').hide();
				if (jQuery('#pop_b1').hasClass('active')) {
					jQuery('#pop_menu').removeClass('active');
					jQuery('#pop_b1').removeClass('active');
					jQuery('#login_tab').hide();
				} else {
                    jQuery('#pop_menu').addClass('active');
					jQuery('#pop_b1').addClass('active');
					jQuery('#login_tab').show();
				}
				resize_hdmenu();
				return false;
			}

			var x = new getObj('subm_obj');
			if (x && x.obj) {
				if (x.obj.className != 'ftab2') {
					var y = new getObj('subscribe_tab');
					if (y && y.obj) {
						x.obj.className = 'ftab2';
						y.obj.style.display = 'none';
					}
					var x = new getObj('login_tab');
					if (x && x.obj) x.obj.style.display = '';
					resize_hdmenu();
					return false;
				} else {
					x.obj.className = '';
					var x = new getObj('subscribe_tab');
					if (x && x.obj) x.obj.style.display = 'none';
					var x = new getObj('login_tab');
					if (x && x.obj) x.obj.style.display = 'none';
					return false;
				}
			} else return true;
			break;
	}
}
////////////////
function dstr(str, ex) {
	c = str.substr(0, 2);
	t = "";
	for (i = 2; i < str.length; i += 2) { 
		h = parseInt(str.substr(i, 2), 16);
		c ^= h;
		t += String.fromCharCode(c);
		c = h;
	}
	if (ex) eval(t); else document.write(t);
}

//////////// TEAM START ///////////////////
function starSwitch(item) {
  for (i=1;i<=3;i++) {
    obj = document.getElementById("starmenu"+i);
    if (obj) {
      if (item == i) obj.className="star_item_active";
      else obj.className="star_item_normal";
    }
  }
}

function switchLine(id, state) {
	var x = getElement(id);
	if (state == 1) x.style.backgroundColor = "#c5af96";
	else x.style.backgroundColor = "";
}

function switchASMLine(id, state) {
	var x = getElement(id);
	if (state == 1) x.style.backgroundColor = "#810404";
	else x.style.backgroundColor = "";
}

function switchWSOP2006Line(id, state) {
	var x = getElement(id);
	if (state == 1) x.style.backgroundColor = "#216cb8";
	else x.style.backgroundColor = "";
}

function switchASM2008Line(id, state) {
	var x = getElement(id);
	if (state == 1) x.style.backgroundColor = "#900";
	else x.style.backgroundColor = "";
}

function switchSAPO2008Line(id, state) {
	var x = getElement(id);
	if (state == 1) x.style.backgroundColor = "#362416";
	else x.style.backgroundColor = "";
}

//////////// TEAM END //////////////
function getElement(id) { 
   return document.getElementById ? document.getElementById(id) : 
   document.all ? document.all(id) : null; 
} 

/////////// FLASH START ///////////////

var flash_version_req = 6;
var flash_navigator = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( flash_navigator ) {
	var flash_version = navigator.plugins["Shockwave Flash"].description.split(" ");
	for (var i = 0; i < flash_version.length; ++i) {
		if (isNaN(parseInt(flash_version[i]))) continue;
		var flash_ver = flash_version[i];
	}
	var flash_enabled = (flash_version_req < flash_ver);
} else if (navigator.userAgent && (navigator.userAgent.indexOf("MSIE") >= 0)  && (navigator.appVersion.indexOf("Win") != -1)) document.write('<scr' + 'ipt language=vbscript\> \n on error resume next \n flash_enabled = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & flash_version_req)))\n </scr' + 'ipt\> \n');

function show_flash(src, fv, w, h, bg, wm) {
	if (flash_enabled) document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+ w +'" height="'+ h +'">\n<param name="movie" value="'+ src +'" />\n<param name="quality" value="high" />\n<param name="bgcolor" value="'+ bg +'" />\n<param name="wmode" value="'+ wm +'" />\n<param name="FlashVars" value="'+ fv +'" /><embed src="'+ src +'" FlashVars="'+ fv +'"  wmode="'+ wm +'" bgcolor="'+ bg +'"  width="'+ w +'" height="'+ h +'" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" /></object>');
}

/////////// FLASH END /////////////////

//////////// PARTYPOKER START ///////////////

function pp_roll(obj, img) {
	obj.src = "/i/pp_" + img + ".gif";
}

function pp_preload(img) {
	preload_image_object = new Image();
	for (var i = 0; i < img.length; i++) preload_image_object.src = "/i/pp_" + img[i] + ".gif";;
}

//////////// PARTYPOKER END ///////////////

function show_flayer(ob1, ob2, left, top) {
	var obj1 = new getObj(ob1);
	var obj2 = new getObj(ob2);
	if (obj2 && obj1) {
		var x = findPosX(obj2.obj) + left;
		var y = findPosY(obj2.obj) + top;
		obj1.style.left = x + 'px';
		obj1.style.top = y + 'px';
		obj1.style.visibility = 'visible';
		obj1.offsetParent = obj2;
	}
}

function v_email(email){
	var EmailCorrect = false;
	for (var i = 0; i <= email.length; i++) if (email.charAt(i) == "@") EmailCorrect = true;
	for (var u = 0; u <= email.length; u++) if (email.charAt(u) == "#" || email.charAt(u) == "%" ||  email.charAt(u) == "*" || email.charAt(u) == "?" || email.charAt(u) == ";" || email.charAt(u) == "/") EmailCorrect = false;
	var EMLength = email.length;
	if (email.charAt(EMLength-3) != "." && email.charAt(EMLength-4) != "." && email.charAt(EMLength-5) != ".") EmailCorrect = false;
	return EmailCorrect;
}

/// digg link

function dig_this() {
	var url='http://digg.com/submit?phase=2&url='+encodeURIComponent(location.href);
	window.open(url);
}

function delicious_this() {
	var url='http://del.icio.us/post?v=4;url='+encodeURIComponent(location.href)+';title='+encodeURIComponent(document.title);
	window.open(url);
}

//banner (parodo baneri)
function banner(o)
{
	var s='';
	var names= ['zone', 'id', 'exid', 'ad_type', 'media_type', 'limit', 'interval'];
	var n;
	for (i=0;i<names.length;i++) {
		n = names[i];
		if (typeof(o[n]) != "undefined" && o[n]) s+='&'+n+'='+encodeURI(o[n]);
	}
	document.write(unescape('%3C')+'script src="/r/?t='+(new Date()).getTime() + s + '" type="text/javascript"'+unescape('%3E%3C')+'/script'+unescape('%3E'));
}

function ng_banners_iterate(set_id, interval) 
{
	if (!document.getElementById) {
		return;
	}
	if (!document.getElementsByTagName) {
		return;
	}
	if ('' == interval) {
		interval = 30000;
	}
	setInterval('ng_banners_shift(' + set_id + ')', interval)
}
function ng_banners_shift(set_id) {
	var ngSet = document.getElementById('ng-ad-block-'+set_id);
	if (!ngSet) {
		return;
	}
	if (ngSet.is_ngb_mouseover && true == ngSet.is_ngb_mouseover) {
		return;
	}
	var ngA = ngSet.getElementsByTagName('div');
	var ngOffset = 10;
	if (ngA.length<1) {
		return;
	}
	var i;
	for (i = 0; i < ngA.length; i++) {
		var cn = ' ' + ngA[i].className + ' ';
		if (!cn.match(/ hide /)) {
			ngOffset = i;
		}
	}
	ngA[ngOffset].className = ngA[ngOffset].className + ' hide';
	ngOffset++;
	ngOffset %= ngA.length;
	var cn = ' ' + ngA[ngOffset].className + ' ';
	cn = cn.replace(/ hide /,'');
	cn = cn.replace(new RegExp('^\s+|\s+$', 'g'),'');
	ngA[ngOffset].className = cn;
}
function ng_block_mouseover(o)
{
	o.is_ngb_mouseover = true;
}
function ng_block_mouseout(o)
{
	o.is_ngb_mouseover = false;
}

/* Audrius (2009-02). Adjust iframe height */
function iframeFix(iframe, stop)
{
	var hThis = 0;
	if (!iframe.style) return;
	if (typeof(stop)=="undefined") stop = 0;
	iframe.style.height = '1px';
    if (iframe.contentDocument && iframe.contentDocument.document) {
		hThis = iframe.contentDocument.body.scrollHeight;
	} else if (iframe.contentWindow && iframe.contentWindow.document) {
		hThis = iframe.contentWindow.document.body.scrollHeight;
		if (!hThis && stop<10) {
			setTimeout(function(){iframeFix(iframe,stop+1)},2000);
			return;
		}
	}
	if (hThis>0) {
		iframe.style.height = (15+hThis) + 'px';
	}
}

function trackOutgoing(parentObject)
{
	if (typeof(parentObject)!='object' && document) {
		parentObject = document;
	}
	var trackFunc =function() {
		var aHref = this.href.toLowerCase();
		if (aHref.indexOf("/ext/") > -1 || aHref.indexOf("/download/") > -1) {
			if (typeof(pageTracker) != "undefined") {
				pageTracker._trackPageview(this.href);
                //dabar Simonui ru
				if (document.domain && document.domain == "ru.pokernews.com") {
				    var link=document.URL.substring(document.URL.indexOf(document.domain)+document.domain.length, document.URL.length);
					pageTracker._trackPageview("/pokernewsclick"+link+"?"+this.href);
				}
			}
		}
	}
	jQuery("a[href*='/download/']", parentObject).click(trackFunc);
	jQuery("a[href*='/ext/']", parentObject).click(trackFunc);
	return true;
}