/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);
}

var xmlhttp=false;var myxmlHTTP=Array();
var GetMode="?mode=ts2vgethtml";
if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
	try {
		xmlhttp = new XMLHttpRequest ();
	} catch (e) {
		xmlhttp = false;
	}
}
function myXMLHttpRequest() {
	var xmlhttplocal;
	try {
		xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP");
	}
	catch (e) {
		try {
			xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP");
		}
		catch (E) {
			xmlhttplocal = false;
		}
	}
	if (!xmlhttplocal && typeof XMLHttpRequest != "undefined") {
		try {
			var xmlhttplocal = new XMLHttpRequest ();
		}
		catch (e) {
			var xmlhttplocal = false;
		}
	}
	return (xmlhttplocal);
}

function ajax_get() {
	var content='';var id='';var oneModule=Array();var target=null;
	errormatch = new RegExp ("^ERROR:");
	if (myxmlHTTP.readyState == 4) {
		if(myxmlHTTP.status == 200) {
			allModules = myxmlHTTP.responseText.split('DELIMITER');
			for(i=0;i<(allModules.length);i++) {
				oneModule='';tmp='';id='';content='';target=null;
				tmp = allModules[i];
				oneModule = tmp.split('@-#');
				if(typeof oneModule[0] == 'undefined') continue;
				if(typeof oneModule[1] == 'undefined') continue;
				id = oneModule[0];
				if(document.all) { target = document.all['ts2'+id]; }
				if(document.getElementById && !document.all) { target = document.getElementById('ts2'+id); }
				if (oneModule[1].match(errormatch)) {
					content = oneModule[1].substring (6, oneModule[1].length);
					if(typeof target != 'undefined' && target != null)	target.innerHTML = content;
				} else { 
					if(typeof target != 'undefined' && target != null)	{ 
						content = oneModule[1];
						target.innerHTML = content;
					}
				}
			}
		}
	}
}
function ajax_update() {
	if(typeof ts2v_refresh_enabled != 'undefined') 
		if (ts2v_refresh_enabled == 0) return;
	if(typeof ts2v_timeout != 'undefined') 
		if(ts2v_timeout == 0) return;
	url = GetMode;
	myxmlHTTP = new myXMLHttpRequest ();
	if(myxmlHTTP) {
		myxmlHTTP.open ("GET", url, true);
		myxmlHTTP.onreadystatechange = ajax_get;
		myxmlHTTP.send(null);
	}
	if(typeof ts2v_timeout != 'undefined')
		setTimeout('ajax_update()', (ts2v_timeout * 1000));
} 
window.addEvent('domready',ajax_update);