// JavaScript Document
//Validations Employer Registration
var RegEx_Mobile = /^([0]{0,1})([9]{1})([234789]{1})([0-9]{8})$/;
var RegEx_Phone = /^([0]{0,1})([0-9]{2,4})([2-8]{1})([0-9]{6,7})$/;
var RegEx_Email = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
var RegEx_Text = /^(([\w]+)([\s\.]*)([\w]*)){6,}$/;
var RegEx_UserPass = /^(([\w]+)([\.-@]*)([\w]*)){6,}$/;
var RegEx_Alpha = /^([a-z\x80-\xFF]+(. )?[ ]?)+$/i;
var RegEx_Number= /^([0-9]+)$/;


var RegEx_Url= /^([http\:\/\/]*[https\:\/\/]*[www\.]+[a-zA-Z0-9_\-]+(?:\.[a-zA-Z0-9_\-]+)*\.[a-zA-Z]{2,4}(?:\/[a-zA-Z0-9_]+)*(?:\/[a-zA-Z0-9_]+\.[a-zA-Z]{2,4}(?:\?[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)?)?(?:\&[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)*)$/;
// Removes leading whitespaces
function LTrim( value ){
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ){
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ){
	return LTrim(RTrim(value));
}


function CheckAvailibility(val){
	var uname = trim(document.getElementById('uname').value);
	if(uname!=''){
		if(!uname.match(RegEx_UserPass)){
			alert('Please provide a valid username. Min 6 Characters');
			document.getElementById('uname').value = '';
			document.getElementById('uname').focus();
			return false;
		}
		CheckAvailibility_Ajax(val,{'target':'AVAIL_CHECK'});
	}
}

function CheckEmailAvailibility(val){
	var email = trim(document.getElementById('email').value);
	if(email!=''){
		if(!email.match(RegEx_Email)){
			alert('Please provide a valid email.');
			document.getElementById('email').value = '';
			document.getElementById('email').focus();
			return false;
		}
		Check_Email_Availibility_Ajax(val,{'target':'AVAIL_Email_CHECK'});
	}
}

function CheckAlternateEmailAvailibility(val){
	//var email = trim(document.getElementById('email3').value);
	var email =val;
	if(email!=''){
		if(!email.match(RegEx_Email)){
			alert('Please provide a valid and different email. The email you selected already exists.');
			document.getElementById('email3').value = '';
			document.getElementById('email3').focus();
			return false;
		}
		Check_Alternate_Email_Availibility_Ajax(val,{'target':'AVAIL_Alter_Email_CHECK'});
	}else{
		document.getElementById('AVAIL_Alter_Email_CHECK').innerHTML='';
	}
}

function CheckCompanyAvailibility(val){
	var uname = trim(document.getElementById('username').value);
	/*if(!uname.match(RegEx_UserPass)){
		alert('Please provide a valid username. Min 6 Characters');
		document.getElementById('username').value = '';
		document.getElementById('username').focus();
		return false;
	}*/
	CheckAvailibilityName_Ajax(val,{'target':'AVAILNAME_CHECK'});	
}

function CheckComapnyEmailAvailibility(val){
	var email = trim(document.getElementById('email').value);
	if(email!=''){
		if(!email.match(RegEx_Email)){
			alert('Please Enter valid Email.');
			document.getElementById('email').value = '';
			document.getElementById('email').focus();
			return false;
		}
		CheckCompanyEmailAvailibility_Ajax(val,{'target':'AVAIL_COMP_Email_CHECK'});
	}
}
function CheckCompanyNameAvailibility(val){
	var companyname = trim(document.getElementById('companyname').value);
	/*if(companyname==''){
		alert('Please provide a valid Company Name.');
		document.getElementById('companyname').value = '';
		document.getElementById('companyname').focus();
		return false;
	}*/
	CheckCompanyNameAvailibility_Ajax(val,{'target':'AVAIL_NAMECHECK'});	
}

function EnableDisableMonths(val){
	if(parseInt(val) >= 0){
		document.getElementById('exp_months').disabled = false;
		document.getElementById('currency').value = 0;
		document.getElementById('currency').disabled =false ;
		document.getElementById('salary_lacs').value = 0;
		document.getElementById('salary_lacs').disabled =false ;
		document.getElementById('salary_thousands').value = -1;
		document.getElementById('salary_thousands').disabled =false ;
		if(document.getElementById('ANNULA_SALARY')) document.getElementById('ANNULA_SALARY').style.display = 'block';
	}else{
		document.getElementById('exp_months').value = -1;
		document.getElementById('exp_months').disabled = true;
		document.getElementById('currency').value = -1;
		document.getElementById('currency').disabled =true ;
		document.getElementById('salary_lacs').value = 0;
		document.getElementById('salary_lacs').disabled =true ;
		document.getElementById('salary_thousands').value = -1;
		document.getElementById('salary_thousands').disabled =true ;
		if(document.getElementById('ANNULA_SALARY')) document.getElementById('ANNULA_SALARY').style.display = 'none';
	}
}


function DeletePost(id){
	var conf = window.confirm('Are you sure you want to delete the post.');
	if(conf){
		DeletePost_Ajax(id,{'target':'post_message'});
	}
}

function RemoveDoc(id){
	var conf = window.confirm('Are you sure you want to delete the file?');
	if(conf){
		RemoveDoc_Ajax(id,{'onFinish':function(response,xmlhttp){
					document.getElementById('resume').innerHTML = '<input type="file" name="res_att" id="res_att" />';
				}
			})
	}
}

//PAGING

function SearchPaging(limit,page,rows){

	document.getElementById('page_mdbg').className = 'TRANSLUCENT';
	
	var offset = limit*(page-1);

	Listing_Ajax(limit,offset,{'target':'SEARCH_LISTING','preloader':'SEARCHLOADING',
				 				'onFinish':function(response,xmlhttp){ 
									document.getElementById("SEARCH_LISTING").focus();
									document.getElementById("page_mdbg").className = 'OPAQUE'; 
								}
							});
	

	var paging = '';	
	var pages = Math.ceil(parseInt(rows)/parseInt(limit)); 
	var ai;
	
	// SHOWING REGORDS X OF Y
	paging +='<table width="100%" border="0" cellspacing="0" cellpadding="5"><tr><td colspan="2" class="tble_hea01"><div id="pager">';
	// SHOWING REGORDS X OF Y
	if(rows <= limit) paging += '<div class="pageMark">Records '+rows+' of '+rows+'</div>';
	else paging += '<div class="pageMark">Records '+((limit*(page-1))+1)+' to '+((limit*page)<rows?(limit*page):rows)+' of '+rows+'</div>';
	
	paging += '<div class="pageNum">';
	// THE FIRST
	if(page!=1) paging += '<span title="First"><b><a id="\first\" href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+1+','+rows+')\">First</a></b></span>';
	else paging += '<span title="First"><b><a id="\first\" href="javascript:void(0);" style=\"background-color:#666666\" >First</a></b></span>';
	
	// PERVIOUS PAGE
	if(page!=1) paging += '<span title="Previous"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page-1)+','+rows+')\">Prev</a></b></span>';
	else paging += '<span title="Previous"><b><a href="javascript:void(0);" style="background-color:#666666">Prev</a></b></span>';	
	
	
	
	if(pages>9){
		if(page<=4){
			start = 1;
			end = 9
		}else if(page>4 && ((page+4) <= pages)){
			start = page-4;
			end = page+4;
		}else if(page>4 && ((page+4) > pages)){
			start = pages-8;
			end = pages;
		}
	}else{
		start = 1;
		end = pages;
	}
	// THE PAGE NUMBERS
	for(ai=start; ai<=end; ai++){
		if(page==ai) paging = paging+ '<a href="javascript:void(0);" style="background-color:#666666">'+ai+'</a>';
		else paging = paging+'<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+ai+','+rows+')\">'+ai+'</a>';
	}
	
	// NEXT PAGE
	if(page!=pages) paging += '<span title="Next"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page+1)+','+rows+')\">Next</a></b></span>';
	else paging += '<span title="Next"><b><a href="javascript:void(0);" style="background-color:#666666">Next</a></b></span>';
	
	// THE LAST
	if(page!=pages) paging += '<span title="Last"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+pages+','+rows+')\">Last&raquo;</a></b></span>';
	else paging += '<span title="Last"><b><a href="javascript:void(0);" style="background-color:#666666">Last&raquo;</a></b></span>';
	
	paging +='</div>';
	paging +='</div></td></tr></table>';
	
	var pagingDivTop = document.getElementById('PAGING_Div_Top');
	var pagingDivBot = document.getElementById('PAGING_Div_Bot');

	pagingDivTop.innerHTML = paging;
	pagingDivBot.innerHTML = paging;
}


