/*
 * Ext JS Library 2.0.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
    var winForgot;
	var winDownload;
var winAbout;
var winFeedback;
var winFAQ;
	
	function hideForgotWindow()
	{
	winForgot.hide();	
	}

	function showForgotWindow(element)
	{
if(!winForgot)
{
            winForgot = new Ext.Window({
                el:'forgot-win',
                layout:'fit',
                width:300,
                height:120,
                closeAction:'hide',
                plain: true,
				modal: true,
				resizable: false
});
}
	winForgot.show(element);	
	}

	function showAboutWindow(element)
	{
if(!winAbout)
{
var xPos = ((screen.width/2)-150);
            winAbout = new Ext.Window({
                el:'about-win',
                layout:'fit',
                width:300,
                height:120,
x:xPos,
y:200,
                closeAction:'hide',
                plain: true,
				modal: true,
				resizable: false
});
}
	winAbout.show(element);	
	}


	function showFAQWindow(element)
	{
if(!winFAQ)
{
var xPos = ((screen.width/2)-250);
            winFAQ = new Ext.Window({
                el:'faq-win',
                layout:'fit',
                width:500,
                height:500,
x:xPos,
y:50,
                closeAction:'hide',
                plain: true,
				modal: true,
				resizable: false
});
}
	winFAQ.show(element);	
	}
	
      
function showDownloadWindow(element)
{


           if(!winDownload)
{
            winDownload = new Ext.Window({
                el:'download-win',
                layout:'fit',
                width:300,
                height:170,
                closeAction:'hide',
                plain: true,
				modal: true,
				resizable: false
            });
        }
        winDownload.show(element);


}

function showFeedbackWindow(element)
{


           if(!winFeedback)
{
            winFeedback = new Ext.Window({
                el:'download-win',
                layout:'fit',
                width:300,
                height:200,
                closeAction:'hide',
                plain: true,
				modal: true,
				resizable: false
            });
        }
        winFeedback.show(element);


}	

	
	function GetXmlHttpObjectForgot()
{
 var obj = null;
 if (window.XMLHttpRequest)
 {
 obj = new XMLHttpRequest();
 }
 if(window.ActiveXObject)
 {
 obj = new ActiveXObject("Microsoft.XMLHTTP");
 }
 return obj;

}



function forgetPasswordCall()

{

document.getElementById("forgotBtn").disabled = true;
document.getElementById("errorDivForgot").innerHTML = "";
document.getElementById("infoDivForgot").style.visibility = "visible";
document.getElementById("infoDivForgot").innerHTML = "Processing...please wait";
xmlObj = GetXmlHttpObjectForgot();

if(xmlObj == null)

{

	alert("your browser doesnot support Http");

	return;

}
var user = document.getElementById("userForgot").value;

var url = "/server/servlet/Verification?UserID="+user + "&action=forgotpass&source=web&rand="+Math.random();

xmlObj.onreadystatechange=stateChangedForgotPassword; 

xmlObj.open("GET",url,true);
//xmlObj.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
xmlObj.send(null);
}

function stateChangedForgotPassword()

{

	if(xmlObj.readyState == 4 || xmlObj.readyState == "complete")

	{
var res = xmlObj.responseText;

if(res != "true")
{
	document.getElementById("infoDivForgot").innerHTML = "";
	document.getElementById("infoDivForgot").style.visibility = "hidden";
		document.getElementById("errorDivForgot").style.visibility = "visible";
	document.getElementById("errorDivForgot").innerHTML = res;
document.getElementById("forgotBtn").disabled = false;
}
else
{
	document.getElementById("errorDivForgot").innerHTML = "";
	document.getElementById("errorDivForgot").style.visibility = "hidden";


	document.getElementById("infoDivForgot").style.visibility = "visible";
	document.getElementById("infoDivForgot").innerHTML = "";
	document.getElementById("infoDivForgot").innerHTML = "Account information has been sent to your e-mail address.";
	

}
	//document.getElementById("topics").innerHTML = xmlObj.responseText;	

	}
}


function verifyEmptyFieldsForgot()
{
var empty = false;
var user = document.getElementById("user").value;
var pass = document.getElementById("pass").value;
var cpass = document.getElementById("cpass").value;
var errStr = "";
var notEqual = false;

if(user == "")
{
	empty = true;
	errorStr = "Email,";
}
else if(pass == "")
{
	empty = true;
	errorStr = "Password,";
	
}

else if(cpass == "")
{
	empty = true;
	errorStr = "Confirm Password,";
	
}

else if(cpass != pass)
{
	empty = true;
	errorStr = "password and confirm password should be same";
	notEqual = true;
	
}


if(empty == true)
{
	if(notEqual == true)
document.getElementById("errorDiv").innerHTML = errorStr;	
else
document.getElementById("errorDiv").innerHTML = errorStr + " cannot be empty";	
}
else
{
registerUser();	
}


}






