// JavaScript Document


var xmlHttp;


var xmlHttp2;


var xmlHttp3;


var xmlHttp4;


var Putt;


var Putlist;


var Putmenu;


var Puterror;


var ques=0;


var roundno=0;


var checkobj;


var verifyuname=0;


var verifypass=0;


var verifypass2=0;


var verifyname1=0;


var verifyname2=0;


var verifyemail=0;


var maxques=0;


var startcheck=0;


/*var image[40]=new Array();

function loadImages()

{

	

    preload_image_object = new Image();

      // set image url

    image[0].src="images/0fdr.gif";

	image[1].src="images/1fdr.gif";

	image[2].src="images/2fdr.gif";

	image[3].src="images/3fdr.gif";

	image[4].src="images/4fdr.gif";

	image[5].src="images/5fdr.gif";

	image[6].src="images/6fdr.gif";

	image[7].src="images/7fdr.gif";

	image[8].src="images/8fdr.gif";

	image[9].src="images/9fdr.gif";



    var i = 0;

    for(i=0; i<=9; i++) 

         preload_image_object.src = image[i];

	

}

*/

$(document).ready(function(){
		
		$('#menu li a').click(function(){
			var id=$(this).attr('id');
			
			//var url= id + "();";
			$('#menu li a.active').removeClass('active');
//			$('#menu li').removeClass('active');
			$(this).addClass('active');
			
			/*$('#content').fadeOut('slow');
			function loadNew(){
				$('#content').load(url);
			}*/
			$('#content').fadeIn('slow');
			});
	});

// obtain xmlhttp object

function GetXmlHttpObject()


{ 

	
	var objXMLHttp=null


	if (window.XMLHttpRequest)

	
{

		
	objXMLHttp=new XMLHttpRequest()

 }

	
else if (window.ActiveXObject)

	
{

		
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")


	}

	
return objXMLHttp

}
 



//obtain the round number

function GetRoundNumber()


{


	Putt=document.getElementById("content");


	xmlHttp2=GetXmlHttpObject()

	
if (xmlHttp2==null)


	{

		
		Putt.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

		
		return;


	}


	var url="round.php";


	xmlHttp2.onreadystatechange=stateChangedRound


	xmlHttp2.open("GET",url,true);


	xmlHttp2.send(null);


}



//works on state change of above function


function stateChangedRound()


{

	
if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")


	{

	
		roundno=xmlHttp2.responseText;


		GetMaxQues();


	}


}




//obtain max ques number


function GetMaxQues()


{


	Putt=document.getElementById("activity");

	
	xmlHttp3=GetXmlHttpObject()


	if (xmlHttp3==null)


	{


		Putt.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";


		return;


	}


	var url="getques.php";


	url=url+"?round="+roundno;


	xmlHttp3.onreadystatechange=stateChangedMaxQues

	
	xmlHttp3.open("GET",url,true);


	xmlHttp3.send(null);




}


74

//works on state change of above function


function stateChangedMaxQues()


{


	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")


	{

	
		maxques=xmlHttp3.responseText;
		

	}

}



//get the question to be displayed

function Getques(question,roundnumber)

{

	if(startcheck==1)

	{

	if(ques==0)

	{

		GetquesList(question,1);

	}

	else

	{

		GetquesList(question,ques);

	}

	ques=question;

	roundno=roundnumber;

	Putt=document.getElementById("content");

	if((ques.length<1) || (ques<1))

	{

		Putt.innerHTML="Invalid page. Please wait while you are redirected back<meta http-equiv='refresh' content='2;url=index.php' />";

		return;

	}

	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)

	{

		Putt.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

		return;

	}

	var url="question.php";

	url=url+"?qno="+ques;

	url=url+"&round="+roundno;

	xmlHttp.onreadystatechange=stateChangedques

	xmlHttp.open("GET",url,true)

	xmlHttp.send(null)

	}

} 



//works on state changed for question

function stateChangedques() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		Putt=document.getElementById("content");

		Putt.innerHTML=xmlHttp.responseText; 

	} 

} 



//generates the question list

function generatelist()

{

	if(startcheck==1)

	{

	var queslist,temp;

	var i=0;

	queslist=document.getElementById("queslist");

	temp=" ";

	for(i=1;i<=maxques;i++)

	{

		temp=temp+"<a href='javascript:Getjumpedques(";

		temp=temp+i;

		temp=temp+")' id='"+i;

		temp=temp+"'>Question ";

		temp=temp+i;

		temp=temp+"</a><br />";

	}

	queslist.innerHTML=temp;

	}

}



//get the question menu (list) to be displayed

function GetquesList(ques1,ques2)

{

	if(startcheck==1)

	{

	var newques,prevques;

	newques=document.getElementById(ques1);

	prevques=document.getElementById(ques2);

	prevques.style.fontWeight="normal";

	prevques.style.color="#e6efcd";

	newques.style.fontWeight="bold";

	newques.style.color="#ffffff";

	}

} 



