/*
Script Name: Your Computer Information
Author: Harald Hope, Website: http://TechPatterns.com/
Script Source URI: http://TechPatterns.com/downloads/browser_detection.php
Version: 1.2.0
Copyright (C) 2 February 2010

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Get the full text of the GPL here: http://www.gnu.org/licenses/gpl.txt

This script requires the Full Featured Browser Detection and the Javascript Cookies scripts
to function.
You can download them here.
http://TechPatterns.com/downloads/browser_detection_php_ar.txt
http://TechPatterns.com/downloads/javascript_cookies.txt

Please note: this version requires the php browser_detection script version 5.2.0 or
newer, because of the new full return of arrays $moz_array and $webkit_array as keys
10 and 11, and use of the new array key 14, true_msie_version.
*/

/*
If your page is XHMTL 1 strict, you have to
put this code into a js library file or your
page will not validate
*/
function client_data(info){
	if (info == 'width'){
		width_height_html = '<h4  class="right-bar">Current Screen Resolution</h4>';
		width = (screen.width) ? screen.width:'';
		height = (screen.height) ? screen.height:'';
		// check for windows off standard dpi screen res
		if (typeof(screen.deviceXDPI) == 'number') {
			width *= screen.deviceXDPI/screen.logicalXDPI;
			height *= screen.deviceYDPI/screen.logicalYDPI;
		} 
		width_height_html += '<p class="right-bar">' + width + " x " + height + " pixels</p>";
		(width && height) ? document.write(width_height_html):'';
	}
	else if (info == 'js' )	{
		document.write('<p class="right-bar">JavaScript is enabled.</p>');
	}
	else if ( info == 'cookies' ){
		expires ='';
		Set_Cookie( 'cookie_test', 'it_worked' , expires, '', '', '' );
		string = '<h4  class="right-bar">Cookies</h4><p class="right-bar">';
		if ( Get_Cookie( 'cookie_test' ) ){
			string += 'Cookies are enabled</p>';
		}
		else {
			string += 'Cookies are disabled</p>';
		}
		document.write( string );
	}
}

