var xmlDoc;

document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
};
function sidebarRight() {
	tt=document.getElementById('sidebar-right');
	if (!tt) {
		return;
	}
	if (document.body.clientWidth<920) {tt.style.display='none'}
	else {
		tt.style.display='block';
		document.documentElement.className=document.documentElement.className+" withrightbanner";
//		document.getElementById('wrap').style.width="920px";
//		document.getElementById('main').style.marginRight='130px';
	}
}
function setreviewheight() {
	tt=getElementsBySelector(document.getElementById('psreview'),".content");
	ttt=getElementsBySelector(document.getElementById('psreview'),".content .left");
	if (tt[0].clientHeight>ttt[0].clientHeight) {
//		ttt[0].style.height=tt[0].clientHeight-90+"px";
	} else {
		tt[0].style.height=ttt[0].clientHeight+"px";
	}
}
function pausecomp(millis)
{
	date = new Date();
	var curDate = null;
	do { var curDate = new Date(); }
	while(curDate-date < millis);
} 
function swapExclusive() {
	tt=HTTPGet("\/item\/106\/rand");
	document.getElementById("eo").innerHTML=tt;
	setTimeout("swapExclusive()",8000);
}
function sendLink(op) {
	tt=document.getElementById('forward');
	frommail=document.getElementById('forward-mail').value;
	fromname=document.getElementById('forward-name').value;
	tomail=document.getElementById('forward-fmail').value;
	switch (op) {
		case "open":
			if (window.innerWidth) {
				tt.style.left=(window.innerWidth-650)/2+"px";
			} else {
				tt.style.left=document.body.offsetLeft+20+"px";
			}
			tt.style.top=document.documentElement.scrollTop+20+"px";
			tt.style.display="block";
			break;
		case "close":
			document.getElementById('firststage').style.display='';
			document.getElementById('fault').style.display='none';
			document.getElementById('success').style.display='none';
			tt.style.display="none";
			break;
		case "send":
			action="remotecall.php";
			data=new Object();
			data['request']='mail';
			data['to']=tomail;
			data['mailfrom']=frommail;
			data['namefrom']=fromname;
			data['mailid']="602";
			data['field1']=document.location.href;
			tt.style.cursor="wait";
	 		resp=HTTPPost(action,false,null,data);
			tt.style.cursor="default";
			if (resp==1) {
				document.getElementById('firststage').style.display='none';
				document.getElementById('success').innerHTML=document.getElementById('success').innerHTML.replace("{friendsemail}",tomail);
				document.getElementById('success').style.display='block';
			} else {
				document.getElementById('firststage').style.display='none';
				document.getElementById('fault').innerHTML=document.getElementById('success').innerHTML.replace("{friendsemail}",tomail);
				document.getElementById('fault').style.display='block';
			}
			break;
	}
}
var lastOpened;
function showHide3Select(sender) {
	if (lastOpened && lastOpened!=sender) {
		document.getElementById('cselect_'+lastOpened).className='cselect';
		lastOpened=null;
	}
	sselects=document.getElementById('cselect_'+sender);
	if (sselects.className=='cselect') {
		sselects.className='cselect opened';
		document.getElementById('scrolled_'+sender).style.width=Math.max(sselects.clientWidth,document.getElementById('scrolled_'+sender).clientWidth)+"px";
		lastOpened=sender;
	} else {
		sselects.className='cselect'
	}
}

function add2fav(){
	title='OnlinePokeReport.com';
	url='http://www.onlinepokereport.com';
	if (document.all)
		window.external.AddFavorite(url, title);
	else if (window.sidebar)
		window.sidebar.addPanel(title, url, "")
}
function setAsHome(f) {
	if ( navigator.appVersion.indexOf('MSIE') != -1) {
		f.style.behavior='url(#default#homepage)'; f.setHomePage('http://www.onlinepokereport.com');
	} else { //FF
		document.location.href='faq.html';
	}
}

