function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function front_getXmlHttpRequestObject()
{
	if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
	else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); }
	return false;
}

function getTest()
{
    var testimony = document.getElementById('testimony');
    var tnum = document.getElementById('tnum').innerHTML;

    var sendReq = front_getXmlHttpRequestObject();
    sendReq.open("GET", '/testimony.php?tnum='+tnum, true);
    sendReq.onreadystatechange = function()
    {
        if(sendReq.readyState==4)
        {
            testimony.innerHTML = sendReq.responseText;
        }
    };
    sendReq.send('');
    return false;
}

function updatecnt()
{
    var sendReq = front_getXmlHttpRequestObject();
    sendReq.open("GET", '/updatecnt.php', true);
    sendReq.onreadystatechange = function()
    {
        if(sendReq.readyState==4)
        {}
    };
    sendReq.send('');
    return false;
}

function onlyshowOne()
{
	try
	{
		MM_preloadImages('/newimages/nav-over.jpg');

        var the_a = document.getElementById('a_1');
		the_a.style.color = '#FFF';
		the_a.style.background = 'url(/newimages/nav-over.jpg) 100% 100% no-repeat';
		var tabContent = document.getElementById('tabcontent');
		var arrElem = getElementsByClass('hiddiv',tabContent);
		for (i=0;i<arrElem.length;i++)
		{
			if (arrElem[i].id != 'showTab_1')
			{
				arrElem[i].style.display = 'none';
			}
		}
		document.getElementById('showTab_1').style.display = '';
	}
	catch (e) {}
}

var olda = 1;
function mouseOverLi(tabid)
{
        if (tabid == 5)
        {
            document.getElementById('readmore').style.display = 'none';
            document.getElementById('readmoretrial').style.display = 'block';
            //getTest();
        }
        else
        {
            document.getElementById('readmoretrial').style.display = 'none';
            document.getElementById('readmore').style.display = 'block';
        }

	var the_a = document.getElementById('a_'+tabid);
	var old_a = document.getElementById('a_'+olda);

	old_a.style.color = '#0E3566';
	old_a.style.background = 'url(/newimages/nav-btn.jpg) 100% 100% no-repeat';

	the_a.style.color = '#FFF';
	the_a.style.background = 'url(/newimages/nav-over.jpg) 100% 100% no-repeat';

	olda = tabid;

	var tabContent = document.getElementById('tabcontent');
	var arrElem = getElementsByClass('hiddiv',tabContent);
	for (i=0;i<arrElem.length;i++)
	{
		if (arrElem[i].id != 'showTab_'+tabid)
		{
			arrElem[i].style.display = 'none';
		}
	}
	document.getElementById('showTab_'+tabid).style.display = '';
        return false;
}

function nextLi()
{
    return mouseOverLi(olda+1);
}

function showEM(dom,user,where)
{
	if (where.className == 'reva')
	{
		return false;
	}

	where.className = 'reva';
	orig = dom+'@'+user;
	text = '';
	for (i = 0; i <= orig.length; i++)
	{
		text = orig.substring(i, i+1) + text;
	}
	where.href = "mailto:"+text;
	where.innerHTML = text;
	return false;
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (
			anchor.getAttribute("href") && (
			anchor.getAttribute("rel") == "external" ||
			anchor.getAttribute("rel") == "external nofollow" ||
			anchor.getAttribute("rel") == "nofollow external" )
			)
		anchor.target = "_blank";
	}
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function doevents()
{
	try {
	document.getElementById('a_1').onmouseover = function() { mouseOverLi(1); };
	document.getElementById('a_1').onfocus = function() { mouseOverLi(1); };
	document.getElementById('a_1').onclick = function() { mouseOverLi(1); return false; };
	document.getElementById('a_1').onkeypress = function() { mouseOverLi(1); return false; };

	document.getElementById('a_2').onmouseover = function() { mouseOverLi(2); };
	document.getElementById('a_2').onfocus = function() { mouseOverLi(2); };
	document.getElementById('a_2').onclick = function() { mouseOverLi(2); return false; };
	document.getElementById('a_2').onkeypress = function() { mouseOverLi(1); return false; };

	document.getElementById('a_3').onmouseover = function() { mouseOverLi(3); };
	document.getElementById('a_3').onfocus = function() { mouseOverLi(3); };
	document.getElementById('a_3').onclick = function() { mouseOverLi(3); return false; };
	document.getElementById('a_3').onkeypress = function() { mouseOverLi(1); return false; };

	document.getElementById('a_4').onmouseover = function() { mouseOverLi(4); };
	document.getElementById('a_4').onfocus = function() { mouseOverLi(4); };
	document.getElementById('a_4').onclick = function() { mouseOverLi(4); return false; };
	document.getElementById('a_4').onkeypress = function() { mouseOverLi(1); return false; };

	document.getElementById('a_5').onmouseover = function() { mouseOverLi(5); };
	document.getElementById('a_5').onfocus = function() { mouseOverLi(5); };
	document.getElementById('a_5').onclick = function() { mouseOverLi(5); return false; };
	document.getElementById('a_5').onkeypress = function() { mouseOverLi(1); return false; };

	document.getElementById('viewdemo1').onclick = function() { var me = this; return clickDemo(this); };
	document.getElementById('viewdemo1').onkeypress = function() { var me = this; return clickDemo(this); };
	
	document.getElementById('anothera').onclick = function() { return getTest(); };
	document.getElementById('anothera').onkeypress = function() { return getTest(); };
	
	document.getElementById('readmore1').onclick = function() { return nextLi(); };
	document.getElementById('readmore1').onkeypress = function() { return nextLi(); };
	
	} catch(e) {}
}
window.addOnloadEvent(doevents);

window.addOnloadEvent(onlyshowOne);
window.addOnloadEvent(externalLinks);
window.addOnloadEvent(updatecnt);