//get the question asked for

function Getjumpedques(question)

{

	if(startcheck==1)

	{

		Puterror=document.getElementById("activity");

		if(document.getElementById("answer"))

		{

			var answer=document.getElementById("answer").value;

			xmlHttp3=GetXmlHttpObject()

			if (xmlHttp3==null)

			{

				Puterror.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

				return;

			}	 

			var url="postanswer.php";

			url=url+"?answer="+answer;

			url=url+"&qno="+ques;

			url=url+"&round="+roundno;

			xmlHttp3.onreadystatechange=stateChangednextQues

			xmlHttp3.open("GET",url,true)

			xmlHttp3.send(null)

			Getques(question,roundno);

		}

		else

		{

			Getques(question,roundno);

		}

	}

}



//works on state changed for next question

function stateChangednextQues()

{

	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")

	{

	} 

}

//Get next question

function GetnextQues()

{

	if(startcheck==1)

	{

	Puterror=document.getElementById("activity");

	var answer=document.getElementById("answer").value;

	xmlHttp3=GetXmlHttpObject()

	if (xmlHttp3==null)

	{

		Puterror.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

		return;

	} 

	var url="postanswer.php";

	url=url+"?answer="+answer;

	url=url+"&qno="+ques;

	url=url+"&round="+roundno;

	xmlHttp3.onreadystatechange=stateChangednextQues

	xmlHttp3.open("GET",url,true)

	xmlHttp3.send(null)

	Getques(ques+1,roundno);

	}

}



//works on state changed for next question

function stateChangednextQues()

{

	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")

	{

	} 

}



// obtains previosu question

function GetprevQues()

{

	if(startcheck==1)

	{

	Puterror=document.getElementById("activity");

	var answer=document.getElementById("answer").value;

	xmlHttp3=GetXmlHttpObject()

	if (xmlHttp3==null)

	{

		Puterror.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

		return;

	} 

	var url="postanswer.php";

	url=url+"?answer="+answer;

	url=url+"&qno="+ques;

	url=url+"&round="+roundno;

	xmlHttp3.onreadystatechange=stateChangedprevQues

	xmlHttp3.open("GET",url,true)

	xmlHttp3.send(null)

	Getques(ques-1,roundno);

	}

}



//works on state changed for previous question

function stateChangedprevQues()

{

	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")

	{

	} 

}

// this is a funtion to start the quiz

function startques()

{
     
	if(startcheck==0)

	{

		xmlHttp2=GetXmlHttpObject();

		Puterror=document.getElementById("activity");

		if (xmlHttp2==null)

		{

			Puterror.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

			return;

		}

		ques=1;

		var url="startquiz.php";

		url=url+"?round="+roundno;

		xmlHttp2.onreadystatechange=stateChangedstartQues

		xmlHttp2.open("GET",url,true)

		xmlHttp2.send(null)

	}

	else

	{

		alert("You cannot start the quiz again");

	}

}



//works on state change of starting the arena

function stateChangedstartQues()

{

	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")

	{

		Putt=document.getElementById("content");

		var abc=xmlHttp2.responseText;

		if(abc=="played")

		{

			Putt.innerHTML="<font color='red'>You have already played this quiz. You can't play it again</font>";

		}

		if(abc=="correct")

		{

			showTime();

			startcheck=1;

			changestartdone(0);

			generatelist();

			Getques(1,roundno);

		}



		if(abc=="invalid page")

		{

			Putt.innerHTML="<font color='red'>This is an invalid page. Please go back and try again</font>";

		}

	}

}





	

function doneQues()

{

	if(startcheck==1)

	{

		xmlHttp3=GetXmlHttpObject();

		xmlHttp4=GetXmlHttpObject();

		Puterror=document.getElementById("activity");

		if (xmlHttp3==null)

		{

			Puterror.innerHTML="Browser does not support HTTP Request. Sorry you cannot participate in the quiz";

			return;

		}

		stopInterval();

		if(document.getElementById("answer"))

		{

			var answer=document.getElementById("answer").value;

			var url="postanswer.php";

			url=url+"?answer="+answer;

			url=url+"&qno="+ques;

			url=url+"&roundno="+roundno;

			xmlHttp3.onreadystatechange=stateChangeddoneQues

			xmlHttp3.open("GET",url,true);

			xmlHttp3.send(null);

		}

		var url2="donequiz.php";

		url2=url2+"?round="+roundno;

		url2=url2+"&minutes="+minute;

		url2=url2+"&seconds="+second;

		xmlHttp4.onreadystatechange=stateChangeddoneQuiz

		xmlHttp4.open("GET",url2,true)

		xmlHttp4.send(null)

	}

	else

	{

		alert("No quiz in progress");

	}

}





//works on state change of finishin ques

function stateChangeddoneQues()

