function getid(elid) {
	return document.getElementById(elid);
}
function sharefacebook() {
	window.open('http://www.facebook.com/share.php?u=' + shareurl);
}
function sharetwitter() {
}
function sharedigg() {
}
function sharebookmark(){
	title = sharetitle;
	url = shareurl;
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}
var cdsec = [];
var cdmin = [];
var cdhou = [];
var cdday = [];
function countdown(id) {
	cdsec[id] = cdsec[id] - 1;
	if (cdsec[id] == 0) {
		cdsec[id] = 59;
		cdmin[id] = cdmin[id] - 1;
		if (cdmin[id] == 0) {
			cdmin[id] = 59;	
			cdhou[id] = cdhou[id] - 1;
			if (cdhou[id] == 0) {
				cdhou[id] = 23;
				cdday[id] = cdday[id]-1;
			}
		}
	}
	var sec = cdsec[id].toString();
	if (sec.length == 1) {
		sec = '0' + sec;
	}
	var min = cdmin[id].toString();
	if (min.length == 1) {
		min = '0' + min;
	}
	var hou = cdhou[id].toString();
	if (hou.length == 1) {
		hou = '0' + hou;
	}
	var day = cdday[id].toString();
	if (day.length == 1) {
		day = '0' + day;
	}
	getid('sec' + id + 'a').innerHTML = sec.substring(0,1);
	getid('sec' + id + 'b').innerHTML = sec.substring(1,2);
	getid('min' + id + 'a').innerHTML = min.substring(0,1);
	getid('min' + id + 'b').innerHTML = min.substring(1,2);
	getid('hou' + id + 'a').innerHTML = hou.substring(0,1);
	getid('hou' + id + 'b').innerHTML = hou.substring(1,2);
	getid('day' + id + 'a').innerHTML = day.substring(0,1);
	getid('day' + id + 'b').innerHTML = day.substring(1,2);
	setTimeout('countdown(\'' + id + '\');',1000);
}
function startcountdown() {
	var divs = document.getElementsByTagName("input");
	for (i=0;i<divs.length;i++) {
		if (divs[i].className == 'cd-stamp') {
			var id = divs[i].id.substring(5);
			var stamp = getid(divs[i].id).value;
			var dif = stamp-timestamp;
			var day = dif/(24*60*60);
			day = Math.floor(day);
			dif = dif-(day*24*60*60);
			var hou = dif/(60*60);
			hou = Math.floor(hou);
			dif = dif-(hou*60*60);
			var min = dif/60;
			min = Math.floor(min);
			dif = dif-(min*60);
			var sec = dif;
			cdsec[id] = sec;
			cdmin[id] = min;
			cdhou[id] = hou;
			cdday[id] = day;
			countdown(id);
		}
	}
}
function showhand(handid,placeid) {
	getid(handid).style.left = posx + 'px';
	getid(handid).style.top = posy + 'px';
	showdivthat(handid);
}
function hidehand(handid) {
	hidedivthat(handid);
}
function menuover(id,color) {
	showdivthat('rd-' + id);
	changeclassthat('me-' + id + '-le','me-but-' + color + '-le-on');
	changeclassthat('me-but-' + id,'me-but-on');
	changeclassthat('me-' + id + '-ri','me-but-' + color + '-ri-on');
}
function menuout(id,color) {
	hidedivthat('rd-' + id);
	changeclassthat('me-' + id + '-le','me-but-' + color + '-le');
	changeclassthat('me-but-' + id,'me-but');
	changeclassthat('me-' + id + '-ri','me-but-' + color + '-ri');
}
function goto(targeturl) {
	window.location = targeturl;
}
function tab(targeturl) {
	window.open(targeturl);
}
function yousure(message, url) {
	if(confirm(message)) location.href = url;
}
function openwindow(url,name,features) {
	window.open(url,name,features);
}
function submitform(formid) {
	getid(formid).submit();
}
function getvaluethat(changeid,changeto) {
	return getid(changeid).value;
}
function changevaluethis(changeid,changeto) {
	changeid.value = changeto;
}
function changevaluethat(changeid,changeto) {
	getid(changeid).value = changeto;
}
function changeimagethis(changeid,changeto) {
	changeid.src = changeto;
}
function changebackgroundthis(changeid,changeto) {
	changeid.style.backgroundImage = "url('" + changeto + "')";
}
function changebackgroundthat(changeid,changeto) {
	getid(changeid).style.backgroundImage = "url('" + changeto + "')";
}
function changeimagethat(changeid,changeto) {
	getid(changeid).src = changeto;
}
function changeclassthis(changeid,changeto) {
	changeid.className = changeto;
}
function changeclassthat(changeid,changeto) {
	getid(changeid).className = changeto;
}
function changetitlethat(changeid,changeto) {
	getid(changeid).title=changeto;
}
function changetitlethis(changeid,changeto) {
	changeid.title=changeto;
}
function changeheightthat(changeid,changeto) {
	getid(changeid).style.height = changeto + 'px';
}
function changeheightthis(changeid,changeto) {
	changeid.style.height = changeto + 'px';
}
function showdivthis(showid) {
	showid.style.visibility = "visible";
}
function showdivthat(showid) {
	getid(showid).style.visibility = "visible";
}
function hidedivthis(hideid) {
	hideid.style.visibility = "hidden";
}
function hidedivthat(hideid) {
	getid(hideid).style.visibility = "hidden";
}
function changemouseoverthis(changeid,changeto) {
	changeid.setAttribute("onmouseover",changeto);
}
function changemouseoverthat(changeid,changeto) {
	getid(changeid).setAttribute("onmouseover",changeto);
}
function changemouseoutthis(changeid,changeto) {
	changeid.setAttribute("onmouseout",changeto);
}
function changemouseoutthat(changeid,changeto) {
	getid(changeid).setAttribute("onmouseout",changeto);
}
function changeclickthis(changeid,changeto) {
	changeid.setAttribute("onclick",changeto);
}
function changehtmlthat(changeid,changeto) {
	getid(changeid).innerHTML=changeto;
}
function changehtmlthis(changeid,changeto) {
	changeid.innerHTML=changeto;
}
function changecolorthat(changeid,changeto) {
	getid(changeid).style.color = changeto;
}
function changeopacitythis(changeid,changeto,changeto2) {
	changeid.style.opacity = changeto;
	changeid.style.filter = 'alpha(opacity=' + changeto2 + ')';
}
function fullopacitythis(changeid) {
	changeid.style.opacity = '1';
	changeid.style.filter = 'alpha(opacity=100)';
}
var divs = [];
var divclasses = [];
var divclassesload = false;
function divclassnames() {
	var divs2 = document.getElementsByTagName("div");
	var j = 0;
	for (i=0;i<divs2.length;i++) {
		var divclass = divs2[i].className;
		if (divclass.substr(divclass.length-2,2) == '-x') {
			divclasses[j] = divclass;
			divs[j] = divs2[i];
			j = j + 1;
		}
	}
	divclassesload = true;
}
function hideall(hideclass) {
	if (divclassesload) {
		for (i=0;i<divs.length;i++) {
			if (divclasses[i] == hideclass) {
				hidedivthis(divs[i]);
			}
		}
	} else {
		var divstemp = document.getElementsByTagName("div");
		for (i=0;i<divstemp.length;i++) {
			var adiv = divstemp[i].className;
			if (divstemp[i].className == hideclass) {
				hidedivthis(divstemp[i]);
			}
		}
	}
}
function showone(showid,hideclass) {
	hideall(hideclass);
	showdivthat(showid);
}
function hidetv() {

	showdivthat('si-videos-header');

	showdivthat('si-videos');

	hidedivthat('si-tvguide-header-' + tvguide);

	hidedivthat('si-tvguide');
	hidedivthat('si-tvguide-' + tvguide);
}

