// JavaScript Document
//var split_word = '|||';
//Create an array
var allPageTags = new Array();

function call_ajax_profile_region_url(url)
	{
		var obj = document.getElementById('city_ajax_id');
    	obj.innerHTML='';
    	obj.style.display='none';
    	var obj = document.getElementById('region_ajax_id');
    	obj.innerHTML='';
    	obj.style.display='none';
    	obj.innerHTML = 'retreiving cities...';
    	obj.style.display='block';
    	box = document.forms['form_profile'].country;
    	var countryValue = box.options[box.selectedIndex].value;
		url = siteURL + url +'?country_code='+countryValue;
		new AG_ajax(url,'call_ajax_profile_region_show');
		return false;
	}

function call_ajax_profile_region_show(data)
	{
		data = unescape(data);
		var obj = document.getElementById('region_ajax_id');
        if(obj!=null)
			{
				obj.innerHTML = data;
				obj.style.display = 'block';
				return(false);
			}
		else
			{
				location.replace(replace_url);return;
			}
    }
function call_ajax_profile_city_url(url)
	{
		var obj = document.getElementById('city_ajax_id');
    	obj.innerHTML='';
    	obj.style.display='none';
    	obj.innerHTML = 'retreiving cities...';
    	obj.style.display='block';
    	box = document.forms['form_profile'].region;
    	var data = box.options[box.selectedIndex].value;
    	regValue = data.substr(0,data.indexOf('##--##'));
		var end = data.indexOf('##++##');
		var start = data.indexOf('##--##')+6;
		var diff = end - start;
		countryValue = data.substr(data.indexOf('##--##')+6, diff);
		url = siteURL + url +'?region_code='+regValue+'&country_code='+countryValue;
		new AG_ajax(url,'call_ajax_profile_city_show');
		return false;
	}
function call_ajax_profile_city_show(data)
	{
		data = unescape(data);
		var obj = document.getElementById('city_ajax_id');
		if(obj!=null)
			{
				obj.innerHTML = data;
				obj.style.display = 'block';
				return(false);
			}
		else
			{
				location.replace(replace_url);return;
			}
    }
/**
 *
 * @access public
 * @return void
 **/
function showCountry(){
	var obj = document.getElementById('country_id_add');
    if(obj != null)
		obj.style.display='none';
    var obj = document.getElementById('region_ajax_id_add');
    if(obj != null)
		obj.innerHTML='';
    var obj = document.getElementById('city_ajax_id_add');
    if(obj != null)
		obj.innerHTML='';
    var obj = document.getElementById('country_id');
    obj.style.display='block';
    var obj = document.getElementById('addNewCity');
    obj.style.display='block';
}

  function hideFields()
      {
      		box = document.forms['form_profile'].city_list;
    		var newCity = box.options[box.selectedIndex].value;
 			cityId = newCity.substr(0,newCity.indexOf('##--##'));
			cityName = newCity.substr(newCity.indexOf('##--##')+6, newCity.length);
			document.getElementById('city').value = cityId;
			var obj = document.getElementById('city_display');
			obj.innerHTML = cityName;
			var obj = document.getElementById('country_id');
    	  	obj.style.display='none';
    	  	var obj = document.getElementById('addNewCity');
    		if(obj != null)
				obj.style.display='none';
    		var obj = document.getElementById('region_ajax_id');
    	  	obj.innerHTML='';
    	  	obj.style.display='none';
    		var obj = document.getElementById('city_ajax_id');
    	  	obj.innerHTML='';
    	  	obj.style.display='none';
    	  	var obj = document.getElementById('changeCountry');
    	  	obj.style.display='block';
      }

/**
 *
 * @access public
 * @return void
 **/
function showField()
{
	if(document.getElementById('type_audio').checked === true)
		{
			document.getElementById('selectVideo').style.display = 'none';
			document.getElementById('selectAlbum').style.display = 'none';
			document.getElementById('selectAudio').style.display = 'block';
		}
	else if(document.getElementById('type_video').checked === true)
		{
			document.getElementById('selectAudio').style.display = 'none';
			document.getElementById('selectAlbum').style.display = 'none';
			document.getElementById('selectVideo').style.display = 'block';
		}
	else if(document.getElementById('type_album').checked === true)
		{
			document.getElementById('selectAudio').style.display = 'none';
			document.getElementById('selectVideo').style.display = 'none';
			document.getElementById('selectAlbum').style.display = 'block';
		}
}

