//	|---------------------------------------------------------------------------|
//	|	PHP-Fusion 7 Content Management System									|
//	|	Copyright © 2002 - 2005 Nick Jones										|
//	|	http://www.php-fusion.co.uk/											|
//	|---------------------------------------------------------------------------|
//	| 	This program is released as free software under the						|
//	| 	Affero GPL license. You can redistribute it and/or						|
//	| 	modify it under the terms of this license which you						|
//	| 	can read by viewing the included agpl.txt or online						|
//	| 	at www.gnu.org/licenses/agpl.html. Removal of this						|
//	| 	copyright header is strictly prohibited without							|
//	| 	written permission from the original author(s).							|
//	|---------------------------------------------------------------------------|
//	|	ModB - Advance MODs Downloads Database Archive Module					|
//	|	Copyright © 2008 Rizald 'Elyn' Maxwell									|
//	|	www.NubsPixel.com														|
//	|	Filename : util.js														|
//	|	Read the source easier via Notepad++ 									|
//	|		comment fonts changed - Courrier New, 10pt							|
//	|---------------------------------------------------------------------------|
//	|	For more informations, please refer to README.TXT						|
//	|---------------------------------------------------------------------------|

function gE(id){
	return document.getElementById(id);
}

// stolen from Panda  :D
function ajaxRequest(content_type,c,method,url,async,funct,param) {
	if (c) {
		c.open(method,url,async);
		c.onreadystatechange = funct;

		if(content_type!=null)
			c.setRequestHeader("Content-Type",content_type);

		c.send(typeof(param)=='undefined'?null:param);
	}
}

function initXmlHttp(){
    var xmlhttp=false;
    if(window.ActiveXObject){
        var aVers = ["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
        for (var i=0;i<aVers.length&&!xmlhttp;i++){
            try{
                xmlhttp=new window.ActiveXObject(aVers[i]);
            }catch(e){
                xmlhttp=false;
            }
        }
        if (!xmlhttp){
            try{
                xmlhttp = window.createRequest();
            }catch(e){
                xmlhttp=false;
            }
        }
    }
    if (!xmlhttp){
        if (typeof XMLHttpRequest != "undefined"){
            xmlhttp = new XMLHttpRequest();
        }
    }
    return xmlhttp;
}

function showAvailable(q){
	var xmlElem = initXmlHttp();
	ajaxRequest(null,xmlElem,'GET','includes/json_page.php?act=author&q='+q,true,function(){
			if (xmlElem.readyState==4 && xmlElem.status==200){
				var xmlObj = xmlElem.responseText;
				var g = eval('('+ xmlObj +')');
				gE('uname_available').style.backgroundPosition = g.status;
		  }
		},null);
}

function checkPass(p){
	var q = gE('password1').value;
	if (q==p)
		gE('ch_pass').style.backgroundPosition = '0px -32px';
	else if (q!=p)
		gE('ch_pass').style.backgroundPosition = '0px 0px';
	else
		gE('ch_pass').style.backgroundPosition = '0px -16px';
}