
function test()
{
	alert('hello there');
}


function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
  	{
	// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
  	// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
		return xmlHttp;
}


function stateChanged()
{  
	if (xmlHttp.readyState==4)
	{ 
		result = xmlHttp.responseText; 
		char = String.fromCharCode(0);
		if (result.substring(0, 1) == char) window.location = "index.php";

		document.getElementById(kontainer).innerHTML=xmlHttp.responseText;
	}
}

function doAjax(url, container, data)
{ 
// 	loading_on(container);
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"?container="+container+"&data="+data+"&sid="+Math.random();
// alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	// loading_off('notifier');
}

function doCleanAjax(url, container)
{ // alert(url);
// 	loading_on(container);
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"&sid="+Math.random();
// alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	// loading_off('notifier');
}



function profileAjax(profile_person, record, url, container)
{
// 	loading_on(container);
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"?profile_person="+profile_person+"&record="+record+"&container="+container+"&sid="+Math.random();
// alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}



function label(container, content)
{
	document.getElementById(container).innerHTML = content;
}



// form ajax (logon, register, profile, comments)
var http_request = false;

function makeRequest(url, parameters, container) {
	   
	kontainer = container;
	http_request = false;
    if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
    	http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType)
		{
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
		}
    }
	else if (window.ActiveXObject)
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e)
		{
			try 
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
				catch (e) {}
		}
	}
	      if (!http_request)
		  {
			alert('Cannot create XMLHTTP instance');
			return false;
    	  }
	
	http_request.onreadystatechange = alertContents;

	http_request.open('GET', url + parameters, true);
	http_request.send(null);
}

function alertContents()
{ 
//	alert(kontainer);
	if (http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{ 
			result = http_request.responseText; // alert(result);
//			char = String.fromCharCode(0); 
			if (result.substring(0, 3) == "...") window.location = "index.php";
			document.getElementById(kontainer).innerHTML = result; 

		}
			else
		{
			alert('There was a problem with the request.');
		}
	}
}

function logonAjax(obj, username, password, container, page)
{

// alert('hello there from logonAjax');
	var getstr = "?";

	username = document.getElementById(username).value;	// get username field text

	password = document.getElementById(password).value;	// get comment field text

//	var test = String.fromCharCode(13);

	getstr += "username="+username+"&"+"password="+password+"&"+"container="+container;

	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}


function registerAjax(obj, username, password, password2, email, container, page)
{
//alert('register ajax');
	var getstr = "?";

	username = document.getElementById(username).value;	// get username field text

	password = document.getElementById(password).value;	// get password field text
	
	password2 = document.getElementById(password2).value;	// get password field text
	
	email = document.getElementById(email).value;	// get email field text

//	var test = String.fromCharCode(13);

	getstr += "username="+username+"&password="+password+"&password2="+password2+"&email="+email+"&container="+container+"&sid="+Math.random();

	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}



function emailformAjax(obj, email, password, container, page, action, record)
{
// alert(record);

	var getstr = "?";

	email = document.getElementById(email).value;	// get username field text

	password = document.getElementById(password).value;	// get comment field text

//	var test = String.fromCharCode(13);

	getstr += "email="+email+"&password="+password+"&container="+container+"&action="+action+"&record="+record+"&sid="+Math.random();
//alert(getstr);
	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}








// comment system Ajax
// augmented by Chris Santala 2008


function loading_on(container)
{ 
//	document.getElementById(container).innerHTML=Image1;
	document.getElementById(container).innerHTML='<img src="factory/images/one_moment_please.gif">';
}


function loading_off(container)
{
	document.getElementById(container).innerHTML='';
}


function test()
{
	alert('hello there - comment_lib.js');
}

function label(container, content)
{
	document.getElementById(container).innerHTML = content;
}