{

	if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")

	{

		Putlist=document.getElementById("queslist");

		Putlist.innerHTML=" ";

	}

}





//works on state change of done quiz

function stateChangeddoneQuiz()

{

	if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete")

	{

	startcheck=2;

	changestartdone(1);

	Putt=document.getElementById("content");

	Putt.innerHTML=xmlHttp4.responseText;

	}

}
//
function leaderboard()
{
	Putt=document.getElementById("content");
	
var oRequest;
try {
        oRequest=new XMLHttpRequest();
     } catch (e)   {
     try {
          oRequest=new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
          try {
              oRequest=new ActiveXObject("Microsoft.XMLHTTP");
               } catch (e) {
                   alert("Your browser does not support AJAX!");
                  return false;
               }
         }
      }
   oRequest.onreadystatechange=function() {
    if(oRequest.readyState==4)
      {
          document.getElementById("content").innerHTML = oRequest.responseText;
      }
    }
  oRequest.open("GET","leaderboard.php",true);
  oRequest.send(null);
  
}
//load all the features of arena at the loading of page

function loadArena()

{

	GetRoundNumber();

//	loadImages();

	Putt=document.getElementById("content");

	//insert the data for home page

	Putt.innerHTML="<p><strong>QUIZ IS OVER. THANK YOU FOR PARTICIPATING.<br/>Results will be declared soon</b></strong><br/><br/><strong>WELCOME</strong></p><p><strong>PANACHE ONLINE</strong></p><p><em></em></p><br />PANACHE ONLINE can in a way be described as the connoisseur edition of panache showcased in REPERTOIRE. It is a forum that doesn&#8217;t follow any set precedents and thus is the perfect annotation, ode or whatever u may like to call it to something that can only be described as Panache. Panache online has always been a source of attraction for all the quizzers. <br /><br />This year Panache Online has touched new heights. This time we have made an AJAX based interface to bring to life the experience of quizzing. So, take a look around and get going with it!! </p>";
	
	
	var Putlogin=document.getElementById("loginid");

	xmlHttp=null;

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		Putt=document.getElementById("activity");

		Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

		return;

	}

	url="login.php";

	xmlHttp.onreadystatechange=stateChangedLogin

	xmlHttp.open("GET",url,true)

	xmlHttp.send(null)

	

}



//works on state change of chk username

function stateChangedLogin() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{

		var Putlogin=document.getElementById("loginid");

		Putlogin.innerHTML=xmlHttp.responseText; 
		
	
	} 

} 



//function to view the registration page

function registerArena()

{

	Putt=document.getElementById("content");
	

	//insert registration page in content box

	Putt.innerHTML="<div><strong>REGISTER</strong></div><form id='formregister' name='formregister'><table width='100%' border='0'><tbody><tr><td><div align='right'><div>Team Name<font color='red'>*</font>:</div></div></td><td>&#160;</td><td><input type='text' onblur='return chkUsername()' id='uname' name='uname'/> </td><td width='50%' class='one' id='unamecom'>&#160;</td></tr><tr><td><div align='right'><div>Password<font color='red'>*</font>:</div></div></td><td>&#160;</td><td><input type='password' onblur='return chkPassword()' id='password1' name='password1'/></td><td class='one' id='passcom'>&#160;</td></tr><tr><td><div align='right'><div>Confirm Password<font color='red'>*</font>: </div></div></td><td>&#160;</td><td><input type='password' onblur='return chkConfirmPassword()' id='password2' name='password2'/></td><td class='one' id='confirmpasscom'>&#160;</td></tr><tr><td><div align='right'><div>First Name<font color='red'>*</font>:</div></div></td><td>&#160;</td><td><input type='text' onblur='return chkFname()' id='fname' name='fname'/></td><td class='one' id='namecom'>&#160;</td></tr><tr><td><div align='right'><div>Last Name<font color='red'>*</font>:</div> </div></td><td>&#160;</td><td><input type='text' onblur='return chkLname()' id='lname' name='lname'/></td>        <td class='one' id='name2com'>&#160;</td>      </tr>	   <tr>        <td height='21'><div align='right'>          <div>Email<font color='red'>*</font>:</div>          </div></td>        <td>&#160;</td>        <td><input type='text' onblur='return chkEmail()' id='email' name='email'/></td>        <td class='one' id='emailcom'>&#160;</td>      </tr>    <tr>        <td height='21'><div align='right'>          <div>2nd Member:</div>          </div></td>        <td>&#160;</td>        <td><input type='text'  id='secmem' name='secmem'/></td>        <td class='one' id='secmemcom'>&#160;</td>      </tr> <tr>        <td height='21'><div align='right'>     <div>3rd Member:</div>          </div></td>        <td>&#160;</td>        <td><input type='text'  id='thirdmem' name='thirdmem'/></td>        <td class='one' id='thirdmemcom'>&#160;</td>      </tr>    <tr>        <td height='21'><div align='right'>          <div>Profession<font color='red'>*</font>:</div>          </div></td>        <td>&#160;</td>        <td><table width='100%' cellspacing='0' cellpadding='0' border='0'><tbody><tr><td align='left'><input type='radio' checked='' onclick='return getyr()' value='0' id='profession0' name='profession'/></td><td align='left' style='font-size: 11px;'>Student</td></tr><tr><td><input type='radio' onclick='return removeyr()' value='1' id='profession1' name='profession'/></td><td style='font-size: 11px;'>Professional</td></tr></tbody></table></td><td id='professioncom'>&#160;</td></tr> <tr><td height='21'><div align='right'><div id='textcollege'>College:</div></div></td><td>&#160;</td><td><input type='text' id='college' name='college'/></td><td id='collegecom'>&#160;</td></tr><tr><td height='21'><div align='right'><div id='puttextyr'>Year:</div></div></td><td>&#160;</td><td id='putselectyear'><select id='year' name='year'><option value='1'>First</option><option value='2'>Second</option><option value='3'>Third</option><option value='4'>Fourth</option></select></td><td id='collegecom'>&#160;</td></tr><tr><td><div align='right'><div>Address: </div></div></td><td>&#160;</td><td><input type='text' id='add' name='add'/></td><td id='addcon'>&#160;</td></tr><tr></tr><tr><td align='center' style='background-color: rgb(39, 40, 36); color: rgb(255, 255, 255); font-size: 11px;' colspan='4'><input type='checkbox' onclick='agreesubmit(this)' name='agreecheck' id='agreecheck'/>I accept all the terms and conditions of spave online</td></tr><tr><td align='center' colspan='4'><a onclick='return defaultagree()' onmouseout='this.style.cursor=''' onmouseover='this.style.cursor='pointer'' style=''><img id='register' name='register' src='images/submitgray.gif'/></a></td></tr></tbody></table></form><br/></div>";

return;

}



