function AllTrim(str){
							    for(var i = 0; i < str.length; i++)
							      if(str.charAt(i) != " ")
							        break;
							    str = str.substr(i, str.length-i);
							
							    for(var i = str.length-1; i > 0; i--)
							      if(str.charAt(i) != " ")
							        break;
							    str = str.substr(0, i+1);
							
							    return str;
			 			 }

function add_ad(){
										var ad_title=AllTrim(document.adf.title.value);
										var ad_txt=AllTrim(document.adf.adtext.value);
										var ad_job=document.adf.job.value;
							
								if (ad_title=='' || ad_txt=='' || ad_job=='0') alert('Συμπλήρωστε όλα τα υποχρεωτικά παιδία με *');
								else	document.adf.submit();
							}	

							
function submit_cv(){
	
	var ok=true;
								var cv_fname=AllTrim(document.cvfrm.fname.value);
								var cv_lname=AllTrim(document.cvfrm.lname.value);
								var cv_email=AllTrim(document.cvfrm.email.value);
								var cv_job=document.cvfrm.job.value;
								var cv_edu=document.cvfrm.education.value;
								var cv_xp=document.cvfrm.experience.value;
								var cv_file=document.cvfrm.cvfile.value;
								

	if (cv_fname=="") ok=false;
	if (cv_lname=="") ok=false;
	if (cv_email=="") ok=false;
	if (cv_job==0) ok=false;
	if (cv_edu==0) ok=false;
	if (cv_xp==0) ok=false;
	if (cv_file=="") ok=false;
	
	if (ok) {
		document.cvfrm.current_page.value=location.href;
		document.cvfrm.submit();
	}
	else alert('Συμπλήρωστε όλα τα υποχρεωτικά παιδία με *')

}



function run_area_chk(){
	// 0 einai nai
	// 1 einai oxi
	
			
		var dealer_select_div = document.getElementById('for_dealer');
		var dealer_select = document.getElementById('for_dealer_id');
		
		var area_select = document.getElementById('areas');
		var ok=false;
		for(i=0;i<area_select.options.length;i++){
			if (area_select.options[i].selected==true) ok=true;
		}
		
		if (ok){
			document.cvfrm.online_cv[1].checked=true;
			dealer_select_div.style.display='block';
			}
		if (!ok){
			dealer_select_div.style.display='none';
			dealer_select.options[0].selected=true;
			document.cvfrm.online_cv[0].checked=true;
			}
		

		
}

function clear_area_chk(){
		var dealer_select_div = document.getElementById('for_dealer');
		var dealer_select = document.getElementById('for_dealer_id');
		
		dealer_select.options[0].selected=true;
		dealer_select_div.style.display='none';
		
		var area_select = document.getElementById('areas');
		for(i=0;i<area_select.options.length;i++){
			area_select.options[i].selected=false;
		}
}

function print_me(){
printwindow=window.open('print_matrix.php','printwindow'); 
printwindow.document.write(this.document.getElementById('table_inside_html').innerHTML);
printwindow.print();
}

function doDelete(td,cid) {
	var tr=td.parentNode.parentNode;
	window.open('delete_cand.php?cid='+cid,'dcwin','width=200,height=10');
	if(tr) tr.style.display='none';
}