/*function SearchPaging(limit,page,rows){

	document.getElementById('SEARCH_LISTING').className = 'TRANSLUCENT';
	
	var offset = limit*(page-1);

	Listing_Ajax(limit,offset,{'target':'SEARCH_LISTING',
				 				'onFinish':function(response,xmlhttp){ 
									document.getElementById("SEARCH_LISTING").className = 'OPAQUE'; 
								}
							});
	

	var paging = '';	
	var pages = Math.ceil(parseInt(rows)/parseInt(limit)); 
	var ai;
	
	// SHOWING REGORDS X OF Y
	if(rows <= limit) paging += '<span class="PAGING_RECORDS">Records '+rows+' of '+rows+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	else paging += '<span class="PAGING_RECORDS">Records '+((limit*(page-1))+1)+' to '+((limit*page)<rows?(limit*page):rows)+' of '+rows+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	
	// THE FIRST
	if(page!=1) paging += '<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+1+','+rows+')\">&laquo;First</a>&nbsp;&nbsp;|&nbsp;&nbsp;';
	else paging += '&laquo;First&nbsp;&nbsp;|&nbsp;&nbsp;';
	
	// PERVIOUS PAGE
	if(page!=1) paging += '<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page-1)+','+rows+')\">Prev</a>&nbsp;&nbsp;|&nbsp;&nbsp;';
	else paging += 'Prev&nbsp;&nbsp;|&nbsp;&nbsp;';	
	
	
	if(pages>9){
		if(page<=4){
			start = 1;
			end = 9
		}else if(page>4 && ((page+4) <= pages)){
			start = page-4;
			end = page+4;
		}else if(page>4 && ((page+4) > pages)){
			start = pages-8;
			end = pages;
		}
	}else{
		start = 1;
		end = pages;
	}
	// THE PAGE NUMBERS
	for(ai=start; ai<=end; ai++){
		if(page==ai) paging = paging+ai+'&nbsp;';
		else paging = paging+'<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+ai+','+rows+')\">'+ai+'</a>&nbsp;';
	}
	
	// NEXT PAGE
	if(page!=pages) paging += '&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page+1)+','+rows+')\">Next</a>';
	else paging += '&nbsp;&nbsp;|&nbsp;&nbsp;Next';
	
	// THE LAST
	if(page!=pages) paging += '&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+pages+','+rows+')\">Last&raquo;</a>';
	else paging += '&nbsp;&nbsp;|&nbsp;&nbsp;Last&raquo;';
	
	var pagingDivTop = document.getElementById('PAGING_Div_Top');
	var pagingDivBot = document.getElementById('PAGING_Div_Bot');

	pagingDivTop.innerHTML = paging;
	pagingDivBot.innerHTML = paging;
}*/