function showtv() {
	hidedivthat('si-videos-header');
	hidedivthat('si-videos');
	showdivthat('si-tvguide-header-' + tvguide);

	showdivthat('si-tvguide');

	showdivthat('si-tvguide-' + tvguide);
	if (home) {
		showone('home-videos-' + tvguidevideos[tvguide],'home-videos-x');
	}
}
function swaptv(changeto) {

	hidedivthat('si-tvguide-dd-list-' + tvguide);
	hidedivthat('si-tvguide-header-' + tvguide);

	hidedivthat('si-tvguide-' + tvguide);

	tvguide = changeto;

	showdivthat('si-tvguide-header-' + tvguide);

	showdivthat('si-tvguide-' + tvguide);

	savesession('tvguide_' + tvguide);
	if (home) {
		showone('home-videos-' + tvguidevideos[tvguide],'home-videos-x');
	}
}
function hidepassword() {
	changehtmlthat('to-club-password','<input type="password" name="password" id="to-club-password-field" tabindex="2">');
	setTimeout("getid('to-club-password-field').focus()", 10);
}
function clubhidepassword() {
	changehtmlthat('club-activate-password','<input type="password" name="password" id="club-activate-password-field" tabindex="2">');
	setTimeout("getid('club-activate-password-field').focus()", 10);
}
function clubhidepassword2() {
	changehtmlthat('club-activate-password2','<input type="password" name="password2" id="club-activate-password2-field" tabindex="2">');
	setTimeout("getid('club-activate-password2-field').focus()", 10);
}
function staylogincheck() {
	changehtmlthat('to-club-stay','<img src="./p/b/to/club/check.gif" id="to-club-stay-field" onclick="stayloginuncheck();">');
	changevaluethat('staylogin','1');
}
function stayloginuncheck() {
	changehtmlthat('to-club-stay','<img src="./p/b/to/club/uncheck.gif" id="to-club-stay-field" onclick="staylogincheck();">');
	changevaluethat('staylogin','0');
}
function ajload(url) {
	if (subdomain == "www") {
		getid('aj').setAttribute('src',url);
	} else {
		getid('aj').setAttribute('src','http://' + subdomain + '.poker.org' + url);
	}
}
function videopartover(partnum,color) {
	changeclassthat('videos-part-le-' + partnum, 'videos-part-' + color + '-le-on');
	changeclassthat('videos-part-mid-' + partnum, 'videos-part-' + color + '-mid-on');
	changeclassthat('videos-part-ri-' + partnum, 'videos-part-' + color + '-ri-on');
}
function videopartout(partnum,color) {
	changeclassthat('videos-part-le-' + partnum, 'videos-part-' + color + '-le');
	changeclassthat('videos-part-mid-' + partnum, 'videos-part-' + color + '-mid');
	changeclassthat('videos-part-ri-' + partnum, 'videos-part-' + color + '-ri');
}
function togglelockthread(id) {
	ajload('/post/toggle/' + id + '/');
}
function videopartwatch(videoid,partnum,parts) {
	ajload('/watchpart/' + videoid + '/' + partnum + '/');
	for (i2=0;i2<parts;i2++) {

		i = i2+1;

		if (i == partnum) {
			newcolor = 'green';
		} else {
			newcolor = 'grey';
		}

		changemouseoverthat('videos-part-' + i,'videopartover(\'' + i + '\',\''+ newcolor +'\');');
		changemouseoutthat('videos-part-' + i,'videopartout(\'' + i + '\',\''+ newcolor +'\');');

		changeclassthat('videos-part-le-' + i, 'videos-part-' + newcolor + '-le');
		changeclassthat('videos-part-mid-' + i, 'videos-part-' + newcolor + '-mid');
		changeclassthat('videos-part-ri-' + i, 'videos-part-' + newcolor + '-ri');
	}
}
function savesession(id) {

	ajload('/save/' + id + '/');

}
function newpost() {
	getid('edit').value = 0;
	getid('reply').value = 0;
	changehtmlthat('co-submit','<input type="image" class="ma-form-submit" src="c/submit/post-reply.gif" onMouseOver="changeimagethis(this,\'c/submit/post-reply-on.gif\');" onMouseOut="changeimagethis(this,\'c/submit/post-reply.gif\');" value="Post Reply" title="Post Reply">');
	changehtmlthat('ma-error','');
}
function deleteblog(blogid) {
	var answer = confirm("Are you sure you want to delete this blog?")
	if (answer){
		goto('/blogs/delete/' + blogid + '/');
	}
}
function deletepost(postid) {
	var answer = confirm("Are you sure you want to delete this post?")
	if (answer){
		ajload('/post/delete/' + postid + '/');	
	}
}
function deletemessage(messageid,question,type) {
	var answer = confirm(question)
	if (answer){
		ajload('/club/messages/delete/' + messageid + '/' + type + '/');	
	}
}
function addleader(teamid,playerid,ask,type) {
	var answer = confirm(ask);
	if (answer) {
		ajload('/club/add-leader/' + teamid + '/' + playerid + '/' + type + '/');	
	}
}
function removeleader(teamid,playerid,ask,type) {
	var answer = confirm(ask);
	if (answer) {
		ajload('/club/remove-leader/' + teamid + '/' + playerid + '/' + type + '/');
	}
}
function leaveteam(teamid,playerid,ask,type) {
	var answer = confirm(ask);
	if (answer) {
		ajload('/club/leave-team/' + teamid + '/' + playerid + '/' + type + '/');	
	}
}
function jointeam(teamid,playerid,type) {
	ajload('/club/join-team/' + teamid + '/' + playerid + '/' + type + '/');	
}
function removefriend(friendid,ask,type) {
	var answer = confirm(ask);
	if (answer) {
		ajload('/club/remove-friend/' + friendid + '/' + type + '/');	
	}
}
function addfriend(friendid,type) {
	ajload('/club/add-friend/' + friendid + '/' + type + '/');	
}
function editpost(id) {
	getid('edit').value = id;
	getid('reply').value = 0;
	changehtmlthat('co-submit','<input type="submit" class="ma-submit" value="Edit Post" onmouseover="changeclassthis(this,\'ma-submit-on\');" onmouseout="changeclassthis(this,\'ma-submit\');">');
	changehtmlthat('ma-error','');
	ajload('/post/edit/' + id + '/');
}
function replypost(id,player) {
	getid('edit').value = 0;
	getid('reply').value = id;
	changehtmlthat('co-submit','<input type="submit" class="ma-submit" value="Post Reply" onmouseover="changeclassthis(this,\'ma-submit-on\');" onmouseout="changeclassthis(this,\'ma-submit\');"><div class="co-reply-to2"> to <b>' + player + '</b></div>');
}
function quotepost(id,postnum) {
	getid('edit').value = 0;
	getid('reply').value = id;
	changehtmlthat('ma-error','');
	ajload('/post/quote/' + id + '/' + postnum + '/');
	changehtmlthat('co-submit','<input type="submit" class="ma-submit" value="Post Reply" onmouseover="changeclassthis(this,\'ma-submit-on\');" onmouseout="changeclassthis(this,\'ma-submit\');" title=\"Post Reply\">');
}
function ratepost(postid,updown,ratingsum) {
	var ratingupdown;
	changehtmlthat('co-rate-' + postid,'<img src="c/co/rated-' + updown + '.gif">');
	if (updown == 'up') {
		ratingsum++;
	} else {
		ratingsum--;
	}
	if (ratingsum > 0) {
		ratingupdown = 'up';
		ratingsign = '+';
	} else if (ratingsum < 0) {
		ratingupdown = 'down';
		ratingsign = '';
	} else {
		ratingupdown = 'def';
		ratingsign = '&plusmn;';
	}
	changehtmlthat('co-rating-' + postid,ratingsign  + ratingsum);
	changeclassthat('co-rating-' + postid,'co-rating-' + ratingupdown);
	changeclassthat('co-rating-le-' + postid,'co-rating-' + ratingupdown + '-le');
	changeclassthat('co-rating-ri-' + postid,'co-rating-' + ratingupdown + '-ri');
	ajload('/post/rate/' + postid + '/' + updown + '/');
}

