x=1;

function move_element(id) {

    elm=$("#elm"+id);
    elm_hidden=$("#elm_hidden"+id);
    cases=$("#cases"+id);
		
    stat=elm_hidden.css('display');
	
	
	if(x==1) {
	    
			if(stat=="none") {
			        x=2;
					elm.animate({
						left: '-=230'						
					  }, 500, function() {
						// Animation complete
						cases.attr('src','images/titleCases2.gif')
						elm_hidden.fadeIn('slow');
                        x=1						
					});
			}
			else {    	
				x=2;
				elm_hidden.fadeOut('normal');
				elm.animate({
					left: '+=230'					
				  }, 500, function() {
					// Animation complete
					cases.attr('src','images/titleCases1.gif')	
					x=1
				});
				
			}	
			
     }
 
}


function show_hide(id, p) {

      if(id.style.display == "none") {
         id.style.display = "block"
         p.src="images/arrowQAOpen.gif"
      }
      
      else {
       id.style.display = "none"
       p.src="images/arrowQA.gif"
      }
}



function checkData() {
	
		var fields=document.ref;

    if(fields.captcha.value==""){
	alert("Please fill code")
	return false;
	}
	if((fields.f_name.value=="")||(fields.surname.value=="")){
	alert("Please fill the name of patient");
	return false;
	}
   	if(((!fields.date_dd.value.match(/[\d0-9]/))||(!fields.date_mm.value.match(/[\d0-9]/))||(!fields.date_yy.value.match(/[\d0-9]/))))	{
	alert("Please fill correct date in format DD, MM, YYYY");
	return false;
	}

	if((fields.h_phone.value=="")&&(fields.w_phone.value=="")&&(fields.mobile.value=="")){
	 alert("Please fill at least one phone number");
	 return false;
	}
	if(fields.address.value==""){
	alert("Please fill the address of patient");
	return false;
	}
if((fields.ref_name.value=="")||(fields.ref_phone.value=="")||(fields.ref_email.value=="")){
 alert("Please fill the details of the Referrer");
 return false;
}

	var flag="off";
		for(var i=1; i<=32; i++){
			if (eval("fields.p_"+i+".checked")==true){
			flag="on";
			break;
			}
			else{
			flag="off";
			}
		}

 var flag_st="off";
	for(var j=1; j<=12; j++){
		if (eval("fields.status_"+j+".checked")==true){
		flag_st="on";
		if((fields.status_6.checked==true)&&((!fields.r_date_dd.value.match(/[\d0-9]/))||(!fields.r_date_mm.value.match(/[\d0-9]/))||(!fields.r_date_yy.value.match(/[\d0-9]/))))	{
	alert("Please fill correct date of the inlcluded radiograph in format DD, MM, YY");
	return false;
		}
		if(fields.status_6.checked==false){
		fields.r_date.value="";
		}
		else{
		fields.r_date.value=fields.r_date_dd.value+"/"+fields.r_date_mm.value+"/"+fields.r_date_yy.value;
		}
		break;
		}
		else { 
		flag_st="off";
		}
	}
 	var flag_d="off";
		for(var i=1; i<=3; i++){
			if (eval("fields.diagnos_"+i+".checked")==true){
			flag_d="on";
			break;
			}
			else{
			flag_d="off";
			}
		}


	if ((flag=="on")&&(flag_st=="on")&&(flag_d=="on")){
	
		checkcode(document.ref.captcha.value);
         return false;	
			
	}
	
	else if(flag=="off"){
	alert("Please mark the relevant tooth on the DENTAL PLAN");
	return false;
	}
	else if(flag_st=="off"){
	 alert("Please mark in the STATUS section");
	 return false;
	}
	else if(flag_d=="off"){
	 alert("Please mark the TREATMENT requested");
	 return false;
	}
	
}




function WinOpen_2pics(file){
window.open(file,"endo",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,top=50,left=50,width=420,height=435');
}

function WinOpen_3pics(file){
window.open(file,"endo",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,top=50,left=50,width=780,height=300');
}





/* Endodontics Guide form */
function SubmitCheckForm(form)
{
if((send_form.C1.checked==false)&&(send_form.C2.checked==false)&&(send_form.C3.checked==false)&&(send_form.C4.checked==false)&&(send_form.C5.checked==false)&&(send_form.C6.checked==false)&&(send_form.C7.checked==false)&&(send_form.C8.checked==false)){
alert("please check at least one 'symptoms' box")
return false;
}
else if(document.send_form.name.value=="")
	{
	alert("Please fill full name")
	document.send_form.name.focus();
	return false;
	}
else if((document.send_form.email.value=="")||(document.send_form.email.value.indexOf('@', 0) == -1))
	{
	alert("Please fill email address")
	document.send_form.email.focus();
	return false;
	}
else if(document.send_form.phone.value=="")
	{
	alert("Please fill phone number")
	document.send_form.phone.focus();
	return false;
	}
else if(document.send_form.captcha.value=="")
	{
	alert("Please fill code")
	document.send_form.captcha.focus();
	return false;
	}
else
	{
	return true;
	}
}


