//document.domain = 'toptenreviews.com';

function resizeFont(element_id, amount, min, max)
{
    amount = Number(amount);
    var font = document.getElementById(element_id);
    doResize(font, amount, min, max);
}

function resizeFontClass(tag_name, class_name, amount, min, max)
{
    amount = Number(amount);
    var all_tags = document.getElementsByTagName(tag_name);
    for (var i = 0; i < all_tags.length; i++)
    {
        if (all_tags[i].className == class_name)
        {
            var font = all_tags[i];
            doResize(font, amount, min, max);
        }
    }
}

function doResize(font, amount, min, max)
{
    var old_size = "12px";
    if (document.defaultView && document.defaultView.getComputedStyle)
    {
        old_size = parseInt(document.defaultView.getComputedStyle(font, "").getPropertyValue("font-size").replace('px', '').replace('em', '').replace('pt', ''));
    }
    else if (font.currentStyle)
    {
        old_size = parseInt(font.currentStyle.fontSize.replace('px', '').replace('em', '').replace('pt', ''));
    }

    if (amount == 0 || old_size == 0)
    {
        return false;
    }
    if (old_size+amount < min)
    {
        font.style.fontSize = min;
    }
    else if (old_size+amount > max)
    {
        font.style.fontSize = max;
    }
    else
    {
        font.style.fontSize = (old_size+amount)+"px";
    }
}

function initSmoothScroll()
{
    window.addEvent('domready',function() { new SmoothScroll({ duration:3000 }, window); });
}


/*//////////////////////////////
    Javascript left navigation

    Takes a javascript data feed var called nav_data and uses it to generate a nav when the user hovers over nav elements.
//////////////////////////////*/


var nav_timeout = null;