//this is to test the users browser for ajax compatibility

function testbrowserArena()

{

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		alert("Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz");

	}

	else

	{

		var x = navigator;

		alert("Congratulations, your browser is compatible.\nIf you have recieved a message of blocked content, then you might need to unblock it to view the page correctly");

	}

	return;

}



//this is to view the rules of arena in the content box

function rulesArena()

{

	Putt=document.getElementById("content");

	Putt.innerHTML="<p><strong>RULES</strong></p><ul>  <li>    You will need to register yourself once, with a valid email to be eligible to play the quiz</li>  <li>    To play the quiz you would need to login using the username and password chosen by you while registering</li>  <li>    Only one chance will be allowed per user to play the quiz</li>  <li>  You will be given 10 minutes to answer the questions</li>  <li>    No negative marking is there for wrong answers</li><li>Answers can be given in any random order</li>  <li>    All questions carry equal marks unless and until specified</li>  <li>    The declaration of results will be done on <a href='http://www.dcetech.com/' target='_blank'>www.dcetech.com</a> </li>  <li>    The decision of results will be final and no requests and rechecking will be entertained</li><li>Do not refresh the page!.You'll be logged out.</li></ul>";

	return;

}



//this is to view the instructions of arena in the content box

function instructionsArena()

{

	Putt=document.getElementById("content");

	Putt.innerHTML="<p><strong>INSTRUCTIONS</strong></p><ul><li>After you have made a successful login, you will see the start button on the page. You will need to click the button to start the quiz.</li>  <li>As soon as you click the start button, a question will appear in your question box  and the timer on top right will start and will not stop as long as you don't run out of time or click the Done button </li>  <li><font color='red'>DONOT</font> click the refresh button or back button or enter key after starting the quiz, otherwise your chance will be lost nd you will not be alowed to play the quiz again.</li>  <li>You will be given 10 minutes to answer the questions</li>  <li>With every question, there will be a input box where answer is to be written.</li>  <li>After writing the answer you can click Next or Previous or use left menu to toggle among the questions.</li>  <li>As soon as you click any button, your answer will be submitted for current question.</li>  <li>You can also use the left menu to toggle among the questions.</li>  <li>When you are finished with the questions, you can click Done botton and your entry will be submitted and timer will be stopped.</li>  <li>If you  reach the end of your allotted time, your entry will automatically be submitted. </li><li>Attempt to hack would lead to disqualification from the game</li><li>DO NOT PRESS ENTER OR REFRESH YOUR PAGE AFTER THE QUIZ HAS BEGUN</li></ul>";

	return;

}



//this is to view the about arena page in the content box

function aboutArena()

{

	Putt=document.getElementById("content");

	Putt.innerHTML="<p><strong>ABOUT PANACHE ONLINE</strong></p> <br />PANACHE ONLINE is an online counterpart of the national level quiz competition panache showcased in REPERTOIRE. Panache online has always been a source of attraction for all the quizzers. This is a quiz organised to invite all the quiz masters across the globe who may or may not make it up to Panache. <br /><br />This year panache Online has touched new heights. This time we have made an AJAX based interface to bring to life the experience of quizzing. So, take a look around and get going with it!! ";

	return;

}