function SearchPagingFolder(limit,page,rows){

	document.getElementById('SEARCH_LISTING').className = 'TRANSLUCENT';
	
	var offset = limit*(page-1);

	Listing_Ajax(limit,offset,{'target':'SEARCH_LISTING',
				 				'onFinish':function(response,xmlhttp){ 
									document.getElementById("SEARCH_LISTING").className = 'OPAQUE'; 
								}
							});
	

	var paging = '';	
	var pages = Math.ceil(parseInt(rows)/parseInt(limit)); 
	var ai;
	paging +='<div id="pager">';
	// SHOWING REGORDS X OF Y
	if(rows <= limit) paging += '<div class="pageMark">Records '+rows+' of '+rows+'</div>';
	else paging += '<div class="pageMark">Records '+((limit*(page-1))+1)+' to '+((limit*page)<rows?(limit*page):rows)+' of '+rows+'</div>';
	
	paging += '<div class="pageNum">';
	
	// THE FIRST
	if(page!=1) paging += '<span title="First"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+1+','+rows+')\">First</a></b></span>';
	else paging += '<span title="First"><b>First</b></span>';
	
	// PERVIOUS PAGE
	if(page!=1) paging += '<span title="Previous"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page-1)+','+rows+')\">Prev</a></b></span>';
	else paging += '<span title="Previous"><b>Prev</b></span>';	
	
	
	if(pages>9){
		if(page<=4){
			start = 1;
			end = 9
		}else if(page>4 && ((page+4) <= pages)){
			start = page-4;
			end = page+4;
		}else if(page>4 && ((page+4) > pages)){
			start = pages-8;
			end = pages;
		}
	}else{
		start = 1;
		end = pages;
	}
	// THE PAGE NUMBERS
	for(ai=start; ai<=end; ai++){
		if(page==ai) paging = paging+ai+'&nbsp;';
		else paging = paging+'<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+ai+','+rows+')\">'+ai+'</a>';
	}
	
	// NEXT PAGE
	if(page!=pages) paging += '<span title="Next"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page+1)+','+rows+')\">Next</a></b></span>';
	else paging += '<span title="Next"><b>Next</b></span>';
	
	// THE LAST
	if(page!=pages) paging += '<span title="Last"><b><a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+pages+','+rows+')\">Last&raquo;</a></b></span>';
	else paging += '<span title="Last"><b>Last</b></span>';
	
	paging +='</div>';
	paging +='</div>';
	var pagingDivTop = document.getElementById('PAGING_Div_Top');
	var pagingDivBot = document.getElementById('PAGING_Div_Bot');
	
	pagingDivTop.innerHTML = paging;
	pagingDivBot.innerHTML = paging;
}