//////////////////////////////////////////////////////////
// validate attribute
//////////////////////////////////////////////////////////
function validateAttribute(frm) {
	var message='';	
	
	if (frm.attributeid.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please select an attribute<br>';
	}
	return displayError(message);
}
//////////////////////////////////////////////////////////
// validate other
//////////////////////////////////////////////////////////
function validateOther(frm) {
	var message='';	
	
	if (frm.otherid.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please select a relevant info list<br>';
	}
	if (frm.othervalue.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please enter a relevant info value<br>';
	}
	return displayError(message);
}
//////////////////////////////////////////////////////////
// validate image upload
//////////////////////////////////////////////////////////
function validateImageUpload(frm) {
	var message='';
	
	if (frm.imagefile.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No image file selected for upload<br>';
	}
	//alert(frm.imagefile.value);
	return displayError(message);
}
//////////////////////////////////////////////////////////
// validate video upload
//////////////////////////////////////////////////////////
function validateVideoUpload(frm) {
	var message='';
	
	if (frm.videofile.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No video file selected for upload<br>';
	}
	return displayError(message);
}
//////////////////////////////////////////////////////////
// validate supplement upload
//////////////////////////////////////////////////////////
function validateSupplementUpload(frm) {
	var message='';
	
	if (frm.supplementfile.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;No supplement file selected for upload<br>';
	}
	return displayError(message);
}
//////////////////////////////////////////////////////////
// validate quick search
//////////////////////////////////////////////////////////
function validateQuickSearch(frm) {
	var message='';	
	
	if (frm.referencecode.value == '') {
		message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter the reference code<br>';
	}	
	return displayError(message);
}
//////////////////////////////////////////////////////////
// validate input
//////////////////////////////////////////////////////////
function validateInput(ctrl,whichPressed) {
	var message='';	
	
	var control = document.getElementById(ctrl);
	if (control == null){
		if (control.value == '') 
			message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select a value from the list<br>';
	}	
	return displayError(message);
}
//////////////////////////////////////////////////////////
// display error messages
//////////////////////////////////////////////////////////
function displayError(message){
	var messageHeader='Please fix the following errors:<br/>';
	
	var messages = document.getElementById('messages');
	if (messages != null){
		messages.style.display = 'none';	
	}
	
	var errorHeader = document.getElementById('errorMessage');
	if (errorHeader != null){
		var error = document.getElementById('errorMessageContent');
		if (error != null){
			if (message.length==0) {
				errorHeader.style.display = 'none';
				return true;
			} 
			else {
				errorHeader.style.display = 'block';
				error.innerHTML = messageHeader + message;
				setTimeout("hideDiv('errorMessage')", 3000);
				return false;
			}	
		}
	}
	return false;
}
//////////////////////////////////////////////////////////
// display ajax results
//////////////////////////////////////////////////////////
function reloadCaptcha(){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	setTimeout("hideDiv('messages')", 3000);
	var url="captcha.ajax.php";
	url=url+"?sid="+Math.random();
	//alert(url);
	xmlhttp.onreadystatechange=stateCaptcha;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

//////////////////////////////////////////////////////////
// display ajax results event
//////////////////////////////////////////////////////////
function stateCaptcha(){
	if (xmlhttp.readyState==4) {
		document.getElementById("ajax_panel_captcha").innerHTML=xmlhttp.responseText;
	}
}

//////////////////////////////////////////////////////////
// display ajax results
//////////////////////////////////////////////////////////
function getStats(cntl){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	setTimeout("hideDiv('messages')", 3000);
	cntl.disabled=true;
	var url="stats.ajax.php";
	url=url+"?sid="+Math.random();
	//alert(url);
	xmlhttp.onreadystatechange=stateChangedStats;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

//////////////////////////////////////////////////////////
// display ajax results event
//////////////////////////////////////////////////////////
function stateChangedStats(){
	if (xmlhttp.readyState==4) {
		document.getElementById("ajax_panel_stats").innerHTML=xmlhttp.responseText;
	}
}
//////////////////////////////////////////////////////////
// display ajax results
//////////////////////////////////////////////////////////
function getPonder(){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	// check to see if the div is expanded. if so, update ajax panel
	var lnkponder = document.getElementById('lnkponder');
	if (lnkponder != null){
		if (lnkponder.style.display != 'none'){
			xmlhttp.onreadystatechange=stateChangedPonder;
			//xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		}
	}
}
//////////////////////////////////////////////////////////
// display ajax results event
//////////////////////////////////////////////////////////
function stateChangedPonder(){
	if (xmlhttp.readyState==4) {
		document.getElementById("ajax_panel_quote_of_the_day").innerHTML=xmlhttp.responseText;
	}
}


//////////////////////////////////////////////////////////
// public search
//////////////////////////////////////////////////////////
function ajaxPublicSearch(actiontype){
	var arr = new Array();
	arr = document.getElementsByName('dropdown');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('dropdown').item(i);
		if (obj.id != 'searchtype')
			obj.value = '';
	}
	arr = document.getElementsByName('panel');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('panel').item(i);
		if (obj.id == 'publicsearchpanel')
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	arr = document.getElementsByName('search');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('search').item(i);
		obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	if (actiontype == ''){
		return;
	}
	var search = document.getElementById(actiontype);
	if (search != null){
		search.style.display = 'block';
		// save to cookies
		setCookie(actiontype, search.style.display, 14);
		//alert(actiontype + ' ' + search.style.display);
		if (actiontype == 'searchquicksearch'){
			ajaxQuickSearch();
		}
		else if (actiontype == 'searchclassified'){
			ajaxClassifiedSearch();
		}
		else if (actiontype == 'searchlearn'){
			ajaxLearnSearch();
		}
		else if (actiontype == 'searchsoulmate'){
			ajaxSoulmateSearch();
		}
		else if (actiontype == 'searchtalent'){
			ajaxTalentSearch();
		}
		else if (actiontype == 'searchteach'){
			ajaxTeachSearch();
		}
	}

}

//////////////////////////////////////////////////////////
// misc
//////////////////////////////////////////////////////////
function ajaxMisc(actiontype){
	var arr = new Array();
	arr = document.getElementsByName('dropdown');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('dropdown').item(i);
		if (obj.id != 'other')
			obj.value = '';
	}
	arr = document.getElementsByName('panel');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('panel').item(i);
		if (obj.id == 'miscpanel')
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	arr = document.getElementsByName('misc');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('misc').item(i);
		obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	if (actiontype == ''){
		return;
	}
	var search = document.getElementById(actiontype);
	if (search != null){
		search.style.display = 'block';
		// save to cookies
		setCookie(actiontype, search.style.display, 14);
	}

}
//////////////////////////////////////////////////////////
// admin search
//////////////////////////////////////////////////////////
function ajaxAdminSearch(actiontype){
	var arr = new Array();
	arr = document.getElementsByName('dropdown');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('dropdown').item(i);
		if (obj.id != 'adminsearch')
			obj.value = '';
	}
	arr = document.getElementsByName('panel');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('panel').item(i);
		if (obj.id == 'adminsearchpanel')
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	arr = document.getElementsByName('admin');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('admin').item(i);
		obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	if (actiontype == ''){
		return;
	}
	var search = document.getElementById(actiontype);
	if (search != null){
		search.style.display = 'block';
		// save to cookies
		setCookie(actiontype, search.style.display, 14);
		if (actiontype == 'adminsearchmember'){
			ajaxAdminMemberSearch();
		}
		else if (actiontype == 'adminsearchorganisation'){
			ajaxAdminOrganisationSearch();
		}
		else if (actiontype == 'adminsearchclassified'){
			ajaxAdminClassifiedSearch();
		}
		else if (actiontype == 'adminsearchlearn'){
			ajaxAdminLearnSearch();
		}
		else if (actiontype == 'adminsearchsoulmate'){
			ajaxAdminSoulmateSearch();
		}
		else if (actiontype == 'adminsearchtalent'){
			ajaxAdminTalentSearch();
		}
		else if (actiontype == 'adminsearchteach'){
			ajaxAdminTeachSearch();
		}
	}

}

