function changeNewsletterAction(url){
	$('newsletter_form').action=url;
}
function change_default(id,default_text,curr_value,type)
{
	if(type==true)
	{
		if(curr_value=='')
		$(id).value=default_text;
	}
	else
	{
		if(curr_value==default_text)
		$(id).value='';
	}
}

function add_dob(){
	var day=$('dob_day').value;
	var month=$('dob_month').value;
	var year=$('dob_year').value;

	if(day==0)
	day="day";
	if(month==0)
	month="month";
	if(year==0)
	year="year";

	$('dob_hidden').value=day+"-"+month+"-"+year;
}

function add_grad(index){
	var month=$('grad_month'+index).value;
	var year=$('grad_year'+index).value;

	if(month==0)
	month="month";
	if(year==0)
	year="year";

	$('grad_hidden'+index).value=month+"-"+year;
}
function add_start_date(){
	var month=$('start_month').value;
	var year=$('start_year').value;

	if(month==0)
	month="month";
	if(year==0)
	year="year";

	$('start_date_hidden').value=month+"-"+year;
}

function add_date(id,index){
	var month=$(id+'_month'+index).value;
	var year=$(id+'_year'+index).value;

	if(month==0)
	month="month";
	if(year==0)
	year="year";

	$(id+'_hidden'+index).value=month+"-"+year;
}

function add_phone(index){
	var country=$('mobile_country').value;
	var area=$('mobile_area').value;
	var num=$('mobile_num').value;


	$('phone_hidden').value=country+"-"+area+"-"+num;
}

function add_phone1(index){
	var country=$('phone_country').value;
	var area=$('phone_area').value;
	var num=$('phone_num').value;


	$('phone_hidden').value=country+"-"+area+"-"+num;

}

function check_passwords(flag){
	var pass1=$('pass_div').value;
	var pass2=$('conf_pass_div').value;

	if(pass1==pass2){
		//$("newsletter_subscription").checked=false;
		//		if($("newsletter_subscription").checked){
		//			if(!flag){
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("fname_field").value=$("CandidateFname").value;
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("lname_field").value=$("CandidateLname").value;
		//			}else{
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("fname_field").value=$("EmployerFname").value;
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("lname_field").value=$("EmployerLname").value;
		//			}
		//			var val=$("country_select").value;
		//
		//			if(document.getElementById("newsletter_frame").contentWindow.document.getElementById("country_field"))
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("country_field").value=$("country_select").options[val].text;
		//			if($('phone_ext'))
		//			var phone_ext=$('phone_ext').value;
		//			else var phone_ext="";
		//			if(phone_ext=="extension")
		//			phone_ext="";
		//			if(phone_ext=="")
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("phone_field").value=$("phone_country").value+"-"+$("phone_area").value+"-"+$("phone_num").value;
		//			else document.getElementById("newsletter_frame").contentWindow.document.getElementById("phone_field").value=$("phone_country").value+"-"+$("phone_area").value+"-"+$("phone_num").value +" (ext:"+phone_ext+")";
		//
		//			if(!flag)
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("dob_field").value=$("dob_day").value+"/"+$("dob_month").value+"/"+$("dob_year").value;
		//
		//			if($("CandidateEmail"))
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("email_field").value=$("CandidateEmail").value;
		//			else
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("email_field").value=$("email_field").value;
		//
		//			document.getElementById("newsletter_frame").contentWindow.document.newsletter_form.submit();
		//
		//		}

		if(flag){
			return check_emails();
		}else
		return true;

	}
	else{
		Effect.toggle('pass_not_match',"blind",{duration:0.5});
		return false;
	}
}

function check_passwords_edit(flag){
	var pass1=$('pass_div').value;
	var pass2=$('conf_pass_div').value;



	if(pass1==pass2){


		//		if(flag){
		return check_emails(flag);
		//		}else
		//		return true;

	}
	else{
		Effect.toggle('pass_not_match',"blind",{duration:0.5});
		return false;
	}
}


function check_emails(flag){
	if(flag){
		var val1=$('email_field').value;
		var val2=$('conf_email_field').value;
	}else{
		val1="";
		val2="";
	}

	if(val1==val2){

		//		if($("newsletter_subscribed_1")){

		//		if($("newsletter_subscribed_1").checked){
		//			if(!flag){
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("fname_field").value=$("CandidateFname").value;
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("lname_field").value=$("CandidateLname").value;
		//			}else{
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("fname_field").value=$("EmployerFname").value;
		//				document.getElementById("newsletter_frame").contentWindow.document.getElementById("lname_field").value=$("EmployerLname").value;
		//			}
		//			var val=$("country_select").value;
		//
		//			if(document.getElementById("newsletter_frame").contentWindow.document.getElementById("country_field"))
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("country_field").value=$("country_select").options[val].text;
		//			if($('phone_ext'))
		//			var phone_ext=$('phone_ext').value;
		//			else var phone_ext="";
		//			if(phone_ext=="extension")
		//			phone_ext="";
		//			if(phone_ext=="")
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("phone_field").value=$("phone_country").value+"-"+$("phone_area").value+"-"+$("phone_num").value;
		//			else document.getElementById("newsletter_frame").contentWindow.document.getElementById("phone_field").value=$("phone_country").value+"-"+$("phone_area").value+"-"+$("phone_num").value +" (ext:"+phone_ext+")";
		//
		//			if(!flag)
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("dob_field").value=$("dob_day").value+"/"+$("dob_month").value+"/"+$("dob_year").value;
		//
		//			if($("CandidateEmail"))
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("email_field").value=$("CandidateEmail").value;
		//			else
		//			document.getElementById("newsletter_frame").contentWindow.document.getElementById("email_field").value=$("email_field").value;
		//
		//			document.getElementById("newsletter_frame").contentWindow.document.newsletter_form.submit();
		//		}else{
		//
		//			if($("CandidateEmail"))
		//			document.getElementById("newsletter_frame2").contentWindow.document.getElementById("email_field").value=$("CandidateEmail").value;
		//			else
		//			document.getElementById("newsletter_frame2").contentWindow.document.getElementById("email_field").value=$("email_field").value;
		//
		//			document.getElementById("newsletter_frame2").contentWindow.document.newsletter_form.submit();
		//		}
		//	}

		return true;

	}
	else{
		Effect.toggle('emails_not_match',"blind",{duration:0.5});
		return false;
	}
}

var menu_flag="";

var sub_flag=false;
var sub_flag_movable=false;


