$(function(){
//plus icon
$(".hp_promo_footer_area:last-child").addClass('plus');
//popup for tabs - local news
$("a.popup").click(function(){$(".hppopupbox .content").html($(this).parent().next().html());$(".hppopupbox").fadeIn('fast').show();});
$(".hppopupbox .close").click(function(){$(".hppopupbox").fadeOut('fast').hide();});
// promotions //
$('#hp_promo .wrapper .item').hover(function(){$(this).find('img').animate({top:'220px'},{queue:false,duration:300});},function(){$(this).find('img').animate({top:'0'},{queue:false,duration:300});});
var bmove=178,sign="+="+bmove+"px",itemcount=$(".wrapper-scroll .item").size(),maxitem=itemcount-2,titem=1,selitem=1;
$(".wrapper").scrollTo(0,0);
$(".wrapper").scrollTo('0px',1,{axis:'x'});
$("#hp_promo #arrow_left a,#hp_promo #arrow_right a").hide();
if(itemcount>3){
var promotimer=null;
$("#hp_promo #arrow_right a").show();
$("#hp_promo #arrow_left a").click(function(){
	clearInterval(promotimer);
	promotimer=null;
	if(selitem>1){
		$(".wrapper").scrollTo('-='+bmove+'px',500,{axis:'x'});
		$("#hp_promo #arrow_right a").fadeIn();
		selitem--;
	}
	if(selitem==1)$("#hp_promo #arrow_left a").fadeOut();
	return false;
});
$("#hp_promo #arrow_right a").click(function(){
	clearInterval(promotimer);
	promotimer=null;
	if(selitem<maxitem){
		$(".wrapper").scrollTo('+='+bmove+'px',500,{axis:'x'});
		$("#hp_promo #arrow_left a").fadeIn();
		selitem++;
	}
	if(selitem==maxitem)$("#hp_promo #arrow_right a").fadeOut();
	return false;
});
function scrollpromo(){
	if(selitem==maxitem){titem=-1;sign="-="+bmove+"px";}else if(selitem==1){titem=1;sign="+="+bmove+"px";}
	selitem+=titem;
	if(selitem>1)$("#hp_promo #arrow_left a").fadeIn();
	if(selitem<maxitem)$("#hp_promo #arrow_right a").fadeIn();
	if(selitem==1)$("#hp_promo #arrow_left a").fadeOut();
	if(selitem==maxitem)$("#hp_promo #arrow_right a").fadeOut();
	$(".wrapper").scrollTo(sign,500,{axis:'x'});
}
function setscrollpromo(){promotimer=setInterval(scrollpromo,5000);}
setscrollpromo();

	$("#hp_promo").hover(function(){clearInterval(promotimer);promotimer=null;},function(){setscrollpromo();});
	$("#hp_promo .item").click(function(){document.location.href=$(this).find('a:first').attr('href');});
}
$("#hp_promo .wrapper-scroll .item:last-child").css({'width':(bmove-7)+'px'});
$("#hp_promo .wrapper-scroll").css({'width':($("#hp_promo .wrapper-scroll .item").width()*$("#hp_promo .wrapper-scroll .item").size()-7)+'px'});
// tabs //
$("#tabs .tab-2 a").attr("href","#tab-2");
$('#tabs > ul').tabs().tabs('rotate',10000);
$('#tabs').hover(function(){$('#tabs > ul').tabs('rotate',0);},function(){$('#tabs > ul').tabs('rotate',5000);});
$(".scroller").jScrollPane({showArrows:true});

}); // and $(function())

function hpgetlang(){
	return document.getElementsByTagName('html')[0].getAttribute('lang');
}
//tournament feed
function hpgetlangid(){var aro={'en':'en_US','it':'it_IT'};var lang=document.getElementsByTagName('html')[0].getAttribute('lang');return (aro[lang]==="undefined")?aro['en']:aro[lang];}

