var pid = null;

function checkPostAd(frm)
{

 	if(frm.adtitle.value=='')
	{
		alert('Please Enter Title');
		frm.adtitle.focus();
		return false;
	}
	if(document.getElementById('longdescription').value == '')
	{
		alert('Please Enter Description');
		frm.longdescription.focus();
		return false;
	}
	if(frm.statenm.value == '')
	{
		alert('Please Select State');
		frm.statenm.focus();
		return false;
	}
	if(frm.email.value == '')
	{
		alert('Enter email id ');
		frm.email.focus();
		return false;
	}	
	else if(frm.email.value != '')
	{
		if(!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(frm.email.value)))
		{
			alert(' Invalid Email Address.. Please Re-enter it ');
			frm.email.focus();
			return false;
		}
	}
	if(frm.postad_security_code.value == '')
	{
		alert(' Please Enter Security Code !!');
		frm.postad_security_code.focus();
		return false;
	}
	return true;
}

function DisplayCategory()
{
	document.getElementById('Category').style.display = '';
	document.getElementById('Location').style.display = 'none';
}
function DisplayLocation()
{
	document.getElementById('Location').style.display = '';
	document.getElementById('Category').style.display = 'none';
}

function checkRegistration(regfrm)
{
	if(regfrm.firstname.value == '')
	{
		alert('Please Enter First Name ');
		regfrm.firstname.focus();
		return false;
	}

    if(regfrm.lastname.value == '')
    {
        alert('Please Enter Last Name ');
        regfrm.lastname.focus();
        return false;
    }

	if(regfrm.nickname.value == '')
	{
		alert('Please Enter NickName ');
		regfrm.nickname.focus();
		return false;
	}

	if(regfrm.job_title.value == '')
	{
		alert('Please Enter Job Title');
		regfrm.job_title.focus();
		return false;
	}


	if(regfrm.industrytype.value == '')
	{
		alert('Please select Industry');
		regfrm.industrytype.focus();
		return false;
	}

	if(regfrm.useremail.value == '')
	{
		alert('Please Enter Email Id ');
		regfrm.useremail.focus();
		return false;
	}
	else if(!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(regfrm.useremail.value)))
	{
		alert('Please Enter Valid Email Id ');
		regfrm.useremail.focus();
		return false;
	}
	
	if(regfrm.userpassword.value == '')
	{
		alert(' Please Enter Password ');
		regfrm.userpassword.focus();
		return false;
	}	
	else if(regfrm.userpassword.value.length < 6)
	{
		alert('Password must be at least 6 characters');
		regfrm.userpassword.focus();
		return false;
	}
	if(regfrm.confirmpassword.value == '')
	{
		alert('Please Enter Confirm Password ');
		regfrm.confirmpassword.focus();
		return false;
	}
	else if(regfrm.userpassword.value != regfrm.confirmpassword.value)
	{
		alert('Your confirm password does not match');
		regfrm.confirmpassword.focus();
		return false;
	}

	if(regfrm.register_security_code.value == '')
	{
		alert(' Please Enter Security Code ');
		regfrm.register_security_code.focus();
		return false;
	}
	return true;
}

function checkSignIn(signfrm)
{
	if(signfrm.signemail.value == '')
	{
		alert(' Please Enter Email Id ');
		signfrm.signemail.focus();
		return false;
	}
	else if(!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(signfrm.signemail.value)))
	{
		alert('Invalid Email Id.. Please Re-enter it');
		signfrm.signemail.focus();
		return false;
	}

	if(signfrm.signpassword.value == '')
	{
		alert('Please Enter Password');
		signfrm.signpassword.focus();
		return false;
	}
	return true;
}

function checkForgotten(forgotfrm)
{
	if(forgotfrm.forgotemail.value == '')
	{
		alert('Please Enter Email Id');
		forgotfrm.forgotemail.focus();
		return false;
	}
	else if(!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(forgotfrm.forgotemail.value)))
	{
		alert('Enter valid email id');
		forgotfrm.forgotemail.focus();
		return false;
	}
	return true;
}

function checkPassword()
{
	if(document.changepassfrm.chcurpassword.value == '')
	{
		alert(' Please Enter Current Password ');
		document.changepassfrm.chcurpassword.focus();
		return false;
	}
	if(document.changepassfrm.chpassword.value == '')
	{
		alert(' Please New Enter Password ');
		document.changepassfrm.chpassword.focus();
		return false;
	}

	if(document.changepassfrm.chrepassword.value == '')
	{
		alert(' Please Re-type Password ');
		document.changepassfrm.chrepassword.focus();
		return false;
	}
	if(document.changepassfrm.chpassword.value != document.changepassfrm.chrepassword.value)
	{
		alert(' Both Passwords does not Match');
		document.changepassfrm.chrepassword.focus();
		return false;
	}
	return true;
}
function checkNickname()
{
	if(document.frmChangeNickname.txtNickname.value == '')
	{
		alert('Please Enter Valid Nickname');
		document.frmChangeNickname.txtNickname.focus();
		return false;
	}
	return true;
}

function checkProfile(proffrm)
{
	if(proffrm.chfirstname.value == '')
	{
		alert('Please Enter First Name');
		proffrm.chfirstname.focus();
		return false;
	}
	return true;
}