function switchleft(side,one,two) {

	if (side == "first") {

		changeclassthat(one,'le-but-1-active-on');

		changemouseoverthat(one,"changeclassthis(this,'le-but-1-active-on');");

		changemouseoutthat(one,"changeclassthis(this,'le-but-1-active');");
		changeclassthat(two,'le-but-2-inactive');

		changemouseoverthat(two,"changeclassthis(this,'le-but-2-inactive-on');");
		changemouseoutthat(two,"changeclassthis(this,'le-but-2-inactive');");
	} else {

		changeclassthat(one,'le-but-2-active-on');

		changemouseoverthat(one,"changeclassthis(this,'le-but-2-active-on');");
		changemouseoutthat(one,"changeclassthis(this,'le-but-2-active');");
		changeclassthat(two,'le-but-1-inactive');
		changemouseoverthat(two,"changeclassthis(this,'le-but-1-inactive-on');");
		changemouseoutthat(two,"changeclassthis(this,'le-but-1-inactive');");
	}
	return false;

}
function switchright(side,one,two) {

	if (side == "first") {
		changeclassthat(one,'ri-but-1-active-on');
		changemouseoverthat(one,"changeclassthis(this,'ri-but-1-active-on');");
		changemouseoutthat(one,"changeclassthis(this,'ri-but-1-active');");
		changeclassthat(two,'ri-but-2-inactive');
		changemouseoverthat(two,"changeclassthis(this,'ri-but-2-inactive-on');");
		changemouseoutthat(two,"changeclassthis(this,'ri-but-2-inactive');");
	} else {
		changeclassthat(one,'ri-but-2-active-on');
		changemouseoverthat(one,"changeclassthis(this,'ri-but-2-active-on');");
		changemouseoutthat(one,"changeclassthis(this,'ri-but-2-active');");
		changeclassthat(two,'ri-but-1-inactive');
		changemouseoverthat(two,"changeclassthis(this,'ri-but-1-inactive-on');");
		changemouseoutthat(two,"changeclassthis(this,'ri-but-1-inactive');");
	}
	return false;

}
function openchat() {
	getid('chfe').setAttribute('src','/chfe.php?openchat=true');
}
