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'>"+"<input type='hidden' value='1' id='lgnname'/>";
 
}else {

document.getElementById('userName').innerHTML = "<img src='images/chk_on.png'>"+"<input type='hidden' value='0' id='lgnname'/>"+"<input type='hidden' value='"+response+"' id='unm'/>";
}

}
	
}


function checkphone(phone)
{
	var url = 'phpfiles/applicantCheckPhone.php?phn='+phone;
	 http.open('GET', url);
    http.onreadystatechange = ApplicantPhoneResponse;
    http.send(null);
	
	
}

function ApplicantPhoneResponse()
{

if(http.readyState == 4){
var response = http.responseText;
//alert(response);
if(response ==0){
//document.getElementById('userText').value = "";
document.getElementById('userphn').innerHTML ="<img src='images/chk_off.png'>"+"<input type='hidden' value='1' id='lgnphn'/>";
}else {

document.getElementById('userphn').innerHTML = "<img src='images/chk_on.png'>"+"<input type='hidden' value='0' id='lgnphn'/>"+"<input type='hidden' value='"+response+"' id='phn'/>";

}

}
	
}
function submitForm()
{
	var vname ; 
	var vmail;
	var vphn;
	vname = document.getElementById('lgnname').value;
	//alert("vname"+ vname);
	vmail = document.getElementById('lgnmail').value;
	vphn = document.getElementById('lgnphn').value;
	var phn=document.getElementById('phn').value;
	var unm=document.getElementById('unm').value;
	var cmail=document.getElementById('mail').value;
	if( vname =="0" && vmail=="0" && vphn=="0" )
	{
		//document.form1.submit() ;
		window.location="About.php?nm="+unm+"&phn="+phn+"&mail="+cmail;
	}
	else
	{
		//do not submit.
	}
}
function ApplicantChkUser(user)
{
	var today= new Date();
	cur_time=" "+today.getSeconds()*10;
	var url='phpfiles/Applicantchkuser.php?name='+user+'&time='+cur_time;
	//alert(url);
	http.open('GET',url);
	http.onreadystatechange=ApplicantuserChkresponse();
	http.send(null);
}


function ApplicantuserChkresponse()
{
	if(http.readyState == 4){
var response = http.responseText;
//alert(response);
if(response == 1){
//document.getElementById('userText').value = "";
document.getElementById('user').innerHTML ="<img src='images/chk_off.png'>";

}else {

document.getElementById('user').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 response = http.responseText;
//var word=response.split(" ");
//alert(response);

if(response == 1){
document.getElementById('emailerr').innerHTML = "<img src='images/chk_off.png'>"+"<font size='2' color='blue'>Invalid Email</font>"+"<input type='hidden' value='1' id='lgnmail'>";

}else {

document.getElementById('emailerr').innerHTML = "<img src='images/chk_on.png'>"+"<input type='hidden' value='0' id='lgnmail'>"+"<input type='hidden' value='"+response+"' id='mail'/>";

}

}
	
}




function ApplicantCheckKey(key){
	var url = 'phpfiles/applicantKeyCheck.php?key='+key;
	 http.open('GET', url);
    http.onreadystatechange = ApplicantKeyResponse;
    http.send(null);
	
}

function ApplicantKeyResponse()
{
if(http.readyState == 4){
var response = http.responseText;
//var val=response.split(" ");
//alert(response);
if(response != 0){
window.location='About.html';
}
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";
    }
	
}
//