function chkLinkToFriend(adlinkmail)
{
	if(adlinkmail.from_email.value == '')
	{
		alert('Please Enter From Email Id');
		adlinkmail.from_email.focus();
		return false;
	}

	else if(!(adlinkmail.from_email.value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)))
	{
		alert('Enter valid From Email Id');
		adlinkmail.from_email.focus();
		return false;
	}

	if(adlinkmail.to_email.value == '')
	{
		alert('Please Enter To Email Id');
		adlinkmail.to_email.focus();
		return false;
	}

	else if(!(adlinkmail.to_email.value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)))
	{
		alert('Enter valid To Email Id');
		adlinkmail.to_email.focus();
		return false;
	}

	if(adlinkmail.linkfrd_security_code.value == '')
	{
		alert('Please Enter Word Verification');
		adlinkmail.linkfrd_security_code.focus();
		return false;
	}

	return true;
}

/* START CODE FOR : for open popup with parent window disable  */
function setLayerPosition(showid,hideid) 
{
	var shadow = document.getElementById(showid);
	var question = document.getElementById(hideid);
	
	shadow.style.width = document.body.clientWidth + "px";
	shadow.style.height = document.body.clientHeight + "px";
	
	shadow = null;
	question = null;
}

function showLayer(showid,hideid)
{
	setLayerPosition(showid,hideid);
	var shadow = document.getElementById(showid);
	var question = document.getElementById(hideid);

	shadow.style.display = "block"; 
	question.style.display = "block";

	shadow = null;
	question = null;
}

function hideLayer(showid,hideid)
{
	var shadow = document.getElementById(showid);
	var question = document.getElementById(hideid);

	shadow.style.display = "none"; 
	question.style.display = "none";

	shadow = null;
	question = null; 
}
/* END CODE FOR : for open popup with parent window disable  */
function deleteCheck(path)
{
	var msg;
	msg=confirm("Are You Sure to Delete This Ad !!!");
	if(msg)
	{
		window.location.href=path;
	}
	return false;
}

function ajaxFunction(resultid,sendurl,passval)
{
	document.getElementById(resultid).style.display = '';
	var startloc = passval;
	startloc = startloc.replace(/\s+/g,'-');
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	var url = sendurl+startloc;
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{	
			if(resultid != 'autoFillRes' && resultid != 'PostCityList')
			{
				var strsearch = xmlHttp.responseText.search("and");
				if(strsearch == -1 )
				{
					document.getElementById(resultid).innerHTML=xmlHttp.responseText;
				}
				else
				{
					var mymsg = xmlHttp.responseText.split("and");
					document.getElementById(resultid).innerHTML=mymsg[0];
					document.getElementById("OpenWatchList").innerHTML=mymsg[1];
				}
					
			}
			else
			{
				
				document.getElementById(resultid).innerHTML=xmlHttp.responseText;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function AutoLocationReturn(ctname)
{
	document.SearchFrm.l.value = ctname
	document.getElementById('autoFillRes').style.display = 'none';
}

function chkingsearch()
{
	if(document.SearchFrm.q.value == '' && document.SearchFrm.l.value == '')
	{
		alert("please enter keyword or location");
		document.SearchFrm.q.focus();
		return false;
	}
	return true;
}

function chkingcontactus(conus)
{
	if(conus.contact_email.value == '')
	{
		alert('Please enter email id ');
		conus.contact_email.focus();
		return false;
	}
	else if(!(conus.contact_email.value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)))
	{
		alert('Enter valid From Email Id');
		conus.contact_email.focus();
		return false;
	}
	if(conus.contact_msg.value == '')
	{
		alert('Please enter message');
		conus.contact_msg.focus();
		return false;
	}
	if(conus.contact_security_code.value == '')
	{
		alert('Please enter word verification');
		conus.contact_security_code.focus();
		return false;
	}
	return true;
}

function validateimproperAd()
{
	var chks = document.getElementsByName('rtpad');
	var hasChecked = false;
	for (var i = 0; i < chks.length; i++)
	{
		if (chks[i].checked)
		{
			hasChecked = true;
			break;
		}
	}
	if (hasChecked == false)
	{
		alert('Please select a reason for reporting this ad');
		return false;
	}
	if(document.reportimproper.report_email.value == '')
	{
		alert('Please enter email id');
		document.reportimproper.report_email.focus();
		return false;
	}
	else if(!(document.reportimproper.report_email.value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)))
	{
		alert('Enter valid From Email Id');
		document.reportimproper.report_email.focus();
		return false;
	}
	return true;
}

function ajaxKeyword(keyword,dest,categoryId,txtbox)
{
	if(!categoryId)
	{
		document.addKeywordsfrm.catlist.focus();
		alert('Select Catagory');
		return false;
	}
	document.getElementById(dest).innerHTML='';
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
		return xmlHttp;
	}
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var url="admin_addKeywords.php";
	url=url+"?action=A&check=insertedKeywords&keyword="+keyword+"&categoryId="+categoryId;
	xmlHttp.onreadystatechange=function() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById(dest).innerHTML=xmlHttp.responseText;
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function loadChild(parentid)
{
	pid = parentid;
	xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Your browser does not support AJAX!");
			return;
		}
	var url="http://www.careerinf.com/admin_loadChild.php";
	url=url+"?id="+parentid;
	
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("children"+pid).innerHTML=xmlHttp.responseText;

		var divid = document.getElementById("children"+pid);
		if(divid.style.display == "inline")
		{
			divid.style.display = "none";
			document.getElementById("image"+pid).src = "../images/plus.gif";
		}
		else
		{
			divid.style.display = "inline";
			document.getElementById("image"+pid).src = "../images/minus.gif";
		}	
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
		try
		{
			xmlHttp=new XMLHttpRequest();
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e)
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
	return xmlHttp;
}

