



		function remove_mce_status_messages()
				{
				var cv_editor_td = document.getElementById('cv_editor_td');
				var cl_editor_td = document.getElementById('cl_editor_td');

				var cv_textarea = document.getElementById('_CV');
				var cl_textarea = document.getElementById('_COVERLETTER');

				var cv_status_td = document.getElementById('cv_status_message_td');
				var cl_status_td = document.getElementById('cl_status_message_td');

				if (cv_status_td) cv_status_td.removeChild(document.getElementById('cv_status_message'));
				if (cl_status_td) cl_status_td.removeChild(document.getElementById('cl_status_message'));

				if (cv_editor_td) cv_editor_td.style.visibility = 'visible';
				if (cl_editor_td) cl_editor_td.style.visibility = 'visible';
				}

		function hide_editors()
				{
				tinyMCE.execCommand('mceRemoveControl',false,'_CV');
				tinyMCE.execCommand('mceRemoveControl',false,'_COVERLETTER');
				}

		function show_editors()
				{
				tinyMCE.execCommand('mceAddControl',false,'_CV');
				tinyMCE.execCommand('mceAddControl',false,'_COVERLETTER');
				}

//					plugins : "style,layer,advhr,advlink,spellchecker,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
//					spellchecker_languages : "+English=en",
//				    theme_advanced_buttons3 : "removeformat,|,sub,sup,|,charmap,spellchecker,advhr,|,ltr,rtl,|,fullscreen",


		function initilize_editor()
				{
				tinyMCE.init(
					{
					mode : "textareas",
					theme : "advanced",
					editor_selector : "mceEditor",
					plugins : "style,layer,advhr,advlink,searchreplace,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

				    theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect,|,bold,italic,underline,|justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor",
				    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink",
				    theme_advanced_buttons3 : "removeformat,|,sub,sup,|,charmap,advhr,|,ltr,rtl",
					theme_advanced_statusbar_location : "bottom",
					theme_advanced_toolbar_location : "top",
					theme_advanced_toolbar_align : "left",
					theme_advanced_disable: "styleselect",

					onpageload : "remove_mce_status_messages",

					paste_use_dialog : false,
					theme_advanced_resizing : true,
					theme_advanced_resize_horizontal : false,

					paste_auto_cleanup_on_paste : true,
					paste_convert_headers_to_strong : false,

					paste_remove_spans : false,
					paste_remove_styles : false		
					});
				}

		function get_iframe_document( iframe )
			{

			if ( iframe.contentDocument )
				{
				if ( iframe.contentDocument.documentElement ) return iframe.contentDocument.documentElement;
				}
			else
				{
				if ( iframe.contentWindow )
					{
					if ( iframe.contentWindow.document ) return iframe.contentWindow.document;
					}
				else
					{
					if ( iframe.document ) 
						{	
						if ( iframe.document.document ) return iframe.document.document;
						}
					else
						{
						return null;
						}
					}
				}
			return null;
			}
		
		function pic_iframe_watchdog()
			{
			var iframe_document	= get_iframe_document( document.getElementById('profileIframe') );
			var content = iframe_document.body ? iframe_document.body.innerText : iframe_document.innerHTML;
			var signature;

			if ( content ) 
				{
				signature = iframe_document.document.getElementById('id_profile_pic');
				if ( !signature )
					{
					submit_profile_pic();
					window.setTimeout('pic_iframe_watchdog()',5000);
	  				}
				}
  			}

		function upload_profile_pic()
			{
			var iframe_document	= get_iframe_document( document.getElementById('profileIframe') );

			if ( iframe_document.body ) 
				iframe_document.body.innerText = "";
			else
				iframe_document.innerText = "";

			submit_profile_pic();
			pic_iframe_watchdog();
  			}

		function submit_profile_pic( )
			{

				show_profile_pic_status();
	
	  			document.JobSeekerRegisterForm.action = '/scripts/submit_profile_pic.php'
	  			document.JobSeekerRegisterForm.target = 'profileIframe';
				document.JobSeekerRegisterForm.submit();
	
	  			document.JobSeekerRegisterForm.target = '';
				document.JobSeekerRegisterForm.action = '';
  			}

		function validate_no_image()
			{
			var div_profile_pic = document.getElementById('div_profile_pic');
			var chk_no_image = document.getElementById('_NO_PIC');
			var name_profile_pic = document.getElementById('_PROFILE_PIC_NAME');

			if ( chk_no_image.checked )
				{
				div_profile_pic.style.display = 'none';	
				reset_file_control();
				chk_no_image.checked = false;
				name_profile_pic.value = '';
  				}
  			}

		function reset_file_control()
			{
			var profile_pic = document.getElementById('_PROFILE_PIC');
			var profile_pic_td = document.getElementById('_PROFILE_PIC_TD');

			profile_pic_td.removeChild(profile_pic);
			profile_pic = gen.create_element( 'input', 'file', '_PROFILE_PIC', '_PROFILE_PIC' );
			profile_pic.className = 'text_fixedwidth';
			profile_pic.onchange = submit_profile_pic;
			profile_pic_td.appendChild(profile_pic);
			}

		function show_profile_pic( )
			{
			document.getElementById('div_profile_pic_status').style.display = 'none';
			document.getElementById('div_profile_pic').style.display = 'block';

			reset_file_control();
			}

		function show_profile_pic_status( )
			{
			document.getElementById('div_profile_pic_status').style.display = 'block';
			document.getElementById('div_profile_pic').style.display = 'none';
			}
		function hide_profile_pic_status( )
			{
			document.getElementById('div_profile_pic_status').style.display = 'none';
			}

		function set_profile_pic( picture_name, error )
			{
  			if ( error ) alert( error );

			if ( !error || picture_name  > '' )
				{ 
				var img_profile_pic = document.getElementById('img_profile_pic');
				var name_profile_pic = document.getElementById('_PROFILE_PIC_NAME');

				img_profile_pic.src = '/images/jobseeker/images_large/' + picture_name;
				img_profile_pic.onload = show_profile_pic;	

				name_profile_pic.value = picture_name;
				}
			else
				hide_profile_pic_status( );
			}


		function load_profile_pic( )
			{
			var picture_name = document.getElementById('_PROFILE_PIC_NAME').value;

			if ( picture_name  > '' )
				{ 
				var img_profile_pic = document.getElementById('img_profile_pic');
				img_profile_pic.src = '/images/jobseeker/images_large/' + picture_name;

				window.setTimeout('show_profile_pic()',500);
				}
			}

		function focus_on_name_control()
			{
			if ( document.JobSeekerRegisterForm )
				{
				if ( document.JobSeekerRegisterForm._NAME )
					{
					document.JobSeekerRegisterForm._NAME.focus();
					document.body.scrollTop = 0;
					}
				}
			}

		function focus_on_profile_pic_control()
			{
			document.JobSeekerRegisterForm._PROFILE_PIC.focus();
			document.body.scrollTop = 0;
			}

		function show_terms_and_conditions()
			{
			Terms = window.open('http://www.jobmail.co.za/form/employer.privacy.content.php',"Terms","width=640,height=480,scrollbars=1"); 
			if ( Terms )
				{
				Terms.window.onload = function()
											{
											window.focus();
											}
				}
			}

		function validate_jobseeker_reg_form()
			{
			var error_number = 0;
			var check_newsletter = document.JobSeekerRegisterForm._RECEIVENEWSLETTER.checked;
			var check_notification = document.JobSeekerRegisterForm._RECEIVENOTIFICATION.checked;
		
			if ( !check_notification ) error_number = 1;
			if ( !check_newsletter )
				{
				if ( error_number == 1) 
					error_number = 3;
				else
					error_number = 2;
				}

			return error_number;
			}

		function submit_jobseeker_reg_form()
			{
			var jobseeker_form = document.JobSeekerRegisterForm; 
			var error = validate_jobseeker_reg_form();
			var submit_form = false;

			if ( !error)
				{
				submit_form	= true;			
				}
			else
				{
				if ( error == 1 || error == 3 )
					{
					var warning_message = 	"Please note that you have not selected the ‘Receive Job Seeker Notification Emails’ checkbox. \n" +
									"The result of this will be that you will also not receive any JobMail Reply emails \n" +
									"from Employers responding to your Applications.\n\n" +
									"Are you sure you want to continue and not Receive Job Seeker Notification emails?";
					if ( confirm( warning_message ) )
						{ 
						submit_form = true;				
						}
					else
						{
						submit_form = false;				
						}
					}
				else
					submit_form	= true;			
				}

			return submit_form;
			}