//////////////////////////////////////////////////////////
// member services
//////////////////////////////////////////////////////////
function ajaxMemberServices(actiontype){
	var arr = new Array();
	arr = document.getElementsByName('panel');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('panel').item(i);
		if (obj.id == 'memberpanel')
			obj.style.display = 'block';
		else
			obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	arr = document.getElementsByName('member');
	for(var i = 0; i < arr.length; i++)
	{
		var obj = document.getElementsByName('member').item(i);
		obj.style.display = 'none';
		setCookie(obj.id, obj.style.display, 14);
	}
	if (actiontype == ''){
		return;
	}
	var search = document.getElementById(actiontype);
	if (search != null){
		search.style.display = 'block';
		if (actiontype == 'myaccount'){
			ajaxMemberAccount();
		}
		else if (actiontype == 'mylisting'){
			ajaxMemberListing();
		}
		else if (actiontype == 'mywatchlist'){
			ajaxMemberWatchlist();
		}
		else if (actiontype == 'mymailbox'){
			ajaxMemberMailbox();
		}
	}

}
//////////////////////////////////////////////////////////
// quick search ajax functionality
//////////////////////////////////////////////////////////
function ajaxQuickSearch(){
	var message='';	

	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	var url="quick.ajax.search.php";
	url=url+"?sid="+Math.random();
	xmlhttp.onreadystatechange=stateChangedQuickSearch;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

//////////////////////////////////////////////////////////
// display ajax results list event
//////////////////////////////////////////////////////////
function stateChangedQuickSearch(){
	if (xmlhttp.readyState==4) {
		document.getElementById("ajax_quick_search").innerHTML=xmlhttp.responseText;
	}
}





