// 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)

		{

			showDefaultUpload();

			document.getElementById('selectAudio').style.display = 'none';

			document.getElementById('selectVideo').style.display = 'none';

			document.getElementById('selectAlbum').style.display = 'block';

		}

}



function showUploadAudioVideo()

{

	var loadingImg = document.getElementById('loadingImg');

	var loadingTxt = document.getElementById('loadingText');

	if(loadingImg != null)

		loadingImg.src = '../images/loadingTiny.gif';

	if(loadingTxt != null)

		loadingTxt.innerHTML = 'Filerna laddas nu upp och processas. Det kan ta några minuter...';

	return true;

}



function showUpload()

{

	var rad_val="";

	var yes="";

	var no="";

	var loadingImg = document.getElementById('loadingImg');

	var loadingTxt = document.getElementById('loadingText');

	if(loadingImg != null)

		loadingImg.src = '../images/loadingTiny.gif';

	if(loadingTxt != null)

		loadingTxt.innerHTML = 'processas....';

	if(Trim(document.getElementById('album_title').value) == '')

		{

			var obj = document.getElementById('showMultiple');

			var description=document.getElementById('album_description').value;

			for (var i=0; i < document.form_profile.album_download.length; i++)

			   {

			   if (document.form_profile.album_download[i].checked)

			      {

			       rad_val = document.form_profile.album_download[i].value;

			      }

			   }

			if(rad_val=="Yes")

				var yes="checked=\"checked\"";

			else

				var no="checked=\"checked\"";



			//obj.innerHTML = "<table><tr><td class=\"clsFormLabelCellError\"><label for=\"album_title\">Albumtitel</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\" id=\"selectAlbum\"><tr><td class=\"clsFormLabelCellError\"><label for=\"album_title\">Albumtitel</label></td><td class=\"clsFormFieldCellError\"><span class=\"clsFormFieldErrTip\">Obligatoriskt</span><input name=\"album_title\" id=\"album_title\" tabindex=\"1045\" value=\"\" type=\"text\"></td></tr><tr><td><label for=\"album_description\">Beskrivning</label></td><td><textarea name=\"album_description\" id=\"album_description\" tabindex=\"1045\" value=\"\">"+description+"</textarea></td></tr><tr><td><label for=\"album_download\">Ladda ned</label></td><td><input type=\"radio\" name=\"album_download\" id=\"album_download\" tabindex=\"1048\" value=\"Yes\" "+yes+" />Ja<input type=\"radio\" name=\"album_download\" id=\"album_download\" tabindex=\"1050\" value=\"No\" "+no+"/>Nej</td></tr><tr><td colspan=\"2\" class=\"clsFormFieldCellDefault\"><input class=\"clsProfileButton\" name=\"profile_submit\" id=\"profile_submit\" tabindex=\"1050\" value=\"Fortsätt\" onclick=\"showUpload()\" type=\"button\"></td></tr></table>";

		}

	else

		{



			var title = document.getElementById('album_title').value;

			var description=escape(document.getElementById('album_description').value);

			for (var i=0; i < document.form_profile.album_download.length; i++)

			   {

			   if (document.form_profile.album_download[i].checked)

			      {

			       rad_val = document.form_profile.album_download[i].value;

			      }

			   }

			url = siteURL + 'members/profilePortfolio_ajax.php' +'?title='+title+'&description='+description+'&download='+rad_val;



			new AG_ajax(url,'call_showUpload');

		}

	if(loadingImg != null)

		loadingImg.src = '../images/pixel.gif';

	if(loadingTxt != null)

		loadingTxt.innerHTML = '';

	return false;

}



function showDefaultUpload()

{

	var obj = document.getElementById('showMultiple');

	var description = '';

	var yes = "checked=\"checked\"";

	var no = "";

	obj.innerHTML = "<table class=\"clsFormTable clsPPAddContentTbl\" id=\"selectAlbum\"><tr><td class=\"clsFormLabelCellDefault\"><label for=\"album_title\">Albumtitel</label></td><td class=\"clsFormFieldCellDefault\"><input name=\"album_title\" id=\"album_title\" tabindex=\"1045\" value=\"\" type=\"text\"></td></tr><tr><td><label for=\"album_description\">Beskrivning</label></td><td><textarea name=\"album_description\" id=\"album_description\" tabindex=\"1045\" value=\"\">"+description+"</textarea></td></tr><tr><td><label for=\"album_download\">Ladda ned</label></td><td><input type=\"radio\" name=\"album_download\" id=\"album_download\" tabindex=\"1048\" value=\"Yes\" "+yes+" />Ja<input type=\"radio\" name=\"album_download\" id=\"album_download\" tabindex=\"1050\" value=\"No\" "+no+"/>Nej</td></tr><tr><td colspan=\"2\" class=\"clsFormFieldCellDefault\"><input class=\"clsProfileButton\" name=\"profile_submit\" id=\"profile_submit\" tabindex=\"1050\" value=\"Fortsätt\" onclick=\"showUpload()\" type=\"button\"></td></tr></table>";

}



