/******************
 *Copyright(c) 2003-2009 TopTenREVIEWS Inc.
 *Created By Daniel Galloway
 *Last Modified 2/5/2009
 ******************/

function abusebox(type,loadurl,width,height,popHeadCode){
	var testUrl = new String(loadurl);
	var index=testUrl.indexOf('report_abuse.php');
	if (testUrl.indexOf('be-the-first.html') > 0 && popHeadCode != 'onclick') {
		return false;
	}
	else if(testUrl.indexOf('report_abuse.php')==-1)
	{
		return false;
	}
    if(window.grayBoxLoading==false){
		window.grayBoxLoading = true;
		setTimeout('window.grayBoxLoading=false;',1000);
		ifm=document.getElementById('popfrm');
		if(type == 1){
			// default width and height if not set
			width=(typeof(width) == "undefined") ? 500:width;
			height=(typeof(height) == "undefined") ? 500:height;
			// hide scroll bars
			windowscroll=document.getElementsByTagName('html')[0];
			//windowscroll.style.overflow="hidden";

			// make the div visible
			box=document.getElementById('faderbox');
			box.style.opacity=0;
			box.style.filter="alpha(opacity=0)";
			showhidediv('faderbox',1);
			// fade in
			window.gbinterval=setInterval("fadeBox('faderbox',0.6)",25);

			// set the top and left based on browser window position
			// get position of pop window

			leftscroll=(document.documentElement.scrollLeft) ?  document.documentElement.scrollLeft : document.body.scrollLeft;
			topscroll=(document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
			// make IE and opera play nice together

			browseheight=(window.innerHeight) ? window.innerHeight:document.documentElement.clientHeight;
			browsewidth=(window.innerWidth) ? window.innerWidth:document.documentElement.clientWidth;

			// if the browser is smaller than the window will be..
			height=(browseheight < height) ? browseheight:height;
			width=(browsewidth < width) ? browsewidth:width;

			browseheight=(browseheight < height) ? 0:browseheight;
			boxtop=(browseheight/2) + topscroll;
			boxtop=boxtop-(height/2);
			boxtop=(boxtop <=0) ? 0:boxtop;

			browsewidth=(browsewidth < width) ? 0:browsewidth;
			boxleft=(browsewidth/2) + leftscroll;
			boxleft=boxleft-(width/2);
			boxleft=(boxleft <= 0) ? 0:boxleft;

			// show the content area with the iframe
			ifm.src=loadurl;
			ifm.style.height=(height)+ "px";
			ifm.style.width=(width - 4)+ "px";
			contbox=document.getElementById('popcontent');

			contbox.style.top=boxtop + "px";
			contbox.style.left=boxleft + "px";

            document.getElementById('pophead').contentWindow.document.body.style.padding="0";
            document.getElementById('pophead').contentWindow.document.body.style.margin="0";
            document.getElementById('pophead').contentWindow.document.body.style.background="#ABABC2";
            document.getElementById('pophead').contentWindow.document.body.style.border="0";
            document.getElementById('pophead').contentWindow.document.getElementsByTagName('html')[0].style.overflow="hidden";
            document.getElementById('pophead').style.width=(width - 8) + "px";

            if(typeof(popHeadCode)=="undefined" || popHeadCode == 'onclick'){
                document.getElementById('pophead').contentWindow.document.body.innerHTML='<div style="width:45px; margin-top:5px; float:right;"><a style="font-size:12px; color:#000000; text-decoration:none;" href="javascript:top.popgbox(2);"><img src="http://www.toptenreviews.com/i/community/w_close.gif" border="0" alt="close box"/> Close</a></div>';
            }
            else {
                document.getElementById('pophead').contentWindow.document.body.innerHTML = popHeadCode;
                document.getElementById('pophead').contentWindow.document.body.style.background="#FFFFFF";

            }
            // slide the content div out?

			// for now just set the width and height to what was passed in
			contbox.style.height=height + "px";
			contbox.style.width=(width-4) + "px";
			contbox.style.display="block";
			// call some function to slide it
		}else{
			// hide the content div
			showhidediv('popcontent',2);
			ifm.src='http://www.toptenreviews.com/community/greybox/blank.html';
			// fade it out
			window.gbinterval=setInterval("fadeBox('faderbox',0)",25);

			// put back the scrolls
			windowscroll=document.getElementsByTagName('html')[0];
			windowscroll.style.overflow="auto";
			// and for safari and chrome
			document.body.scrollTop += 1;
			document.body.scrollTop -= 1;
		}
	}
}