function Checkany(chk,id)
{
	if(id.checked==true){
		for (i = 0; i < chk.length; i++) {
			chk[i].checked = false ;
		}
		id.checked=true;	
		switch(id.name) {
				case 'hair_vol[]':
						importance = 'importance_hairvol_low';
				break;
				case 'hair_color[]':
						importance = 'importance_haircolor_low';
				break;
				case 'hair_texture[]':
						importance = 'importance_hairtexture_low';
				break;
				case 'hair_length[]':
						importance = 'importance_hairtlength_low';
				break;

				case 'haskid[]':
						importance = 'importance_kid_low';
				break;

				default :
					importance = 'importance_'+id.name;
					importance = importance.replace('[','');
					importance = importance.replace(']','');		
					importance = importance+'_low';		
				break;
			}		
		document.getElementById(importance).checked = true;
	}
}

function unCheckany(chk,value)
{
		for (i = 0; i < chk.length; i++) {
			if(chk[i].value==value) {
				chk[i].checked = false ;
			}
		}
}

function eye_check(chk,value)
{
	for (i = 0; i < chk.length; i++) {
		if(value==2) {
			if(chk[i].value==4) {
				chk[i].checked = false ;
			}
		}
		
		if(value==4) {
			if(chk[i].value==2) {
				chk[i].checked = false ;
			}
		}
		
		if(value==8) {
			if(chk[i].value==16) {
				chk[i].checked = false ;
			}
		}
		
		if(value==16) {
			if(chk[i].value==8) {
				chk[i].checked = false ;
			}
		}

}		
}

function countCheck(chk) {
	var total = 0;
	var idx_max = chk.length;
	for (var idx = 0; idx < idx_max; idx++) {
	if (chk[idx].checked == true) {
		total += 1;
		if(total>4) {
			chk[idx].checked = false;
		}
	   }
	}
		if(total >4 ) {
			alert("เลือกได้ไม่เกิน 4 ข้อ ");		
		}
	
}

function radio_button_checker()
{
	// set var radio_choice to false
	var radio_choice = false;
	
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.form1.gender.length; counter++) {
		if (document.form1.gender[counter].checked)
			radio_choice = true; 
	}
	
	if (!radio_choice) {
	// If there were no selections made display an alert box 
		alert("กรุณาระบุเพศของท่านด้วย.");
		document.form1.gender[0].focus();
		return false;
	} else {
		return true;
	}
}

// ตัวอย่างการใช้ อยู่ที่ http://localhost/Freelance/shop_jk/jk/test/javascript_check.php