function buildLeftNavBox(nav_element_id, data, data_section, bullet_image, left_offset, e)
{
    nav_element = document.getElementById(nav_element_id);

    if (!nav_element.defaultClassName)
    //defines the defaultClassName for the nav elements hovered over.
    {
        nav_element.defaultClassName = nav_element.className;
        if (nav_element.className.indexOf('left_nav_subcat_text') != -1
            && nav_element.parentNode.className.indexOf('left_nav_subcat_box') != -1
            && !nav_element.parentNode.defaultClassName)
        {
            nav_element.parentNode.defaultClassName = nav_element.parentNode.className;
        }
    }

    if (!data || !nav_element)
    //the nav needs either of these vars defined properly to work.
    {
        return false;
    }

    //Clear left nav elements except for the current element ID, which is the safe nav element.
    clearLeftNav(nav_element_id);

    var leftnav = document.getElementById('leftnav');
    var all_divs = leftnav.getElementsByTagName('div');
    var all_children = nav_element.getElementsByTagName('div');
    for (var i = 0; i < all_divs.length; i++)
    //This block loops through all divs in left nav and grays them out.
    {
        if (all_divs[i].className.indexOf('left_nav') != -1
            && all_divs[i].defaultClassName
            && all_divs[i].className.indexOf('grayed') == -1)
        {
            var found = false;
            for (var i2 = 0; i2 < all_children.length; i2++)
            {
                if (all_divs[i] == all_children[i2])
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                all_divs[i].className += ' grayed';
            }
        }

        if ((nav_element.className.indexOf('left_nav_subcat_text') != -1 || nav_element.className.indexOf('left_nav_subcat_box') != -1) && all_divs[i].defaultClassName)
        //This will reset the top-level nav elements when they get grayed out when switching to another top-level nav element.
        {
            all_divs[i].className = all_divs[i].defaultClassName;
        }
    }

    for (var i = 0; i < leftnav.childNodes.length; i++)
    //This block clears main nav element gray classes when going down a level in the nav.
    {
        if (leftnav.childNodes[i].className
            && leftnav.childNodes[i].className.indexOf('left_nav_subcat_box') != -1
            && leftnav.childNodes[i].className.indexOf('static') == -1
            && leftnav.childNodes[i].defaultClassName)
        {
            var subcat_all_divs = leftnav.childNodes[i].getElementsByTagName('div');
            var found = false;
            for (var i2 = 0; i2 < subcat_all_divs.length; i2++)
            {
                if (subcat_all_divs[i2] == nav_element)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                leftnav.childNodes[i].className = leftnav.childNodes[i].defaultClassName;
                for (var i2 = 0; i2 < leftnav.childNodes[i].childNodes.length; i2++)
                {
                    if (leftnav.childNodes[i].childNodes[i2].className
                        && leftnav.childNodes[i].childNodes[i2].className.indexOf('left_nav_subcat_text') != -1
                        && leftnav.childNodes[i].childNodes[i2].className.indexOf('static') == -1
                        && leftnav.childNodes[i].childNodes[i2].defaultClassName)
                    {
                        leftnav.childNodes[i].childNodes[i2].className = leftnav.childNodes[i].childNodes[i2].defaultClassName;
                    }
                }
            }
        }
    }

    if (data[data_section])
    {
        //These two functions are the in/out events of the majority of elements, other than the "list" elements which can pop up a new nav.
        var outevent = function(e) { clearTimeout(nav_timeout); nav_timeout = window.setTimeout('clearLeftNav()', 5);  if (!e) { e = window.event; } cancelBubbling(e); return false; };
        var inevent = function(e) { clearTimeout(nav_timeout);  if (!e) { e = window.event; } cancelBubbling(e); return false; };

        //Creates the containing box for the new nav
        var box = document.createElement('div');
        box.className = "left_nav_pop_menu";
        if (!box.defaultClassName) { box.defaultClassName = box.className; }
        box.style.position = "absolute";
        box.style.display = "block";
        box.onmouseout = outevent;
        box.onmouseover = function(e) {
        //This function is different from the normal function because of the space at the top of the box between
        //the first element and the edge.
            if (!e)
            {
                e = window.event;
            }
            if (e.fromElement)
            //IE
            {
                if (e.srcElement.className.indexOf('left_nav_pop_menu') != -1
                    && (e.fromElement.className.indexOf('left_nav_pop_link_top') != -1
                        || e.fromElement.parentNode.className.indexOf('left_nav_pop_link_top') != -1))
                {
                    //Clears navs but sends the current nav as the safe nav instead of any new navs.
                    clearTimeout(nav_timeout);
                    var parent_menu = grab_parent_menu(e.srcElement);
                    nav_timeout = window.setTimeout("clearLeftNav('" + parent_menu.parentNode.id + "');", 5);
                    var parent_children = e.srcElement.childNodes;
                    //reset box
                    e.srcElement.className = e.srcElement.defaultClassName;
                    //reset tab in previous nav that leads to box
                    e.srcElement.parentNode.className = e.srcElement.parentNode.defaultClassName;
                    for (var i = 0; i < parent_children.length; i++)
                    //reset all of the children of the box.
                    {
                        if (parent_children[i].defaultClassName)
                        {
                            parent_children[i].className = parent_children[i].defaultClassName;
                        }
                    }
                    if (e.srcElement.parentNode.parentNode.className.indexOf('left_nav_subcat_box') != -1
                        && e.srcElement.parentNode.parentNode.defaultClassName)
                    //if a top level element, reset the subcat_box also, since the parent is subcat_text which is reset above.
                    {
                        e.srcElement.parentNode.parentNode.className = e.srcElement.parentNode.parentNode.defaultClassName;
                    }
                }
                else
                {
                    clearTimeout(nav_timeout);
                }
            }
            else if (e.relatedTarget)
            //DOM2 (same as above)
            {
                if (e.target.className.indexOf('left_nav_pop_menu') != -1
                    && (e.relatedTarget.className.indexOf('left_nav_pop_link_top') != -1
                        || e.relatedTarget.parentNode.className.indexOf('left_nav_pop_link_top') != -1))
                {
                    clearTimeout(nav_timeout);
                    var parent_menu = grab_parent_menu(e.target);
                    nav_timeout = window.setTimeout("clearLeftNav('" + parent_menu.parentNode.id + "');", 5);

                    var parent_children = e.target.childNodes;
                    e.target.className = e.target.defaultClassName;
                    e.target.parentNode.className = e.target.parentNode.defaultClassName;
                    for (var i = 0; i < parent_children.length; i++)
                    {
                        if (parent_children[i].defaultClassName)
                        {
                            parent_children[i].className = parent_children[i].defaultClassName;
                        }
                    }
                    if (e.target.parentNode.parentNode.className.indexOf('left_nav_subcat_box') != -1
                        && e.target.parentNode.parentNode.defaultClassName)
                    {
                        e.target.parentNode.parentNode.className = e.target.parentNode.parentNode.defaultClassName;
                    }
                }
                else
                {
                    clearTimeout(nav_timeout);
                }
            }
            cancelBubbling(e);
        };
        //insert box before inserting anything into box, due to opera/safari/chrome bug that causes it to not be able tor ead the class without it being in the DOM.
        nav_element.insertBefore(box, nav_element.firstChild);

        //calculate left margin for new nav
        var new_margin = getStyleProp(nav_element, 'width')+getStyleProp(nav_element, 'border-right-width');
        if (window.opera)
        //Opera hack.  Opera appears to include padding in the width.
        {
            new_margin -= getStyleProp(nav_element, 'padding-left')+getStyleProp(nav_element, 'padding-right');
        }

        if (left_offset)
        {
            new_margin += left_offset;

            if (document.all && !document.querySelector)
            //Double the offset for IE, but not IE8
            {
                new_margin += left_offset;
            }
        }

        if (nav_element.className.indexOf('left_nav_pop_link') != -1)
        {
            if (document.all)
            {
                new_margin -= 14;
            }
            else if (window.opera)
            {
                new_margin += 9;
            }
            else
            {
                new_margin += 12;
            }
        }
        else if (document.all)
        {
            new_margin -= 16;
        }

        box.style.marginLeft = new_margin + "px";

        var new_margin = 0;
        if (!window.opera)
        //Opera hack
        {
            new_margin += getStyleProp(nav_element, 'border-top-width')+getStyleProp(nav_element, 'padding-top')+getStyleProp(nav_element, 'margin-top');
        }
        if (!new_margin)
        //In case there is no margin (probably due to incompatible CSS), set the margin to 1.
        {
            new_margin = 1;
        }

        box.style.marginTop = "-" + new_margin + "px";
        //box.style.backgroundColor = document.defaultView ? getStyleProp(nav_element, 'background-color') : camelize(getStyleProp(nav_element, 'background-color'));
        if (data[data_section].length > 0)
        {
            if (typeof document.body.style.maxHeight != "undefined")
            //Adds the blank space that covers a piece of the regular border in order to make the tab from the first nav merge into the new nav.
            {
                var blank_space = document.createElement('div');
                blank_space.className = 'left_nav_blank_space';
                blank_space.defaultClassName = blank_space.className;
                var nav_size = getStyleProp(nav_element, 'height');//+getStyleProp(nav_element, 'border-bottom-width')+getStyleProp(nav_element, 'padding-bottom')+getStyleProp(nav_element, 'padding-top');

                blank_space.style.position = "absolute";
                blank_space.style.height = nav_size+"px";
                var box_width = getStyleProp(box, 'border-left-width');

                blank_space.style.width = box_width+"px";
                var margin_offset = getStyleProp(box, 'padding-top');

                blank_space.style.marginTop = (-margin_offset)+"px";
                margin_offset = getStyleProp(box, 'padding-left')+getStyleProp(box, 'border-left-width');

                blank_space.style.marginLeft = (-margin_offset)+"px";

                //blank_space.style.backgroundColor = document.defaultView ? getStyleProp(nav_element, 'background-color') : camelize(getStyleProp(nav_element, 'background-color'));
                blank_space.onmouseout = outevent;
                blank_space.onmouseover = inevent;
                box.appendChild(blank_space);
            }

            //adds new list items based on the nav data presented to it.
            var site_array = data[data_section];
            for (var i = 0; i < site_array.length; i++)
            {
                var list_item = document.createElement('div');
                list_item.className = "left_nav_pop_link";
                if (i == 0)
                //top nav element
                {
                    list_item.className += " left_nav_pop_link_top";
                }
                else if (i == site_array.length-1)
                //bottom nav element
                {
                    list_item.className += " left_nav_pop_link_bottom";
                }
                if (!list_item.defaultClassName) { list_item.defaultClassName = list_item.className; }
                list_item.id = site_array[i]["id"];
                list_item.onmouseout = outevent;
                list_item.onmouseover = inevent;

                if (bullet_image)
                //if there is a bullet image....
                {
                    var new_bullet_image = document.createElement('img');
                    new_bullet_image.className = 'nav_bullet_image';
                    new_bullet_image.src = bullet_image;
                    new_bullet_image.onmouseout = inevent;
                    new_bullet_image.onmouseover = inevent;
                    list_item.appendChild(new_bullet_image);
                }

                var link = document.createElement('a');
                link.href = site_array[i]["url"];
                link.appendChild(document.createTextNode(site_array[i]["name"]));
                link.onmouseout = outevent;
                //Removed because it was causing a bubbling problem in Safari.
                //link.onmouseover = inevent;

                if (site_array[i]["data"])
                {
                    //nasty workaround to solve scoping issues.
                    //This was the only way to get the variables within the events to stick without being overridden.
                    var scoping_workaround = function(list_item, data_arg, new_id_arg) {
                        var data2 = data_arg;
                        var new_id2 = new_id_arg;

                        list_item.onmouseout = function(e) {
                            clearTimeout(nav_timeout);
                            nav_timeout = window.setTimeout("clearLeftNav('" + new_id2 + "');", 5);
                        };
                        list_item.onmouseover = function(e) {
                            buildLeftNavBox(new_id2, data2, data_section, bullet_image ? bullet_image : '', left_offset);
                        };
                    }

                    var s_e = new scoping_workaround(list_item, site_array[i]["data"], site_array[i]["id"]);
                }

                list_item.appendChild(link);
                box.appendChild(list_item);
            }
        }

        if (box.parentNode.defaultClassName)
        //This resets the top-level nav elements after building a new nav.
        {
            box.parentNode.className = box.parentNode.defaultClassName;

            if (box.parentNode.parentNode.className.indexOf('left_nav_subcat_box') != -1
                && box.parentNode.parentNode.defaultClassName)
            {
                box.parentNode.parentNode.className = box.parentNode.parentNode.defaultClassName;
            }
        }

        //Safari/Opera/Chrome bug:  Can't use document.defaultView.getComputedStyle on elements that haven't been added to the DOM yet.
        //To fix it I had to put the insertBefore before I called any getStyleProp()s.
        //nav_element.insertBefore(box, nav_element.firstChild);
    }
}