function chekingAddKeyword()
{
	if(document.addKeywordsfrm.catlist.value == '')
	{
		alert("Please select category ");
		document.addKeywordsfrm.catlist.focus();
		return false;
	}
	return true;
}

function nospaces(textname)
{
	var t = textname;
	var v = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
	var w = "";
	for (i=0; i < t.value.length; i++) 
	{
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
			w += x;
	}
	t.value = w;
	document.getElementById('nicknm').innerHTML=w;
	
}

/********* for disable share button when twite empty ********/
function blah(form_obj)
{
	var ttltext = form_obj.post_conv.value.length;
    if (form_obj.post_conv.value != '')
	{
		if(ttltext > 140 )  
        {
            form_obj.Share.className = 'bg_button_disable';
        }
        else
        {
            form_obj.Share.className = 'bg_button3';
        }   
	}
    else
        form_obj.Share.className = 'bg_button_disable';
	
	var remainingtext = 140 - ttltext;
	if(remainingtext < 10)
	{
		document.getElementById("myCounter").style.color = "#d40d12";
	}
	else
	{
		document.getElementById("myCounter").style.color = "";
	}
	document.getElementById("myCounter").innerHTML = remainingtext;
}

function blah_msg(form_objmsg)
{
    if (form_objmsg.direct_msg.value != '' && form_objmsg.to_user.value != '')
        form_objmsg.Send.disabled = false;
    else
        form_objmsg.Send.disabled = true;
}

/*** ajax function for twitter module ****/
function ajaxConversation(sendurl,qrytype,delid)
{
	if(qrytype == 'add')
	{
		convmsg = document.comv_message.post_conv.value;	
	}
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	if(qrytype == 'add')
	{
		var url = sendurl+"/convAjax.php";
		var replyId = document.comv_message.replyid.value;
		var returntype = document.comv_message.form_type.value;
		var params = "postConv="+convmsg+"&replyid="+replyId+"&reply_type="+returntype;

	}
	else
	{
		if(confirm("Are you sure you want to delete this record ?"))
		{	
			var url = sendurl+"/convAjax.php";
			if(qrytype == 'Updelete')
			{
				var params = "del_update="+delid;
			}
			else
			{
				var params = "del_conv="+delid;
			}
		}
	}	
	xmlHttp.open("POST", url, true);

	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var mymsg = xmlHttp.responseText.split("!&CONV&!");
			if(qrytype == 'add' && convmsg != ' ')
			{
				document.getElementById('latest_conv').innerHTML=convmsg;
				document.getElementById('myCounter').innerHTML=140;
				document.comv_message.post_conv.value = '';
				document.getElementById("replyTitle").innerHTML= "Share with your friends !";
				document.getElementById("CancelVal").innerHTML= "";
				document.comv_message.replyid.value = "";
				document.comv_message.Share.value = "Share";
			}
			if(qrytype == 'delete')
			{
				document.getElementById('latest_conv').innerHTML=mymsg[1];
			}
			
			/** for only update delete return msg */
			if(qrytype == 'Updelete')
			{
				document.getElementById('LatestUpdates').innerHTML=mymsg[0];
				document.getElementById('TtlUpdate').innerHTML=mymsg[1];
			}
			/** for all return msg */
			else
			{
				document.getElementById('ttlupdates').innerHTML=mymsg[0];
				document.getElementById('UserAllConv').innerHTML=mymsg[2];
			}
		}
	}
	xmlHttp.send(params);
}