/*function SearchPagingFolder(limit,page,rows){

	document.getElementById('SEARCH_LISTING').className = 'TRANSLUCENT';
	
	var offset = limit*(page-1);

	Listing_Ajax(limit,offset,{'target':'SEARCH_LISTING',
				 				'onFinish':function(response,xmlhttp){ 
									document.getElementById("SEARCH_LISTING").className = 'OPAQUE'; 
								}
							});
	

	var paging = '';	
	var pages = Math.ceil(parseInt(rows)/parseInt(limit)); 
	var ai;
	
	// SHOWING REGORDS X OF Y
	if(rows <= limit) paging += '<span class="PAGING_RECORDS">Records '+rows+' of '+rows+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	else paging += '<span class="PAGING_RECORDS">Records '+((limit*(page-1))+1)+' to '+((limit*page)<rows?(limit*page):rows)+' of '+rows+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	
	// THE FIRST
	if(page!=1) paging += '<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+1+','+rows+')\">&laquo;First</a>&nbsp;&nbsp;|&nbsp;&nbsp;';
	else paging += '&laquo;First&nbsp;&nbsp;|&nbsp;&nbsp;';
	
	// PERVIOUS PAGE
	if(page!=1) paging += '<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page-1)+','+rows+')\">Prev</a>&nbsp;&nbsp;|&nbsp;&nbsp;';
	else paging += 'Prev&nbsp;&nbsp;|&nbsp;&nbsp;';	
	
	
	if(pages>9){
		if(page<=4){
			start = 1;
			end = 9
		}else if(page>4 && ((page+4) <= pages)){
			start = page-4;
			end = page+4;
		}else if(page>4 && ((page+4) > pages)){
			start = pages-8;
			end = pages;
		}
	}else{
		start = 1;
		end = pages;
	}
	// THE PAGE NUMBERS
	for(ai=start; ai<=end; ai++){
		if(page==ai) paging = paging+ai+'&nbsp;';
		else paging = paging+'<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+ai+','+rows+')\">'+ai+'</a>&nbsp;';
	}
	
	// NEXT PAGE
	if(page!=pages) paging += '&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+(page+1)+','+rows+')\">Next</a>';
	else paging += '&nbsp;&nbsp;|&nbsp;&nbsp;Next';
	
	// THE LAST
	if(page!=pages) paging += '&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"SearchPaging('+limit+','+pages+','+rows+')\">Last&raquo;</a>';
	else paging += '&nbsp;&nbsp;|&nbsp;&nbsp;Last&raquo;';
	
	var pagingDivTop = document.getElementById('PAGING_Div_Top');
	var pagingDivBot = document.getElementById('PAGING_Div_Bot');

	pagingDivTop.innerHTML = paging;
	pagingDivBot.innerHTML = paging;
}*/
//END OF PAGING


//Remove Picture for jobseeker
function RemovePic(pic){
	var conf = window.confirm('Are you sure you want to delete this picture.');
	if(conf){
		DelPic_Ajax(pic,{'onFinish':function(response,xmlhttp){
							document.getElementById("img_photo").innerHTML = '<input type="file" name="photo_upload" id="photo_upload" />';
						}
							
					}
		);
	}
	
}


//REMOVE LOGO

function RemoveLogo(pic){
	var conf = window.confirm('Are you sure you want to delete this Logo.');
	if(conf){
		DelLogo_Ajax(pic,{'onFinish':function(response,xmlhttp){
							document.getElementById("img_logo").innerHTML = '<input type="file" name="logo_upload1" id="logo_upload1" />';
						}
							
					}
		);
	}
	
}

function ActivateDeactivateUser(status){
	if(parseInt(status)==1){ 
		 DeActivateUser_Ajax({'onFinish':function(response,xmlhttp){
										document.getElementById('USER_STATUS').innerHTML = '<a href="javascript:void(0);" onclick="ActivateDeactivateUser(0)">Deactive</a>';
								}
						  }
						 );
	}else{
		ActivateUser_Ajax({'onFinish':function(response,xmlhttp){
										document.getElementById('USER_STATUS').innerHTML = '<a href="javascript:void(0);" onclick="ActivateDeactivateUser(1)">Active</a>';							
								}
						  }
						 );
	}
}

function ActivateDeactivateUserResume(status,js_id){ 
	if(parseInt(status)==0){
		Searchable_Resume_Ajax(js_id,{'onFinish':function(response,xmlhttp){
									document.getElementById('RESUME_STATUS'+js_id).innerHTML = '<a href="javascript:void(0);" onclick="ActivateDeactivateUserResume(1,'+js_id+')">Not-Searchable</a>';										   
								}
						  }
						 );
	}else{ 
		NonSearchable_Resume_Ajax(js_id,{'onFinish':function(response,xmlhttp){
									document.getElementById('RESUME_STATUS'+js_id).innerHTML = '<a href="javascript:void(0);" onclick="ActivateDeactivateUserResume(0,'+js_id+')">Searchable</a>';										   
								}
						  }
						 );
	}
}

function ActivatePost(id,vals){
	var conf = window.confirm('Are you sure you want to change status.');
	if(conf){
		ActivatePost_Ajax(id,vals,{'target':'posts',
							'onFinish':function(response,xmlhttp){
									document.getElementById('posts').innerHTML = '';
								}
							})
	}
}

function ActivateEmployers(id,vals){
	var conf = window.confirm('Are you sure you want to change status.');
	if(conf){
		ActivateEmloyersStatus_Ajax(id,vals,{'target':'posts',
							'onFinish':function(response,xmlhttp){
									document.getElementById('posts').innerHTML = '';
								}
							})
	}
}

function ActivateINJobseekers(id,vals){
	var conf = window.confirm('Are you sure you want to change status.');
	if(conf){
		ActivateJobseekerStatus_Ajax(id,vals,{'target':'posts',
							'onFinish':function(response,xmlhttp){
									document.getElementById('posts').innerHTML = '';
								}
							})
	}
}


