
// select the option for the advertisement text / image
function txtadd()
{
		document.getElementById('imgadd').style.display='none';
		document.getElementById('imgadd2').style.display='none';
		
		document.getElementById('textadd').style.display='block';
		document.getElementById('textadd2').style.display='block';
}

// select the option for the advertisement text / image
function addimg()
{
		document.getElementById('imgadd').style.display='block';
		document.getElementById('imgadd2').style.display='block';
		
		document.getElementById('textadd').style.display='none';
		document.getElementById('textadd2').style.display='none';
}

// validate the fields for the advertiesments
function valform()
{
		var msg ='';
		if(document.getElementById('contactname').value==''){ msg+='Enter the Contact Name\n';}
		if(document.getElementById('contactnumber').value==''){ msg+='Enter the Contact Number\n';}
		if(document.getElementById('dob1').value==''){ msg+='Select End Date\n';}
		if(document.getElementById('addvertise').value!='' && document.getElementById('addtextarea').value!=''){ msg+='Select One at a time picture / text \n';}
		if(document.getElementById('addvertise').value=='' && document.getElementById('addtextarea').value==''){ msg+='Select Uploaded picture  or Text \n';}
		if(msg=='')
		{
				return true;
		}
		else
		{
				alert(msg);
				return false;
		}
		
		
}

// subscribe for email alert 

function subsemail()
{
	var divid = 'msgbox'
	if(document.getElementById('emailsub').value=='' || document.getElementById('emailsub').value=='example@xyz.com')
	{
		document.getElementById('msgbox').innerHTML='<font color=red>Invalid email</font>';
		
	}
	else
	{
		var useremail = document.getElementById('emailsub').value;
		document.getElementById('msgbox').style.display ='block';
		var url = "ajaxphp.php?val="+encodeURI(useremail)+"&p=subsemail";
		makeRequest(url,divid);
	}
}
/////////////////////////////////////////////
function applyforjob(jid,divid)
{
	document.getElementById(divid).innerHTML='<table width=100%><tr><td valign="middle" align="center"><img src="images/progress_bar.gif" border="0" ></td></tr></table>';
	var url = "ajaxphp.php?p=applyforjob&jid="+jid;
	makeRequest(url,divid);
}

function resumeisactive(val,resumeid)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&resumeid="+encodeURI(resumeid)+"&p=resumeisactive&rand="+myRandom;
	//alert(url);
	document.getElementById('isactivetd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'isactivetd');
}

function addreference(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=addreference&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'referencediv');
}
function removereference(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=removereference&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'referencediv');
}

function addeducation(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=addeducation&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'educationdiv');
}
function removeeducation(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=removeeducation&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'educationdiv');
}

function addperformance(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=addperformance&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'performancediv');
}
function removeperformance(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=removeperformance&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'performancediv');
}

function addexperience(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=addexperience&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'experiencediv');
}
function removeexperience(val)
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    
	url = "ajaxphp.php?val="+encodeURI(val)+"&p=removeexperience&rand="+myRandom;
	//alert(url);
	document.getElementById('waittd').innerHTML='<table><tr><td valign="middle" align="left"><img src="images/progress_bar1.gif" border="0" ></td></tr></table>';
	makeRequest(url,'experiencediv');
}
///// for availablity div ////////////////////////////////////////////
function availablity(path,value,divid)
{
	
	if(divid=='divcompname')
	{
		var url = path+'ajaxphp.php?p=compavailability&value='+value;
	}
	else if(divid=='availablity')
	{
		var url = path+'ajaxphp.php?p=avail&value='+value;	
	}
	document.getElementById(divid).style.display ='block';
	document.getElementById(divid).innerHTML ='<table width="100%"><tr><td valign="left" align="left"><img src="'+path+'images/progress_bar.gif" border="0" ></td></tr></table>';
	makeRequest(url,divid);
	
}
//////////////////////////////////////////////////////////////////////
function uploadpic()
{
//var pic= document.getElementById('cv_fileUpload2').value;
//alert(pic);

var myRandom = parseInt(Math.random()*99999999); // cache buster
    //var upimg = document.getElementById('upimg').value;
	var cv_fileUpload2 = document.getElementById('cv_fileUpload2').value;
	
	url = "ajaxfiles/ajaxphp.php?cv_fileUpload2="+encodeURI(cv_fileUpload2)+"&action=uppic&rand="+myRandom;
	alert(url);
	makeRequest(url,'imgdivw');


}
function step4()
{
	var myRandom = parseInt(Math.random()*99999999); // cache buster
    var email = document.getElementById('email').value;
	var passw = document.getElementById('passw').value;
	var cpass = document.getElementById('cpass').value;
	
	url = "ajaxphp.php?email="+encodeURI(email)+"&passw="+encodeURI(passw)+"&cpass="+encodeURI(cpass)+"&action=step4&rand="+myRandom;
	//alert(url);
	makeRequest2(url,'section4');
}



//////////////////////////////////////
var showobj;
//var myBigvar = 'alpha_list';
function makeRequest(url,obj) 
{
	
	//alert(url);
	showobj=obj;
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	
	http_request.onreadystatechange = function() { alertContents(http_request,url,showobj); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
//////////////////////////////////////

function makeRequest2(url,obj) {
	//alert(url);
	showobj=obj;
	//alert(obj);
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { alertContents(http_request); };
	http_request.open('GET', url, true);
	http_request.send(null); 
}
////////////////////////////////////
function alertContents(http_request,url,showobj) {//alert(http_request); alert(showobj);
	
	if (http_request.readyState == 4) {
		//alert(http_request.responseText)
		if (http_request.status == 200) {
			
			//alert("live here");
			//alert(http_request.responseText);
			
			document.getElementById(showobj).innerHTML = http_request.responseText;
			//document.getElementById('div_progess').style.display = 'none';
			//alert(document.getElementById(showobj).innerHTML = http_request.responseText);
		} else {
			alert('There was a problem with the request.');
		}
	}

}