function chkpersonalfrm()
{
    var str = document.personalfrm.txt_address.value;
    var newstr = str.replace(/\n/g," ");
    result = newstr.split(" ");

    var loopcounter = 0;
    while(loopcounter < result.length)
    {
        if(result[loopcounter].length > 50)
        {
            alert('One of the word in Address you provided is too long.(The maximum word length is 50 characters).');
            document.personalfrm.txt_address.focus();
            return false;
        }
        loopcounter+=1;
    }

	var leapyear = '';
	if(document.personalfrm.sel_month.value == 2)
	{
		if(document.personalfrm.sel_year.value%100 == 0)
		{
			if(document.personalfrm.sel_year.value%400 == 0)
			{
				leapyear = 'true';
			}
			else
			{
				leapyear = 'false';
			}
		}
		else
		{
			if(document.personalfrm.sel_year.value%4 == 0)
			{
				leapyear = 'true';
			}
			else
			{
				leapyear = 'false';
			}
		}

		if(leapyear == 'true')
		{
			if(document.personalfrm.sel_day.value > 29)
			{
				alert('You cant select Date '+document.personalfrm.sel_day.value+' in this Month');
				return false;
			}
		}
		else
		{
			if(document.personalfrm.sel_day.value > 28)
			{
				alert('You cant select Date '+document.personalfrm.sel_day.value+' in this Month');
				return false;
			}
		}
	}
	else if(document.personalfrm.sel_month.value == 4 || document.personalfrm.sel_month.value == 6 || document.personalfrm.sel_month.value == 9 || document.personalfrm.sel_month.value == 11)
	{
		if(document.personalfrm.sel_day.value > 30)
		{
			alert('You cant select Date '+document.personalfrm.sel_day.value+' in this Month');
			return false;
		}
	}

	if(document.personalfrm.sel_day.value  != '00')
	{
		if(document.personalfrm.sel_month.value == '00' || document.personalfrm.sel_year.value == '0000')
		{
			alert('Please specify full Birthdate');
            document.personalfrm.sel_month.focus();
			return false;
		}
	}

	if(document.personalfrm.sel_month.value != '00')
	{
		if(cdocument.personalfrm.sel_year.value == '0000' || document.personalfrm.sel_day.value  == '00')
		{
			alert('Please specify full Birthdate');
            document.personalfrm.sel_day.focus();
			return false;
		}
	}

	if(document.personalfrm.sel_year.value != '0000')
	{
		if(document.personalfrm.sel_day.value == '00' || document.personalfrm.sel_month.value == '00')
		{
			alert('Please specify full Birthdate');
            document.personalfrm.sel_day.focus();
			return false;
		}
	}

	return true;
}

function displayCropping()
{
	if (xmlHttp.readyState==4)
	{
		document.getElementById("imgArea").style.display='';
		document.getElementById("imgArea").innerHTML=xmlHttp.responseText;
	}
}
function nodisplayCropping(imgArea)
{
	document.getElementById(imgArea).style.display='none';
}

function currentwork()
{
	if(document.experiencefrm.ch_currentry_working.checked == true)
	{
		document.getElementById('selectyear').style.display = 'none';
		document.getElementById('presentyear').style.display = '';
		document.experiencefrm.hid_present.value = 'yes';
	}
	else
	{
		document.getElementById('selectyear').style.display = '';
		document.getElementById('presentyear').style.display = 'none';
		document.experiencefrm.hid_present.value = 'no';
	}
}