function clearCity(){
	var city = '<select name="city_id" id="city_id" class="INPUT" disabled="disabled"><option value="0">Select</option></select>';	
	dd_city = document.getElementById('DD_CITY');
	alert(dd_city.innerHTML);
	dd_city.innerHTML = city;
}
function CountAndLimit(ele){
	var str = ele.value;
	if(str.length > 1000){
		alert("The Limit is over!");
		ele.value = str.substr(0,1000);
	}else{
		document.getElementById('count_char').value = 1000-str.length;
	}
}

function CheckNew(obj){
	
	
	if(obj.value=='new'){
		
		document.getElementById('newCoverLetter').style.display = 'block';
		document.getElementById('CoverLetter').disabled = true;
		
		
	}else{
		document.getElementById('CoverLetter').disabled = false;
		document.getElementById('newCoverLetter').style.display = 'none';
	}
	/*document.getElementById('submit1').disabled = true;
	document.getElementById('submit1').style.background='#ddddd';*/
}

//Fade in Fade Out Effect START ********************************************************

function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	//alert(document.getElementById(id).style.visibility);
	document.getElementById(id).style.visibility='visible';
	if(document.getElementById(id).style.opacity == 0) {
		//opacity('showDetails', 100, 0, millisec);
		opacity(id, 0, 100, millisec);
		currentOpac('showDetails', 20, 1000);
	} else {
		opacity(id, 100, 0, millisec);
		//opacity('showDetails', 0, 100, millisec);	
		currentOpac('showDetails', 100, 1000);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}
//Fade in Fade Out Effect END ********************************************************

function DeleteRESUMESFolder_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the folder.');
	if(conf){
	DeleteMyResumeFolder_Ajax(id,{'target':'txtFolderHints','preloader':'pr',
						'onFinish':function(response,xmlhttp){
								document.getElementById('txtFolderHints').innerHTML = 'Folder Deleted!';
							}
						});
	}
		
}

function DeleteFolder_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the folder.');
	if(conf){
	DeleteMyFolder_Ajax(id,{'target':'showSearch',
						'onFinish':function(response,xmlhttp){
								document.getElementById('showSearch').innerHTML = '';
							}
						});
	}
		
}

function DeleteEmployerSearch_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the folder.');
	if(conf){
	DeleteMySearch_Ajax(id,{'target':'txtHints','preloader':'prs',
						'onFinish':function(response,xmlhttp){
								document.getElementById('txtHints').innerHTML = 'Folder Deleted!';
							}
						});
	}
}

function DeleteSavedJob_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the job.');
	if(conf){
	DeleteMyJob_Ajax(id,{'target':'jobHint','preloader':'pr',
						'onFinish':function(response,xmlhttp){
								document.getElementById('jobHint').innerHTML = 'Job Deleted!';
							}
						});
	}
		
}

function UpdateJobName(jobId){
	if(document.getElementById(jobId).style.display=='none'){
		document.getElementById(jobId).style.display='block';
		//document.getElementById('SaveMyJobs').style.display='none';
	}else{
		document.getElementById(jobId).style.display='none';
		//document.getElementById('SaveMyJobs').style.display='block';
	}
}
function updateThisJob(obj){
	document.getElementById('jobName_'+obj.name).innerHTML=obj.value;
	document.getElementById(obj.name).style.display='none';
	UpdateMySavedJob_Ajax(obj.name,obj.value,{'target':'jobHint','onFinish':function(response,xmlhttp){
								document.getElementById('jobHint').innerHTML = ' ';
							}
						});
	
}

/*function JobQuestPopup(obj,job_id){  
	if(obj.checked){
		document.getElementById('Quest_'+job_id).style.display='block';		
	}else{
		document.getElementById('Quest_'+job_id).style.display='none';		
	}
}*/

function DeleteResumeFolder_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the folder.');
	if(conf){
	DeleteMyResumeFolder_Ajax(id,{'target':'txtHint','preloader':'pr',
						'onFinish':function(response,xmlhttp){
								document.getElementById('txtHint').innerHTML = 'Folder Deleted!';
							}
						});
	}
		
}

function DeleteSavedResume_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the Resume.');
	if(conf){
	DeleteMyResume_Ajax(id,{'target':'txtResumeHint','preloader':'pr',
						'onFinish':function(response,xmlhttp){
								document.getElementById('txtResumeHint').innerHTML = 'Record Deleted!';
							}
						});
	}
		
}

function DeleteQuestion_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the Question.');
	if(conf){
	DeleteMyQuestion_Ajax(id,{'target':'txtHint','preloader':'pr',
						'onFinish':function(response,xmlhttp){
							document.getElementById('txtHint').innerHTML = 'Deleted!';
						    document.getElementById('formData').style.display = 'none';
						
							}
						});

	}
}

function DeleteCommonQuestion_Ajax(id){
	var conf = window.confirm('Are you sure you want to delete the Question.');
	if(conf){
	DeleteMyCommonQuestion_Ajax(id,{'target':'txtHint','preloader':'pr',
						'onFinish':function(response,xmlhttp){
								document.getElementById('txtHint').innerHTML = 'Deleted!';
								document.getElementById('formData').style.display = 'none';
							}
						});
	}
}

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