function clearLeftNav(nav_element_id_safe)
//This should always be put on a timer, otherwise it will clear the nav before you have a chance to hover over it.
{
    if (nav_timeout)
    {
        clearTimeout(nav_timeout);
    }

    var leftnav = document.getElementById('leftnav');

    var all_divs = leftnav.getElementsByTagName('div');

    var parent_array = new Array();
    if (nav_element_id_safe)
    //if there is a safe element, define nav_element and find all of its parent menus.
    {
        var nav_element = document.getElementById(nav_element_id_safe);
        var possible_menu = nav_element.firstChild;
        _rec_check_parent(possible_menu, parent_array);
        parent_array.push(possible_menu);
    }
    else
    {
        //If no safe element define, reset all top-level navs.
        for (var i = 0; i < leftnav.childNodes.length; i++)
        {
            var subcat = leftnav.childNodes[i];
            if (subcat.className && subcat.className.indexOf('left_nav_subcat_box') != -1 && subcat.defaultClassName)
            {
                subcat.className = subcat.defaultClassName;
                for (var i2 = 0; i2 < subcat.childNodes.length; i2++)
                {
                    if (subcat.childNodes[i2].className
                        && subcat.childNodes[i2].className.indexOf('left_nav_subcat_text') != -1
                        && subcat.childNodes[i2].defaultClassName)
                    {
                        subcat.childNodes[i2].className = subcat.childNodes[i2].defaultClassName;
                    }
                }
            }
        }
    }



    var all_boxes = new Array();
    for (var i = 0; i < all_divs.length; i++)
    //adds all boxes to an array.
    {
        if (all_divs[i].className.indexOf('left_nav_pop_menu') != -1)
        {
            all_boxes.push(all_divs[i]);
        }
    }

    for (var i = 0; i < all_boxes.length; i++)
    //loop through all of the boxes and remove it, but only if it doesn't appear in the parent array.
    {
        var found = false;
        if (parent_array.length > 0)
        {
            for (var i2 = 0; i2 < parent_array.length; i2++)
            {
                if (parent_array[i2] === all_boxes[i])
                {
                    found = true;
                    break;
                }
            }
        }

        if (!found)
        {
            all_boxes[i].parentNode.removeChild(all_boxes[i]);
        }
    }
}