function show_menu(type,f){
	if(f){
		menu_flag=type;
		if(menu_flag!='')
		document.getElementById(menu_flag+'_div').setAttribute('src','/img/user/menu/'+menu_flag+'_on.gif');

	}
	document.getElementById(type+'_div').setAttribute('src','/img/user/menu/'+type+'_on.gif');
	if(sub_flag!=false)
	$(sub_flag).style.display='block';
}

function close_menu(menu){

	document.getElementById(menu+'_div').setAttribute('src','/img/user/menu/'+menu+'_off.gif');
	if(menu_flag==menu){
		document.getElementById(menu_flag+'_div').setAttribute('src','/img/user/menu/'+menu_flag+'_on.gif');
	}
	if(sub_flag!=false)
	$(sub_flag).style.display='block';

}

var submenu_flag=false;
var submenu_opened_flag=false;
function open_sub(sub_id,other_sub_id,flag){

//	if($('submenu_bar').style.display=='none'){
//		Effect.toggle('submenu_bar','slide',{duration:0.3});
//	}
////	$(sub_id).style.display='block';
//	if($(sub_id).style.display=="none"){
//		Effect.toggle(sub_id,'slide',{duration:0.3});
//	}

	submenu_flag=true;
	if($('submenu_bar').style.display=='none'){
		Effect.toggle('submenu_bar','slide',{duration:0.3});
	}
	if($(sub_id).style.display=="none"){
		$(sub_id).style.display='block';
		if(other_sub_id && other_sub_id!=''){
			if($(other_sub_id).style.display=='block')
				$(other_sub_id).style.display='none';
		}
	}
	if(flag){
		submenu_opened_flag=sub_id;
	}

}

function close_sub(sub_id,flag){
	submenu_flag=false;
	setTimeout("if(submenu_flag==false && submenu_opened_flag==false)$('submenu_bar').style.display='none';else{if(submenu_flag==false && $('my_cvs_sub')){$('my_cvs_sub').style.display='none';$('my_jobs_sub').style.display='none';$('"+submenu_opened_flag+"').style.display='block';}}",500);
	
	
//	if((sub_flag_movable!=sub_id) && sub_id!=sub_flag){
//		if($(sub_id).style.display!="none"){
//			Effect.toggle(sub_id,'slide',{duration:0.2});
//			setTimeout("if(sub_flag_movable==false)$('submenu_bar').style.display='none'",500);
//			
//		}
//	}else{
//		
//	}
}


//function open_sub(sub_id,flag){
//
//	if($(sub_id).style.display=="none"){
//		if(sub_id=='my_jobs_sub'){
//			if(sub_flag!=false){
////				$('my_cvs_sub').style.display='none';
////				$(sub_id).style.display='block';
//				$('the_sub_div').innerHTML=$(sub_id).innerHTML;
//			}else{
//				Effect.toggle('my_cvs_sub','slide',{duration:0.7});
//				Effect.toggle(sub_id,'slide',{duration:0.5});
//			}
//		}
//		else if(sub_id=='my_cvs_sub'){
//			if(sub_flag!=false){
////				$('my_jobs_sub').style.display='none';
////				$(sub_id).style.display='block';
//				$('the_sub_div').innerHTML=$(sub_id).innerHTML;
//			}else{
//				Effect.toggle('my_jobs_sub','slide',{duration:0.7});
//				Effect.toggle(sub_id,'slide',{duration:0.5});
//			}
//		}
//	}else{
//		if(sub_id=='my_jobs_sub'){
//			$('my_cvs_sub').style.display='none';
////			Effect.toggle('my_cvs_sub','slide',{duration:0.7});
//		}
//		if(sub_id=='my_cvs_sub'){
//			$('my_jobs_sub').style.display='none';
////			Effect.toggle('my_jobs_sub','slide',{duration:0.7});
//		}
//	}
//
//}
//
//function close_sub(sub_id,flag){
//
//	if((sub_flag_movable!=sub_id) && sub_id!=sub_flag){
//
//		if($(sub_id).style.display!="none"){
//			if(flag)
//				$(sub_id).style.display='none';
//			else
//			Effect.toggle(sub_id,'slide',{duration:0.5});
//		}
//	}
//}

//function open_sub(sub_id){
//	sub_flag_movable=sub_id;
//	if($(sub_id).style.display=="none"){
//		Effect.toggle(sub_id,'slide',{duration:0.5});
//	}
//
//}
//
//function close_sub(sub_id,flag){
////	alert(sub_id);
//
//	if((sub_id!=sub_flag_movable)){
//		if($(sub_id).style.display!="none"){
//				Effect.toggle(sub_id,'slide',{duration:0.5});
//		}
//
//		if(sub_flag!=false )
//		open_sub(sub_flag);
//	}
//}


function open_builder(chosen_builder){

	//	if(chosen_builder!="our_builder_div"){
	//		$("our_builder_div").style.display='none';
	//		$('our_builder_btn').src='/img/user/our_builder.gif';
	//	}
	if(chosen_builder!="upload_cv_div"){
		$("upload_cv_div").style.display='none';
		//$('upload_cv_btn').src='/img/user/upload_cv.gif';
	}
	if(chosen_builder!="copy_paste_div"){
		$("copy_paste_div").style.display='none';
		//$('copy_paste_btn').src='/img/user/copy_paste.gif';
	}

	Effect.toggle(chosen_builder+'_div',"blind",{duration:0.5});
	$("hidden_type").value=chosen_builder;
	//$(chosen_builder+'_btn').src='/img/user/'+chosen_builder+'_on.gif';
	//	Effect.toggle('submit_div','appear',{duration:0.5});
	if($('submit_div'))
	$('submit_div').style.display='block';
	if($('form_opened'))
	$('form_opened').style.display='block';

	//	setTimeout("$('"+chosen_builder+"_div').scrollTo();",500);
}

function open_builder_form(){
	var chose_builder='';
	if($('check1').checked){
		var cv_name=$("CvName").value;
		//		var ser_name=$('dataform').CvName.serialize();
		cv_name=addslashes(cv_name);
		window.location="/cvs/advanced/"+cv_name;
		return false;
	}
	if($('check2').checked)
	open_builder("upload_cv");
	if($('check3').checked)
	open_builder("copy_paste");
	if($('check4')){
		if($('check4').checked){
			window.location="/candidates";
			return false;
		}
	}
}