function UpdateProfileName_Ajax(name,js_id){
	var reWhiteSpace = /^\s+$/
	if(name=='' || reWhiteSpace.test(name)){
		alert('Please Enter the Name.');
		return false;
	}else{
		 if(!name.match(RegEx_Alpha)){
		alert('Name can accept only Alphabates');
		return false;
		 }else{
		UpdateMyProfileName_Ajax(name,js_id,{'target':'txtProfileName','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('nameDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfileName').innerHTML = '';
									document.getElementById('showNameText').style.display = 'none';
									document.getElementById('showName').style.display = 'block';
								}
							});
		       }
	}
}

function UpdateProfilePhone_Ajax(stdcode,phonenum,phone,js_id){
	if(stdcode.length<1 || stdcode.length>6){
		alert('Please enter valid STD Code for phone number.');
			return false;
	}else
	if(!stdcode.match(RegEx_Phone)){
	   alert('Please enter valid stdcode number.');
		return false;
   }else
	if(phonenum.length<8 || phonenum.length>10){
		alert('Please enter valid phone number.');
			return false;
	}else
	if(stdcode<1 && phonenum<1){
		alert('Please enter valid phone number.');
			return false;
	}else{
		UpdateMyProfilePhone_Ajax(stdcode,phonenum,js_id,{'target':'txtProfilePhone','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('phoneDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfilePhone').innerHTML = '';
									document.getElementById('showPhoneText').style.display = 'none';
									document.getElementById('showPhone').style.display = 'block';
								}
							});
	}
}

var numb = '0123456789';
var lwrupr = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

function isCheckValid(parm,val) { 
  if (parm == "") return true;
  for (i=0; i<parm.length; i++) { 
    if (val.indexOf(parm.charAt(i),0) == -1) return false;
  }
  return true;
}


function UpdateProfileMobile_Ajax(mobile,js_id){
	
	var numb = '0123456789';
	if(mobile!=''){
		check_mobile= mobile;		
		mobilenum = mobile.replace(/[()\s+]+/g,'');
		
		//if(!mobilenum.match(RegEx_Number)){
		if(!isCheckValid(mobilenum,numb)){	
			alert('Incorrect mobile number');
			return false;
		}
		var chkm =check_mobile.charAt(0);
		var firstchar =mobile.charAt(1);
		var secondchar =mobile.charAt(2);
		if(chkm=='+'){
				if(mobilenum.length>12 || mobilenum.length<12){
					alert('Incorrect mobile number. Must contain atleast 10 digits.');
					return false;
				}else if(firstchar!=9 || secondchar!=1){
					alert('Incorrect country code. Must start from +91 digits.');
					return false;
				}else{
				
				UpdateMyProfileMobile_Ajax(" "+check_mobile,js_id,{'target':'txtProfileMobile','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('mobileDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfileMobile').innerHTML = '';
									document.getElementById('showMobileText').style.display = 'none';
									document.getElementById('showMobile').style.display = 'block';
								}
							});
		       }
		}else{
			
			if(mobilenum.length<10 || mobilenum.length>10){
					alert('Incorrect mobile number. Must contain atleast 10 digits.');
					return false;
			}else{
				UpdateMyProfileMobile_Ajax(mobile,js_id,{'target':'txtProfileMobile','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('mobileDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfileMobile').innerHTML = '';
									document.getElementById('showMobileText').style.display = 'none';
									document.getElementById('showMobile').style.display = 'block';
								}
							});
		    }
		}
	
	}else{
		alert('Please Enter the Mobile number.');
		return false;
		
	}
	
	
	
	
	
}

function UpdateProfileEmail_Ajax(email,js_id){
	 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(email=='' || reWhiteSpace.test(email)){
			alert('Please Enter Email Address');
			return false;
		}else
		if(reg.test(email) == false) {
			alert('Invalid Email Address');
			return false;
		}else{ 
			UpdateMyProfileEmail_Ajax(email,js_id,{'target':'txtProfileEmail','preloader':'pr',
								'onFinish':function(response,xmlhttp){
										document.getElementById('emailDiv').style.background ='#F0E8F5';
										document.getElementById('txtProfileEmail').innerHTML = '';
										document.getElementById('showEmailText').style.display = 'none';
										document.getElementById('showEmail').style.display = 'block';
									}
								});
		}
}


//**************Employer Side **********************************************************
var reWhiteSpace = /^\s+$/
function EMPUpdateCompanyName_Ajax(name,employer_id){
	var reWhiteSpace = /^\s+$/
	
	if(name=='' || reWhiteSpace.test(name)){
		alert('Please Enter the Company Name!');
	}else{
		UpdateEMPMyCompanyName_Ajax(name,employer_id,{'target':'txtProfileName','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('nameDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfileName').innerHTML = name;
									document.getElementById('showNameText').style.display = 'none';
									document.getElementById('showName').style.display = 'block';
								}
							});
	}
}