function confirmProfileDelete(str)
{
	var s = confirm("Are you sure you want to delete this "+str+" ?");
	if (s == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function charCount(elementid,divelement)
{
    var str = document.getElementById(elementid).value;
    var newstr = str.replace(/\n/g," ");
    result = newstr.split(" ");

    var loopcounter = 0;
    while(loopcounter < result.length)
    {
        if(result[loopcounter].length > 50)
        {
            var extra = result[loopcounter].length - 50;
            document.getElementById(divelement).innerHTML = 'You have exceeded the maximum word length of 50 by '+extra+' characters';
            document.getElementById(divelement).style.display = '';
            return false;
        }

        document.getElementById(divelement).style.display = 'none';
        loopcounter+=1;
    }
}

function chkexperiencefrm(current_month,current_year)
{
	if(document.experiencefrm.txt_company_name.value == '')
	{
		alert('Please specify the Company Name');
		document.experiencefrm.txt_company_name.focus();
		return false;
	}

	if(document.experiencefrm.txt_job_title.value == '')
	{
		alert('Please specify a Job Title');
		document.experiencefrm.txt_job_title.focus();
		return false;
	}

	if(document.experiencefrm.sel_start_month.value == '00')
	{
		alert('Please specify a Month for the Start Date.');
		document.experiencefrm.sel_start_month.focus();
		return false;
	}

	if(document.experiencefrm.txt_start_year.value == '' || document.experiencefrm.txt_start_year.value == 'year')
	{
		alert('Please specify a Year for the Start Date.');
		document.experiencefrm.txt_start_year.focus();
		return false;
	}

	if(document.experiencefrm.txt_start_year.value < 1900 || document.experiencefrm.txt_start_year.value > current_year)
	{
		alert('Please specify the Start Year between 1900 and '+current_year);
		document.experiencefrm.txt_start_year.focus();
		return false;
	}

	if(document.experiencefrm.txt_start_year.value == current_year)
	{
		if(document.experiencefrm.sel_start_month.value > current_month)
		{
			alert('Please specify a Date no later than this month.');
			document.experiencefrm.sel_start_month.focus();
			return false;
		}
	}

	if(!document.experiencefrm.ch_currentry_working || (document.experiencefrm.ch_currentry_working && document.experiencefrm.ch_currentry_working.checked == false))
	{
		if(document.experiencefrm.sel_end_month.value == '00')
		{
			alert('Please specify a Month for the End Date.');
			document.experiencefrm.sel_end_month.focus();
			return false;
		}

		if(document.experiencefrm.txt_end_year.value == '' || document.experiencefrm.txt_end_year.value == 'year')
		{
			alert('Please specify a Year for the End Date.');
			document.experiencefrm.txt_end_year.focus();
			return false;
		}

		if(document.experiencefrm.txt_end_year.value < 1900 || document.experiencefrm.txt_end_year.value > current_year)
		{
			alert('Please specify the End Year between 1900 and '+current_year);
			document.experiencefrm.txt_end_year.focus();
			return false;
		}

		if(document.experiencefrm.txt_end_year.value == current_year)
		{
			if(document.experiencefrm.sel_end_month.value > current_month)
			{
				alert('Please specify a Date no later than this month.');
				document.experiencefrm.sel_end_month.focus();
				return false;
			}
		}

		if(document.experiencefrm.txt_start_year.value > document.experiencefrm.txt_end_year.value)
		{
			alert('Please be sure the Start Date is not after the End Date.');
			document.experiencefrm.txt_end_year.focus();
			return false;
		}

		if(document.experiencefrm.txt_start_year.value == document.experiencefrm.txt_end_year.value)
		{
			if(document.experiencefrm.sel_start_month.value > document.experiencefrm.sel_end_month.value)
			{
				alert('Please be sure the Start Date is not after the End Date.');
				document.experiencefrm.sel_end_month.focus();
				return false;
			}

			if(document.experiencefrm.sel_start_month.value == document.experiencefrm.sel_end_month.value)
			{
				alert('Please be sure the Experience is not less than 1 month');
				document.experiencefrm.sel_end_month.focus();
				return false;
			}
		}
	}

    var str = document.experiencefrm.txt_job_description.value;
    var newstr = str.replace(/\n/g," ");
    result = newstr.split(" ");

    var loopcounter = 0;
    while(loopcounter < result.length)
    {
        if(result[loopcounter].length > 50)
        {
            alert('One of the word in Job Description you provided is too long.(The maximum word length is 50 characters).');
            document.experiencefrm.txt_job_description.focus();
            return false;
        }

        loopcounter+=1;
    }

	return true;
}

function isNumberKey(evt)
{
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;
	else
		return true;
}

function getText(txt_element)
{
	if(document.getElementById(txt_element).value == 'year')
	{
		document.getElementById(txt_element).value = '';
		document.getElementById(txt_element).style.color = "#000000";
	}
}

function putText(txt_element)
{
	if(document.getElementById(txt_element).value == '')
	{
		document.getElementById(txt_element).value = 'year';
		document.getElementById(txt_element).style.color = "#999999";
	}
}

function chkeducationfrm()
{
	if(document.educationfrm.txt_degree.value == '')
	{
		alert('Please specify a Degree');
		document.educationfrm.txt_degree.focus();
		return false;
	}

	if(document.educationfrm.sel_degree_start.value == '0000')
	{
		alert('Please specify the Degree starting year');
		document.educationfrm.sel_degree_start.focus();
		return false;
	}

	if(document.educationfrm.sel_degree_end.value == '0000')
	{
		alert('Please specify the Degree ending year');
		document.educationfrm.sel_degree_end.focus();
		return false;
	}

	if(document.educationfrm.sel_degree_start.value > document.educationfrm.sel_degree_end.value)
	{
		alert('Please be sure the start year is not after the end year.');
		document.educationfrm.sel_degree_end.focus();
		return false;
	}

	if(document.educationfrm.sel_university.value == -2)
	{
		if(document.educationfrm.txt_university1.value == '')
		{
			alert('Please enter the name of the University/School you attended.');
			document.educationfrm.txt_university1.focus();
			return false;
		}
	}

	if(document.educationfrm.sel_university.value == -1)
	{
		if(document.educationfrm.txt_university2.value == '')
		{
			alert('Please enter the name of the University/School you attended.');
			document.educationfrm.txt_university2.focus();
			return false;
		}
	}

    var str = document.educationfrm.txt_additional_notes.value;
    var newstr = str.replace(/\n/g," ");
    result = newstr.split(" ");

    var loopcounter = 0;
    while(loopcounter < result.length)
    {
        if(result[loopcounter].length > 50)
        {
            alert('One of the word in Additional notes you provided is too long.(The maximum word length is 50 characters).');
            document.educationfrm.txt_additional_notes.focus();
            return false;
        }
        loopcounter+=1;
    }
	return true;
}

function chkbasicfrm()
{
	if(document.basicfrm.txt_first_name.value == '')
	{
		alert('Please specify First Name');
		document.basicfrm.txt_first_name.focus();
		return false;
	}

    if(document.basicfrm.txt_first_name.value.length > 20)
    {
        alert('Your First Name is too long. The maximum limit is 20 characters');
        document.basicfrm.txt_first_name.focus();
        return false;
    }

    if(document.basicfrm.txt_last_name.value == '')
    {
        alert('Please specify Last Name');
        document.basicfrm.txt_last_name.focus();
        return false;
    }

    if(document.basicfrm.txt_last_name.value.length > 20)
    {
        alert('Your Last Name is too long. The maximum limit is 20 characters');
        document.basicfrm.txt_last_name.focus();
        return false;
    }

    if(document.basicfrm.txt_nick_name)
    {
        if(document.basicfrm.txt_nick_name.value == '')
        {
            alert('Please specify Nick Name');
            document.basicfrm.txt_nick_name.focus();
            return false;
        }
        else if(document.basicfrm.txt_nick_name.value.length > 15)
        {
            alert('Your Nick Name is too long. The maximum limit is 15 characters');
            document.basicfrm.txt_nick_name.focus();
            return false;
        }
    }

	if(document.basicfrm.txt_profession.value == '')
	{
		alert('Please specify Profession');
		document.basicfrm.txt_profession.focus();
		return false;
	}

	return true;
}

function getDefaultUrl(txt_element)
{
	if(document.getElementById(txt_element).value == '(Ex: http://www.site.com)')
	{
		document.getElementById(txt_element).value = '';
		document.getElementById(txt_element).style.color = "#000000";
	}
}

function putDefaultUrl(txt_element)
{
	if(document.getElementById(txt_element).value == '')
	{
		document.getElementById(txt_element).value = '(Ex: http://www.site.com)';
		document.getElementById(txt_element).style.color = "#999999";
	}
}

function chkadditionalfrm()
{
	if(document.additionalfrm.txt_website1.value == '(Ex: http://www.site.com)')
	{
		document.additionalfrm.txt_website1.value = '';
	}

	if(document.additionalfrm.txt_website2.value == '(Ex: http://www.site.com)')
	{
		document.additionalfrm.txt_website2.value = '';
	}

	if(document.additionalfrm.txt_website3.value == '(Ex: http://www.site.com)')
	{
		document.additionalfrm.txt_website3.value = '';
	}

	if(document.additionalfrm.txt_website1.value != '')
	{
		if(document.additionalfrm.sel_website1_type.value == '')
		{
			alert('Please specify a website type for '+document.additionalfrm.txt_website1.value);
			document.additionalfrm.sel_website1_type.focus();
			return false;
		}
	}

	if(document.additionalfrm.txt_website2.value != '')
	{
		if(document.additionalfrm.sel_website2_type.value == '')
		{
			alert('Please specify a website type for '+document.additionalfrm.txt_website2.value);
			document.additionalfrm.sel_website2_type.focus();
			return false;
		}
	}

	if(document.additionalfrm.txt_website3.value != '')
	{
		if(document.additionalfrm.sel_website3_type.value == '')
		{
			alert('Please specify a website type for '+document.additionalfrm.txt_website3.value);
			document.additionalfrm.sel_website3_type.focus();
			return false;
		}
	}

    var str1 = document.additionalfrm.txt_interests.value;
    var newstr1 = str1.replace(/\n/g," ");
    result1 = newstr1.split(" ");

    var loopcounter1 = 0;
    while(loopcounter1 < result1.length)
    {
        if(result1[loopcounter1].length > 50)
        {
            alert('One of the word in Intrests you provided is too long.(The maximum word length is 50 characters).');
            document.additionalfrm.txt_interests.focus();
            return false;
        }
        loopcounter1+=1;
    }

    var str2 = document.additionalfrm.txt_honors_awards.value;
    var newstr2 = str2.replace(/\n/g," ");
    result2 = newstr2.split(" ");

    var loopcounter2 = 0;
    while(loopcounter2 < result2.length)
    {
        if(result2[loopcounter2].length > 50)
        {
            alert('One of the word in Honors and Awards you provided is too long.(The maximum word length is 50 characters).');
            document.additionalfrm.txt_honors_awards.focus();
            return false;
        }
        loopcounter2+=1;
    }

	return true;
}

function getVcardInfo(userId,siteUrl)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url=siteUrl+"/vCardInfo.php";
    url=url+"?userId="+userId;

    xmlHttp.onreadystatechange=showVcardInfo;

    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function showVcardInfo()
{
    if (xmlHttp.readyState == '4')
    {
        document.getElementById("vCardInfo").innerHTML=xmlHttp.responseText;
    }
}

function getUniversity(country_id,siteUrl)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url=siteUrl+"/universityList.php";
    var params = "country_id="+country_id;
	
    xmlHttp.open("POST", url, true);

    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

	xmlHttp.onreadystatechange=countryChanged;

	xmlHttp.send(params);
}

function countryChanged()
{
	if (xmlHttp.readyState == '4')
	{
		document.getElementById("UniName").innerHTML=xmlHttp.responseText;
	}
}

function otherUniversity(universityVal)
{
	if(universityVal == 0)
	{
		document.getElementById("otherSchool").style.display = '';
	}
	else
	{
		document.getElementById("otherSchool").style.display = 'none';
	}
}

function check_inviteByEmail()
{
	if(document.frmAddresses.addresses.value == '')
	{
		document.frmAddresses.addresses.focus();
		alert('Please Enter Email Address');
		return false;
	}
	return true;
}

function replyvalue(textval)
{
	document.comv_message.post_conv.style.color = "#999";
	document.comv_message.post_conv.value = "reply here .... ";
	document.getElementById("replyTitle").innerHTML= "Reply to "+textval+":";
	document.comv_message.replyid.value = textval;
	document.getElementById("CancelVal").innerHTML= " or <a href='javascript:void(0);' onclick='canclereply();'>cancel</a>";
	document.comv_message.Share.value = "Reply";
	window.scrollTo(0,0);
}

function canclereply()
{
	document.getElementById("replyTitle").innerHTML= "Share with your friends !";
	document.getElementById("CancelVal").innerHTML= "";
	document.comv_message.replyid.value = "";
	document.comv_message.post_conv.value = "";
	document.getElementById("myCounter").innerHTML= "140";
	document.comv_message.Share.value = "Share";
	document.comv_message.post_conv.focus();	
}

function setTextare()
{
	if(document.comv_message.post_conv.value == "reply here .... ")
	{
		document.comv_message.post_conv.value = ''; 
	}
	document.comv_message.post_conv.style.color = "#000";
}

function replyFromOther()
{
	document.conv_home.submit();
}
/* for Openinviter */
function toggleAll(element) 
{
	var form = document.forms.openinviter;
	var z = 0;
	for(z=0; z<form.length; z++)
	{
	if(form[z].type == 'checkbox')
		form[z].checked = element.checked;
	}
}

function displayList(opr,providerType)
{
    if(opr == 'show')
        document.getElementById('pList').style.display = '';
    else
        document.getElementById('pList').style.display = 'none';
    
    if(providerType == 'others')
        document.getElementById("providerType").innerHTML= "";
    else
        document.getElementById("providerType").innerHTML= "<input type='hidden' name='provider_box' value='"+providerType+"'/>";
}

function composeMessage(display)
{
    if(display == 'no')
        document.getElementById('compose_msg').style.display = 'none';
    else
        document.getElementById('compose_msg').style.display = '';
}

function mailAjax(sendurl)
{
    var xmlHttp;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    var url = sendurl+"/mailAjax.php";
    var fwEmail = document.sendMail.forward_email.value;
    var params = "fwEmail="+fwEmail;

    xmlHttp.open("POST", url, true);

    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            document.getElementById("forward_email").innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.send(params);
}

function jobAlert(alerttype)
{
	if(alerttype == 'show')
	{
		document.getElementById('jobAlert2').style.display = '';
		document.getElementById('jobAlert1').style.display = 'none';
	}
	else
	{
		document.getElementById('jobAlert2').style.display = 'none';
		document.getElementById('jobAlert1').style.display = '';
	}
}

function jobAlertAjax(sendurl)
{
    var xmlHttp;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
   var url = sendurl+"/jobAlerts.php";
    var altEmail = document.jobAlertfrm.alert_email.value;
    var idCity = document.jobAlertfrm.id_city.value;
	var Cityname = document.jobAlertfrm.city_name.value;
    var idCategory = document.jobAlertfrm.id_category.value;
    var idKeyword = document.jobAlertfrm.id_keyword.value;
    var searchText = document.jobAlertfrm.search_keyword.value;    
    var idState = document.jobAlertfrm.id_state.value;    

    var params = "alertEmail="+altEmail+"&idCity="+idCity+"&Cityname="+Cityname+"&idCategory="+idCategory+"&idKeyword="+idKeyword+"&searchText="+searchText+"&idState="+idState;
    
    xmlHttp.open("POST", url, true);

    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.responseText == 'done')
            {
                document.getElementById('alert_detail').style.display = 'none';
                document.getElementById('alt_status').innerHTML='<span class="black"><b>Please check your email</b> - we have sent a confirmation message. <br/>Click on the link in this email to start receiving your job alerts.</span>';
            }
            else
            {
                document.getElementById('alt_status').innerHTML=xmlHttp.responseText;
            }
        }
    }
    xmlHttp.send(params);
}
function public_profile_currnet_position(chid,imgid)
{
    if(document.frmPublicProfile.currnet_position.checked)
    {
        document.frmPublicProfile.currnet_position_detail.checked = true;
        ShowImage(chid,'pic_work_experience1');
    }
    ShowImage(chid,imgid);
}