//this is to view the team page in the content box

function teamArena()

{

	Putt=document.getElementById("content");

	Putt.innerHTML="<table><tr><th><strong>TEAM PANACHE ONLINE</strong></th><td>&nbsp;</td></tr><tr><th align='left'></tr><tr><th align='left'>Content Team:</th><td>&nbsp;</td></tr><tr><th align='left'>Panache Team</th><td>&nbsp;</td></tr></table>";

	return;

}

//this is to view the web team page in the content box
function webTeam()
{
		Putt=document.getElementById("content");
		 Putt.innerHTML='<table align="center" cellpadding="20" cellspacing="20"><tr><th colspan="4"><strong>WEB TEAM : PANACHE ONLINE</strong></th></tr><tr><th align="left">Ishaan Malhotra</th><td>&nbsp;</td><td>&nbsp;</td><td>ishaan@dcetech.com</td></tr><tr><th align="left">Puneet Goyal</th><td>&nbsp;</td><td>&nbsp;</td><td> puneet@dcetech.com</td></tr><tr><th align="left">Dhruv Balhara</th><td>&nbsp;</td><td>&nbsp;</td><td>aimhighdb@gmail.com</td></tr><tr><th align="left">Nancy Aggarwal</th><td>&nbsp;</td><td>&nbsp;</td><td>nancy22418@gmail.com</td></tr></table>';

}
//this is the feedback form for arena to be displayed in the content box

function feedbackArena()

{

	Putt=document.getElementById("content");

	Putt.innerHTML=leaderboard.php;

	return;

}





//This function is used to check the username

function chkUsername()

{

	verifyuname=1;

	var uname=document.getElementById("unamecom");

	uname.innerHTML="Please wait..";

	username=document.getElementById("uname").value;

	if(username.length<4)

	{

		uname.innerHTML="<font color='red'>Too short</font>";

		verifyuname=0;

		return;

	}

	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_";

	var checkOKstart = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

	ch = username.charAt(0);

	for(j = 0; j< checkOKstart.length; j++)

		if(ch == checkOKstart.charAt(j)) break;

	if (j == checkOKstart.length)

	{

		uname.innerHTML="Invalid Username, Can not start with  " + ch;

		verifyuname=0;

		return;

	}

	for (i = 1;  i < username.length;  i++)

	{

		ch = username.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

			if (ch == checkOK.charAt(j)) break;

		if (j == checkOK.length)

		{

			uname.innerHTML="<font color='red'Invalid Username, It cannot contain " + ch + "</font>";

			verifyuname=0;

			return;

		}

	}

	xmlHttp=null;

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		Putt=document.getElementById("activity");

		Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

		return;

	}

	url="verification.php";

	url=url+"?Content=username";

	url=url+"&Value="+username;

	xmlHttp.onreadystatechange=stateChangedchkUsername

	xmlHttp.open("GET",url,true)

	xmlHttp.send(null)

}



//works on state change of chk username

function stateChangedchkUsername() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{

		var uname=document.getElementById("unamecom");

		if(xmlHttp.responseText=="correct")

		{

			uname.innerHTML=xmlHttp.responseText; 

		}

		else

		{

			uname.innerHTML="<font color='red'>Already exist</font>";

			verifyuname=0;

		}

	} 



}



//check the correctness of password

function chkPassword()

{

	verifypass=1;

	var password = document.getElementById("password1").value;

	var objPut1 = document.getElementById("passcom");

	if(password.length<4)

	{

		objPut1.innerHTML="<font color='red'>Too short</font>";

		verifypass=0;

		return;

	}

	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_";

	for (i = 0;  i < password.length;  i++)

	{

		ch = password.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

			if (ch == checkOK.charAt(j)) break;

		if (j == checkOK.length)

		{

			objPut1.innerHTML="<font color='red'>Invalid Password, It cannot contain " + ch + "</font>";

			verifypass=0;

			return;

		}

	}

	objPut1.innerHTML="Correct";

	return;

}



//Check the entries match on confirm password

function chkConfirmPassword()

{

	verifypass2=0;

	var password = document.getElementById("password1").value;

   	var password1 = document.getElementById("password2").value;

	var objPut1 = document.getElementById("confirmpasscom");

	if(password == password1)

	{

		objPut1.innerHTML = "Correct";

		verifypass2=1;

	}

	else 

	{

		objPut1.innerHTML="<font color='red'>Your password entries did not match</font>";

		verifypass2=0;

	}

}



//verify First Name

function chkFname()