function EMPUpdateProfileName_Ajax(name,js_id){
	var reWhiteSpace = /^\s+$/
	if(name=='' || reWhiteSpace.test(name)){
		alert('Please Enter the Name.');
		return false;
	}else{
		UpdateEMPMyProfileName_Ajax(name,js_id,{'target':'txtProfilecontactName','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('contactnameDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfilecontactName').innerHTML = '';
									document.getElementById('showcontactNameText').style.display = 'none';
									document.getElementById('showcontactName').style.display = 'block';
								}
							});
	}
}

function EMPUpdateProfilePhone_Ajax(stdcode,phonenum,phone,js_id){ 
	/*if(compltNum!=''){
		if(!compltNum.match(RegEx_Phone)){
			alert('Please enter valid phone number.');
			return false;
		}
	}*/
	if(stdcode.length<1 || stdcode.length>6){
		alert('Please enter valid STD Code for phone number.');
			return false;
	}else
	if(phonenum.length<8 || phonenum.length>10){
		alert('Please enter valid phone number.');
			return false;
	}else
	if(stdcode<1 && phonenum<1){
		alert('Please enter valid phone number.');
			return false;
	}else{
		UpdateEMPMyProfilePhone_Ajax(phone,js_id,{'target':'txtProfilePhone','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('phoneDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfilePhone').innerHTML = '';
									document.getElementById('showPhoneText').style.display = 'none';
									document.getElementById('showPhone').style.display = 'block';
								}
							});
	}
}

function EMPUpdateProfileMobile_Ajax(mobile,js_id){
	/*
	var contactmobile = mobile.replace(/[()+\-]+/g,'');
	if(mobile=='' || reWhiteSpace.test(mobile)){
		alert('Please Enter the Mobile number.');
		return false;
	}else
	if(!contactmobile.match(RegEx_Number)){
		alert('Incorrect mobile number. Must contain atleast 10 digits.');
		return false;
	}else
	if(contactmobile.length<10){
		alert('Incorrect mobile number. Must contain atleast 10 digits.');
		return false;
		*/
	var mobile = trim(document.getElementById('mobile').value);
	if(mobile!=''){
		mobilenum = mobile.replace(/[()+]+/g,'');
		if(!mobilenum.match(RegEx_Number)){
			alert('Incorrect mobile number');
			return false;
		}
		var chkm =mobile.charAt(0);
		var firstchar =mobile.charAt(1);
		var secondchar =mobile.charAt(2);
		if(chkm=='+'){
				if(mobilenum.length>12 || mobilenum.length<12){
					alert('Incorrect mobile number. Must contain atleast 10 digits.');
					return false;
				}else if(firstchar!=9 || secondchar!=1){
					alert('Incorrect country code. Must start from +91 digits.');
					return false;
				}else{
				
				UpdateEMPMyProfileMobile_Ajax(mobile,js_id,{'target':'txtProfileMobile','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('mobileDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfileMobile').innerHTML = '';
									document.getElementById('showMobileText').style.display = 'none';
									document.getElementById('showMobile').style.display = 'block';
								}
							});
		       }
		}else{
			if(mobilenum.length<10 || mobilenum.length>10){
					alert('Incorrect mobile number. Must contain atleast 10 digits.');
					return false;
			}else{
				UpdateEMPMyProfileMobile_Ajax(mobile,js_id,{'target':'txtProfileMobile','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('mobileDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfileMobile').innerHTML = '';
									document.getElementById('showMobileText').style.display = 'none';
									document.getElementById('showMobile').style.display = 'block';
								}
							});
		    }
		}
	
	}else{
		alert('Please Enter the Mobile number.');
		return false;
		
	}
}

function EMPUpdateProfileEmail_Ajax(email,js_id,oldEmail){
	 var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(email=='' || reWhiteSpace.test(email)){
			alert('Please Enter Email Address');
			return false;
		}else
		if(reg.test(email) == false) {
			alert('Invalid Email Address');
			return false;
		}else{ 
			UpdateEMPMyProfileEmail_Ajax(email,js_id,oldEmail,{'target':'txtProfileEmail','preloader':'pr',
								'onFinish':function(response,xmlhttp){
										document.getElementById('emailDiv').style.background ='#F0E8F5';
										document.getElementById('txtProfileEmail').innerHTML = '';
										document.getElementById('showEmailText').style.display = 'none';
										document.getElementById('showEmail').style.display = 'block';
									}
								});
		}
	
}