function _rec_check_parent(child, parent_array)
//This function can be used recursively to grab all parent menus
{
    if (child.parentNode)
    {
        if (child.parentNode.className && child.parentNode.className.indexOf('left_nav_pop_menu') != -1)
        {
            parent_array.push(child.parentNode);
        }
        _rec_check_parent(child.parentNode, parent_array);
    }
}

function grab_parent_menu(child)
//Finds the menu no matter what element the event executes on.
{
    if (child.className && child.className.indexOf('left_nav_pop_menu') != -1)
    {
        return child;
    }
    if (child.parentNode)
    {
        return grab_parent_menu(child.parentNode);
    }
    return null;
}

function getStyleProp(element, property)
//Gets a style from an element.  Some named properties aren't currently supported, such as "auto", though it does try to recover from such errors since they occur often on opera and safari.
{
    var value = null;
    if (element.currentStyle)
    //IE and Opera
    {
        value = element.currentStyle[camelize(property)];
    }
    else if (document.defaultView && document.defaultView.getComputedStyle)
    //FireFox, Safari, and Chrome
    {
        value =  document.defaultView.getComputedStyle(element, "").getPropertyValue(property);
    }

    return value !== null && value.match(/(?:px|em|pt)/i) ? cleanStyle(element, property, parseInt(value.replace(/(?:px|em|pt)/g, ''))) : cleanStyle(element, property, value);
}