function public_profile_past_position(chid,imgid)
{
    if(document.frmPublicProfile.past_position.checked)
    {
        document.frmPublicProfile.past_position_detail.checked = true;
        ShowImage(chid,'pic_work_experience2');
    }
    ShowImage(chid,imgid);
}

function public_profile_education(chid,imgid)
{
    if(document.frmPublicProfile.education.checked)
    {
        document.frmPublicProfile.education_detail.checked = true;
        ShowImage(chid,'pic_education_qualification');
    }
    ShowImage(chid,imgid);
}

function ShowImage(chid,imgid)
{
    var chBox = "document.frmPublicProfile."+chid+".checked";
    if(eval(chBox))
        eval("document.getElementById('"+imgid+"').style.display = 'block';");
    else
        eval("document.getElementById('"+imgid+"').style.display = 'none';");

    if(imgid == 'pic_websites' && eval(chBox) && chid == 'websites')
        document.getElementById('pic_additional_Information_websites').style.display = 'block';
    if(imgid == 'pic_websites' && !eval(chBox) && chid == 'websites')
        document.getElementById('pic_additional_Information_websites').style.display = 'none';
}

function choosePassword(choosepass)
{
    if(choosepass.reg_pass.value == '')
    {
        alert('Please Enter Password');
        choosepass.reg_pass.focus();
        return false;
    }
 
    else if(choosepass.reg_pass.value.length < 6)
    {
        alert('Password must be at least 6 characters');
        choosepass.reg_pass.focus();
        return false;
    }
   
    if(choosepass.reg_conf_pass.value == '')
    {
        alert('Please Enter Confirm Password');
        choosepass.reg_conf_pass.focus();
        return false;
    }      

    else if(choosepass.reg_conf_pass.value.length < 6)
    {
        alert('Password must be at least 6 characters');
        choosepass.reg_conf_pass.focus();
        return false;
    }

    if(choosepass.reg_pass.value != choosepass.reg_conf_pass.value)
    {
        alert('Your confirm password does not match');
        choosepass.reg_conf_pass.focus();
        return false;
    }

    return true;
}
function chkAllwatchedAd()
{
    var tot = document.getElementById('chAll').value;
    for(var i=0;i<tot;i++)
    {
        ch = 'ch'+i;
        if(document.getElementById('chAll').checked)
            document.getElementById(ch).checked = true;
        else
            document.getElementById(ch).checked = false;
    }
}
function deletecheck()
{
    var tot = document.getElementById('chAll').value;
    var flag = false;
    var cnf;
    for(var i=0;i<tot;i++)
    {
        ch = 'ch'+i;
        if(document.getElementById(ch).checked)
            flag = true;
    }
    if(flag)
    {
        cnf = confirm('Are you sure to delete Ads from Watch List !!!');
        if(cnf)
            return true;
        else
            return false;
    }
    else
    {
        alert('Please select at least One Ad to delete');
        return false;
    }
}

