// JavaScript Document

/*---Popup window -------------------------------------------------------------------------------*/
var win=null;
function NewWindowTop(mypage,myname,w,h,scroll,resize){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable='+resize;
	win = window.open(mypage,myname,settings);
	if (window.focus) {win.focus()}
	return false;

}

/*/----For Check Email value------------------------------------------------------------------------*/
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i

function checkmail(e){
var returnval=emailfilter.test(e)
/*if (returnval==false){
alert("Invalid email address.")
e.select()
}*/
return returnval
}

//ตรวจสอบให้ใส่ได้เฉพาะตัวเลขจำนวนเต็มเท่านั้น
function chk_numberic(chkmsg) {
	if(chkmsg == "") return false;
	chkstr = "0123456789"
	chkstr += '"';
	for (count = 0;count < chkmsg.length;count++) {
		chk_ok = 0
		for (count2 = 0;count2 < chkstr.length;count2++) {
			if (chkmsg.charAt(count) == chkstr.charAt(count2)) {
				chk_ok = 1;
				break;
			}
		}
		if (chk_ok == 0) {
			if (chkmsg.charCodeAt(count) != 13 && chkmsg.charCodeAt(count) != 10) {
				return false;
			}
		}
	}
	return true;
}

//Send to Friends-------------------------
function popupSend(url) {
	pageName="Send";
	w=360;
	h=310;
	scr=0;
	resize=0;
	NewWindowTop(url,pageName,w,h,scr,resize);
	return false;
}



//add favorite

/***********************************************
* Bookmark site script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
