function focusInput(input)
{
	input.style.border='1px solid #D3B591';	
}

function blurInput(input)
{
	input.style.border='1px solid #000000';	
}

function search()
{
	if (form = document.getElementById('searchForm'))
	{
		form.submit();
	}
}

function login()
{
	if (form = document.getElementById('loginForm'))
	{
		form.submit();
	}
}

function channelPartnersApplication()
{
	if (form = document.getElementById('channelPartnersApplicationForm'))
	{
		form.submit();
	}
}

function subscribeNewsletter()
{
	if (form = document.getElementById('newsletterSubscribeForm'))
	{
		form.submit();
	}
}

function register()
{
	if (form = document.getElementById('registerForm'))
	{
		form.submit();
	}
}

function send()
{
	if (form = document.getElementById('sendForm'))
	{
		form.submit();
	}
}

function forgotPassword()
{
	if (form = document.getElementById('forgotPasswordForm'))
	{
		form.submit();
	}
}

function subscribe()
{
	if (form = document.getElementById('newsletterForm'))
	{		
		form.submit();
	}
}

function unsubscribe()
{
	if ((newsletterTypeAction = document.getElementById('newsletterTypeAction')) && (form = document.getElementById('newsletterForm')))
	{
		newsletterTypeAction.value = 'unsubscribe';
		form.submit();
	}
}

function searchSelectionChanged(selectObject)
{
	PrepXML();
	if (xmlhttp)
    {
		xmlhttp.onreadystatechange=xmlhttpChange;
		xmlhttp.open("GET","../ajax/section/advanced_search.php?"+selectObject.name+"="+selectObject.options[selectObject.selectedIndex].value,true)
		xmlhttp.send(true)
    }
}

function xmlhttpChange()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
	    {
			document.getElementById('content_ajax').innerHTML=xmlhttp.responseText;
		}
	}
}

function openPrint(url)
{
	var width = 800;
	var height = 600;
	var y=(screen.height/2)-(height/2);
	var x=(screen.width/2)-(width/2);
	var myWindow; 	
	width = width;
	height = height;
	myWindow = window.open(url,'Print','width='+screen.width+',height='+screen.height+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,top='+y+',left='+x);		
	myWindow.focus();
	void(0);	
}

/* START chat module */
var chatWidth = 371;
var chatHeight = 392;
var refreshRate = 1000;
var currentSessionId = null;

function PrepXML()
{
	try 
	{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) 
	{
		try 
		{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
		xmlhttp = new XMLHttpRequest();
	}
}

function getOnlineUser()
{
	PrepXML();
	if (xmlhttp)
    {
		xmlhttp.onreadystatechange = populateOnlineList;
		xmlhttp.open("GET","/ajax/section/online_list.php",true);
		xmlhttp.send(true);
    }
}

function populateOnlineList()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
	    {			
			document.getElementById('user_list').innerHTML = xmlhttp.responseText;
		}
		checkActiveUsers();
		userListTimerOn();
	}	
}

function checkActiveUsers()
{
	PrepXML();
	if (xmlhttp)
    {
		xmlhttp.onreadystatechange = alertActiveUsers;
		xmlhttp.open("GET","/ajax/section/check_alert_que.php",true);
		xmlhttp.send(true);
    }
}

function alertActiveUsers()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
	    {					
			if (xmlhttp.responseText.length)
				alert(xmlhttp.responseText);
		}
	}	
}

function userListTimerOn()
{
	setTimeout("userListTimerOff()", refreshRate);
}

function userListTimerOff()
{
	getOnlineUser();
}

function verifyChat(sessionId, username)
{
	currentSessionId = sessionId;	
	PrepXML();
	if (xmlhttp)
    {
		xmlhttp.onreadystatechange = executeChat;
		xmlhttp.open("GET","/ajax/section/verify_chat.php?sessionId="+sessionId+'&username='+username,true);
		xmlhttp.send(true);
    }	
}

function executeChat()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
	    {
			if (xmlhttp.responseText.length)
				openChat(xmlhttp.responseText);
		}		
	}		
}

function openChat(url)
{	
	var now = new Date();
	var x=(screen.width/2)-(chatWidth/2);
	var y=(screen.height/2)-(chatHeight/2);
	var myWindow; 	
	myWindow = window.open(url,'TopexChat'+now.getMilliseconds(),'width='+chatWidth+',height='+chatHeight+',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,top='+y+',left='+x);
	myWindow.focus();
	void(0);	
}

function refreshChat(sessionId)
{
	currentSessionId = sessionId;
	PrepXML();
	if (xmlhttp)
    {
		xmlhttp.onreadystatechange = populateMessageList;
		xmlhttp.open("GET","/ajax/section/get_messages.php?sessionId="+sessionId,true);
		xmlhttp.send(true);
    }
}

function populateMessageList()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
	    {			
			document.getElementById('messages').innerHTML = xmlhttp.responseText;
		}
		var div = document.getElementById('messages');
		div.scrollTop = div.scrollHeight;
		messageListTimerOn();
	}		
}

function messageListTimerOn()
{
	setTimeout("messageListTimerOff()", refreshRate);
}

function messageListTimerOff()
{
	refreshChat(currentSessionId);
}

function closeChat(sessionId)
{
	currentSessionId = sessionId;
	PrepXML();
	if (xmlhttp)
    {
		xmlhttp.onreadystatechange = exitChat;
		xmlhttp.open("GET","/ajax/section/close_chat.php?sessionId="+sessionId,true);
		xmlhttp.send(true);
    }
}

function exitChat()
{
	if (xmlhttp.readyState==4)
	{
		if (xmlhttp.status==200)
	    {			
			window.close();
		}		
	}		
}
/* END chat module */