function cleanStyle(element, property, value)
//Tries to find named properties when there should be a number and replace them with numbers.  More of a quick hack for the nav and not a function to use casually.
{
    if (value == "auto" || value == "medium")
    {
        if (!element.parentNode)
        {
            //Causes errors in IE5
            //throw new Exception('Unable to find style property in parents in nav.');
            return 0;
        }
        value = cleanStyle(element.parentNode, property, getStyleProp(element.parentNode, property));
    }

    return parseInt(value).toString() == "NaN" ? value : parseInt(value);
}


function camelize(in_string) {
//taken from prototype because it works on Opera and IE5.  These two browsers break when passing delegates to String.replace().
//turns a string with dashes into a semi-camel-cased string so it works with IE and opera.
    var parts = in_string.split('-'), len = parts.length;
    if (len == 1) return parts[0];

    var camelized = in_string.charAt(0) == '-'
      ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
      : parts[0];

    for (var i = 1; i < len; i++)
      camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);

    return camelized;
  }

function cancelBubbling(e)
//cross-browser bubble canceling.
{
    if (!e)
    {
        e = window.event;
    }
    e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
}
//////////////
// end stuff for the CE style left nav ?
/////////////////////////
function toggleSlideDisappear(objname,obj2name){
    if(document.getElementById(objname).style.display == "none"){
        // div is hidden, so let's slide down
        //slideup(obj2name);
        document.getElementById(obj2name).style.display = "none";
        document.getElementById(objname).style.display = "block";
    }else{
        // div is not hidden, so slide up
        slideup(objname);
    }
}
function toggleSlide2(objname) {
    if (document.getElementById(objname).style.display == "none") {
        document.getElementById(objname).style.display = "block";
        var imagevar = objname + "img";
        changearrow(imagevar, "http://toptenreviews.com/i/new_temp/down-arrow.gif");
    }
    else {
        document.getElementById(objname).style.display = "none";
        var imagevar = objname + "img";
        changearrow(imagevar, "http://toptenreviews.com/i/new_temp/right-arrow.gif");
    }
}

function changearrow(img_name,img_src) {
    document.getElementById(img_name).src=img_src;
}

function toggleSlide3(objname){
  if(document.getElementById(objname).style.display == "none"){
    slidedown(objname);

  }else{
    // div is not hidden, so slide up
	//slideup(objname);

  }
}

//graybox stuff---------------------------------------------------------
function fadeBox(divName, endOpac){
	var grayBox = document.getElementById(divName);
	var i = parseFloat(grayBox.style.opacity);
	var step = 0.1;

	if(endOpac){
		if(i < endOpac){
			i += step;
			document.getElementById(divName).style.filter = "alpha(opacity=" + i*100 + ")";
			document.getElementById(divName).style.opacity = i;
		}else window.gbinterval = clearInterval(window.gbinterval);
	}else{
		if(i > endOpac){
			i -= step;
			document.getElementById(divName).style.filter = "alpha(opacity=" + (i*100) + ")";
			document.getElementById(divName).style.opacity = i;
		}else {
			window.gbinterval = clearInterval(window.gbinterval);
			showhidediv(divName,2);
		}
	}
}

function showhidediv(divname,type){
	box=document.getElementById(divname);
	box.style.display=(type==1) ? "block":"none";
}

//use this for a greybox fadeout
function smokeScreen(divId,endOpac){
    if(endOpac>0){
        // hide scroll bars
        windowscroll=document.getElementsByTagName('html')[0];
        windowscroll.style.overflow="hidden";
        //initialize opacity
        box=document.getElementById(divId);
        box.style.opacity=0;
        box.style.filter="alpha(opacity=0)";
        //make div visible
        showhidediv(divId,1);
    }
    else{
        // 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;
    }
    // fade in/out
    window.gbinterval=setInterval("fadeBox('"+divId+"',"+endOpac+")",25);
}

//this function will scroll to and element and trigger the smokescreen
//set the smokescreen z-index to be lower than the element for highlight effect
//highlightElementHeight is in pixels and endOpacity is a number between 0 and 1
//to turn off the smoke screen simply call the smokeScreen function with an endOpac of 0
function spotLight(highlightId,smokeScreenId,highlightElementHeight,endOpacity){
    if(endOpacity>1) endOpacity = 1;
    else if(endOpacity<0) endOpacity = 0;
    var height = (window.innerHeight) ? window.innerHeight : document.documentElement.clientHeight;
    var eTop = document.getElementById(highlightId).offsetTop;
    var scrollLoc = eTop + (highlightElementHeight - height)/2.0;
    if(scrollLoc<0) scrollLoc = 0;
    smokeScreen(smokeScreenId,endOpacity);
    document.getElementById(smokeScreenId).style.top = scrollLoc+'px';
    document.body.scrollTop = scrollLoc;
    document.documentElement.scrollTop  = scrollLoc;
}

