function checkavailablity()
{
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "checkavail.php?inputText="+document.getElementById('quick_user').value, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput;
	}
}
function validate_VV()
{
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "visualverify.php?inputText="+document.getElementById('captcha_code').value, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput_VV;
	}
}
function checkavailablitydate()
{
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "checkavaildate.php?inputDate="+document.getElementById('expdate').value, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutputdate;
	}
}
var user,email,pass,phone,date,vv;
function validate_regQ()
{ 
	if (user&&email&&pass&&phone&&date) return true;
						 else return false; 
}
function validate_reg()
{ 
if (user&&email&&vv) return true;
						 else return false; 
}
function validate_reg_singup()
{ 
	if (user&&email&&pass&&phone) return true;
						 else return false; 
}
function checkavailablity_email()
{
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "checkemail.php?inputEmail="+document.getElementById('emailid').value, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput_email;
	}
}
function validate_pass(){
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "checkpass.php?pass1="+document.getElementById('passuser1').value+"&pass2="+document.getElementById('passuser2').value, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput_pass;
	}
}
function validate_phone()
{
	httpObject = getHTTPObject();
	if (httpObject != null) 
	{
		httpObject.open("GET", "checkphone.php?ph="+document.getElementById('phonenumber').value, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput_phone;
	}
}
function validate_email()
{     
	    var str= document.getElementById("emailid").value ;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if ( str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr  || str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr )
		{
		   return false ;
		}
		if (str.indexOf(at,(lat+1))!=-1)
		{
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		    return false ;
		 }
		 if (str.indexOf(dot,(lat+2))==-1)
		{
		    return false ;
		 }
		 if (str.indexOf(" ")!=-1)
		 {
		 return false ;
		 }
return true;
}
function getHTTPObject()
{
	if (window.ActiveXObject) 
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) 
		return new XMLHttpRequest();
	else 
	{
		alert("Your browser does not support AJAX.");
		return null;
	}
}
function setOutput()
{
	if(httpObject.readyState == 4)
	{
		var tmp =document.getElementById('quick_user');
		var res=httpObject.responseText;
		if(res=="available"){
		    var add_image1 = document.createElement('img');
	        add_image1.setAttribute('src','images/available.gif');
			 add_image1.setAttribute('title','This UserID is Available');
			if(tmp.nextSibling) tmp.parentNode.removeChild(tmp.nextSibling);
	         tmp.parentNode.insertBefore(add_image1,tmp.nextSibling);
			user=true; 
		}
		else {
		    var add_image2 = document.createElement('img');
	        add_image2.setAttribute('src','images/notavailable.gif');
			 add_image2.setAttribute('title','This UserID is Already Taken');
		    if(tmp.nextSibling) tmp.parentNode.removeChild(tmp.nextSibling);
			tmp.parentNode.insertBefore(add_image2,tmp.nextSibling);
		 user=false;
		}
	}
}
function setOutputdate()
{
	if(httpObject.readyState == 4)
	{
		var tmp16 =document.getElementById('expdate');
		var res6=httpObject.responseText;
		if(res6=="Yes"){
		    var add1_image6 = document.createElement('img');
	        add1_image6.setAttribute('src','images/available.gif');
			 add1_image6.setAttribute('title','This Date is Available');
			if(tmp16.nextSibling) tmp16.parentNode.removeChild(tmp16.nextSibling);
	         tmp16.parentNode.insertBefore(add1_image6,tmp16.nextSibling);
			date=true; 
		}
		else {
		    var add2_image6= document.createElement('img');
	        add2_image6.setAttribute('src','images/notavailable.gif');
			 add2_image6.setAttribute('title','Deadline should be greater than Current Time');
		    if(tmp16.nextSibling) tmp16.parentNode.removeChild(tmp16.nextSibling);
			tmp16.parentNode.insertBefore(add2_image6,tmp16.nextSibling);
		 date=false;
		}
	}
}
function setOutput_email()
{   
	if(httpObject.readyState == 4)
	{
		var tmp1 =document.getElementById('emailid');
		var res1=httpObject.responseText;
		var t=validate_email();
		if((res1=="notexist") && validate_email()){
		    var add_image3 = document.createElement('img');
	        add_image3.setAttribute('src','images/available.gif');
			add_image3.setAttribute('title','You can user this Email Id');
			if(tmp1.nextSibling) tmp1.parentNode.removeChild(tmp1.nextSibling);
	         tmp1.parentNode.insertBefore(add_image3,tmp1.nextSibling);
		email=true; 
		}
		else {
		    var add_image4 = document.createElement('img');
	        add_image4.setAttribute('src','images/notavailable.gif');
			add_image4.setAttribute('title',"Please Check Your Email Id");
		    if(tmp1.nextSibling) tmp1.parentNode.removeChild(tmp1.nextSibling);
			tmp1.parentNode.insertBefore(add_image4,tmp1.nextSibling);
		   email=false; 
			 }
	}
}
function setOutput_pass()
{  
	if(httpObject.readyState == 4)
	{
		var tmp3 =document.getElementById('passuser2');
		var res3=httpObject.responseText;
		if(res3=='same'){
		    var add_image5 = document.createElement('img');
	        add_image5.setAttribute('src','images/available.gif');
			if(tmp3.nextSibling) tmp3.parentNode.removeChild(tmp3.nextSibling);
	         tmp3.parentNode.insertBefore(add_image5,tmp3.nextSibling);
			pass=true;
		}
		else {
		    var add_image6 = document.createElement('img');
	        add_image6.setAttribute('src','images/notavailable.gif');
			 add_image6.setAttribute('title','Password and Verify Password is not Same');
		    if(tmp3.nextSibling) tmp3.parentNode.removeChild(tmp3.nextSibling);
			tmp3.parentNode.insertBefore(add_image6,tmp3.nextSibling);
		 pass=false; 
		}
	}
}
function setOutput_phone()
{  
	if(httpObject.readyState == 4)
	{
		var tmp4 =document.getElementById('phonenumber');
		var res4=httpObject.responseText;
		if(res4=='correct'){
		    var add_image7 = document.createElement('img');
	        add_image7.setAttribute('src','images/available.gif');
			if(tmp4.nextSibling) tmp4.parentNode.removeChild(tmp4.nextSibling);
	         tmp4.parentNode.insertBefore(add_image7,tmp4.nextSibling);
			phone=true;
		}
		else {
		    var add_image8 = document.createElement('img');
	        add_image8.setAttribute('src','images/notavailable.gif');
			 add_image8.setAttribute('title','Phone No. Must be Numeric');
		    if(tmp4.nextSibling) tmp4.parentNode.removeChild(tmp4.nextSibling);
			tmp4.parentNode.insertBefore(add_image8,tmp4.nextSibling);
		 phone=false; 
		}
	}
}
function setOutput_VV()
{  
	if(httpObject.readyState == 4)
	{
		var temp =document.getElementById('captcha_code');
		var fd=httpObject.responseText; 
		if(fd=='correct')
						{
			 var add_imag = document.createElement('img');
	        add_imag.setAttribute('src','images/available.gif');
			if(temp.nextSibling) temp.parentNode.removeChild(temp.nextSibling);
	         temp.parentNode.insertBefore(add_imag,temp.nextSibling);
					vv=true;		
						}
		else {
		    var add_imag8 = document.createElement('img');
	        add_imag8.setAttribute('src','images/notavailable.gif');
			var divv = document.createElement('div');
			divv.style.color="#FF0000";
			divv.innerHTML="Your Image input in incorrect";
			 add_imag8.setAttribute('title','Your Image input in incorrect');
		    if(temp.nextSibling) temp.parentNode.removeChild(temp.nextSibling);
			temp.parentNode.insertBefore(divv,temp.nextSibling);
		vv=false;
		}
	}
}
/// test function
// test function ends
var glow_counter=1;
function addAttachmentElement() {
var container = document.getElementById('attachment_container');
var counter = document.getElementById('attachment_counter').value;
counter++;
document.getElementById('attachment_counter').value=counter;
if( counter < 4 )
{
glow_counter++;
document.getElementById('attachment_counter').value = counter;
var attachment_div = document.createElement('div');
attachment_div.setAttribute('id','attachment_'+glow_counter);
attachment_div.setAttribute('class','attachment');
	var attachment_label = document.createElement('label');
	attachment_label.id="label"+glow_counter;
	attachment_label.innerHTML = "";
	attachment_div.appendChild(attachment_label);
	var attachment_input = document.createElement('input');
	attachment_input.setAttribute('type','file');
	attachment_input.setAttribute('size','33');
	attachment_input.setAttribute('id','file_'+glow_counter);
	attachment_input.setAttribute('name','file_'+glow_counter);
	attachment_div.appendChild(attachment_input);
	var attachment_a2 = document.createElement('a');
	//attachment_a2.setAttribute('href','');
	attachment_a2.setAttribute('onclick','removeAttachmentElement('+glow_counter+');return false;');
		var attachment_img2 = document.createElement('img');
		attachment_img2.setAttribute('id','RemoveButton_'+counter);
		attachment_img2.setAttribute('src','images/1.gif');
		attachment_img2.setAttribute('alt','Remove');
		attachment_img2.setAttribute('onmousedown',"this.src='images/1.gif';");
		attachment_img2.setAttribute('onmouseup',"this.src='images/1.gif';");
		attachment_a2.appendChild(attachment_img2);
	attachment_div.appendChild(attachment_label);
	attachment_div.appendChild(attachment_a2);
container.appendChild(attachment_div);
if (counter ==3)
	document.getElementById('anchorremoval').style.display = 'none';
}
else 
{
document.getElementById('anchorremoval').style.display = 'none';
}
}
function removeAttachmentElement(num_id) {
	glow_counter=num_id-1;
	var counter = document.getElementById('attachment_counter').value;
	counter--;
	document.getElementById('attachment_counter').value=counter;
	var container = document.getElementById('attachment_container');
	container.removeChild( document.getElementById('attachment_'+num_id) );
	if( counter >= 3 )
	{
		document.getElementById('anchorremoval').style.display = 'none';
	}
	else
		document.getElementById('anchorremoval').style.display = '';
	changeText(num_id);
}
function changeText(num)
{
	if (num==1)
	{
		if(document.getElementById('label2'))
			document.getElementById('label2').innerHTML="";
		if(document.getElementById('label3'))
			document.getElementById('label3').innerHTML="";
	}
	if (num==2)
	{		
		if(document.getElementById('label3'))
			document.getElementById('label3').innerHTML="";			
	}
}
function validate_formnewproject()
{
if( (document.getElementById("np").value =='') || ( document.getElementById("expdate").value=='' ) )
{
alert("Please Fill in the Project title & The Deadline of the Project!");
return false;
}
var dateStr = document.getElementById("expdate").value ;
re = /^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/ ;
if( !(dateStr.match(re)) )
{
alert('Please enter date in yyyy-mm-dd format');
return false ; 
}
}
function show_ans(cont,dv){
    resetALL();
	if (document.getElementById(dv).style.display=='block'){
	 document.getElementById(dv).style.display='none';
	 cont.getElementsByTagName("img")[0].src='images/faqs_q.png';
	}
	else{
	 document.getElementById(dv).style.display='block';
	 cont.getElementsByTagName("img")[0].src='images/faqs_a.png';
	}
}
function resetALL(){
var DivFaqs= document.getElementById('faqs').getElementsByTagName("*");
for (var i = 0; i < DivFaqs.length; i++) {
var type=DivFaqs[i].tagName  ;
if (type=="IMG") DivFaqs[i].src='images/faqs_q.png';
if (type=="DIV")  DivFaqs[i].style.display='none';
}
}
	

