function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
		try {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
		//ro = null; // to free up memory
		} catch(e) {
			window.location='error.php';
		}

    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function postValues(formName,divID,url) {

		
		var formObj = new DHTMLSuite.form({ formRef:formName,action:url,responseEl:divID});
		formObj.submit();
		
	}
function ApplicantCheckUserName(username) {

	var today = new Date();
	cur_time = " "+today.getSeconds()*10;	
	var url = 'phpfiles/applicationUserCheck.php?user='+username+'&time='+cur_time;
	 
 	http.open('GET', url);
    http.onreadystatechange = ApplicantuserResponse;
    http.send(null);
	
	
	
}

function ApplicantuserResponse(){
	
if(http.readyState == 4){
var response = http.responseText;
//alert(response);
if(response == 1){
//document.getElementById('userText').value = "";
document.getElementById('userName').innerHTML ="<img src='images/chk_off.png'>" +"User already exists";

}else {

document.getElementById('userName').innerHTML = "<img src='images/chk_on.png'>";
}

}
	
}



function ApplicantCheckEmail(email) {

	var today = new Date();
	cur_time = " "+today.getSeconds()*10;	
	var url = 'phpfiles/applicationMailCheck.php?mail='+email+'&time='+cur_time;
	 
 	http.open('GET', url);
    http.onreadystatechange = ApplicantmailResponse;
    http.send(null);
	}

function ApplicantmailResponse(){
	
if(http.readyState == 4){
//var id = 
var response = http.responseText;
//var word=response.split(" ");
//alert(response);

if(response == 1){
document.getElementById('useremail').innerHTML = "<img src='images/chk_off.png'>" +"Email already exists";
/*if(confirm('Are you Already a user')) {
window.location='opportunity.php?fid='+word[0]+'&fname='+word[1];
}
else {
window.location='index.php';

}*/

}else {

document.getElementById('useremail').innerHTML = "<img src='images/chk_on.png'>";
}

}
	
}


function ApplicantCheckMail(mail)
{
	var today = new Date();
	cur_time = " "+today.getSeconds()*10;	
	var url = 'phpfiles/applicantmailCheck.php?em='+mail+'&time='+cur_time;
	 
 	http.open('GET', url);
    http.onreadystatechange = ApplicantMailRespns;
    http.send(null);
}
	
function ApplicantMailRespns(){
if(http.readyState == 4){
var response = http.responseText;
var val=response.split(" ");
//alert(response);
if(response != 0){
window.location='opportunity.php?fid='+val[0]+'&fname='+val[1];
}
else {
alert('You are not a user!');

}
}
}	

function Deletemsg(id,div_id) {
	//alert("hdjkshdjkhsj"); 
	document.getElementById(div_id).innerHTML = "Deleted";
	var  url = "../phpfiles/deletemsg.php?eid="+id;
	postValues("form1","appFrm",url);
		
}	
	
	function checkPasswordlen(form,divid){
	if(form.pass.value.length<8){
		//alert('Password required Min: 8 character');
		document.getElementById(divid).innerHTML = "<font color='red'>Password required Min: 8 character</font>";
		form.pass.value="";
		form.pass.focus();
		//document.getElementById(divid).focus();		
	}
	else
	  {
	   	  document.getElementById(divid).innerHTML = "<font color='red'>&nbsp;</font>";
	  }
}
function checkPass(form,divid){
	 // alert("hcvjsd");
	  if(form.pass.value!=form.cpass.value)
	  {
	   	  //alert("Passwords doesnot match!");
		  form.cpass.value="";
	   	  document.getElementById(divid).innerHTML = "<font color='red'>Password Mismatch</font>";
	      form.pass.focus();
	  }
	  else
	  {
	   	  	document.getElementById(divid).innerHTML = "&nbsp;<img src='images/btn_tic.jpg'>";
			 
	  }
}

//
function fname(form,divid){
	   
	  if(form.firstname.value=="")
	  {	   	   
		  form.firstname.value="";
	   	  document.getElementById(divid).innerHTML = "<font color='red'>Please Fill First Name</font>";
	      form.firstname.focus();
	  }
	   else
	  {
	   	  	document.getElementById(divid).innerHTML = "";
	  } 
}
//
function lname(form,divid){
	 
	  if(form.lastname.value=="")
	  {	   	   
		  form.lastname.value="";
	   	  document.getElementById(divid).innerHTML = "<font color='red'>Please Fill Last Name</font>";
	      form.lastname.focus();
	  }
	  else
	  {
	   	  	document.getElementById(divid).innerHTML = "";
	  }
	  
}
//
function chkCountry(form,divid){
	 
	  if(form.country.value=="select")
	  {	   	   
		  
	   	  document.getElementById(divid).innerHTML = "<font color='red'>Please Fill Country Name</font>";
	       form.phonetxt.focus();
	  }
	  else
	  {
	   	  	document.getElementById(divid).innerHTML = "";
	  }
	  
}
//
function UpdateApprove(id,div_id) {
	 
	document.getElementById(div_id).innerHTML = "Approved";
	var  url = "../phpfiles/setApprove.php?eid="+id;
	
	postValues("approve","appFrm",url);
		
}




function UpdateDeny(id,div_id) {
	alert("hdjkshdjkhsj");
	document.getElementById(div_id).innerHTML = "Denied";
	var  url = "../phpfiles/setDeny.php?eid="+id;
	postValues("approve","appFrm",url);
		
}
//
function typeChanged() {
 
 	
	 
		
}
function typeChanged(typetxt) {
    var value = (typetxt.options[typetxt.selectedIndex].value);
    document.entryFrm.typetxt.selected = true;
    if (value=="Text") {
        alert("saoudhasiodaskod");
    }
	if (value=="Photo") {
        alert("saoudhasiodaskod");
    }
	if (value=="Video") {
        document.getElementById("videoDiv").style.display = "inline";
    }
	
}

//