function get_hp_tournament_feed(startsat){
$.getJSON('/news/feeds/PokerTourneyFeed_PARTYIT_'+hpgetlangid()+'.js',function(i){
	function sortby(a,b){var order='asc';var x=eval("a.timestamp.toString().toLowerCase()");var y=eval("b.timestamp.toString().toLowerCase()");return(order=='asc')?((x<y)?-1:((x>y)?1:0)):((x>y)?-1:((x<y)?1:0));}
	var mya=i,tmpa=[],y=0;
	for(var x=0;x<mya['Tournaments'].length;x++){
		var t=mya['Tournaments'][x],tl=t['Name'].toLowerCase();
		if(tl.search("gtd")>-1&&tl.search("satellite")==-1&&tl.search("qualifier")==-1){tmpa[y]={'timestamp':t['StartDate'],'prize':t['PrizePool'],'limit':t['LimitType']};y++;}
	};
	tmpa.sort(sortby);
	$("#tab-2 .scroller").empty();
	for(var z=0;z<10;z++) $("#tab-2 .scroller").append("<p><a href=\"/tournaments/schedule.htm\"><strong>"+tmpa[z]['prize']+"</strong> Gtd <span>"+tmpa[z]['limit']+"</span> "+startsat+" <span>"+tmpa[z]['timestamp'].split(' ').slice(1,3).join(' ')+"</span></a></p>");
	$('#tab-2 .scroller').jScrollPane({showArrows:true});
});
}//sifr//
var etelka={src:'/images/etelka.swf'};
sIFR.activate(etelka);
sIFR.replace(etelka,{selector:'#hp_branding_right h1',css:'.sIFR-root{font-size:18px;color:#ffffff;leading:0;}',wmode:'transparent'});
sIFR.replace(etelka,{selector:'#hp_branding_right h2',css:'.sIFR-root{font-size:16px;color:#FFFFFF; font-style:italic;leading:0; width:265px;}',wmode:'transparent'});
sIFR.replace(etelka,{selector:'#hp_promo h2',wmode:'transparent',css:['.sIFR-root { font-size:16px; color:#EDBB27;}','.sIFR-root a { color:#EDBB27; text-decoration: none; }','.sIFR-root a:hover { color:#EDBB27; text-decoration: none; }','.sIFR-root a:visited { color:#EDBB27; text-decoration: none; }']});
sIFR.replace(etelka,{selector:'#hp_promo_footer h3',css:'.sIFR-root{font-size:13px;color:#EDBB27;leading:0;cursor:pointer;text-align:center;}',wmode:'transparent',onRelease:function(){jQuery("#panel").slideToggle("slow");jQuery("#panel").toggleClass("active");if(jQuery("#panel").hasClass('active')){$(".hp_promo_footer_area:last-child").addClass('minus');}else{$(".hp_promo_footer_area:last-child").removeClass('minus');};return false;}});
sIFR.replace(etelka,{selector:'#hp_learn .one',css:'.sIFR-root{line-height:48px;font-size:17px;font-style:italic;color:#ffffff;leading:0;cursor:pointer;text-align:left;}',wmode:'transparent',onRelease:function(){location.href=jQuery("#hp_learn a:eq(0)").attr('href');}});
//utils.js
function getChildLocation(L,J,K,F,M,B){var E=30;var I=parseInt(K+"");var D=parseInt(F+"");var C=parseInt(M+"");var A=parseInt(B+"");var H=parseInt((I-(C+10))/2);H=H+parseInt(L+"");var G=parseInt((D-(A+E))/2);G=G+parseInt(J+"");topLeft=parseInt(H+"");topRight=parseInt(G+"");return"screenX="+topLeft+",screenY="+topRight+",left="+topLeft+",top="+topRight}function getScreenXYParamString(A,B){return getChildLocation(0,0,window.screen.width,window.screen.height,A,B)}function round(C,B){C=C-0;B=B||2;var A=Math.pow(10,B);C=Math.round(C*A)/A;C+=Math.pow(10,-(B+1));C+="";return B==0?C.substring(0,C.indexOf(".")):C.substring(0,C.indexOf(".")+B+1)}function getScreenXYParamsStringWithOffset(B,G){var E=30;var C=781;var D=537;var A=round((window.screen.width-C)/2,0);var F=round((window.screen.height-(D+E))/2,0);topLeft=parseInt(A+"");topRight=parseInt(F+"");topLeft=topLeft+B;topRight=topRight+G;return"screenX="+topLeft+",screenY="+topRight+",left="+topLeft+",top="+topRight}function getDateString(){var A=new Date();return A.getHours()+""+A.getMinutes()+""+A.getSeconds()+""+A.getMilliseconds()}function isRefresh(A){if(window.event){keyNum=A.keyCode}else{if(A.which){keyNum=A.which}}if(keyNum==116||(A.ctrlKey&&keyNum==82)||(A.metaKey&&keyNum==82)){top.frames[6].document.GameLobby.doJob("31","","");top.reset()}}var currentContainerProps=new WindowProps("","",0,0,false);var pageIndex=0;var pageURLs=new Array();function WindowProps(D,C,E,B,A){this.url=D;this.customWin=C;this.width=E;this.height=B;this.isSameDomain=A}function getPageAt(A){return pageURLs[A]}function getWindowProps(D){var B=false;if(D.indexOf(document.domain)!=-1){B=true}else{B=false}D=D+"";if(D==""){null}var C="";var F=D.split(",");D=F[0];var E,A;if(F.length>=2){if(F[1]=="0"){C="resizable=no,toolbar=no,"}E=460;A=480}if(F.length==4){E=F[2];A=F[3]}if(isIEInNN==null){if(navigator.appName&&navigator.appName.indexOf("Netscape")==-1&&navigator.appVersion.indexOf("Netscape")!=-1){E=E+iDeltaWidth;A=A+iDeltaHeight;isIEInNN="Yes"}else{isIEInNN="No"}}else{if(isIEInNN=="Yes"){E=E+iDeltaWidth;A=A+iDeltaHeight}}return new WindowProps(D,C,E,A,B)};

function genericSetCookie(B,D,A,F,C,E){document.cookie=B+"="+escape(D)+((A)?"; expires="+A.toGMTString():"")+((F)?"; path="+F:"")+((C)?"; domain="+C:"")+((E)?"; secure":"")}
function genericGetCookie(C){var B=document.cookie;
var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){D=B.indexOf(E);
if(D!=0){return null}}else{D+=2}var A=document.cookie.indexOf(";",D);
if(A==-1){A=B.length}return unescape(B.substring(D+E.length,A))}
function getWMURL(A){location.href=A+"?wm="+genericGetCookie("PPWMID")}function switchLang(B){var C=B;
var A=C;var D=new Date();
D.setTime(D.getTime()+2592000000);
genericSetCookie("PPLCID",A,D,"/",".partypoker.it",0);
location.href=A};
function switchLang(B){
        var C=B;
        var A=C;
        var Z = document.location.href;
        var U="";
        var D=new Date();
        D.setTime(D.getTime()+2592000000);
        genericSetCookie("PPLCID",A,D,"/",".partypoker.it",0);
        var Y = Z.split('/');
        var I = (Y[0].length) + (Y[2].length)
        var U  = Z.substring(I+2,Z.length);
        window.location.href=B+U;
        return false;
};
