/**
 * @author supachet2526
 */
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e){
	if (IE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	}
	else { // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}
}	
	
	
	
	
	$(function(){
		//$("#dialog").bgiframe();
		//$("#dialog").draggable();
	});
	
	//ต้องอยู่ ไล์เดียวกัน
	
	
	
	function Popup_close(){
		
		$("#dialog").hide("slow");

	}
	
	function Popup(msg){
	$("#dcon").html(msg);
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#dialog").height();
	var popupWidth = $("#dialog").width();
	//centering
	
	$("#dialog").css({
		"position": "absolute",
		"top": windowHeight / 2 - popupHeight / 2+150,
		"left": windowWidth / 2 - popupWidth / 2+40,
		//"top": tempY-50,
		//"left": tempX-50,
		"padding":"5px 5px 5px 5px"
	});
//	$("#dialog").draggable();
	$("#dialog").show("slow");

	//only need force for IE6
}
function Popup_mouse(msg){
	$("#dcon").html(msg);
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#dialog").height();
	var popupWidth = $("#dialog").width();
	//centering
	
	if(tempX>500){
		tempX=500;
		
	}
	
	
	$("#dialog").css({
		"position": "absolute",
		//"top": windowHeight / 2 - popupHeight / 2+150,
		//"left": windowWidth / 2 - popupWidth / 2+40,
		"top": tempY+150,
		"left": tempX+5,
		"padding":"5px 5px 5px 5px"
	});
//	$("#dialog").draggable();
	$("#dialog").show("slow");

	//only need force for IE6
}
function call_ajax(file,fun){
		 $.ajax({

   url: file,
   cache: false,
   success: function(msg){
     fun(msg);
   }
 });
 

	
		}
		
		
function send_frm(id){
	

	 frm_e_card = '<form name="frm_send_card" id="frm_send_card" action="http://www.baanamphawa.co.th/lib/mail.php" method="post"><p>Mail To :<br><input type="hidden" value="'+id+'" name="sq"> <input type="text" name="email"></p><p>Mail Form :<br><input type="text" name="f_mail"></p><p>Subject:<br><input type="text" name="subject"></p><p>Message :<br> <textarea name="msg" rows="4"></textarea></p><p><input type="submit" name="btecard" value="Send" ></p></form>';
//alert(frm_e_card);	
		//alert(frm_e_card);
	Popup(frm_e_card);
	
	
	
}	

function send_to_e(){
	
	
	//alert(document.frm_send_card.sq.value);
	//alert(document.frm_send_card.email.value);
	//alert(document.frm_send_card.f_mail.value);
		//alert(document.frm_send_card.msg.value);
		
		sq = document.frm_send_card.sq.value;
		m_to = document.frm_send_card.email.value;
		m_f = document.frm_send_card.f_mail.value;
		ms = document.frm_send_card.msg.value;
	
 $.ajax({
   type: "POST",
   url: "../lib/mail.php",
   data: "sqpic="+sq+"&m_to="+m_to+"&m_f="+m_f+"&ms="+ms,
   success: function(msg){
     //alert( "Data Saved: " + msg );
	 
	 Popup_close();
	 alert(msg);
	 
   }
 }); 
	
	
	
	
	
}	