function alertMultipleCity(cityId,stateName)
{
    document.eidtAler.city_id.value=cityId;
    document.getElementById('state_name').innerHTML='(state : '+stateName+')';
}

function confirmAction(msg)
{
    if(confirm(msg)) return true;
    return false;
}

function checkContactUs(confrm)
{
    if(confrm.first_name.value == '')
    {
        alert('Please enter first name');
        confrm.first_name.focus();
        return false;
    }

    if(confrm.contact_email.value == '')
    {
        alert('Please enter your email address');
        confrm.contact_email.focus();
        return false;
    }
    else if(confrm.contact_email.value != '')
    {
        if(!(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(confrm.contact_email.value)))
        {
            alert('Please enter valid email address ');
            confrm.contact_email.focus();
            return false;
        }
    }

    if(confrm.contact_msg.value == '')
    {
        alert('Please enter message');
        confrm.contact_msg.focus();
        return false;
    }

    if(confrm.contact_security_code.value == '')
    {
        alert('Please enter word verification');
        confrm.contact_security_code.focus();
        return false;
    }

    return true;
}
function cityShowHide(displayType)
{
    if(displayType == 'Y')
    {
        document.getElementById('parent_city').style.display='';
    }
    else
    {
        document.getElementById('parent_city').style.display='none';
    }    

    document.getElementById('rssURL').style.display='';
    document.getElementById('buttonDis').colSpan=3;    
}