function showUpload()
{
	if(Trim(document.getElementById('album_title').value) == '')
		{
			var obj = document.getElementById('showMultiple');
			//obj.innerHTML = "<table><tr><td class=\"clsFormLabelCellError\"><label for=\"album_title\">Album title</label></td><td class=\"clsFormFieldCellError\"><span class=\"clsFormFieldErrTip\">Compulsory</span><input name=\"album_title\" id=\"album_title\" tabindex=\"1045\" value=\"\" type=\"text\"></td></tr><tr><td colspan=\"2\" class=\"clsFormFieldCellDefault\"><input class=\"clsProfileButton\" name=\"profile_submit\" id=\"profile_submit\" tabindex=\"1050\" value=\"Submit\" onclick=\"showUpload()\" type=\"button\"></td></tr></table>";
			obj.innerHTML = "<table class=\"clsFormTable clsPPAddContentTbl\"><tr><td class=\"clsFormLabelCellError\"><label for=\"album_title\">Album title</label></td><td class=\"clsFormFieldCellError\"><span class=\"clsFormFieldErrTip\">Compulsory</span><input name=\"album_title\" id=\"album_title\" tabindex=\"1045\" value=\"\" type=\"text\"></td></tr><tr><td><label for=\"album_description\">Description</label></td><td><textarea name=\"album_description\" id=\"album_description\" tabindex=\"1045\" value=\"\"></textarea></td></tr><tr><td colspan=\"2\" class=\"clsFormFieldCellDefault\"><input class=\"clsProfileButton\" name=\"profile_submit\" id=\"profile_submit\" tabindex=\"1050\" value=\"Submit\" onclick=\"showUpload()\" type=\"button\"></td></tr></table>";
			return false;
		}
	else
		{
			var title = document.getElementById('album_title').value;
			var description=escape(document.getElementById('album_description').value);
			url = siteURL + 'members/profilePortfolio_ajax.php' +'?title='+title+'&description='+description;
			new AG_ajax(url,'call_showUpload');
			return false;
		}
}

function call_showUpload(data)
{
	data = unescape(data);
	var obj = document.getElementById('showMultiple');
	if(obj!=null)
		{
			obj.innerHTML = data;
			return false;
		}
	else
		{
			location.replace(replace_url);return;
		}
}
function call_ajax_show_address(url)
	{
		var fromcv="";
		if(document.getElementById('personal_info').checked)
		{
			fromcv="78e9e8t";
		}
		var obj = document.getElementById('showAddress');
		obj.innerHTML = '';
		url = siteURL + url+'?fromcv='+fromcv;
		new AG_ajax(url,'call_ajax_address_show');
		return true;
	}
function call_ajax_address_show(data)
	{
		data = unescape(data);
		var obj = document.getElementById('showAddress');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}

function call_ajax_city_list(url)
	{
		var obj = document.getElementById('ajax_city_id');
		obj.innerHTML = '';
		country = document.form_profile.country;
		country_code = country.options[country.selectedIndex].value;
		region = document.form_profile.region_list;
		region_code = region.options[region.selectedIndex].value;
		url = siteURL + url + '?region_code=' + region_code +'&country_code=' + country_code;
		new AG_ajax(url,'call_ajax_city_show');
		return false;

	}
function call_ajax_city_show(data)
	{
		data = unescape(data);
		var obj = document.getElementById('ajax_city_id');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}

function replaceImage(albumid, photoid)
{
	url = siteURL + 'members/profilePortfolio_ajax.php' +'?albumid='+albumid+'&photoid='+photoid;
	new AG_ajax(url,'call_replaceImage');
	return false;
}