function EMPUpdateWebsite_Ajax(website,js_id){
	var RegEx_Url= /[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;
	var v = new RegExp();
	v.compile("^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
	if(website=='' || reWhiteSpace.test(website)){
		alert('Website cannot be blank.');
		return false;
	}else
	if(!v.test(website)) {
		alert("You must supply a valid URL.");
		return false;
	}else{
		UpdateEMPMyWebsiteName_Ajax(website,js_id,{'target':'txtProfilewebsite','preloader':'pr',
							'onFinish':function(response,xmlhttp){
									document.getElementById('websiteDiv').style.background ='#F0E8F5';
									document.getElementById('txtProfilewebsite').innerHTML = '';
									document.getElementById('showwebsiteText').style.display = 'none';
									document.getElementById('showwebsite').style.display = 'block';
								}
							});
	}
}


function CheckLogo(){
	var ctrl = document.getElementById('logo_upload');
	var val = document.getElementById('logo_upload').value;
	valArr = val.split('.');
	ext = valArr[valArr.length-1].toLowerCase();
	if(ext!='jpg' && ext!='gif' && ext!='png'){
		alert('Please upload valid images only of type JPEG, GIF or PNG.');	
		document.getElementById('logo_upload').select();
		return false;
	}
}

function CheckImage(){
	var ctrl = document.getElementById('photo_upload');
	var val = document.getElementById('photo_upload').value;
	valArr = val.split('.');
	ext = valArr[valArr.length-1].toLowerCase();
	if(ext!='jpg' && ext!='gif' && ext!='png'){
		alert('Please upload valid images only of type JPEG, GIF or PNG.');	
		document.getElementById('photo_upload').select();
		return false;
	}
}

function gotoback(){
	window.history.back();
}

function AllowteaxtArea(){
	handicapN = document.getElementById('handicapN').checked;	
	 handicap = document.getElementById('handicap').checked;
	 if(handicapN){
		  document.getElementById('description1').disabled=false;
		  document.getElementById('description1').style.backgroundColor='#ffffff';
		  document.getElementById('description1').value='';
	 }else{
		 document.getElementById('description1').disabled=true;
		  document.getElementById('description1').style.backgroundColor='#dddddd';
		  document.getElementById('description1').value='';
	 }
	 
	 if(handicap){
		  document.getElementById('description1').disabled=false;
		  document.getElementById('description1').style.backgroundColor='#ffffff';
		  document.getElementById('description1').value='';
	 }else{
		 document.getElementById('description1').disabled=true;
		  document.getElementById('description1').style.backgroundColor='#dddddd';
		  document.getElementById('description1').value='';
	 }
	 
	 
	
}

function CheckLogo1(){
	var ctrl = document.getElementById('logo_upload1');
	var val = document.getElementById('logo_upload1').value;
	valArr = val.split('.');
	ext = valArr[valArr.length-1].toLowerCase();
	if(ext!='jpg' && ext!='gif' && ext!='png'){
		alert('Please upload valid images only of type JPEG, GIF or PNG.');	
		document.getElementById('logo_upload1').select();
		return false;
	}
}


function refreshHomeFolderBox(){
	RefreshHomePageFolderBox_AJAX({'target':'txtHint',
							'onFinish':function(response,xmlhttp){
									document.getElementById('txtHint').innerHTML = '';
								}
							});
}

function refreshEmployerHomeFolderBox(){
	RefreshHomePageFolderBox_AJAX({'target':'txtFolderHints',
							'onFinish':function(response,xmlhttp){
									document.getElementById('txtFolderHints').innerHTML = '';
								}
							});
}

function CreateResumeSession(resumeid,obj){
	//alert(obj.checked);
	if(obj.checked){
		action="1";
	}else{
		action="0";
	}
	CreateResumeSession_AJAX(resumeid,action,{'target':'txtResumeID',
							'onFinish':function(response,xmlhttp){
									document.getElementById('txtResumeID').innerHTML = '';
								}
							});
	CreateSearchSession_AJAX(resumeid,action,{'target':'txtearchID',
							'onFinish':function(response,xmlhttp){
									document.getElementById('txtearchID').innerHTML = '';
								}
							});
}

function DeleteSearchAgent(searchagent_id){
		DeleteSearchAgent_Ajax(searchagent_id,{'target':'txtsearchagent',
							'onFinish':function(response,xmlhttp){
									document.getElementById('txtsearchagent').innerHTML = '';
								}
							});
}

function ActivateSearchAgent(id,vals){
	var conf = window.confirm('Are you sure you want to change status.');
	if(conf){
		ActivateSearchAgent_Ajax(id,vals,{'target':'ActivateSearchAgentposts',
							'onFinish':function(response,xmlhttp){
									document.getElementById('ActivateSearchAgentposts').innerHTML = '';
								}
							})
	}
}

function DeleteResumeSearchAgent(searchagent_id){
		DeleteResumeSearchAgent_Ajax(searchagent_id,{'target':'txtsearchagent',
							'onFinish':function(response,xmlhttp){
									document.getElementById('txtsearchagent').innerHTML = '';
								}
							});
}

function ActivateResumeSearchAgent(id,vals){
	var conf = window.confirm('Are you sure you want to change status.');
	if(conf){
		ActivateResumeSearchAgent_Ajax(id,vals,{'target':'ActivateSearchAgentposts',
							'onFinish':function(response,xmlhttp){
									document.getElementById('ActivateSearchAgentposts').innerHTML = '';
								}
							});
	}
}

function DeleteCoverLetter(id){
	var conf = window.confirm('Are you sure you want to delete Cover Letter.');
	if(conf){
		DeleteCoverLetter_Ajax(id,{'target':'COVER_LETTER_LIST',
							'onFinish':function(response,xmlhttp){
									//document.getElementById('ActivateSearchAgentposts').innerHTML = '';
								}
							});
	}
}