/**
 * For Profile Basic Creation
 */
function find_image_loc(input_file_id, target_id, main_val)
{
	try {
		//$(target_id).value = $(input_file_id).value;
		$(target_id).value = main_val;
		$('profile_add_another_container').style.display = 'block';
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function profile_image_submit(curr_num, target_id)
{
try {
		var affiliationVal = $('profile_affiliation').value;
		if (affiliationVal !='') {
			if ($('warning_affiliation') != null) {
				$('warning_affiliation').innerHTML = "";
				$('warning_affiliation').style.display = "none";
			}
			
			$('submit_time').value = 'now';
			$(target_id).action = 'Pic_upload_review.php';
			$(target_id).submit();
		}
		else {
			if ($('warning_affiliation') != null) {
				$('warning_affiliation').innerHTML = "You must select an affiliation to continue.";
				$('warning_affiliation').style.display = "block";
				$('profile_affiliation').focus();
			}
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
	
}

function profile_image_add_another()
{
	$('profile_add_another_container').style.display = 'none';
	$('profile_image_upload_container').style.display = 'block';
}

function profile_check_basic(target_id)
{
	try {
		var affiliationVal = $('profile_affiliation').value;
		if (affiliationVal !='') {
			if ($('warning_affiliation') != null) {
				$('warning_affiliation').innerHTML = "";
				$('warning_affiliation').style.display = "none";
			}
			
			$('submit_time').value = 'now';
			$(target_id).action = 'Pic_upload_review.php';
			$(target_id).submit();
		}
		else {
			if ($('warning_affiliation') != null) {
				$('warning_affiliation').innerHTML = "You must select an affiliation to continue.";
				$('warning_affiliation').style.display = "block";
				$('profile_affiliation').focus();
			}
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function profile_back_metadata_entry( target_id )
{
	$('submit_time').value = 'back';
	$(target_id).action = 'Profile_ContentSubmission.php';
	$(target_id).submit();
}

function profile_back_metadata_submission( target_id )
{
	$('submit_time').value = 'back';
	$(target_id).action = 'Profile_MetaDataEntry.php';
	$(target_id).submit();
}
function back_to_previous( target_id,frmname )
{

	document.getElementById('submit_time').value = 'back';
	$(frmname).action = target_id;
	$(frmname).submit();
}
function profile_cop_sub_cat_options( arg )
{
	try {
		if( arg == 38 ) { // For COP Category being "Other"
			$('profile_cop_text').style.display = 'none';
			$('profile_cop_sub_cat_container').style.display = 'none';
			$('profile_cop_other_container').style.display = 'block';
		}
		else {
			var target_id = "profile_cop_sub_cat";
			var queryStr = "arg=" + arg;
			var url = 'ajax/profile_cop_sub_cat.php';
			
			var myAjax = new Ajax.Updater(target_id, url,
			{
				method: 'post',
				parameters: queryStr,
				onLoading: function () {
				},
				onComplete: function () {
				},
				onSuccess: function(req) {
					var response_text = req.responseText;
					if( response_text != '' ) {
						$('profile_cop_text').style.display = 'block';
						$('profile_cop_sub_cat_container').style.display = 'block';
						$('profile_cop_other_container').style.display = 'none';
					}
					else {
						$('profile_cop_text').style.display = 'block';
						$('profile_cop_sub_cat_container').style.display = 'none';
						$('profile_cop_other_container').style.display = 'none';
					}
				},
				onFailure: function (req)
				{
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function profile_place_passing_change()
{
	try {
		if( $('place_passing_us_container').style.display == 'block' ) {
			$('place_passing_switch').innerHTML = 'switch to U.S.';
			$('place_passing_us_container').style.display = 'none';
			$('place_passing_inter_container').style.display = 'block';
		}
		else if( $('place_passing_us_container').style.display == 'none' ) {
			$('place_passing_switch').innerHTML = 'switch to international';
			$('place_passing_us_container').style.display = 'block';
			$('place_passing_inter_container').style.display = 'none';
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}
function open_search_ob()
{

// try {
// 		var fname = $('profile_fname').value;
// 		var lname = $('profile_lname').value;
// 		if ((fname != 'First' && fname != '') || (lname != 'Last' && lname != '')) {
// 
// 		
// 				var queryStr = "&fname=" +	encodeURIComponent(fname) +	"&lname=" +	encodeURIComponent(lname) ;
// 				/*var firstname = document.getElementById('profile_fname').value;
// 				var lastname = document.getElementById('profile_lname').value;
// 				var search_pop = document.getElementById(frmName).search_pop.value;*/
// 				//var queryStr = "firstname=" + firstname + "&lastname=" + lastname + "&search_pop=" + search_pop;
// 				var url = 'ajax/obiname_search.php';
// 				var myAjax = new Ajax.Updater('', url, {
// 					method: 'post',
// 					parameters: queryStr,
// 					onLoading: function(){
// 					},
// 					onComplete: function(){
// 					},
// 					onSuccess: function(req){
// 			
// 						// alert(req.responseText);
// 						var responseText = req.responseText;
// 						if(responseText == 'PopupShow')
// 						{
// 						var flname ='searchresult_obname.php?obfname='+fname+'&oblname='+lname;
// 						//MM_showHideLayers('obituary_name_popup_result', '', 'show');
// 						Mypopup('searchresult_obname.php?obfname='+fname+'&oblname='+lname,'Obituary',500,600);
// 						}
// 						if(responseText == 'SubmitData')
// 						{
// 							$('submit_time').value = 'now';
// 							$(target_id).action = 'Profile_MetadataSubmission.php';
// 							//$(target_id).submit();
// 						}
// 					},
// 					onFailure: function(req){
// 						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
// 			
// 					}
// 			
// 				});
// 				
// 			}
// 		}	
// 	 catch (e) {
// 		alert('An error has occurred: ' + e.message);
// 	}
}
function profile_check_metadata_entry(target_id)
{
	try {
		var fname = $('profile_fname').value;
		var lname = $('profile_lname').value;
		var mname = $('profile_mname').value;
		var niname = $('profile_niname').value;
		var other = $('profile_cop_other_text').value;
		var main_arg = $('profile_id').value;
		
		var dob_month = $('dob_month').value;
		var dob_date = $('dob_date').value;
		var dob_year = $('dob_year').value;
		
		var dop_month = $('dop_month').value;
		var dop_date = $('dop_date').value;
		var dop_year = $('dop_year').value;
		
		var cop_cat_id = $('profile_cop_cat').value;
		var cop_id = 0;
		




		if (fname == 'First' || lname == 'Last') {
			var name_focus_id = (fname == 'First') ? 'profile_fname' : (lname == 'Last' ? 'profile_lname' : 'profile_fname');
			
			alert("Please provide the Name of the Person you are contributing!");
			$(name_focus_id).focus();
			return false;
		}
		else if ( dob_month == 'MM' || dob_date == 'DD' || dob_year == 'YYYY' ) {
			var dob_focus_id = (dob_month == 'MM') ? 'dob_month' : (dob_date == 'DD' ? 'dob_date' : (dob_year == 'YYYY' ? 'dob_year' : 'dob_month'));
			
			alert("Please provide the Date of Birth!");
			$(dob_focus_id).focus();
			return false;
		}
		else if ( dop_month == 'MM' || dop_date == 'DD' || dop_year == 'YYYY' ) {
			var dop_focus_id = (dop_month == 'MM') ? 'dop_month' : (dop_date == 'DD' ? 'dop_date' : (dop_year == 'YYYY' ? 'dop_year' : 'dop_month'));
			
			alert("Please provide the Date of Passing!");
			$(dop_focus_id).focus();
			return false;
		}
		else {
			if (cop_cat_id == '' && cop_cat_id != 38) {
				alert("Please select Cause of Passing!");
				$('profile_cop_cat').focus();
				return false;
			}
			else {
				if ($('profile_cop_sub_cat_container').style.display == 'block' && $('profile_cop_other_container').style.display == 'none') {
					if (document.getElementsByName('profile_sub_cat') != null) {
						var cop_sub_cat_name = document.getElementsByName('profile_sub_cat');
						var num_cop_sub_cat_elements = cop_sub_cat_name.length;
						var default_checked = false;
						
						for (var counter = 0; counter < num_cop_sub_cat_elements; counter++) {
							if (cop_sub_cat_name[counter].checked == true) {
								cop_id = cop_sub_cat_name[counter].value;
								default_checked = true;
								break;
							}
						}
						
						if( default_checked == false ) {
							//alert("Please select any one of the Cause of Passing Sub-Categories!");
							//cop_sub_cat_name[0].focus();
							//return false;
							cop_id = cop_cat_id;
						}
					}
				}
				else if ($('profile_cop_sub_cat_container').style.display == 'none' && $('profile_cop_other_container').style.display == 'block') {
					cop_id = cop_cat_id;
					
					var cop_other = $('profile_cop_other_text').value;
					
					if( cop_other == '' ) {
						alert("Please enter keywords for COP!");
						$('profile_cop_other_text').focus();
						return false;
					}
					else {
						var cop_other_array = cop_other.split(',');
						if( cop_other_array.length > 4 ) {
							$('warning_profile_cop_other_text').style.display = 'block';
							$('profile_cop_other_text').focus();
							$('profile_cop_other_text').select();
							return false;
						}
						else {
							$('warning_profile_cop_other_text').style.display = 'none';
						}
					}
				}
				else { // For no Sub-Categories or Other option
					cop_id = cop_cat_id;
				}
				
				var gender = $('profile_gender_f').checked ? $('profile_gender_f').value : $('profile_gender_m').value;
				var ethnicity = $('profile_eth').value;
				
				var passing_country = $('profile_passing_country').value;
				var passing_city = $('profile_passing_city').value;
				var passing_zip = $('profile_passing_zip').value;
				
				var cop_hide = $('cop_hide').checked ? 'Y' : 'N';
				var edit_images = document.getElementById('edit_images').value;
				var queryStr = "main_arg=" + main_arg +
								"&fname=" +	encodeURIComponent(fname) +	"&lname=" +	encodeURIComponent(lname) +
								"&gender=" + gender + "&ethnicity=" + encodeURIComponent(ethnicity) +
								"&cop_id=" + cop_id + "&cop_hide=" + cop_hide +
								"&dob_year=" + dob_year + "&dob_month=" + dob_month + "&dob_date=" + dob_date +
								"&dop_year=" + dop_year + "&dop_month=" + dop_month + "&dop_date=" + dop_date +
								"&passing_country=" + encodeURIComponent(passing_country) + "&passing_city=" + encodeURIComponent(passing_city) + "&passing_zip=" + passing_zip + "&other=" + encodeURIComponent(other);
				/*var firstname = document.getElementById('profile_fname').value;
				var lastname = document.getElementById('profile_lname').value;
				var search_pop = document.getElementById(frmName).search_pop.value;*/
				//var queryStr = "firstname=" + firstname + "&lastname=" + lastname + "&search_pop=" + search_pop;


var queryStr1 = "fname="+ encodeURIComponent(fname)+"lname="+ encodeURIComponent(lname)+"mname="+ encodeURIComponent(mname)+"niname="+ encodeURIComponent(niname);
			var url1 = 'ajax/ob_badwords_check.php';
			var myAjax = new Ajax.Updater('', url1, {
			method: 'post',
				parameters: queryStr1,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
						if(edit_images == 'Yes')
							{
							$('submit_time').value = 'now';
							$(target_id).action = 'Profile_MetadataSubmission.php';
							$(target_id).submit();
							}
						else
						{
						var url = 'ajax/obiname_search.php';
						var myAjax = new Ajax.Updater('', url, {
							method: 'post',
							parameters: queryStr,
							onLoading: function(){
							},
							onComplete: function(){
							},
							onSuccess: function(req){
								// alert(req.responseText);
								var responseText = req.responseText;

								if(responseText == 'PopupShow')
								{
								document.getElementById('open_popup').value='Yes';
								//var flname ='searchresult_obname.php?obfname='+fname+'&oblname='+lname;
								MM_showHideLayers('obituary_name_popup_result', '', 'show');
								//document.getElementById('showduplicate').innerHTML = "Please click to check to ";
								//Mypopup('searchresult_obname.php?obfname='+fname+'&oblname='+lname,'Obituary',500,600);
								//$(target_id).submit();
								}
								
								if(responseText == 'SubmitData')
								{
									$('submit_time').value = 'now';
									$(target_id).action = 'Profile_MetadataSubmission.php';
									$(target_id).submit();
								}
							},
							onFailure: function(req){
							alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					
							}
					
						});
						
					}
					 
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);

				}

			});





			}
		}
	} catch (e) {
		alert('An error has occurred: ' + e.message);
	}
}
function obconfirm(target_id)
{
 var Confirmation = window.confirm("Do you want to continue the obituary creation?");
		if( Confirmation == true ) {
			$('submit_time').value = 'now';
			$(target_id).action = 'Profile_MetadataSubmission.php';
			$(target_id).submit();
		}
		else {
			document.getElementById('open_popup').value='';
			MM_showHideLayers('obituary_name_popup_result', '', 'hide');
		}
}
function profile_check_metadata_submission(target_id)
{
	try {
		var about_note = Trim( $('profile_about_note').value );
// 		if( about_note.length > 2500 ) {
// 			alert( "Please provide the note of a maximum of 2,500 characters!" );
// 			$('profile_about_note').focus();
// 			$('profile_about_note').select();
// 			return false;
// 		}
		
		var main_arg = $('profile_id').value;
		var org = $('org_selected_id').value;
		
		var occupation = new Array();
		var num_occupation_elements = $('profile_occup').length;
		for (var i = 0; i < num_occupation_elements; i++) {
			if ($('profile_occup')[ i ].selected) 
				occupation.push($('profile_occup')[ i ].value);
		}
		
		var hobbies = new Array();
		var num_hobbies_elements = $('profile_hobbies').length;
		for (var i = 0; i < num_hobbies_elements; i++) {
			if ($('profile_hobbies')[ i ].selected) 
				hobbies.push($('profile_hobbies')[ i ].value);
		}

		var school = $('profile_school').value;
		var religion = $('profile_religion').value;
		var links = $('profile_links').value;
		
		var grew_country = $('profile_grew_country').value;
		var grew_city = $('profile_grew_city').value;
		var grew_zip = $('profile_grew_zip').value;
		
		var queryStr = "main_arg=" + main_arg +
						"&occupation=" + occupation + "&hobbies=" + hobbies + "&org=" + org +
						"&grew_country=" + grew_country + "&grew_city=" + grew_city + "&grew_zip=" + grew_zip +
						"&school=" + school + "&religion=" + religion + "&links=" + links +
						"&about_note=" + about_note;

		$('submit_time').value = 'now';
		$(target_id).action = 'Profile_SubmissionConfirmation.php';
		$(target_id).submit();
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function profile_check_submission_confirm(target_id)
{
	try {
		var main_arg = $('profile_id').value;
		
		var queryStr = "main_arg=" + main_arg;
		var url = 'Profile_SubmissionSuccess.php';
		
		$('submit_time').value = 'now';
		$(target_id).action = 'Profile_SubmissionSuccess.php';
		$(target_id).submit();
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function find_charity(showHideArg_1, showHideArg_2, org_field, target_id)
{
	try {
		var org_keywords = $(org_field).value;
		var org_array = org_keywords.split(',');
		
		var queryStr = "org_keywords=" + org_keywords;
		var url = 'ajax/charity_search_result.php';
		
		var myAjax = new Ajax.Updater(target_id, url, {
			method: 'post',
			parameters: queryStr,
			onLoading: function(){
			},
			onComplete: function(){
			},
			onSuccess: function(req){
				var response_text = req.responseText;
				MM_showHideLayers(showHideArg_1, '', showHideArg_2);
			},
			onFailure: function(req){
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
			}
		});
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function change_charity_result()
{
	
}

function charity_selected_replacement(showHideArg_1, showHideArg_2, value_id)
{
	var org_id = 0;
	var org_name = '';
	var charity_result_obj = document.getElementsByName('charity_result_set');
	
	if( charity_result_obj != null ) {
		var num_charity_result_elements = charity_result_obj.length;
		var default_checked = false;
		
		for (var counter = 0; counter < num_charity_result_elements; counter++) {
			if (charity_result_obj[counter].checked == true) {
				org_id = charity_result_obj[counter].value;
				org_name = charity_result_obj[counter].title;
				default_checked = true;
				break;
			}
		}
		
		if( default_checked == false ) {
			MM_showHideLayers(showHideArg_1, '', showHideArg_2);
			$('charity_find_btn_container').style.display = 'block';
			$('charity_finished_container').style.display = 'none';
		}
		else if( org_id != 0 && org_name != '' ) {
			MM_showHideLayers(showHideArg_1, '', showHideArg_2);
			$('charity_find_btn_container').style.display = 'none';
			$('charity_finished_container').style.display = 'block';
			document.getElementById('add_chrty').style.display = 'none';
			$(value_id).value = org_id;
			$('charity_name_text').innerHTML = org_name;
		}
	}
}

function ob_creation_text_edit(arg_mode, arg_flag, arg_href_id, arg_val_show_id, arg_val_edit_container_id, arg_val_edit_box_id, ob_id_val, last_arg)
{
	try {
		if( arg_mode == 'edit' ) { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_text_edit('save', '" + arg_flag + "', '" + arg_href_id + "', '" + arg_val_show_id + "', '" + arg_val_edit_container_id + "', '" + arg_val_edit_box_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_text_edit('save', arg_flag, arg_href_id, arg_val_show_id, arg_val_edit_container_id, arg_val_edit_box_id, ob_id_val, last_arg)};
			$(arg_val_show_id).style.display = 'none';
			$(arg_val_edit_container_id).style.display = 'block';
		}
		else if( arg_mode == 'save' ) { // Save mode
			var main_val = $(arg_val_edit_box_id).value;ob_creation_text_edit
			
			var queryStr = "ajax_mode=text" + "&ajax_flag=" + arg_flag + "&last_arg=" + last_arg +
							"&ob_id=" + ob_id_val + "&main_val=" + encodeURIComponent( main_val );
// alert(queryStr);
			var url = 'ajax/obituary_creation_edit.php';
			
			var myAjax = new Ajax.Updater(arg_val_show_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
// 					alert(response_text);
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_text_edit('edit', '" + arg_flag + "', '" + arg_href_id + "', '" + arg_val_show_id + "', '" + arg_val_edit_container_id + "', '" + arg_val_edit_box_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_text_edit('edit', arg_flag, arg_href_id, arg_val_show_id, arg_val_edit_container_id, arg_val_edit_box_id, ob_id_val, last_arg)};
					$(arg_val_show_id).style.display = 'block';
					$(arg_val_edit_container_id).style.display = 'none';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_religion_edit(arg_mode, arg_href_id, ob_id_val, last_arg)
{
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_religion_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_religion_edit('save', arg_href_id, ob_id_val, last_arg)};
			$('ob_religion_value').style.display = 'none';
			$('ob_religion_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = $('ob_religion_edit_option').value;
			var target_id = 'ob_religion_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=dropdown" + "&ajax_flag=religion" +
							"&ob_id=" + ob_id_val + "&main_val=" + main_val + "&last_arg=" + last_arg;
			
			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_religion_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_religion_edit('edit', arg_href_id, ob_id_val, last_arg)};
					$('ob_religion_edit_container').style.display = 'none';
					$('ob_religion_value').style.display = 'block';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_hobbies_edit(arg_mode, arg_href_id, ob_id_val, last_arg)
{
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_hobbies_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_hobbies_edit('save', arg_href_id, ob_id_val, last_arg)};
			$('ob_hobbies_value').style.display = 'none';
			$('ob_hobbies_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = new Array();
			var num_main_val_elements = $('ob_hobbies_edit_option').length;
			for (var i = 0; i < num_main_val_elements; i++) {
				if ($('ob_hobbies_edit_option')[ i ].selected) 
					main_val.push($('ob_hobbies_edit_option')[ i ].value);
			}
			
			var target_id = 'ob_hobbies_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=dropdown" + "&ajax_flag=hobbies" + "&last_arg=" + last_arg +
							"&ob_id=" + ob_id_val + "&main_val=" + encodeURI( main_val );
			
			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_hobbies_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_hobbies_edit('edit', arg_href_id, ob_id_val, last_arg)};
					$('ob_hobbies_edit_container').style.display = 'none';
					$('ob_hobbies_value').style.display = 'block';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_org_edit(arg_mode, arg_href_id, ob_id_val, last_arg)
{
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_org_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_org_edit('save', arg_href_id, ob_id_val, last_arg)};
			$('ob_org_value').style.display = 'none';
			$('ob_org_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = $('ob_org_edit_option').value;
			var target_id = 'ob_org_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=dropdown" + "&ajax_flag=organization" +
							"&ob_id=" + ob_id_val + "&main_val=" + main_val + "&last_arg=" + last_arg;
			
			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_org_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_org_edit('edit', arg_href_id, ob_id_val, last_arg)};
					$('ob_org_edit_container').style.display = 'none';
					$('ob_org_value').style.display = 'block';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}


function ob_creation_affiliation_edit(arg_mode, arg_href_id, ob_id_val, last_arg)
{
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_affiliation_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_affiliation_edit('save', arg_href_id, ob_id_val, last_arg)};
			$('ob_affiliation_value').style.display = 'none';
			$('ob_affiliation_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = $('ob_affiliation_edit_option').value;
			var target_id = 'ob_affiliation_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=dropdown" + "&ajax_flag=affiliation" +
							"&ob_id=" + ob_id_val + "&main_val=" + main_val + "&last_arg=" + last_arg;

			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_affiliation_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_affiliation_edit('edit', arg_href_id, ob_id_val, last_arg)};
					$('ob_affiliation_value').style.display = 'block';
					$('ob_affiliation_edit_container').style.display = 'none';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_occupation_edit(arg_mode, arg_href_id, ob_id_val, last_arg)
{
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_occupation_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_occupation_edit('save', arg_href_id, ob_id_val, last_arg)};
			$('ob_occupation_value').style.display = 'none';
			$('ob_occupation_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = new Array();
			var num_main_val_elements = $('ob_occupation_edit_option').length;
			for (var i = 0; i < num_main_val_elements; i++) {
				if ($('ob_occupation_edit_option')[ i ].selected) 
					main_val.push($('ob_occupation_edit_option')[ i ].value);
			}
			
			var target_id = 'ob_occupation_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=dropdown" + "&ajax_flag=occupation" +
							"&ob_id=" + ob_id_val + "&main_val=" + main_val + "&last_arg=" + last_arg;
			
			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_occupation_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_occupation_edit('edit', arg_href_id, ob_id_val, last_arg)};
					$('ob_occupation_value').style.display = 'block';
					$('ob_occupation_edit_container').style.display = 'none';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_grew_edit(arg_mode, arg_href_id, ob_id_val,last_arg)
{
	
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_grew_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_grew_edit('save', arg_href_id, ob_id_val, last_arg)};
			$('ob_grew_value_container').style.display = 'none';
			$('ob_grew_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = $('ob_grew_city_edit_box').value;
			var state_val = $('ob_grew_state_edit_box').value;
			var zip_val = $('ob_grew_zip_edit_box').value;
			var cntry_val = $('ob_country_edit_option').value;
		
			var target_id = 'ob_grew_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=text" + "&ajax_flag=grew" + "&last_arg=" + last_arg + "&ob_id=" + ob_id_val +
							"&main_val=" + encodeURI( main_val ) + "&state_val=" + encodeURI( state_val ) + "&zip_val=" + encodeURI( zip_val ) + "&cntry_val=" + encodeURI( cntry_val );
		
			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_grew_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_grew_edit('edit', arg_href_id, ob_id_val, last_arg)};
					$('ob_grew_value_container').style.display = 'block';
					$('ob_grew_edit_container').style.display = 'none';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_passing_edit(arg_mode, arg_href_id, ob_id_val, constant_val, last_arg)
{
	
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_passing_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + constant_val + "', '" + last_arg + "');");
			$(arg_href_id).onclick = function() {ob_creation_passing_edit('save',arg_href_id,ob_id_val,constant_val,last_arg)};
			$('ob_passing_value').style.display = 'none';
			$('ob_passing_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = $('ob_lname_edit_box').value;
			var first_val = $('ob_fname_edit_box').value;
			var city_val = $('ob_passing_city_edit_box').value;
			var state_val = $('ob_passing_state_edit_box').value;
			var zip_val = $('ob_passing_zip_edit_box').value;
			var cntry_val = $('ob_countrypass_edit_option').value;
			
			var target_id = 'ob_passing_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=text" + "&ajax_flag=passing" + "&last_arg=" + last_arg + "&ob_id=" + ob_id_val +
							"&main_val=" + encodeURI( main_val ) + "&first_val=" + encodeURI( first_val ) +
							"&city_val=" + encodeURI( city_val ) + "&state_val=" + encodeURI( state_val ) +"&zip_val=" + encodeURI( zip_val ) + "&cntry_val=" + encodeURI( cntry_val ) + "&constant_val=" + encodeURI( constant_val );
			
			var myAjax = new Ajax.Updater('', url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					var arr_response_text = response_text.split('-----=====');
					$(target_id).innerHTML = arr_response_text[0];
					$('ob_fname_change_1').innerHTML = arr_response_text[1];
					$('ob_fname_change_1').innerHTML = arr_response_text[1];
					$('ob_href_change_1').innerHTML = arr_response_text[2];
					//alert(arr_response_text[2]);
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_passing_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + constant_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_passing_edit('edit', arg_href_id, ob_id_val, constant_val, last_arg)};
					$('ob_passing_value').style.display = 'block';
					$('ob_passing_edit_container').style.display = 'none';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}

function ob_creation_cop_edit(arg_mode, arg_href_id, ob_id_val, last_arg)
{
	try {
		if (arg_mode == 'edit') { // Edit mode
			$(arg_href_id).innerHTML = 'save';
			//$(arg_href_id).setAttribute('onclick', "return ob_creation_cop_edit('save', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');" );
			$(arg_href_id).onclick = function() {ob_creation_cop_edit('save', arg_href_id, ob_id_val, last_arg);};
			
			$('ob_cop_value').style.display = 'none';
			$('ob_cop_edit_container').style.display = 'block';
		}
		else if (arg_mode == 'save') { // Save mode
			var main_val = $('ob_cop_edit_option').value;
			var target_id = 'ob_cop_value';
			var url = 'ajax/obituary_creation_edit.php';
			var queryStr = "ajax_mode=dropdown" + "&ajax_flag=cop" + "&last_arg=" + last_arg +
							"&ob_id=" + ob_id_val + "&main_val=" + main_val;
			
			var myAjax = new Ajax.Updater(target_id, url, {
				method: 'post',
				parameters: queryStr,
				onLoading: function(){
				},
				onComplete: function(){
				},
				onSuccess: function(req){
					var response_text = req.responseText;
					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
						alert("You cant enter this type of words in our site.");
						}
					else {
					$(arg_href_id).innerHTML = 'edit';
					//$(arg_href_id).setAttribute('onclick', "return ob_creation_cop_edit('edit', '" + arg_href_id + "', '" + ob_id_val + "', '" + last_arg + "');");
					$(arg_href_id).onclick = function() {ob_creation_cop_edit('edit', arg_href_id, ob_id_val, last_arg);};
					$('ob_cop_value').style.display = 'block';
					$('ob_cop_edit_container').style.display = 'none';
					}
				},
				onFailure: function(req){
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			});
		}
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}
function orgindexsearch( indexalp, frmindex) {

	var alphabet=indexalp;
	/*document.getElementById(frmindex).alpha.value=alphabet;
	document.getElementById(frmindex).submit();*/
	try {
		
		
		var queryStr = "alphabet=" + alphabet;
		var url = 'ajax/charity_search_result.php';
		
		var myAjax = new Ajax.Updater(frmindex, url, {
			method: 'post',
			parameters: queryStr,
			onLoading: function(){
			},
			onComplete: function(){
			},
			onSuccess: function(req){
				var response_text = req.responseText;

				/*MM_showHideLayers(showHideArg_1, '', showHideArg_2);*/
			},
			onFailure: function(req){
				alert("There was a problem while using XMLHTTP:\n" + req.statusText);
			}
		});
	} catch( e ) {
		alert('An error has occurred: ' + e.message);
	}
}
function frm_sub(page,frmname,rurl)
	{
		document.getElementById(frmname).action=rurl;
		document.getElementById(frmname).page.value = page;
		document.getElementById(frmname).submit();
	}
function delete_pic(arg1)
{
		document.getElementById('del_pic').value=arg1;
		document.getElementById('submit_time').value='back';
		document.getElementById('upload_review').action='Pic_upload_review.php';
		document.upload_review.submit();
}
function delete_video(arg1)
{
		document.getElementById('del_pic').value=arg1;
		document.getElementById('submit_time').value='back';
		document.getElementById('upload_video').action='video_upload.php';
		document.upload_video.submit();
}
function delete_video_confirm(arg1)
{
		document.getElementById('del_video').value=arg1;
		document.getElementById('submit_time').value='back';
		document.getElementById('video_confirm_review').action='video_review_confirmation.php';
		document.video_confirm_review.submit();
}
function delete_youtubevideo(arg1)
{
		document.getElementById('del_video').value=arg1;
		document.getElementById('submit_time').value='back';
		document.getElementById('vupload_review').action='video_youtube_upload.php';
		document.vupload_review.submit();
}
function add_imgdata()
{
		document.getElementById('del_pic').value='';
		document.getElementById('con_data').value='confirm_data';
		document.getElementById('submit_time').value='back';
		
// 		if(document.getElementById('isprimary').checked==true)
// 		document.getElementById('isprimary').value = 'Y';
// 		else
// 		document.getElementById('isprimary').value = 'N';
		
		var hidcnttitle=document.upload_review.hidcnttitle.value;
		for (var counter = 0; counter < hidcnttitle; counter++) {
				
				var obimgprimary=document.getElementById('isprimary_'+counter);
				var obimghidprimary=document.getElementById('ishidprimary_'+counter);
							if (obimgprimary.checked==true) {
										
								obimghidprimary.value = 'make_primary';
							
								}
							else {
								obimghidprimary.value = '';
									//alert(obimgprimary.value);
							}
						}
		if(document.getElementById('edit_images').value == 'Yes') {	
		document.getElementById('pic_upload').value='Y';
		document.getElementById('upload_review').action='video_review_confirmation.php';
		}
		else {
		document.getElementById('upload_review').action='video_upload.php';
		}
		document.upload_review.submit();
}

function add_more_img()
{
document.getElementById('del_pic').value='';
document.getElementById('submit_time').value='back';
	if(document.getElementById('flag_obimage_pop').value=='Y')
		{
		MM_showHideLayers('upgradeaccount_pop', '', 'show');
		return false;
		}
	if(document.getElementById('redirect').value=='Y')
		{
		document.getElementById('upload_review').action='Profile_ContentSubmission.php';
		}
document.upload_review.submit();
}
function add_video(arg1)
{
// 	alert("dfgfg");
// 
// var val = document.getElementById('title_').value;
// //try {
// 			var queryStr = "body_content="+ encodeURIComponent(val);
// 			var url = 'ajax/guestbook_entry_check.php';
// 			var myAjax = new Ajax.Updater('', url, {
// 			method: 'post',
// 				parameters: queryStr,
// 				onLoading: function(){
// 				},
// 				onComplete: function(){
// 				},
// 				onSuccess: function(req){
// 					var response_text = req.responseText;
// 					alert(response_text);
// 					if( response_text.replace(new RegExp(/\s+$/),"")=='Congratulations' ) {
// 						alert("You cant enter this type of words in our site.");
// 						}
// 					else
// 					{
// 							MM_showHideLayers('loadingimage','','show');
// 							document.getElementById('submit_time').value='back';
// 							document.upload_video.submit();
// 					}
// 
// 				},
// 				onFailure: function(req){
// 					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
// 
// 				}
// 
// 			});
// 
// 
// 		//} catch( e ) {
// 		//	alert('An error has occurred: ' + e.message);
// 		//}
MM_showHideLayers('loadingimage','','show');
							document.getElementById('submit_time').value='back';
							document.upload_video.submit();
	
}
function search_youtube()
{
	if(document.getElementById('user_plan').value=='N') {
	MM_showHideLayers('upgradeacc', '', 'show')
	}
	else {
	document.searchyoutube.submit_time.value='back';
	document.searchyoutube.action = 'youtubesearch.php';
	document.searchyoutube.submit();
	}
}
function upload_youvideo()
{
	document.getElementById('submit_time').value='back';
	document.getElementById('video_confirm').value='Yes';
	document.searchyoutube.action = 'video_youtube_upload.php';
	document.searchyoutube.submit();
}
function chkvideo()
	{
		var frm = document.searchyoutube;
		var obvideo = document.searchyoutube.elements["videoid[]"];
		var videotitle = document.searchyoutube.elements["titlevideo[]"];

		var unchkid = '';
		var chkid = '';
		var chktitle = '';
		var unchktitle = '';
		for(i=0; i<obvideo.length;i++)
		{
			if(obvideo[i].checked==false)
			{
				unchkid += obvideo[i].value+",";
				unchktitle += videotitle[i].value+",";
			}
			if(obvideo[i].checked==true)
			{
				chkid += obvideo[i].value+",";
				chktitle += videotitle[i].value+",";
			}
		}
		document.getElementById('videoid_title').value = chktitle;
		document.getElementById('delvideo_title').value = unchktitle;
		document.getElementById('videoid_total').value = chkid;
		document.getElementById('delvideoid').value = unchkid;
		
	}
function video_review_confirm()
{
	document.getElementById('video_confirm').value='Yes';
	document.getElementById('submit_time').value='back';
	document.vupload_review.action = 'video_review_confirmation.php';
	document.vupload_review.submit();
}
function goto_next_step()
{
	// document.getElementById('video_confirm').value='Yes';
	document.video_confirm_review.action = 'Profile_MetaDataEntry.php';
	document.video_confirm_review.submit();
}
function add_more_video()
{
	document.video_confirm_review.action = 'video_upload.php';
	document.video_confirm_review.submit();
}
function next_videoreview()
{
	document.getElementById('submit_time').value='back';
	document.getElementById('video_upload_next').value='Y';
	document.upload_video.action = 'video_review_confirmation.php';
	document.upload_video.submit();
}
// **********For adding charity
function showcharitypop()
{
	MM_showHideLayers('addcharity', '', 'show');
}
function charityoverview()
{
	MM_showHideLayers('addcharity', '', 'hide');
	MM_showHideLayers('charityoverview', '', 'show');
}
function backtocharty()
{
	MM_showHideLayers('addcharity', '', 'show');
	MM_showHideLayers('charityoverview', '', 'hide');
}
function submitcharity()
{
	MM_showHideLayers('charityconfirm', '', 'hide');
}
function charityconfirm()
{
	var orgname = document.getElementById('home_name').value;
	var staddress = document.getElementById('staddress').value;
	var city = document.getElementById('city').value;
	var state = document.getElementById('state').value;
	var zip = document.getElementById('zip').value;
	var phone = document.getElementById('phone').value;
	var keywords = document.getElementById('keywords').value;
	var summery = document.getElementById('summery').value;
	var ObId = document.getElementById('profile_id').value;
	var queryStr = "obId=" + encodeURIComponent(ObId) + "&orgname=" + encodeURIComponent(orgname) + "&staddress=" + encodeURIComponent(staddress) + "&city=" + encodeURIComponent(city) + "&state=" + encodeURIComponent(state) + "&zip=" + encodeURIComponent(zip) + "&phone=" + encodeURIComponent(phone) + "&keywords=" + encodeURIComponent(keywords) + "&summery=" + encodeURIComponent(summery) ;

	var url = 'ajax/add_charity.php';
				var myAjax = new Ajax.Updater('', url,
				{
					method: 'post',
					parameters: queryStr,
					onLoading: function () {
					},
					onComplete: function () {
					},
					onSuccess: function(req) {
						var response_text = req.responseText;
						if( response_text != "" ) {
					    document.getElementById('charity_name_dis').innerHTML = response_text;
						MM_showHideLayers('charityoverview', '', 'hide');
						MM_showHideLayers('charityconfirm', '', 'show');
						}
					},
					onFailure: function (req)
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}

				});
		
}