//this is a greybox with an iframe popup in it
window.grayBoxLoading = false;
function popgbox(type,loadurl,width,height,popHeadCode){
	var testUrl = new String(loadurl);
	if (testUrl.indexOf('be-the-first.html') > 0 && popHeadCode != 'onclick') {
		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;

            //call the smokescreen
            smokeScreen('faderbox',0.6);

			// 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;
			if(popHeadCode==-1)ifm.style.height = height + "px";
            else ifm.style.height = (height - 25) + "px";
			ifm.style.width = width + "px";
			contbox=document.getElementById('popcontent');

			contbox.style.top=boxtop + "px";
			contbox.style.left=boxleft + "px";

            if(popHeadCode!=-1){
                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 + "px";
                document.getElementById('pophead').style.border="0px";

                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";

                }
            }
            else{
                document.getElementById('pophead').style.height="0px";
            }
            // 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 + "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
			smokeScreen('faderbox',0);
		}
	}
}
//end graybox stuff-----------------------------------------------------

var is_logfrm_first_load = true;

//login stuff--------------------------------------
function checklogstatus(iFrameId,loginDivId,errorDivId,pwdDivId,msgDivId) {
    if(is_logfrm_first_load){
        is_logfrm_first_load = false;
    }
    else{
        ifm=document.getElementById(iFrameId).contentWindow.document.body;

        type=(document.getElementById(loginDivId).style.display == 'block') ? 1:2;
        if(ifm.innerHTML == 'success' && type == 1) {
            // the login came back with successful
            window.location.href=window.location.href;
        }
        else {
            if(ifm.innerHTML.replace(new RegExp("^[ \n ]+", "g"), "") == '') {
                // blank iframe, nothing loaded (for initial page load)
                return false;
            }
            document.getElementById(errorDivId).innerHTML=ifm.innerHTML;
            if(type == 1) {
                // it came from the login box, build error message and link for re-display login box
                showhidediv(loginDivId,2);
                document.getElementById(errorDivId).innerHTML += '<br /><a href="javascript: showhidediv(\''+msgDivId+'\',2); showhidediv(\''+pwdDivId+'\',2); showhidediv(\''+loginDivId+'\',1);">Try Again</a>';
            }
            else if(type == 2 && document.getElementById(pwdDivId).style.display == 'block') {
                // lost password submit
                showhidediv(pwdDivId,2);
                if(document.getElementById(errorDivId).innerHTML == 'success') {
                    // it verified the password and sent the email
                    document.getElementById(errorDivId).innerHTML = 'Thank you.  Check your email for confirmation.';
                }
                else {
                    // error from the password script
                    document.getElementById(errorDivId).innerHTML += '<br /><a href="javascript: showhidediv(\''+msgDivId+'\',2); showhidediv(\''+loginDivId+'\',2); showhidediv(\''+pwdDivId+'\',1);">Try Again</a>';
                }
            }
            if(ifm.innerHTML != '') {
                // show any errors
                showhidediv(msgDivId,1);
            }
        }
    }
}
//end login stuff-----------------------------------------------------------
// jumper functions
//  Params:
//      elementId - the id of the element that will be moving
//      jumpSize - the size of a single jump in pixels
//      totalCount - the total number of items in the jump element
//      displayCount - the number of items that are seen at once ex) 4 of 20 can be seen at a time
//      interval - the interval in miliseconds for the setInterval
//  Use:
//      construct - Jumper object defined normally ex) myJumpy = new Jumper('jumpman',200,30,4)
//      Jumper.jump(dir) method - call to make a jump.
//          dir = 1 moves one right, dir = -1 moves one left
function Jumper(elementId,jumpSize,totalCount,displayCount,interval){
    this.jumpTo = 0;
    this.rightLimit = totalCount-displayCount;
    this.leftLimit = 0;
    this.interval = interval;
    this.jumpSize = parseInt(jumpSize);
    this.totalCount = totalCount;
    this.displayCount = displayCount;
    var setInt;
    var direction = 0;
    var stopPosition = 0;
    var element = document.getElementById(elementId);
    element.style.marginLeft = '0px';

    function step(){
        var position = parseInt(element.style.marginLeft);
        var distance = stopPosition-position;
        if(distance*distance>1.4) element.style.marginLeft = -2*direction+position+distance/3+'px';
        else{
                element.style.marginLeft = stopPosition+'px';
                clearInterval(setInt);
        }
    }
    this.move = function(){
        if(this.jumpTo>this.rightLimit) this.jumpTo = this.rightLimit;
        else if(this.jumpTo<this.leftLimit) this.jumpTo = this.leftLimit;
        stopPosition = -this.jumpTo*this.jumpSize;
        clearInterval(setInt);
        setInt = setInterval(step,interval);
    }
    this.jump = function(dir){
        direction = dir/Math.abs(dir);
        this.jumpTo += dir;
        this.move();
    }
    this.pageJump = function(pageNum){
        var nextJump = (pageNum-1)*displayCount;
        direction = (nextJump-this.jumpTo)/Math.abs((nextJump-this.jumpTo));
        this.jumpTo = nextJump;
        this.move();
    }
}
// end jumper functions