function parentCity()
{
    document.getElementById('parent_city').style.display='none';
    document.getElementById('rssURL').style.display='none';
    document.getElementById('buttonDis').colSpan=2;    
}

function signinBox(displayVal)
{
    if(displayVal == 'Y')
    {
        document.getElementById('signInBox').style.display = '';
    }
    else
    {
        document.getElementById('signInBox').style.display = 'none';
    }
}

function ajaxSignin()
{
    var xmlHttp;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    var url = "/ajaxSignin.php";
    var sEmail = document.Singin.email.value;
    var sPassword = document.Singin.spassword.value;
    var params = "email_id="+sEmail+"&password="+sPassword;

    xmlHttp.open("POST", url, true);

    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.responseText == 'done')
            {
                window.location.reload();
                var openUrl=document.Singin.url_open.value;
                window.open(openUrl);
            }
            else
            {
                document.getElementById('returnMsgSign').innerHTML=xmlHttp.responseText;
            }
        }
    }
    xmlHttp.send(params);
}

function ajaxRegister()
{
    var xmlHttp;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e)
            {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    var url = "/ajaxRegister.php";
    var rFirstName=document.registerfrm.firstname.value;
    var rLastName=document.registerfrm.lastname.value;
    var rNickName=document.registerfrm.nickname.value;
    var rjobTtl=document.registerfrm.job_title.value;
    var rCountry=document.registerfrm.country.value;
    var rIndustry=document.registerfrm.industrytype.value;
    var rEmail=document.registerfrm.useremail.value;
    var rPassword=document.registerfrm.userpassword.value;
    var rVerify=document.registerfrm.register_security_code.value;
    var params = "fname="+rFirstName+"&lname="+rLastName+"&nickname="+rNickName+"&jobttl="+rjobTtl+"&country="+rCountry+"&industry="+rIndustry+"&email="+rEmail+"&pass="+rPassword+"&imgcode="+rVerify;

    xmlHttp.open("POST", url, true);

    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close");

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if(xmlHttp.responseText == 'done')
            {
                window.location='/userhome.html';
                var openUrl=document.registerfrm.url_open.value;
                window.open(openUrl);
            }
            else
            {
                document.getElementById('returnMsg').innerHTML=xmlHttp.responseText;
            }
        }
    }
    xmlHttp.send(params);
}