function commentAjax(url, container)
{ 	
	loading_on(container);
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"&container="+container+"&sid="+Math.random();
//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function editorAjax(url, container)
{ 	
	loading_on(container);
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"&container="+container+"&sid="+Math.random();
//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function editprofileAjax(url, container)
{ //	alert(container);
	loading_on(container);
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"&action=edit"+"&container="+container+"&sid="+Math.random();
//alert(url); 
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}




function commentformAjax(obj, username, email, website, comment, record, container, page)
{	
// alert(record);
	var getstr = "?";

	username = document.getElementById(username).value;	// get username field text


//	email = document.getElementById(email).value;	// get email field text
	
//	website = document.getElementById(website).value;	// get email field text

	comment = document.getElementById(comment).value;	// get password field text

	comment = comment.replace(/#/g, "moneeba" );		
	comment = encodeURI( comment );

	getstr += "username="+username+"&email="+email+"&website="+website+"&comment="+comment+"&record="+record+"&container="+container;
	getstr = getstr.replace(/%0A/g, 'mon33ba');
	
	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}

function commentformAjax_b(obj, username, email, website, comment, record, container, page)
{	
// alert(record);
	var getstr = "?";

//	username = document.getElementById(username).innerHTML;

//	email = document.getElementById(email).value;	// get email field text
	
//	website = document.getElementById(website).innerHTML;	// get email field text

	comment = document.getElementById(comment).value;	// get password field text

	comment = comment.replace(/#/g, "moneeba" );		
	comment = encodeURI( comment );

	getstr += "username="+username+"&email="+email+"&website="+website+"&comment="+comment+"&record="+record+"&container="+container;
	getstr = getstr.replace(/%0A/g, 'mon33ba');

	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}

function editorformAjax(obj, title, text, record, container, action, page)
{	
// alert(record);
	var getstr = "?";

	title = document.getElementById(title).value;	// get email field text
//	alert(container);
	text = document.getElementById(text).value;	// get email field text
// alert(title); alert(text);

	title = title.replace(/#/g, "moneeba" );	
	text = text.replace(/#/g, "moneeba" );		
	text = encodeURI( text );

	var test = String.fromCharCode(0);

	getstr += "&container="+container+"&record="+record+"&title="+title+"&text="+text+"&action="+action;
	getstr = getstr.replace(/%0A/g, 'mon33ba');
	
	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}

function profileformAjax(obj, record, url, caption, email, password1, password2, free, container, action, page)
{	
// alert(record);
//	alert(container);
	
	var getstr = "?";
	
	if (action != 'edit')
	{
		url = document.getElementById(url).value;
		caption = document.getElementById(caption).value;
		email = document.getElementById(email).value;
		password1 = document.getElementById(password1).value;	
		password2 = document.getElementById(password2).value;
		free = document.getElementById(free).value;
	
// alert(title); alert(text);

		url = url.replace(/#/g, "moneeba" );	
		caption = caption.replace(/#/g, "moneeba" );
		email = email.replace(/#/g, "moneeba" );
		password1 = password1.replace(/#/g, "moneeba" );
		password2 = password2.replace(/#/g, "moneeba" );
		free = free.replace(/#/g, "moneeba" );
		free = encodeURI( free );
	}
//	else {url = null; caption = null; email = null; password1 = null; password2 = null; free = null; }

	getstr += "&container="+container+"&record="+record+"&url="+url+"&caption="+caption+"&email="+email+"&password1="+password1+"&password2="+password2+"&free="+free+"&action="+action+"&sid="+Math.random();
	getstr = getstr.replace(/%0A/g, 'mon33ba');
	
	for (i=0; i<obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].type == "hidden")
		{
        	getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
        }
	}
	
	makeRequest(page, getstr, container);	
	
}


function alertComment(comment, record, container)
{ 
// 	loading_on(container);

	url = "factory/comment_system/report_comment.php";
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
	url=url+"?comment="+comment+"&record_id="+record+"&container="+container+"&sid="+Math.random();
// alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}


// pagination system Ajax
// augmented by Chris Santala 2008

function paginatorAjax(url, container, record)
{
	kontainer = container; // global variable hack to allow dynamic container names
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
		alert ("Your browser does not support AJAX!");
		return;
	} 
//	url=url+"&container="+container+"&sid="+Math.random();
	url=url+"&container="+container+"&record="+record+"&sid="+Math.random();
//alert(url);
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}



// buffering
Image1 = new Image(93,10);
Image1.src = "images/one_moment_please.gif";