{

	verifyname1=1;

   	var checkStr = document.getElementById("fname").value;

	var objPut2 = document.getElementById("namecom");
	

	objPut2.innerHTML = "Checking...";

	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .";

	var checkOKstart = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

	ch = checkStr.charAt(0);

	for(j = 0; j< checkOKstart.length; j++)

		if(ch == checkOKstart.charAt(j)) break;

	if (j == checkOKstart.length)

	{

		objPut2.innerHTML="<font color='red'>Invalid Name, Starting can not be " + ch + "</font>";

		verifyname1=0;

		return;

	}

	for (i = 1;  i < checkStr.length;  i++)

	{

		ch = checkStr.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

			if (ch == checkOK.charAt(j)) break;

		if (j == checkOK.length)

		{

			objPut2.innerHTML="<font color='red'>Invalid Name, It cannot contain " + ch + "</font>";

			verifyname1=0;

			return;

		}

	}

objPut2.innerHTML = "Correct";

}





//verify Last Name

function chkLname()

{

	verifyname2=1;

   	var checkStr = document.getElementById("lname").value;

	var objPut2 = document.getElementById("name2com");

	objPut2.innerHTML = "Checking...";

	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .";

	var checkOKstart = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

	ch = checkStr.charAt(0);

	for(j = 0; j< checkOKstart.length; j++)

		if(ch == checkOKstart.charAt(j)) break;

	if (j == checkOKstart.length)

	{

		objPut2.innerHTML="<font color='red'>Invalid Name, Starting can not be " + ch + "</font>";

		verifyname2=0;

		return;

	}

	for (i = 1;  i < checkStr.length;  i++)

	{

		ch = checkStr.charAt(i);

		for (j = 0;  j < checkOK.length;  j++)

			if (ch == checkOK.charAt(j)) break;

		if (j == checkOK.length)

		{

			objPut2.innerHTML="<font color='red'>Invalid Name, It cannot contain " + ch + "</font>";

			verifyname2=0;

			return;

		}

	}

objPut2.innerHTML = "Correct";

}



//verify email address


function chkEmail()