if(typeof(XMLHttpRequest)=='undefined'){
	XMLHttpRequest = function(){
		try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")} catch(e){}
		try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")} catch(e){}
		try{return new ActiveXObject("Msxml2.XMLHTTP")} catch(e){}
		try{return new ActiveXObject("Microsoft.XMLHTTP")} catch(e){}
		throw new Error("This browser does not support XMLHttpRequest.")
	}
}

function get(obj) {

     var one;
     var two;
     var three;
     var refer=document.getElementById("nl_ref");
     if(document.getElementById("boxes[1]").checked==true)
     {
        one=document.getElementById("boxes[1]").value;
     }
     if(document.getElementById("boxes[2]").checked==true)
     {
        two=document.getElementById("boxes[2]").value;
     }
     if(document.getElementById("boxes[3]").checked==true)
     {
        two=document.getElementById("boxs[3]").value;
     }
      var poststr = "email=" + encodeURI( document.getElementById("nl_email").value ) +
                    "&checkbox1=" + encodeURI(one) +
                    "&checkbox2=" + encodeURI(two) +
                    "&checkbox3=" + encodeURI(three)+
                    "&ref="+encodeURI(document.getElementById("nl_ref").value);
      send_request('http://www.toptenreviews.com/scripts/submit_newsletter.php', poststr, function (x){
            if(x=="1")
            {
            var email_box=document.getElementById('nl_email_addr_box');
            email_box.style.visibility="hidden";
            email_box.style.width="0px";
            email_box.style.height="0px";
            var button=document.getElementById('nl_signup_button');
            button.style.visibility="hidden";
            button.style.width="0px";
            button.style.height="0px";
            var thanks=document.getElementById('thanks');
            thanks.innerHTML='Thank you for subscribing to TopTenREVIEWS newsletters.';
            thanks.style.visibility="visible";
            thanks.style.height="auto";
            thanks.style.width="150px";
            }
            else{
                alert('An error occured. \nPlease try again.');
            }
        });
}

function validateNlPost()
{
    var form=document.getElementById('signup_form');
    if(validateEmail()==true)
    {
        if(document.getElementById("boxes[1]").checked==true||document.getElementById("boxes[2]").checked==true||document.getElementById("boxes[3]").checked==true){
            form.submit();
        }
        else{
            alert('Please select at least one newsletter');
        }
    }
}

function validateHomeNlPost()
{
    var form=document.getElementById('signup_form');
    if(validateEmail()==true)
    {
        if(document.getElementById("boxes[1]").checked==true||document.getElementById("boxes[2]").checked==true){
            form.submit();
        }
        else{
            alert('Please select at least one newsletter');
        }
    }
}

function clearbox()
{
    var box=document.getElementById('nl_email');
    box.value='';
    box.style.fontStyle='normal';

}

function validateEmail()
{
    var box=document.getElementById('nl_email');
    email=box.value;
    if(isEmail(email)==false)
    {
    alert('Please Provide a valid email address');
    box.focus();
    return false;
    }
    else
    {
       var form=document.getElementById('signup_form');
       return true;
    }
}

function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}

function send_request(url,vars,callbackFunction){
	var request =  new XMLHttpRequest();
	request.open("POST", url, true);
	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	request.onreadystatechange = function(){
		var done = 4, ok = 200;
		if(request.readyState==done && request.status==ok) if(request.responseText) callbackFunction(request.responseText);
	}
	request.send(vars);
}


/*********************ADDING OMNITURE VIDEO TRACKING FUNCTIONS*************************/
function loadMovie(movieName, movieLength, moviePlayerName){
	s.Media.open(movieName, movieLength, moviePlayerName);
	s.Media.play(movieName,0);
}
function playMovie(movieName, offset){
	s.Media.play(movieName, offset);
}
function pauseMovie(movieName, offset){
	s.Media.stop(movieName, offset);
}
function finishMovie(movieName, offset){
	s.Media.stop(movieName, offset);
	s.Media.close(movieName);
}
/*********************END OMNITURE VIDEO TRACKING FUNCTIONS****************************/

/**
 *Appends the Omniture Tracking ID to the paramaters passed to trans_id.php
 */