function open_builder_form_adv(){
	var chose_builder='';
	if($('check1').checked){

	}
	if($('check2').checked){
		var cv_name=$("CvName").value;
		cv_name=addslashes(cv_name);
		window.location="/cvs/post_cv/1/1/"+cv_name;
		return false;
	}
	if($('check3').checked){
		var cv_name=$("CvName").value;
		cv_name=addslashes(cv_name);
		window.location="/cvs/post_cv/1/2/"+cv_name;
		return false;
	}
}

function addslashes(str) {
	str=str.replace(/\\/g,'\\\\');
	str=str.replace('/','\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function show_continue(){
	if($('check1').checked){
		$('continue_div').style.display='none';
	}else
	$('continue_div').style.display='block';
}
function force_open_section(section){
	if($(section).style.display=='none'){
		Effect.BlindDown(section,{duration:0.5});
		$(section+'_arrow').src='/img/user/white_arrow_opened.gif';
	}
}
function open_section(section){
	Effect.toggle(section,'blind',{duration:0.5});
	if($(section).style.display=='none')
	$(section+'_arrow').src='/img/user/white_arrow_opened.gif';
	else $(section+'_arrow').src='/img/user/white_arrow.gif';
}
function open_section_search(section){
	Effect.toggle(section,'blind',{duration:0.5});
	if($(section).style.display=='none')
	$(section+'_update_div').style.display='none';
	else $(section+'_update_div').style.display='block';
}

function change_has_experience(){
	if($('has_exp_field').checked)
	{
		$('add_work_div').style.display='none';
		$('add_another_1').style.display='none';

		var el = document.getElementById('work_exp_form'),
		all = el.getElementsByTagName('input');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = true;
			all[i].removeClassName('validate-insert-company-name');
			all[i].removeClassName('validate-job-title');
			all[i].removeClassName('required validate-notEmpty-orZero');
		}
		all = el.getElementsByTagName('select');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = true;
			all[i].removeClassName('validate-notEmpty-orZero');
		}
		all = el.getElementsByTagName('checkbox');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = true;
		}
		all = el.getElementsByTagName('textarea');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = true;
		}


	}
	else{
		$('add_work_div').style.display='block';
		$('add_another_1').style.display='block';

		var el = document.getElementById('work_exp_form'),
		all = el.getElementsByTagName('input');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = false;
			all[i].addClassName('validate-insert-company-name');
			all[i].addClassName('validate-job-title');
		}
		all = el.getElementsByTagName('select');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = false;
			//all[i].addClassName('validate-notEmpty-orZero');
		}
		all = el.getElementsByTagName('checkbox');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = false;
		}
		all = el.getElementsByTagName('textarea');
		for (var i = 0; i < all.length; i++) {
			all[i].disabled = false;
		}
	}
}

function change_default_cv(id,elmt,user_id){
	if(elmt.checked){

		new Ajax.Request('/cvs/set_default/'+id+'/'+user_id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {

				if($('default_msg').style.display=='none')
				Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
			}
		})
	}
}

function publish_job(id){

	if(confirm("Are you sure you want to publish this job?")){

		$('publish_div_'+id).innerHTML='<div style="float:left;margin-top:0px;height:15px;"><a href="#" onclick="unpublish_job('+id+');return false;" style="text-decoration:none;color:#1e72af">published</a></div><div style="float:left;padding-top:0px;height:15px;width:5px;">&nbsp;</div>';
		new Ajax.Request('/jobs/publish/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {

				if($('default_msg').style.display=='none')
				Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);


			}
		})
	}

}


function unpublish_job(id){

	if(confirm("Are you sure you want to unpublish this job?")){

		$('publish_div_'+id).innerHTML='<div style="float:left;margin-top:0px;height:15px;"><a href="#" onclick="publish_job('+id+');return false;" style="text-decoration:none;color:#1e72af" >publish</a></div><div style="float:left;padding-top:0px;height:15px;"><a href="#" onclick="publish_job('+id+');return false;"><img src="/img/user/publish.gif" alt="" border="0"/></a></div>';
		new Ajax.Request('/jobs/unpublish/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {

				if($('default_msg').style.display=='none')
				Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);


			}
		})
	}
}

function delete_cv(id){
	if(confirm("Are you sure you want to delete this cv?")){

		Effect.toggle("cv_row_"+id,"blind",{duration:0.5});
		Effect.toggle("cv_row2_"+id,"blind",{duration:0.5});
		new Ajax.Request('/cvs/delete/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
				$('max_cv').style.display='none';
				$('add_cv').style.display='block';
			}
		})
	}
}

function delete_saved_cv(id,folder_id){
	if(confirm("Are you sure you want to delete this cv?")){

		Effect.toggle("cv_row_"+id,"blind",{duration:0.5});
		new Ajax.Request('/cvs/delete_saved_cv/'+id+'/'+folder_id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {

				if($('default_msg3').style.display=='none')
				Effect.toggle("default_msg3","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg3").style.display!="none")Effect.toggle("default_msg3","appear",{duration:0.5,from:1,to:0});',5000);
			}
		})
	}
}

function delete_search(id){
	if(confirm("Are you sure you want to delete this search?")){

		Effect.toggle("search_row_"+id,"blind",{duration:0.5});
		new Ajax.Request('/search/delete_search/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
				if($('default_msg').style.display=='none')
				Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
			}
		})
	}
}

function delete_job(id){
	if(confirm("Are you sure you want to delete this job?")){

		Effect.toggle("job_row_"+id,"blind",{duration:0.5});
		Effect.toggle("job_row2_"+id,"blind",{duration:0.5});
		new Ajax.Request('/jobs/delete/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {

			}
		})
	}
}
function delete_applied_job(cv_id,job_id){
	if(confirm("Are you sure you want to delete this cv?")){

		Effect.toggle("cv_row_"+cv_id,"blind",{duration:0.5});
		Effect.toggle("cv_row2_"+cv_id,"blind",{duration:0.5});
		new Ajax.Request('/jobs/delete_applied_cv/'+cv_id+'/'+job_id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
				var response_text=response.responseText;
				if(response_text==1){
					if($('default_msg').style.display=='none')
					Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
					setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
				}
			}
		})
	}
}
function delete_my_jobs(job_id,candidate_id){
	if(confirm("Are you sure you want to delete this job application?")){

		Effect.toggle("job_row_"+job_id,"blind",{duration:0.5});
		Effect.toggle("job_row2_"+job_id,"blind",{duration:0.5});
		new Ajax.Request('/jobs/delete_my_jobs/'+job_id+'/'+candidate_id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
				var response_text=response.responseText;
				if(response_text==1){
					$('default_msg_value').innerHTML="Job application deleted successfully";
					if($('default_msg').style.display=='none')
					Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
					setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
				}
			}
		})
	}
}

