// JavaScript Document
function chksquery(fview)
  {
  var urisearch =  document.location;
  var filename = urisearch.href.replace(/^.*\//, '');
  var pathname = urisearch.href.replace(/([^(\|\/|\:)]+)$/, '');
  var sts = (filename.indexOf("strquery")==-1)?true:false;
  var strpath = pathname+fview+"?strquery="+filename;
  if(sts)urisearch.replace(strpath);
  }
function chks_query(fview)
  {
  var urisearch =  document.location;
  var filename = urisearch.href.replace(/^.*\//, '');
  var pathname = urisearch.href.replace(/([^(\|\/|\:)]+)$/, '');
  var sts = (filename.indexOf("str_query")==-1)?true:false;
  var strpath = pathname+fview+"?str_query="+filename;
  if(sts)urisearch.replace(strpath);
  }
var objdoc = {
	fanpage : function (){
var img = '<img src="../../images/img_ico/Like_TAF_on_Facebook.jpg">';
var htmlobj = '<a onmouseover="ddrivetip(\'<font style=font-size:13px><strong>Find us on Facebook</strong></font>\', 100)" onmouseout="hideddrivetip();" href="http://www.facebook.com/pages/Thai-Appraisal-Foundation/151663968622" target="_blank">'+
img +'</a>';
 return htmlobj;
	}
}

function doc_chksttus()
	{
		return $('input[type=checkbox]:checked').length;
	}
function doc_dischksttus()
	{
	$('input[type=checkbox]:not(:checked)').each(function(){	
		$(this).attr('disabled', true);
		});
	}
function doc_getchklen()
	{ 
	var lnk_group="";
	$('input[type=checkbox]:checked').each(function(){	
		lnk_group += $(this).val()+";";
		});
	return lnk_group;
	}
function doc_mkchk(id)
	{
	var stus = doc_chksttus();
	if(stus==0){alert("กรุณาคลิกที่ชื่อวิทยากร เพื่อเลือกเอกสารดาวโหลด");return;	}
	if($("#doc_chkall").length!=-1){$("#doc_chkall").hide();}
	doc_fmailloading(id, "../../dowload_file/form-email_download.php");
	}
function doc_fmailloading(id, url)
	{
	$.ajax({ 
	  url: url, 
	  cache: false, 
	  success: function(html){
		$("#"+id).html(html);
	  } 
	});
	}
function doc_postmail()
	{
	var stus = doc_chksttus();
	if(stus==0){	alert("กรุณาคลิกที่ชื่อวิทยากร เพื่อเลือกเอกสารดาวโหลด");return;}
	var qstring = "email="+$("#email").val()+"&lnk_groups="+doc_getchklen();
	$.ajax({ 
	   type: "POST", 
	   url: "../../dowload_file/send-email_download.php", 
	   data: qstring, 
	   success: function(html){
	   if(html!="no"){
			 $("#result").html("<span style='color:#0000FF;'>ระบบส่งลิงค์ดาวโหลดไปยังเมล์ของท่านแล้ว<br />โปรดตรวจสอบที่: "+html+"</span><br><div>หมายเหตุ: หากไม่ได้รับโปรดตรวจสอบอีกครั้งที่ \"กล่องอีเมล์ขยะ\"</div>");
		   }else{
			  $("#result").html("<span style='color:#FF0000;'>ระบบไม่ตอบสนอง: ขออภัยไม่สามารถส่งข้อมูลได้โปรดแจ้งปัญหาที่: 0.2295.3171 ต่อ 112</span>");
		   }
	   } 
	 });
	 }
 function doc_allchk()
	 {
		 $('input[type=checkbox]').attr("checked", true);
	 }