function appendTi(link,ti)
{
    // Replace ti param with new transaction id
    if(link.href.match('/?')){
        var url_parts = link.href.split('?');
        var url_base = url_parts[0];
        var params = url_parts[1].split('&');
        for (var i = 0; i < params.length; i++) {
                if (params[i].split('=')[0] == 'ti') {
                        //array.splice(indexNumber,numberOfElementsToRemove, itemToAdd1,itemToAdd2, ...)
                        params.splice(i, 1);
                }
        }

        params.push('ti='+ti);
        link.href=url_base+'?'+params.join('&');
    }
    else{
        link.href += '?ti='+ti;
    }
}

// ////////////////
// functions from js.js
function createCookie(name,value,days) {
	var docurl=document.URL;
	if(docurl.indexOf(".toptenreviews.com")>0)
		var dmn = "; domain=.toptenreviews.com;";
	else
		var dmn = ";";
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/"+dmn;
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}

function splitURL(s) {
	s.match( /^([^\/]+\/\/)?([^\/]+)([^\?#]+)(.*$)/ );
	return RegExp.$1 + RegExp.$2 ;
}

function goPop(thePage){ window.open(thePage,'screen','width=378,height=600,scrollbars=yes,resizable=yes'); }
function goPopup(thePage,w,h){
	if(thePage=="http://www.toptenreviews.com/email-a-friend.php"){
		currentPage=escape(document.URL);
		//currentPageA=splitURL(currentPage);
		//thePage=thePage+'?rud='+currentPageA;
		thePage=thePage+'?rud='+currentPage;
	}
	if(thePage=="http://www.toptenreviews.com/email-a-friend2.php"){
		currentPage=escape(document.URL);
		//currentPageA=splitURL(currentPage);
		//thePage=thePage+'?rud='+currentPageA;
		thePage=thePage+'?rud='+currentPage;
	}
	window.open(thePage,'screen','width='+w+',height='+h+',scrollbars=yes,resizable=yes');
}
/// end js.js stuff
//////
// ad swap / content swap
function swapit(to,from) {
        swapcontent=document.getElementById(from).innerHTML;
        document.getElementById(to).innerHTML=swapcontent;
        document.getElementById(from).innerHTML='';
}
function swapad(to,from) {
        var todiv=document.getElementById(to);
        var fromdiv=document.getElementById(from);
        todiv.innerHTML='';
        var par=fromdiv.parentNode;
        setTimeout(function() {
            par.removeChild(fromdiv);
            todiv.appendChild(fromdiv);
        },0);
        fromdiv.style.display="block";
}
function tabSwap(id){
  var slideshow_e = id;
  selId = Number(id);
  for(s=1;s<=5;s++){
    if(slideshow_e == s){
      document.getElementById(s+10).style.display = "block";
      if(slideshow_e == 5){
        document.getElementById(slideshow_e).className = "nhp_topic_tab nhp_topic_sel nhp_topic_bot";
      }else{
        document.getElementById(slideshow_e).className = "nhp_topic_tab nhp_topic_sel";
      }
    }else{
      document.getElementById(s+10).style.display = "none";
      if(s == 5){
        document.getElementById(s).className = "nhp_topic_tab nhp_topic_bot";
      }else{
        document.getElementById(s).className = "nhp_topic_tab";
      }
    }
  }
}
function slideShow(){
  artSwitch = setInterval("changeInfo()", 5000);
}
function changeInfo(){
  if(slideshow_first){
    slideshow_i=1;
    slideshow_first = false;
  }
  if(selId != 10){
    selId = selId - 1;
    slideshow_i = selId;
    selId = 10;
  }
  for(s=1;s<=5;s++){
    sid = s-1;
    if(s == slideshow_ids[slideshow_i]){
      str = imageId[sid];
      document.getElementById(str).style.display = "block";
      if(s == 5){
        document.getElementById(slideshow_ids[sid]).className = "nhp_topic_tab nhp_topic_sel nhp_topic_bot";
      }else{
        document.getElementById(slideshow_ids[sid]).className = "nhp_topic_tab nhp_topic_sel";
      }
      slideshow_j = slideshow_j + 1;
    }else{
      str = imageId[sid];
      document.getElementById(str).style.display = "none";
      if(s == 5){
        document.getElementById(slideshow_ids[sid]).className = "nhp_topic_tab nhp_topic_bot";
      }else{
        document.getElementById(slideshow_ids[sid]).className = "nhp_topic_tab";
      }
      slideshow_j = slideshow_j + 1;
    }
    if(slideshow_j==5){
      slideshow_j=0;
    }
  }
  
  slideshow_i = slideshow_i + 1;
  if (slideshow_i > (slideshow_ids.length - 1)) {slideshow_i = 0;}
  if(!intContinue) {clearInterval(artSwitch);}
}