{		

	verifyemail=1;

	var	emailStr =document.getElementById("email").value;
	
	var objPut3 = document.getElementById("emailcom");
	objPut3.innerHTML = "Checking...";
	var emailPat=/^(.+)@(.+)$/

	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

	var validChars="\[^\\s" + specialChars + "\]"

	var quotedUser="(\"[^\"]*\")"

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

	var atom=validChars + '+'

	var word="(" + atom + "|" + quotedUser + ")"

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	var matchArray=emailStr.match(emailPat)
	

	if (matchArray==null) 

	{

		objPut3.innerHTML="<font color='red'>Email address seems incorrect (check @ and .'s)</font>";

		verifyemail=0;

		return;

	}
	
	var user=matchArray[1]

	var domain=matchArray[2]
	

	if (user.match(userPat)==null) 

	{

		objPut3.innerHTML="<font color='red'>The username in your e-mail doesn't seem to be valid.</font>";

		verifyemail=0;

    	return;

	}

	var IPArray=domain.match(ipDomainPat)
	

	if (IPArray!=null) 

	{

	  	for (var i=1;i<=4;i++) 

	  	{

	    	if ((IPArray[i]>255)) 

			{

				objPut3.innerHTML="<font color='red'>Destination IP address is invalid!</font>";

				verifyemail=0;

				return;

	    	}

      	}

	}

	var domainArray=domain.match(domainPat)
	

	if (domainArray==null)

	{

		objPut3.innerHTML="<font color='red'>The domain name of your e-mail doesn't seem to be valid.</font>";

		verifyemail=0;

    	return;

	}

	var atomPat=new RegExp(atom,"g")

	var domArr=domain.match(atomPat)
	
	var len=domArr.length
	
	if (len<2)

	{

		objPut3.innerHTML="<font color='red'>This e-mail address is missing a hostname!</font>";

		verifyemail=0;

    	return;

	}

	xmlHttp=null;

	xmlHttp=GetXmlHttpObject();
	

	if (xmlHttp==null)
	{

		Putt=document.getElementById("activity");

		Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

		return;

	}

	url="verification.php";

	url=url+"?Content=email";
	
	url=url+"&Value="+emailStr;
	

	xmlHttp.onreadystatechange=stateChangedchkEmail
	
	xmlHttp.open("GET",url,true)
	

	xmlHttp.send(null)
	

}
/*function chkEmail2()

{		

	verifyemail2=1;

	
	var emailStr2 =document.getElementById("email2").value;
	
	var objPut5 = document.getElementById("emailcom2");

	objPut5.innerHTML = "Checking...";

	var emailPat=/^(.+)@(.+)$/

	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

	var validChars="\[^\\s" + specialChars + "\]"

	var quotedUser="(\"[^\"]*\")"

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

	var atom=validChars + '+'

	var word="(" + atom + "|" + quotedUser + ")"

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	
	var matchArray2=emailStr2.match(emailPat)

	
if (matchArray2==null)
	{

		objPut5.innerHTML="<font color='red'>Email address seems incorrect (check @ and .'s)</font>";

		verifyemail2=0;

		return;

	}

	
	var user2=matchArray2[1]

	
	var domain2=matchArray2[2]

	if (user2.match(userPat)==null) 

	{

		objPut5.innerHTML="<font color='red'>The username in your e-mail doesn't seem to be valid.</font>";

		verifyemail2=0;

    	return;

	}

	
	var IPArray2=domain2.match(ipDomainPat)

	if (IPArray2!=null)

	{

	  	for (var i=1;i<=4;i++) 

	  	{

	    	if (IPArray2[i]>255)

			{

				objPut5.innerHTML="<font color='red'>Destination IP address is invalid!</font>";

				verifyemail2=0;

				return;

	    	}

      	}

	}

	
	var domainArray2=domain2.match(domainPat)

	if (domainArray2==null) 

	{

		objPut5.innerHTML="<font color='red'>The domain name of your e-mail doesn't seem to be valid.</font>";

		verifyemail2=0;

    	return;

	}

	var atomPat=new RegExp(atom,"g")

	
	var domArr2=domain2.match(atomPat)

	var len2=domArr2.length

	if (len2<2)

	{

		objPut5.innerHTML="<font color='red'>This e-mail address is missing a hostname!</font>";

		verifyemail2=0;

    	return;

	}

	xmlHttp=null;
	xmlHttp2=GetXmlHttpObject();

	if (xmlHttp2==null)

	{

		Putt=document.getElementById("activity");

		Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

		return;

	}

	url="verification.php";

	url=url+"?Content=email";
	
	url2=url+"&Value="+emailStr2;

	
	xmlHttp2.onreadystatechange=stateChangedchkEmail2

	
	xmlHttp2.open("GET",url,true)

	

	xmlHttp2.send(null)

}
function chkEmail1()

{		

	verifyemail=1;

	
	var emailStr1 =document.getElementById("email1").value;
	
	
	var objPut4 = document.getElementById("1");

	objPut4.innerHTML = "Checking...";emailcom

	var emailPat=/^(.+)@(.+)$/

	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

	var validChars="\[^\\s" + specialChars + "\]"

	var quotedUser="(\"[^\"]*\")"

	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/

	var atom=validChars + '+'

	var word="(" + atom + "|" + quotedUser + ")"

	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")

	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	
	var matchArray1=emailStr1.match(emailPat)
	

	
	if (matchArray1==null)
	{

		objPut4.innerHTML="<font color='red'>Email address seems incorrect (check @ and .'s)</font>";

		verifyemail=0;

		return;

	}


	
	var user1=matchArray1[1]
	
	
	var domain1=matchArray1[2]


	if (user1.match(userPat)==null) 

	{

		objPut4.innerHTML="<font color='red'>The username in your e-mail doesn't seem to be valid.</font>";

		verifyemail1=0;

    	return;

	}

	
	var IPArray1=domain1.match(ipDomainPat)
	

	if (IPArray1!=null) 

	{

	  	for (var i=1;i<=4;i++) 

	  	{

	    	if (IPArray1[i]>255) 

			{

				objPut4.innerHTML="<font color='red'>Destination IP address is invalid!</font>";

				verifyemail1=0;

				return;

	    	}

      	}

	}

	
	var domainArray1=domain1.match(domainPat)
	

	if (domainArray1==null) 

	{

		objPut4.innerHTML="<font color='red'>The domain name of your e-mail doesn't seem to be valid.</font>";

		verifyemail1=0;

    	return;

	}

	var atomPat=new RegExp(atom,"g")

	
	var domArr1=domain1.match(atomPat)
	

	
	var len1=domArr1.length
	

	if (len1<2)

	{

		objPut4.innerHTML="<font color='red'>This e-mail address is missing a hostname!</font>";

		verifyemail1=0;

    	return;

	}

	xmlHttp1=null;

	
	xmlHttp1=GetXmlHttpObject();
	
	if (xmlHttp1==null)

	{

		Putt=document.getElementById("activity");

		Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

		return;

	}

	url="verification.php";

	url=url+"?Content=email";
	
	
	url1=url+"&Value="+emailStr1;
	

	
	xmlHttp1.onreadystatechange=stateChangedchkEmail1
	
	
	xmlHttp1.open("GET",url,true)
	

	
	xmlHttp1.send(null)
	
}

*/

//works on state change of chk username

function stateChangedchkEmail() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{

		var ename=document.getElementById("emailcom");

		if(xmlHttp.responseText=="correct")

		{

			ename.innerHTML=xmlHttp.responseText; 

		}

		else

		{

			ename.innerHTML="<font color='red'>Already registered</font>";

			verifyemail=0;

		}

	} 
}



//Change the image of submit button on clicking agree

function agreesubmit(el){

checkobj=el;

if (document.getElementById("register"))

{

	var tempobj=document.getElementById("register");



	if(checkobj.checked)

	{

		tempobj.src="images/submit.gif";



	}

	else

	{

		tempobj.src="images/submitgray.gif";



	}

}

}