function delete_saved_jobs(job_id,candidate_id){
	if(confirm("Are you sure you want to delete this saved job?")){

		Effect.toggle("saved_job_row_"+job_id,"blind",{duration:0.5});
		Effect.toggle("saved_job_row2_"+job_id,"blind",{duration:0.5});
		new Ajax.Request('/jobs/delete_saved_jobs/'+job_id+'/'+candidate_id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
				var response_text=response.responseText;
				if(response_text==1){
					$('default_msg_value').innerHTML="Job deleted successfully";
					if($('default_msg').style.display=='none')
					Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
					setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
				}
			}
		})
	}
}
function edit_cv(path){
	window.parent.opener.location.href = path;
	window.parent.close();
}

function edit_job(path){
	window.parent.opener.location.href = path;
	window.parent.close();
}
function delete_print_cv(id){
	if(confirm("Are you sure you want to delete this cv?")){
		window.parent.opener.location.href = "/cvs/delete/"+id+"/true";
		window.parent.close();
	}
}
function delete_print_job(id){
	if(confirm("Are you sure you want to delete this job?")){
		window.parent.opener.location.href = "/jobs/delete/"+id+"/true";
		window.parent.close();
	}
}


function copy_cv(id){
	window.parent.opener.location.href = "/cvs/copy_cv/"+id;
	window.parent.close();
}

function turn_page(page,pages,controller,action){

	$('data_div').innerHTML="<div style='margin-top:80px;width:590px;text-align:center;'><img src='/img/user/loader.gif' alt='' /></div>";
	if(!action)
	var path='/'+controller+'/index_ajax/'+page+'/'+pages;
	else var path='/'+controller+'/'+action;

	new Ajax.Request(path, {
		onSuccess: function(response) {
			text=response.responseText;
			$('data_div').innerHTML=text;
		}
	})
	return false;
}

function delete_comp(id){
	if(confirm("Are you sure you want to delete this company?")){

		Effect.toggle("comp_row_"+id,"blind",{duration:0.5});
		Effect.toggle("comp_row2_"+id,"blind",{duration:0.5});
		new Ajax.Request('/companies/delete_company/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
			}
		})
	}
}

