function nothing() {}

var tabs_called, tabs_exclude;
tabs_called=0;
tabs_exclude=0;

var ts, ajax, a_target;ajax=null;a_target=null;

function ajax_set_target(new_id)
	{
	a_target=new_id;
	}
function state_Change()	{	if (ajax.readyState==4)		{		if (ajax.status==200)			{			document.getElementById(a_target).innerHTML=ajax.responseText;
			var s = document.getElementById(a_target);
			var sc = s.getElementsByTagName('script');

			for (i=0; i<sc.length; i++)
				{
				eval(sc[i].innerHTML);
				}
			}		else			{			document.getElementById(a_target).innerHTML="Error ("+ajax.status+")";			}		}	}
function ajax_init(url)	{	if (window.XMLHttpRequest)		{		ajax=new XMLHttpRequest();		}	else if (window.ActiveXObject)		{		ajax=new ActiveXObject("Microsoft.XMLHTTP");		}
	if (ajax!=null)		{		ts = new Date();	
		ts = ts.getTime();
		wait_panel();
		ajax.onreadystatechange=state_Change;		ajax.open("GET", url+'&ts='+ts, true);		ajax.send(null);		}	else		{		alert("Your browser does not support ajax");		}	}
function wait_panel()
	{
	document.getElementById(a_target).innerHTML="<div id='ajax_loading'><img align='center' src='/ajax_loading.gif' /><br clear='all' /><span>Loading Data</span><br /></div>";
	}

// sleep function in mili-seconds
function sleep(naptime)
	{
	var sleeping = true;
	var now = new Date();
	var alarm;
	var startingMSeconds = now.getTime();

	while(sleeping)
		{
		alarm = new Date();
		alarmMSeconds = alarm.getTime();
        		if (alarmMSeconds - startingMSeconds > naptime) { sleeping = false; }
		}
	}

 // obj = [target object], is_horiz = (horizonal centering), is_absolute = (use css absolute position?), moreHeight = (manually add more pixels to marginHeight/top)
function centering(obj, is_horiz, is_absolute, moreHeight)
	{
	var winHeight = document.documentElement.clientHeight;
	var winWidth = document.documentElement.clientWidth;

	var objHeight=0;
	var objWidth=0;

	if (obj.currentStyle)
		{
		objHeight = obj.currentStyle['height'];
		objWidth = obj.currentStyle['width'];
		}
	else
		{
		if (window.getComputedStyle)
			{
			objHeight = document.defaultView.getComputedStyle(obj, null).getPropertyValue('height');
			objWidth = document.defaultView.getComputedStyle(obj, null).getPropertyValue('width');
			}
		}

	objHeight = objHeight.toString();
	objHeight = parseInt(objHeight.replace('px', ''));

	objWidth = objWidth.toString();
	objWidth = parseInt(objWidth.replace('px', ''));

	if (objHeight==0 || objWidth==0)
		return;

	if (is_absolute==0)
		{
		obj.style.position = 'static';
		obj.style.marginTop = ((winHeight/2)-(objHeight/2)+moreHeight)+'px';
		obj.style.marginBottom = 0;

		if (is_horiz==1)
			{
			obj.style.marginLeft = 'auto';
			obj.style.marginRight = 'auto';
			}
		}
	else
		{
		obj.style.position = 'absolute';
		obj.style.top = ((winHeight/2)-(objHeight/2)+moreHeight)+'px';

		if (is_horiz==1)
			{
			obj.style.left = ((winWidth/2)-(objWidth/2))+'px';
			}
		}
	}

	function expand_listing(id)
		{
		var arr = document.getElementById('listing_ar'+id);
		var det = document.getElementById('listing_det'+id);

		if (det.style.display=='none')
			{
			arr.src = '/images/listing_ar2.gif';
			det.style.display='block';
			}
		else
			{
			arr.src = '/images/listing_ar1.gif';
			det.style.display='none';
			}
		}

	function go_tabs(tab, source)
		{
		if (typeof is_women != 'undefined' && is_women)
			{
			source = 'women';
			}

		if (tab==1)
			{
			ajax_set_target('most_content');
			ajax_init('/news_most_read_ajax.rtx?exc='+tabs_exclude+'&src='+source);
			}

		if (tab==2)
			{
			ajax_set_target('most_content');
			ajax_init('/news_most_comments_ajax.rtx?exc='+tabs_exclude+'&src='+source);
			}
		}

	function go_top_search()
		{
		var obj = document.getElementById('top_search_input');
		var query_txt = obj.value;

		if (query_txt.length>=MIN_LENGTH)
			{
			// location.href='news_search.rtx?query='+escape(query_txt);
			location.href='/news_search.rtx?query='+query_txt;
			return false;
			}
		else
			{
			window.alert('Please enter at least '+MIN_LENGTH+' characters to search for');
			obj.focus();
			return false;
			}
		}

	function vid_navigator(opt)
		{
		var MAX_STEPS = 3;

		var obj = document.getElementById('vid_navigator_clips');
		var step = document.getElementById('vid_navigator_step');

		var nav_next = document.getElementById('vid_navigator_next');
		var nav_prev = document.getElementById('vid_navigator_prev');
		var nav_indexing = document.getElementById('vid_navigator_indexing');

		var SCROLL = 285;
		var STEP = parseInt(step.value);
		var FINAL, EVERY;
		var START = obj.scrollLeft;

		if (opt=='next')
			{
			var mSTEP = STEP+1;

			if (mSTEP>MAX_STEPS)
				{
				return;
				}
			}
		else
			{
			var mSTEP = STEP-1;

			if (mSTEP<0)
				{
				return;
				}
			}

		switch (mSTEP)
			{
			case 0:
				{
				nav_next.src='/images/vid_navigator_next_live.gif';
				nav_prev.src='/images/vid_navigator_prev_dead.gif';
				break;
				}

			case MAX_STEPS:
				{
				nav_next.src='/images/vid_navigator_next_dead.gif';
				nav_prev.src='/images/vid_navigator_prev_live.gif';
				break;
				}

			default:
				{
				nav_next.src='/images/vid_navigator_next_live.gif';
				nav_prev.src='/images/vid_navigator_prev_live.gif';
				}
			}

		if (opt=='next')
			{
			if (STEP+1>MAX_STEPS)
				{
				return;
				}

			STEP++;

			FINAL = (SCROLL*STEP);
			EVERY = (SCROLL/15);

			for (i=1; i<=15; i++)
				{
				sleep(25);
				obj.scrollLeft=(START+(EVERY*i));
				}
			}
		else
			{
			STEP--;

			if (STEP<0)
				{
				return;
				}

			FINAL = (SCROLL*STEP);
			EVERY = (SCROLL/15);

			for (i=1; i<=15; i++)
				{
				sleep(25);
				obj.scrollLeft=(START-(EVERY*i));
				}
			}

		step.value = STEP;

		var elms = nav_indexing.getElementsByTagName('img');

		for (j=0; j<elms.length; j++)
			{
			if (j==STEP)
				{
				elms[j].src = '/images/vid_navigator_index_live.gif';
				}
			else
				{
				elms[j].src = '/images/vid_navigator_index_dead.gif';
				}
			}
		}

	function top_menu_click()
		{
		if (!e)
			{
			var e = window.event;
			var s = e.srcElement;
			}
		else
			{
			var s = e.target;
			}

		var anchors = s.getElementsByTagName('a');

		location.href=anchors[0].href;
		}