function count_link() {
	HTTPGet("/directory/cl.php?id="+this.id);
	return true;
}
function validateLogin() {
	frm=document.getElementById("user-login-form");
	if (frm.elements['edit-name'].value && frm.elements['edit-pass'].value) {
		return true;
	} else {
		alert ('Both username and password fields have to be entered');
		return false;
	}
}
function  postCommentCheck() {
	forma=document.getElementById("comment_form");
	nname=forma.elements['edit-name'];
	mmail=forma.elements['edit-mail'];
	namemailOK=true;
	if (nname) {
//		namemailOK=(nname.value.length>3 && mmail.value.length>5);
		namemailOK=(nname.value.length && mmail.value.length);
	}
	try {   
		content=tinyMCE.getContent();
	} catch (err) {
		content=document.getElementById("edit-comment").value;
	}
	if (content.length && namemailOK) {
		return true;
	} else {
		alert("Some required fields are empty.\nPlease fill all the required fields to add a comment.");
		return false;
	}
}
function showCommentForm(hide) {
	tt=document.getElementById("floated-comment-form");
	if (!tt) return false;
	if (hide) {
		tt.style.display='none';
	} else {
		if (window.innerWidth) {
			tt.style.left=(window.innerWidth-650)/2+"px";
		} else {
			tt.style.left=document.body.offsetLeft+20+"px";
		}
		tt.style.top=document.documentElement.scrollTop+20+"px";
		tt.style.display='block';
	}
}
function restoreEmails(){
	var rt=document.getElementsByTagName('A');
	var cc=rt.length;
	for (i=20; i<cc; i++) {
		if(rt[i].id != '') {
			rt[i].onclick = count_link;
		}
		if (rt[i].href.indexOf("@")>0) {
			rt[i].href=rt[i].href.replace("::-::","@");
		}
	}
}
function CheckEmail(Email) {

	hasDot = Email.indexOf(".");
	hasAt = Email.indexOf("@");

	if (hasDot == -1 || hasAt == -1) {
		alert("Please enter a valid email address.");
		return false;
	}
	return true;
}
function subscribeToHunter() {
	email1=document.getElementById('hunterEmail').value;
	if (CheckEmail(email1)) {
		action="remotecall.php";
		data=new Object();
 		data['action']="http://www.specialbonus.org/sendmaster/users/form.php?FormID=87";
 		data['FormCode']="1c7707d2e39ba6f977af95d85ee84fcc";
 		data['Format']="2";
		data['SelectLists[32]']="YES";
		data['request']='bonushunter';
		data['Email']=email1;
 		tt=HTTPPost(action,false,null,data)
		if (tt) {
			//document.getElementById('hunterForm').innerHTML='Thank you for your subscription';
			document.getElementById('hunterForm').innerHTML=tt;
			//setTimeout('document.getElementById("hunterForm").parentNode.parentNode.style.display="none"',5000);
		};
	}
}
function clickButton(which) {
	if (which=document.getElementById(which)) {
		which.click();
	}
}
function runnewsmarquee() {
	i=0;
	tt=document.getElementById('block-views-news_block');
	if (tt) {
		while (tt.childNodes[i].className!='content') {i++}
		ttt=tt.childNodes[i];
		if (ttt) {
			ttt.innerHTML="<marquee onmouseover='this.stop()' onmouseout='this.start()' direction='up' id='newsmarquee' scrolldelay='30' truespeed='1' scrollamount='1'>"+ttt.innerHTML+"</marquee>";
			document.getElementById('newsmarquee').start();
		}
	}
}
function showBigImage(sender) {
	if (document.getElementById('bigimage')) {
		tt=document.getElementById('bigimage');
		if (tt.style.display=='block') {
			tt.style.display='none';
			tt.removeChild(document.getElementById("BIImg"));
			tt.innerHTML="";
		} else {
			abutton="";
			if (sender.getAttribute("buttonData")) {
				abutton=sender.getAttribute("buttonData").split("|");
				abutton="<table cellpadding='0' cellspacing=0'><tr><td class='sshot-button-left'></td><td class='sshot-button-center'><a href='"+abutton[1]+"' target='"+abutton[3]+"' title='"+abutton[2]+"'>"+abutton[0]+"</a></td><td class='sshot-button-right'></td></tr></table>";
			}
			aclose="<table class='sshot-button'><tr><td width='50'><a href='javascript:showBigImage(false)'>Close</a></td>";
			
			ttt=document.createElement('IMG');
			ttt.src=sender.src.replace("thub.","");
			ttt.id="BIImg";
			tt.appendChild(ttt);
			tt.innerHTML=tt.innerHTML+aclose+"<td align='center'>"+abutton+"</td></tr></table>";
			if (window.innerWidth) {
				tt.style.left=(window.innerWidth-250)/2+"px";
			} else {
				tt.style.left=document.body.offsetLeft+20+"px";
			}
			tt.style.top=document.documentElement.scrollTop+20+"px";
			tt.style.display='block';
			
		}
	}
}
function showHideComment(sender) {
	if (sender.parentNode.className=="comment unfolded") {
		sender.parentNode.className="comment";
		sender.nextSibling.style.display='none';
	} else {
		sender.parentNode.className="comment unfolded";
		sender.nextSibling.style.display='block';
	}
}
//DRAGGING
function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }
}

function setAsHomepage()
{
	f=document.getElementById("setashome-icon");
	if ( navigator.appVersion.indexOf('MSIE') != -1) {
		f.style.behavior='url(#default#homepage)'; f.setHomePage('http://www.onlinepokereport.com'); 
	} else {
		location.href='/doc/startpage.html' 
	}
}
addLoadEvent(restoreEmails);
addLoadEvent(sidebarRight);