function call_replaceImage(data)
{
	data = unescape(data);
	var obj = document.getElementById('ajaxImageUpdate');
	if(obj!=null)
		{
			obj.innerHTML = data;
			return false;
		}
	else
		{
			location.replace(replace_url);return;
		}
}
function call_ajax_add_work()
	{

		var obj = document.getElementById('addWorkTable');
		//obj.innerHTML = '';
		var company = document.form_profile.company.value;
		var position = document.form_profile.position.value;

		var temp=position;
		var pattern=/[\!\@\#\$\%\^\&\*\(\)\-\+\=\{\}\?\/\\\~\`\'\"]/;
		var reg = new RegExp(pattern);
		if(reg.test(temp))
		 {
		alert('Please select a valid name');
		return false;
		  }


		var fromdate = document.form_profile.fromdate.value;
		var todate = document.form_profile.todate.value;
		var industry = document.form_profile.industryid;
		var industryid = industry.options[industry.selectedIndex].value;
		var position_desc = document.form_profile.position_desc.value;
		url = siteURL + 'members/addWork_ajax.php' + '?company=' + company +'&position=' + position+'&fromdate=' + fromdate+'&todate=' + todate+'&industryid=' + industryid+'&position_desc=' + position_desc+'&add_work_submit=add_work_submit';
		new AG_ajax(url,'call_ajax_addwork_show');
		return false;

	}
function call_ajax_addwork_show(data)
	{
		var obj = document.getElementById('addWorkTable');
		obj.innerHTML = '';
		data = unescape(data);
		if (data == 'PASS')
			{

				parent.document.location = 'profileProfessional.php';
			}
		var obj = document.getElementById('addWorkTable');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}
function call_ajax_edit_work(editid)
	{

		url = siteURL + 'members/addWork_ajax.php' + '?editid=' + editid;
		new AG_ajax(url,'call_ajax_work_show');
		return false;

	}
function call_ajax_edit_work_submit(editid)
	{
		var company = document.form_profile.company.value;
		var position = document.form_profile.position.value;
		var fromdate = document.form_profile.fromdate.value;
		var todate = document.form_profile.todate.value;
		var industryid = document.form_profile.industryid.value;
		//var industryid = industry.options[industry.selectedIndex].value;
		var position_desc = document.form_profile.position_desc.value;
		url = siteURL + 'members/addWork_ajax.php' + '?company=' + company +'&editid=' + editid+'&position=' + position+'&fromdate=' + fromdate+'&todate=' + todate+'&industryid=' + industryid+'&position_desc=' + position_desc+'&edit_work_submit=edit_work_submit';
		new AG_ajax(url,'call_ajax_work_show');
		return false;
	}
function call_ajax_delete_work(deleteid)
	{

		var answer = confirm("Are you sure you want to delete?");
		if (answer)
			{
			url = siteURL + 'members/addWork_ajax.php' + '?deleteid=' + deleteid;
			new AG_ajax(url,'call_ajax_work_show');
			return false;
			}
			else
				return false;


	}
function call_ajax_work_show(data)
	{

		var obj = document.getElementById('addWorkTable');
		obj.innerHTML = '';
		data = unescape(data);
		if (data == 'PASS')
			{

				parent.document.location = 'index.php?url=profileProfessional.php';
			}
		var obj = document.getElementById('addWorkTable');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}

function call_ajax_add_edu()
	{

		var institutename = document.form_profile.institutename.value;

		var temp=institutename;
		var pattern=/[\!\@\#\$\%\^\&\*\(\)\-\+\=\{\}\?\/\\\~\`\'\"]/;
		var reg = new RegExp(pattern);
		if(reg.test(temp))
		 {
		alert('Please select a valid name');
		return false;
		  }

		var from_year = document.form_profile.from_year.value;
		var to_year = document.form_profile.to_year.value;
		var education = document.form_profile.education_id;
		var education_id = education.options[education.selectedIndex].value;
		//var education_desc = document.form_profile.education_desc.value;
		url = siteURL + 'members/addEducation_ajax.php' + '?institutename=' + institutename +'&education_id=' + education_id+'&from_year=' + from_year+'&to_year=' + to_year+'&add_education_submit=add_education_submit';
		new AG_ajax(url,'call_ajax_addedu_show');
		return false;

	}
function call_ajax_addedu_show(data)
	{

		var obj = document.getElementById('addEducationTable');
		obj.innerHTML = '';
		//var obj = document.getElementById('showEduTable');
		//obj.innerHTML = '';
		data = unescape(data);
		if (data == 'PASS')
			{

				parent.document.location = 'profileProfessional.php';
			}
		var obj = document.getElementById('addEducationTable');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}

function call_ajax_edit_edu(editid)
	{

		//var obj = document.getElementById('showEduTable');
		//obj.innerHTML = '';

		url = siteURL + 'members/addEducation_ajax.php' + '?editid=' + editid;
		new AG_ajax(url,'call_ajax_editedu_show');
		return false;

	}
function call_ajax_editedu_show(data)
	{

		var obj = document.getElementById('addEducationTable');
		obj.innerHTML = '';
		data = unescape(data);
		if (data == 'PASS')
			{

				parent.document.location = 'index.php?url=profileProfessional.php';
			}
		var obj = document.getElementById('addEducationTable');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}
function call_ajax_edit_edu_submit(editid)
	{
		var institutename = document.form_profile.institutename.value;

		var temp=institutename;
		var pattern=/[\!\@\#\$\%\^\&\*\(\)\-\+\=\{\}\?\/\\\~\`\'\"]/;
		var reg = new RegExp(pattern);
		if(reg.test(temp))
		 {
		alert('Please select a valid name');
		return false;
		  }

		var from_year = document.form_profile.from_year.value;
		var to_year = document.form_profile.to_year.value;
		var education = document.form_profile.education_id;
		var education_id = education.options[education.selectedIndex].value;
		//var education_desc = document.form_profile.education_desc.value;
		url = siteURL + 'members/addEducation_ajax.php' + '?institutename=' + institutename +'&editid=' + editid+'&education_id=' + education_id+'&from_year=' + from_year+'&to_year=' + to_year+'&edit_education_submit=edit_education_submit';
		new AG_ajax(url,'call_ajax_edit_edu_submit_show');
		return false;



	}
function call_ajax_edit_edu_submit_show(data)
	{

		var obj = document.getElementById('addEducationTable');
		obj.innerHTML = '';
		data = unescape(data);
		if (data == 'PASS')
			{

				parent.document.location = 'index.php?url=profileProfessional.php';
			}
		var obj = document.getElementById('addEducationTable');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}
function call_ajax_delete_edu(deleteid)
	{

		var answer = confirm("Are you sure you want to delete?");
		if (answer)
			{
			url = siteURL + 'members/addEducation_ajax.php' + '?deleteid=' + deleteid;
			new AG_ajax(url,'call_ajax_delete_edu_show');
			return false;
			}
			else
				return false;


	}
function call_ajax_delete_edu_show(data)
	{

		var obj = document.getElementById('addEducationTable');
		obj.innerHTML = '';
		data = unescape(data);
		if (data == 'PASS')
			{

				parent.document.location = 'index.php?url=profileProfessional.php';
			}
		var obj = document.getElementById('addEducationTable');
		if(obj!=null)
			{
				obj.innerHTML = data;
			}
	}

function checkIndustry()

{
	if(document.getElementById('position').value == '')

		{

			alert('Please enter title');

			return false;

		}
	else if(document.getElementById('member_comp').value != '' && (document.getElementById('member_company').value  == '' || document.getElementById('member_company').value  == 0))

		{
			alert('Please select Valid Profile Company,otherwise add new company');

			return false;

		}
	else

		{

/*			if(document.getElementById('addEduTable').style.display == 'block')

				{

						if(document.getElementById('industryid').value == '')

							{

								alert('Please select industry in Experience');

								return false;

							}

						else

							{

								return true;

							}

				}*/

			return true;

		}

}


function openNewCompanyForm(id, companyNameid)
{
	var companyVal = document.getElementById(id).value;
	var companyNameVal = document.getElementById(companyNameid).value;

 	if ((companyVal == 0 || companyVal == '')/* && (companyNameVal == 'Add New Company')*/)
		return true;
	return false;
}// EOF openNewCompanyForm()