function change_folder_name(folder_id){

	var new_folder=$('folder_edit_'+folder_id).value;

	new_folder=new_folder.stripTags();

	$("folder_name_"+folder_id).innerHTML=new_folder;
	Effect.toggle('edit_div_'+folder_id,'blind',{duration:0.5});

	new Ajax.Request('/cvs/edit_folder/'+folder_id+'/'+new_folder, {
		method:"post",
		asyncronous:true,
		onSuccess: function(response) {

			var return_string=response.responseText;
			if(return_string==1){
				if($('default_msg').style.display=='none')
				Effect.toggle("default_msg","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
			}
		}
	})
}

function add_comment(folder_id,cv_id){

	var new_comment=$('textarea_'+folder_id+'_'+cv_id).value;

	new_comment=new_comment.stripTags();

	Effect.toggle('cvs_comment_'+folder_id+'_'+cv_id,'blind',{duration:0.5});

	new Ajax.Request('/cvs/add_comment/'+folder_id+'/'+cv_id+'/'+new_comment, {
		method:"post",
		asyncronous:true,
		onSuccess: function(response) {

			var return_string=response.responseText;
			if(return_string==1){
				if($('default_msg2').style.display=='none')
				Effect.toggle("default_msg2","appear",{duration:0.5,from:0,to:1});
				setTimeout('if($("default_msg2").style.display!="none")Effect.toggle("default_msg2","appear",{duration:0.5,from:1,to:0});',5000);
			}
		}
	})
}

function delete_folder(id){
	if(confirm("Are you sure you want to delete this folder?")){

		Effect.toggle("folder_row_"+id,"blind",{duration:0.5});
		$("edit_div_"+id).style.display='none';
		$("cvs_div_"+id).style.display='none';
		//$("cvs_comment_"+id).style.display='none';

		new Ajax.Request('/cvs/delete_folder/'+id, {
			method:"post",
			asyncronous:true,
			onSuccess: function(response) {
			}
		})
	}
}

////////////Password meter//////
var updateStrength = function(pw) {

	var strength = getStrength(pw);
	var width = (211/32)*strength;
	new Effect.Morph('psStrength', {style:'width:'+width+'px', duration:'0.4'});

}

var getStrength = function(passwd) {
	intScore = 0;
	if (passwd.match(/[a-z]/)) // [verified] at least one lower case letter
	{
		intScore = (intScore+1)
	} if (passwd.match(/[A-Z]/)) // [verified] at least one upper case letter
	{
		intScore = (intScore+5)
	} // NUMBERS
	if (passwd.match(/\d+/)) // [verified] at least one number
	{
		intScore = (intScore+5)
	} if (passwd.match(/(\d.*\d.*\d)/)) // [verified] at least three numbers
	{
		intScore = (intScore+5)
	} // SPECIAL CHAR
	if (passwd.match(/[!,@#$%^&*?_~]/)) // [verified] at least one special character
	{
		intScore = (intScore+5)
	} if (passwd.match(/([!,@#$%^&*?_~].*[!,@#$%^&*?_~])/)) // [verified] at least two special characters
	{
		intScore = (intScore+5)
	} // COMBOS
	if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case
	{
		intScore = (intScore+2)
	} if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers
	{
		intScore = (intScore+2)
	} // [Verified] Upper Letters, Lower Letters, numbers and special characters
	if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/) && passwd.match(/[!,@#$%^&*?_~]/))
	{
		intScore = (intScore+2)
	}
	return intScore;
}

function fill_browse(fromDiv,toDiv){

	$(toDiv).value = $(fromDiv).value

}


function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight  && window.scrollMaxY) {

		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;

	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
	return [pageWidth,pageHeight];
}

function open_saved_folder(folder_id){
	if($("cvs_div_"+folder_id).style.display!="none"){
		$('folder_img_'+folder_id).src='/img/user/folder_closed.gif';
	}else{
		$('folder_img_'+folder_id).src='/img/user/folder_opened.gif';
	}

	Effect.toggle('cvs_div_'+folder_id,"blind",{duration:0.5});
}

function save_job(job_id){
	new Ajax.Request('/jobs/save_job/'+job_id, {
		method:"post",
		asyncronous:true,
		onSuccess: function(response) {
			var response_text=response.responseText;

			if(response_text==1){
				$('default_msg_value').innerHTML="Job saved successfully";
				$('default_msg').style.display='block';
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
			}else{
				$('default_msg_value').innerHTML="Job already saved";
				$('default_msg').style.display='block';
				setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
			}
		}
	})
}

function check_newsletter_form(){
	var name=$('UserFname').value;
	var email=$('UserEmail').value;

	if(name=="" || name=="name"){
		$('msg_box_value').innerHTML="Please enter your name";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(!email.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$") || email=="" || email=="email"){

		$('msg_box_value').innerHTML="Please enter a valid email address";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);

		return false;
	}
	return true;
}

function submit_contact(){
	var fname=$('ContactFname').value.stripTags();
	var lname=$('ContactLname').value.stripTags();
	var email=$('ContactEmail').value.stripTags();
	var country=$('ContactCountry').value;
	var message=$('ContactMessage').value.stripTags();
	//	message=message.replace(/\n\r/g,"__brr__");
	//	message=message.replace(/\n/g,"__brr__");
	//	var param=fname+"||"+lname+"||"+email+"||"+country+"||"+message;

	if(fname=="" || fname=="insert first name" || lname=="" || lname=="insert family name" || email=="" || email=="insert your email address" || country=="" || country=="select country" || message=="" || message=="message" || !email.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$")){
		return false;
	}

	$('dataform').request({onComplete: function(request){form_submitted(request); }	 });

	//var param=$('dataform').serialize(true);

	//	new Ajax.Request('/contact/submit_contact/'+param, {
	//		method:"post",
	//		asyncronous:true,
	//		onSuccess: function(response) {
	//			$('default_msg').style.display='block';
	//			//				Effect.toggle('default_msg','appear',{duration:0.5,from:0,to:1});
	//			$('ContactMessage').value="message";
	//			if(!$('ContactLoggedin')){
	//				$('ContactFname').value="insert first name";
	//				$('ContactLname').value="insert family name";
	//				$('ContactEmail').value="insert your email address";
	//				$('ContactCountry').value='select country';
	//			}
	//
	//			setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
	//		}
	//	})
}

function form_submitted(request){
	if(request.responseText){
		$('default_msg').style.display='block';
		$('ContactMessage').value="message";
		if(!$('ContactLoggedin')){
			$('ContactFname').value="insert first name";
			$('ContactLname').value="insert family name";
			$('ContactEmail').value="insert your email address";
			$('ContactCountry').value='select country';
		}

		setTimeout('if($("default_msg").style.display!="none")Effect.toggle("default_msg","appear",{duration:0.5,from:1,to:0});',5000);
	}
}

function tell_a_friend(){
	var name1=$('TellName').value.stripTags();
	var email1=$('TellEmail').value.stripTags();

	var name2=$('TellName2').value.stripTags();
	var email2=$('TellEmail2').value.stripTags();

	if(name1=="" || name1=="your name"){
		$('msg_box_value').innerHTML="Please enter your name";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(name2=="" || name2=="your friend name"){
		$('msg_box_value').innerHTML="Please enter your friend's name";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(email1=="" || email1=="your email" || !email1.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$")){
		$('msg_box_value').innerHTML="Please enter your email";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(email2=="" || email2=="your friend email" || !email2.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$")){
		$('msg_box_value').innerHTML="Please enter your friend's email";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}

	new Ajax.Request('/contact/tell_friend/'+name1+"/"+email1+"/"+name2+"/"+email2, {
		method:"post",
		asyncronous:true,
		onSuccess: function(response) {
			Effect.toggle('tell_friend_box',"appear",{duration:0.5,from:1,to:0});
			Effect.toggle('tell_friend_msg_box','appear',{duration:0.5,from:0,to:1});
			setTimeout("Effect.toggle('tell_friend_msg_box','appear',{duration:0.5,from:1,to:0})",5000);
		}
	})

}

function tell_a_friend_job(job_name){
	var name1=$('TellName').value.stripTags();
	var email1=$('TellEmail').value.stripTags();

	var name2=$('TellName2').value.stripTags();
	var email2=$('TellEmail2').value.stripTags();

	if(name1=="" || name1=="your name"){
		$('tell_friend_err_value').innerHTML="Please enter your name";
		Effect.toggle('err_msg_tell_friend','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("err_msg_tell_friend").style.display!="none")Effect.toggle("err_msg_tell_friend","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(name2=="" || name2=="your friend name"){
		$('tell_friend_err_value').innerHTML="Please enter your friend's name";
		Effect.toggle('err_msg_tell_friend','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("err_msg_tell_friend").style.display!="none")Effect.toggle("err_msg_tell_friend","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(email1=="" || email1=="your email" || !email1.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$")){
		$('tell_friend_err_value').innerHTML="Please enter your email";
		Effect.toggle('err_msg_tell_friend','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("err_msg_tell_friend").style.display!="none")Effect.toggle("err_msg_tell_friend","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(email2=="" || email2=="your friend email" || !email2.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$")){
		$('tell_friend_err_value').innerHTML="Please enter your friend's email";
		Effect.toggle('err_msg_tell_friend','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("err_msg_tell_friend").style.display!="none")Effect.toggle("err_msg_tell_friend","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}

	new Ajax.Request('/contact/tell_friend_job/'+name1+"/"+email1+"/"+name2+"/"+email2+"/"+job_name, {
		method:"post",
		asyncronous:true,
		onSuccess: function(response) {
			Effect.toggle('tell_friend_box',"appear",{duration:0.5,from:1,to:0});
			Effect.toggle('succ_msg_tell_friend','appear',{duration:0.5,from:0,to:1});
			setTimeout("Effect.toggle('succ_msg_tell_friend','appear',{duration:0.5,from:1,to:0})",5000);
		}
	})

}


function forgot_password(controller){
	var email=$('ForgotEmail').value;

	//	if(name=="" || name=="username"){
	//		$('msg_box_value').innerHTML="Please enter your username";
	//		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
	//		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
	//		return false;
	//	}
	if(email=="" || email=="email"){
		$('msg_box_value').innerHTML="Please enter your email";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	if(!email.match("^[A-Za-z0-9_-]+([A-Za-z0-9]+\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([A-Za-z0-9]+\\.[A-Za-z0-9-]+)*$")){
		$('msg_box_value').innerHTML="Please enter a valid email";
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}

	new Ajax.Request('/'+controller+'/forgot_pass/'+email, {
		method:"post",
		asyncronous:true,
		onSuccess: function(response) {
			Effect.toggle('forgot_pass_box',"appear",{duration:0.5,from:1,to:0});
			$("msg_box_general_value").innerHTML="An email has been sent to reset your password.";
			Effect.toggle('msg_box_general',"appear",{duration:0.5,from:0,to:1});
		}
	})
}
function validChars(e,goods,typeId) {
	var key, keychar;

	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if(key==48){

	}
	if (key == null) return true;



	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
	if (goods.indexOf(keychar) != -1)
	return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27){
		return true;
	}

	return false;

}

function check_search_cand(){
	var search=$('SearchPhrase').value;
	var country=$('search_select_area').value;
	var industry=$('industry_search_area').value;

	if((search=="" || search=="put job title, skills, company name, etc") && country==0 && industry==0){
		$("msg_box_value").innerHTML="Please enter a search phrase that has more than 3 characters"
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	return true;
}


function check_search_emp(){

	////Not Allowed to Search///////////
	//$("msg_box_value").innerHTML="You are not allowed to search for the time being";
	//Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
	//setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
	//return false;
	////END - Not Allowed to Search//////

	var search=$('SearchPhrase').value;
	var country=$('search_select_area').value;
	var major=$('major_search_area').value;

	if((search=="" || search=="CV name, major, level, etc.") && country==0 && major==0){
		$("msg_box_value").innerHTML="Please enter a search phrase that has more than 3 characters"
		Effect.toggle('newsletter_msg_box','appear',{duration:0.5,from:0,to:1});
		setTimeout('if($("newsletter_msg_box").style.display!="none")Effect.toggle("newsletter_msg_box","appear",{duration:0.5,from:1,to:0});',5000);
		return false;
	}
	return true;
}

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2008 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion()
{
	var version;
	var axo;
	var e;
	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful.

			// default to the first public version
			version = "WIN 6,0,21,0";
			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";
			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}
	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}

	return version;
}
// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}
	return flashVer;
}
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
		// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
			return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
				return true;
			}
		}
		return false;
	}
}
function AC_AddExtension(src, ext)
{
	if (src.indexOf('?') != -1)
	return src.replace(/\?/, ext+'?');
	else
	return src + ext;
}
function AC_Generateobj(objAttrs, params, embedAttrs)
{
	var str = '';
	if (isIE && isWin && !isOpera)
	{
		str += '<object ';
		for (var i in objAttrs)
		{
			str += i + '="' + objAttrs[i] + '" ';
		}
		str += '>';
		for (var i in params)
		{
			str += '<param name="' + i + '" value="' + params[i] + '" /> ';
		}
		str += '</object>';
	}
	else
	{
		str += '<embed ';
		for (var i in embedAttrs)
		{
			str += i + '="' + embedAttrs[i] + '" ';
		}
		str += '> </embed>';
	}
	document.write(str);
}
function AC_FL_RunContent(){

	var ret =
	AC_GetArgs
	(  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
	, "application/x-shockwave-flash"
	);
	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_SW_RunContent(){
	var ret =
	AC_GetArgs
	(  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
	, null
	);
	AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
	var ret = new Object();
	ret.embedAttrs = new Object();
	ret.params = new Object();
	ret.objAttrs = new Object();
	for (var i=0; i < args.length; i=i+2){
		var currArg = args[i].toLowerCase();
		switch (currArg){
			case "classid":
			break;
			case "pluginspage":
			ret.embedAttrs[args[i]] = args[i+1];
			break;
			case "src":
			case "movie":
			args[i+1] = AC_AddExtension(args[i+1], ext);
			ret.embedAttrs["src"] = args[i+1];
			ret.params[srcParamName] = args[i+1];
			break;
			case "onafterupdate":
			case "onbeforeupdate":
			case "onblur":
			case "oncellchange":
			case "onclick":
			case "ondblclick":
			case "ondrag":
			case "ondragend":
			case "ondragenter":
			case "ondragleave":
			case "ondragover":
			case "ondrop":
			case "onfinish":
			case "onfocus":
			case "onhelp":
			case "onmousedown":
			case "onmouseup":
			case "onmouseover":
			case "onmousemove":
			case "onmouseout":
			case "onkeypress":
			case "onkeydown":
			case "onkeyup":
			case "onload":
			case "onlosecapture":
			case "onpropertychange":
			case "onreadystatechange":
			case "onrowsdelete":
			case "onrowenter":
			case "onrowexit":
			case "onrowsinserted":
			case "onstart":
			case "onscroll":
			case "onbeforeeditfocus":
			case "onactivate":
			case "onbeforedeactivate":
			case "ondeactivate":
			case "type":
			case "codebase":
			case "id":
			ret.objAttrs[args[i]] = args[i+1];
			break;
			case "width":
			case "height":
			case "align":
			case "vspace":
			case "hspace":
			case "class":
			case "title":
			case "accesskey":
			case "name":
			case "tabindex":
			ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
			break;
			default:
			ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
		}
	}
	ret.objAttrs["classid"] = classid;
	if (mimeType) ret.embedAttrs["type"] = mimeType;
	return ret;
}

function show_login_msg(flag){
	if(flag!=1){
		Effect.toggle('login_err_msg','appear',{from:0,to:1,duration:1});
		setTimeout("if($('login_err_msg').style.display!='none')Effect.toggle('login_err_msg','appear',{from:1,to:0,duration:1});",5000);
		return false;
	}else{
		return true;
	}
}/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* Version 1.5.4.1 (2007-01-05)
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/
var Validator = Class.create();
Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) {},
			onElementValidate : function(result, elm) {}
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) {
			Event.stop(ev);
		}
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
			
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					if(name=='required-picker')
						advice = '<div style="margin-bottom:17px;margin-top:-17px;position:relative;top:17px;" class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							new Insertion.After(elm, advice);
				    }
					advice = Validation.getAdvice(name, elm);
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
						window.alert('he');
					
				} else {
//					new Effect.Appear(advice, {duration : 1 });
					Effect.toggle(advice, "blind",{duration : 0.5 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', 'This is a required field.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['required-picker', 'This is a required field.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', 'Please enter a valid number in this field.', function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', 'Please use only letters (a-z) or numbers (0-9) or(.)( _ )( - )characters', function(v) {
				return Validation.get('IsEmpty').test(v) ||  /^[-_a-zA-Z0-9\\.]+$/.test(v)
			}],
	['validate-date', 'Please enter a valid date.', function(v) {
				var test = new Date(v);
				return Validation.get('IsEmpty').test(v) || !isNaN(test);
			}],
	['validate-email', 'Please enter a valid email address. For example johnsmith@domain.com .', function (v) {
				return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
			}],
//	['validate-url', 'Please enter a valid URL.', function (v) {
//				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
//			}],
			['validate-url', 'Please enter a valid URL', function (v) {

				if(v=="insert your website address")
					return true;
				return Validation.get('IsEmpty').test(v) || /^(((http|https|ftp):\/\/){0,1}(www)\.([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
			
			['validate-url2', 'Please enter a valid URL', function (v) {

			if(v=="insert website address")
				return true;
				if(Validation.get('IsEmpty').test(v))
					return true;
				return /^(((http|https|ftp):\/\/){0,1}(www)\.([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
			
			
			['validate-insert-username', 'Please insert your username', {
				isNot : 'insert username'
			}],
			['validate-password', 'Please insert your password', {
				isNot : 'insert password'
			}],
			['validate-insert-first-name', 'Please insert your first name', {
				isNot : 'insert first name'
			}],
			['validate-insert-family-name', 'Please insert your family name', {
				isNot : 'insert family name'
			}],
			['validate-dob', 'This is a required field', function(v) {
				
				var regex = /^[0-9]+\-[0-9]+\-[0-9]+$/;
				
				if(!regex.test(v)) return false;
				return true;
			}],
			['validate-zero', 'This is a required field', {
				isNot : 0
			}],
			['validate-password2', 'Your password must be more than 6 characters', {
				minLength : 6
			}],
			['validate-password3', 'Your password must be more than 6 characters', function (v) {
				if(Validation.get('IsEmpty').test(v))
					return true;
					if(v.length>0 && v.length<7){
						return false;
					}
					return true;
			}],
			['validate-insert-email', 'Please insert your email', {
				isNot : 'insert your email address'
			}],
			['validate-mailing-address', 'Please insert the mailing address', {
				isNot : 'insert email address'
			}],
			['validate-confirm-email', 'The email and its confirmation do not match', {
				equalToField:'email_field'
			}],
			['validate-insert-address', 'Please insert your address', {
				isNot : 'insert your address'
			}],
			['validate-phone1', 'Please insert a valid phone number', function(v) {
				
				var regex = /^[+0-9 ]+\-[0-9 ]+\-[0-9 ]+$/;
				
				if(!regex.test(v)) return false;
				return true;
			}],
			['validate-phone', 'Please insert a valid mobile number', function(v) {
				
				var regex = /^[+0-9 ]+\-[0-9 ]+\-[0-9 ]+$/;
				
				if(!regex.test(v)) return false;
				return true;
			}],
			['validate-job-title', 'Please enter your job title', {
				isNot : 'enter your job title'
			}],
			['validate-job-title2', 'Please insert job title', {
				isNot : 'insert job title'
			}],
			['validate-school', 'This is a required field', {
				isNot : 'insert school / college / university'
			}],
			['validate-grad', 'Please insert a valid date', function(v) {
				
				var regex = /^[0-9]+\-[0-9]+$/;
				
				if(!regex.test(v)) return false;
				return true;
			}],
			['validate-comp', 'Please insert company name', {
				
				isNot : 'insert company name'
			}],
			['validate-insert-skill-name', 'Please insert skill name', {
				isNot : 'insert skill name'
			}],
			['validate-insert-company-name', 'Please insert company name', {
				isNot : 'insert company name'
			}],
			['validate-notEmpty-orZero', 'Please select', function(v){
				if(Validation.get('IsEmpty').test(v) || v=='0') return false;
				else return true;
			}],
			['validate-insert-website-address', 'Please insert website address', {
				isNot : 'insert website address'
			}],
			['validate-choose-title', 'Please choose title', {
				isNot : 'choose title'
			}],
			['validate-skills', 'Please insert skills', {
				isNot : 'insert skills'
			}],
			['validate-message', 'Please insert message', {
				isNot : 'message'
			}],
			['validate-passwords', 'Your passwords do not match', {
				equalToField:'pass_div'
			}],
			
			
			
			
	['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
	['validate-selection', 'Please make a selection', function(v,elm){
				return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
			}],
	['validate-one-required', 'Please select one of the above options.', function (v,elm) {
				var p = elm.parentNode;
				var options = p.getElementsByTagName('INPUT');
				return $A(options).any(function(elm) {
					return $F(elm);
				});
			}]
]);/*
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * This is the integration file for JavaScript.
 *
 * It defines the FCKeditor class that can be used to create editor
 * instances in a HTML page in the client side. For server side
 * operations, use the specific integration system.
 */

// FCKeditor Class
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
{
	// Properties
	this.InstanceName	= instanceName ;
	this.Width			= width			|| '100%' ;
	this.Height			= height		|| '400' ;
	this.ToolbarSet		= toolbarSet	|| 'Default' ;
	this.Value			= value			|| '' ;
	this.BasePath		= FCKeditor.BasePath ;
	this.CheckBrowser	= true ;
	this.DisplayErrors	= true ;
	this.ContentLangDirection="ltr";
	

	this.Config			= new Object() ;

	
	// Events
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )
}

/**
 * This is the default BasePath used by all editor instances.
 */
FCKeditor.BasePath = '/fckeditor/' ;

/**
 * The minimum height used when replacing textareas.
 */
FCKeditor.MinHeight = 200 ;

/**
 * The minimum width used when replacing textareas.
 */
FCKeditor.MinWidth = 750 ;

FCKeditor.prototype.Version			= '2.6.3' ;
FCKeditor.prototype.VersionBuild	= '19836' ;

FCKeditor.prototype.Create = function()
{
	document.write( this.CreateHtml() ) ;
}

FCKeditor.prototype.CreateHtml = function()
{
	// Check for errors
	if ( !this.InstanceName || this.InstanceName.length == 0 )
	{
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
		return '' ;
	}

	var sHtml = '' ;

	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
	{
		sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;
		sHtml += this._GetConfigHtml() ;
		sHtml += this._GetIFrameHtml() ;
	}
	else
	{
		var sWidth  = this.Width.toString().indexOf('%')  > 0 ? this.Width  : this.Width  + 'px' ;
		var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;

		sHtml += '<textarea name="' + this.InstanceName +
			'" rows="4" cols="40" style="width:' + sWidth +
			';height:' + sHeight ;

		if ( this.TabIndex )
			sHtml += '" tabindex="' + this.TabIndex ;

		sHtml += '">' +
			this._HTMLEncode( this.Value ) +
			'<\/textarea>' ;
	}

	return sHtml ;
}

FCKeditor.prototype.ReplaceTextarea = function(lang)
{
	if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
	{
		// We must check the elements firstly using the Id and then the name.
		var oTextarea = document.getElementById( this.InstanceName ) ;
		var colElementsByName = document.getElementsByName( this.InstanceName ) ;
		var i = 0;
		while ( oTextarea || i == 0 )
		{
			if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )
				break ;
			oTextarea = colElementsByName[i++] ;
		}

		if ( !oTextarea )
		{
			alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
			return false;
		}
		
		oTextarea.style.display = 'none' ;

		if ( oTextarea.tabIndex )
			this.TabIndex = oTextarea.tabIndex ;
		this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;
		this._InsertHtmlBefore( this._GetIFrameHtml(lang), oTextarea ) ;
	}
}

FCKeditor.prototype._InsertHtmlBefore = function( html, element )
{
	var a=0;
	if (a==0)
	{
		$(element.id).insert({ after : html});
	}
	else if ( element.insertAdjacentHTML )	// IE
	{
		element.insertAdjacentHTML('beforeEnd',html);
	}
	else								// Gecko
	{
		var oRange = document.createRange() ;
		oRange.setStartBefore( element ) ;
		var oFragment = oRange.createContextualFragment( html );
		element.parentNode.insertBefore( oFragment, element ) ;
	}
}

FCKeditor.prototype._GetConfigHtml = function()
{
	var sConfig = '' ;
	for ( var o in this.Config )
	{
		if ( sConfig.length > 0 ) sConfig += '&amp;' ;
		sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ;
	}

	return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
}

FCKeditor.prototype._GetIFrameHtml = function(lang)
{
//	var sFile = 'fckeditor.html' ;
	var sFile = 'fckeditor_'+lang+'.html' ;

	try
	{
		if ( (/fcksource=true/i).test( window.top.location.search ) )
			sFile = 'fckeditor.original.html' ;
	}
	catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }

	var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ;
	if (this.ToolbarSet)
		sLink += '&amp;Toolbar=' + this.ToolbarSet ;

	html = '<iframe id="' + this.InstanceName +
		'___Frame" src="' + sLink +
		'" width="' + this.Width +
		'" height="' + this.Height ;

	if ( this.TabIndex )
		html += '" tabindex="' + this.TabIndex ;

	html += '" frameborder="0" scrolling="no"></iframe>' ;

	return html ;
}

FCKeditor.prototype._IsCompatibleBrowser = function()
{
	return FCKeditor_IsCompatibleBrowser() ;
}

FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription )
{
	this.ErrorNumber		= errorNumber ;
	this.ErrorDescription	= errorDescription ;

	if ( this.DisplayErrors )
	{
		document.write( '<div style="COLOR: #ff0000">' ) ;
		document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ;
		document.write( '</div>' ) ;
	}

	if ( typeof( this.OnError ) == 'function' )
		this.OnError( this, errorNumber, errorDescription ) ;
}

FCKeditor.prototype._HTMLEncode = function( text )
{
	if ( typeof( text ) != "string" )
		text = text.toString() ;

	text = text.replace(
		/&/g, "&amp;").replace(
		/"/g, "&quot;").replace(
		/</g, "&lt;").replace(
		/>/g, "&gt;") ;

	return text ;
}

;(function()
{
	var textareaToEditor = function( textarea )
	{
		var editor = new FCKeditor( textarea.name ) ;

		editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;
		editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;

		return editor ;
	}

	/**
	 * Replace all <textarea> elements available in the document with FCKeditor
	 * instances.
	 *
	 *	// Replace all <textarea> elements in the page.
	 *	FCKeditor.ReplaceAllTextareas() ;
	 *
	 *	// Replace all <textarea class="myClassName"> elements in the page.
	 *	FCKeditor.ReplaceAllTextareas( 'myClassName' ) ;
	 *
	 *	// Selectively replace <textarea> elements, based on custom assertions.
	 *	FCKeditor.ReplaceAllTextareas( function( textarea, editor )
	 *		{
	 *			// Custom code to evaluate the replace, returning false if it
	 *			// must not be done.
	 *			// It also passes the "editor" parameter, so the developer can
	 *			// customize the instance.
	 *		} ) ;
	 */
	FCKeditor.ReplaceAllTextareas = function()
	{
		var textareas = document.getElementsByTagName( 'textarea' ) ;

		for ( var i = 0 ; i < textareas.length ; i++ )
		{
			var editor = null ;
			var textarea = textareas[i] ;
			var name = textarea.name ;

			// The 'name' attribute must exist.
			if ( !name || name.length == 0 )
				continue ;

			if ( typeof arguments[0] == 'string' )
			{
				// The textarea class name could be passed as the function
				// parameter.

				var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;

				if ( !classRegex.test( textarea.className ) )
					continue ;
			}
			else if ( typeof arguments[0] == 'function' )
			{
				// An assertion function could be passed as the function parameter.
				// It must explicitly return "false" to ignore a specific <textarea>.
				editor = textareaToEditor( textarea ) ;
				if ( arguments[0]( textarea, editor ) === false )
					continue ;
			}

			if ( !editor )
				editor = textareaToEditor( textarea ) ;

			editor.ReplaceTextarea() ;
		}
	}
})() ;

function FCKeditor_IsCompatibleBrowser()
{
	var sAgent = navigator.userAgent.toLowerCase() ;

	// Internet Explorer 5.5+
	if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 )
	{
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
		return ( sBrowserVersion >= 5.5 ) ;
	}

	// Gecko (Opera 9 tries to behave like Gecko at this point).
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
		return true ;

	// Opera 9.50+
	if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 )
		return true ;

	// Adobe AIR
	// Checked before Safari because AIR have the WebKit rich text editor
	// features from Safari 3.0.4, but the version reported is 420.
	if ( sAgent.indexOf( ' adobeair/' ) != -1 )
		return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ;	// Build must be at least v1

	// Safari 3+
	if ( sAgent.indexOf( ' applewebkit/' ) != -1 )
		return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ;	// Build must be at least 522 (v3)

	return false ;
}