function showUploadEdit(albumid)

{

	var loadingImg = document.getElementById('loadingImg');

	var loadingTxt = document.getElementById('loadingText');

	if(loadingImg != null)

		loadingImg.src = '../images/loadingTiny.gif';

	if(loadingTxt != null)

		loadingTxt.innerHTML = 'processas....';



	url = siteURL + 'members/profilePortfolio_ajax.php' +'?albumid='+albumid;

	new AG_ajax(url,'call_showUpload');



	if(loadingImg != null)

		loadingImg.src = '../images/pixel.gif';

	if(loadingTxt != null)

		loadingTxt.innerHTML = '';

	return false;

}



function showUploadDelete(albumid, photoid)

{

	if(confirm("Är du säker på att du vil radera filen permanent?"))

		{

       		var loadingImg = document.getElementById('loadingImgDelete'+photoid);

			var loadingTxt = document.getElementById('loadingTextDelete'+photoid);

			if(loadingImg != null)

				loadingImg.src = '../images/loadingTiny.gif';

			if(loadingTxt != null)

				loadingTxt.innerHTML = 'processas....';



			url = siteURL + 'members/profilePortfolio_ajax.php' +'?albumid='+albumid+'&delete='+photoid;

			new AG_ajax(url,'call_showUpload');

			return false;

    	}

	else

		{

       		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;

			}

	}

/* Code Put by Shadab For New Task 6 */ 
function call_ajax_likedportfolio_list(portfolioid,indutryid,startlimit,randomly) {
	this.test_portfolioid = portfolioid ;
	//alert(portfolioid);
	url = siteURL + 'members/index_ajax.php' +'?liked_portfolio='+portfolioid+'&industryID='+indutryid+'&startlimit='+startlimit+'&randomly='+randomly;

	new AG_ajax(url,'call_ajax_likedportfolio_show');

	return false;

}

function call_ajax_likedportfolio_show(data,portfolioid){
	//alert(data+'==========='+test_portfolioid);
	data = unescape(data);

	var obj = document.getElementById('liked_portfolio_'+test_portfolioid);

	if(obj!=null)	{
			obj.innerHTML = data;
			return false;
	}else{
			location.replace(replace_url);return;
		}
}


function call_jobsave(div,job_id,start) {
	//alert(div+job_id);
	//alert(start);
	//return false;
	this.job_divid = div+job_id;
	url = siteURL + 'members/index_ajax.php' +'?job_id='+job_id+'&start='+start;
	new AG_ajax(url,'call_ajax_jobsave');
	return false;
}

function call_ajax_jobsave(data){
	data = unescape(data);
	var obj = document.getElementById(job_divid);

	if(obj!=null)	{
			obj.innerHTML = '';
			obj.style.display = 'none';
			
			return false;
	}else{
			location.replace(replace_url);return;
	}
}
/* Code Put by Shadab Complete For New Task 6 */ 


function replaceImage(albumid, photoid, status)

{

	url = siteURL + 'members/profilePortfolio_ajax.php' +'?albumid='+albumid+'&photoid='+photoid+'&status='+status;

	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;
			initLightbox(); // Code Put By Chintan For Task 32
			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 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 = escape(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 industry = document.form_profile.industryid;

		var industryid = industry.options[industry.selectedIndex].value;

		var position_desc = escape(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 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 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 = escape(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+'&education_desc=' + education_desc+'&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 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 = escape(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+'&education_desc=' + education_desc+'&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 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 replaceRecentJob(start)

{



	url = siteURL + 'members/recentJob_ajax.php' +'?start='+start;

	new AG_ajax(url,'call_replaceRecentJob');

	return false;

}



function call_replaceRecentJob(data)

{

	data = unescape(data);



	var obj = document.getElementById('ajaxRecentJobUpdate');

	if(obj!=null)

		{

			obj.innerHTML = data;

			return false;

		}

	else

		{

			location.replace(replace_url);return;

		}

}