//function to swap the start and done button

function changestartdone(flag)

{

	var getObj=document.getElementById("start");

	var getObj2=document.getElementById("done");

	if(flag==0)

	{

		if(startcheck==1)

		{

			getObj.src="images/startgray.gif";

			getObj2.src="images/done.gif";

		}

	}

	if(flag==1)

	{

		if(startcheck==2)

		{

			getObj2.src="images/donegray.gif";	

		}

	}

}



//verifies that the registration is correct or not

function defaultagree()

{	

	var text="Errors!!";

	if(verifyuname!=1)

		text=text+"\nUsername";

	if((verifypass!=1)||(verifypass2!=1))

		text=text+"\nPassword";

	if((verifyname1!=1)||(verifyname2!=1))

		text=text+"\nName";

	if(verifyemail!=1)

		text=text+"\nEmail ID";

	
	if(text=="Errors!!")

	{	



	alert("Registration in Progress!");
	
	







		

		var username=document.getElementById("uname").value;

		var password=document.getElementById("password1").value;

		var fname=document.getElementById("fname").value;

		var lname=document.getElementById("lname").value;

		var add=document.getElementById("add").value;

		var email=document.getElementById("email").value;
		var name1=document.getElementById("secmem").value;
		var name2=document.getElementById("thirdmem").value;
		//alert(name1);
		//alert(name2);

		var college=document.getElementById("college").value;

		var year;

		Putt=document.getElementById("activity");

		xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

			{

		

			Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

			return;

		}

		var url="register.php";

		var check=document.getElementById("profession1");

		if(check.checked)

		{

			url=url+"?username="+username+"&password="+password+"&fname="+fname+"&lname="+lname+"&add="+add+"&email="+email+"&name1="+name1+"&name2="+name2+"&company="+college;

		}

		else

		{

			url=url+"?username="+username;

			year=document.getElementById("year").value;

			url=url+"&password="+password+"&fname="+fname+"&lname="+lname+"&add="+add+"&email="+email+"&name1="+name1+"&name2="+name2+"&college="+college+"&year="+year;

		

		}

		xmlHttp.onreadystatechange=stateChangedregister

		xmlHttp.open("GET",url,true)

		xmlHttp.send(null)

	}

	else

	{

		alert(text);

	}



}



//function to get year if the person is a student

function getyr()

{

	var check=document.getElementById("profession0");

	if(check.checked)

	{

		document.getElementById("textcollege").innerHTML="College:";

		document.getElementById("puttextyr").innerHTML="Year:";

		document.getElementById("putselectyear").innerHTML="<select name='year'><option value='1'>First</option><option value='2'>Second</option><option value='3'>Third</option><option value='4'>Fourth</option></select>";

	}

}



//function to remove year if the person is a professional

function removeyr()

{

	var check=document.getElementById("profession1");

	if(check.checked)

	{

		document.getElementById("textcollege").innerHTML="Company:";

		document.getElementById("puttextyr").innerHTML="&nbsp;";

		document.getElementById("putselectyear").innerHTML="&nbsp;";

	}

}





//works on state changed for question

function stateChangedregister() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		Putt=document.getElementById("content");

		Putt.innerHTML=xmlHttp.responseText; 

	} 

} 



function showForgetpswd()

{

	Putt=document.getElementById("content");

	Putt.innerHTML="Please enter your username and email id. Your registration details will be sent to you on your email address.<form name='forgetform' id='forgetform'><table cellpadding='0' cellspacing='0' border='0'><tr><td width='101'><p>Username:</p></td><td width='147'><input type='text' name='uname' id='uname' /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td><p>Email Address:</p></td><td><input type='text' name='email' id='email'  /></td></tr><tr><td>&nbsp;</td><td><a onMouseOver=this.style.cursor='pointer' onMouseOut=this.style.cursor='' onClick='return submitForgetpswd()' ><img src='images/submit.gif' alt='submit' /></a></table></form>";

}



function submitForgetpswd()

{

	if((document.getElementById("uname"))&&(document.getElementById("email")))

	{

		var username=document.getElementById("uname").value;

		var email=document.getElementById("email").value;

		Putt=document.getElementById("activity");

		

			xmlHttp=GetXmlHttpObject();

			if (xmlHttp==null)

			{

				

				Putt.innerHTML="Sorry your browser does not support HTTP Request.\nYou will have to update your browser to play the quiz";

				return;

			}

			var url="forgetpswd.php";

			url=url+"?Content=FORGET";

			url=url+"&username="+username+"&email="+email;

			xmlHttp.onreadystatechange=stateChangedforget

			xmlHttp.open("GET",url,true)

			xmlHttp.send(null)



	}

}



function stateChangedforget()

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		Putt=document.getElementById("content");

		Putt.innerHTML=xmlHttp.responseText; 

	} 

} 




