/*window.status="MakeWebEz.com - บริการเว็บสำเร็จรูป พัฒนาเว็บไซต์";*/
var place=1;
function scrollIn() {
	window.status=Message.substring(0, place);
	if (place >= Message.length) {
		place=1;
		window.setTimeout("scrollOut()",300); 
	} else {
		place++;
		window.setTimeout("scrollIn()",50); 
   } 
}
function scrollOut() {
	window.status=Message.substring(place, Message.length);
	if (place >= Message.length) {
		place=1;
		window.setTimeout("scrollIn()", 100);
	} else {
		place++;
		window.setTimeout("scrollOut()", 50);
   }
}

function roll_over(img_name, img_src){
	document[img_name].src = img_src;
}

/// Max Add ------------------------------------------------------------------------
function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	} else {
		alert("handler could not be attached");
	}
}
function CheckEnterNew(callFunction,valueFunction,e){
	var cChr;
	cChr = e.keyCode || e.which;
	if (cChr == 13)
	{
		callFunction(e,valueFunction);
	}
}
function noRightClick(){
	if(event.button==2){
		document.oncontextmenu =function(){
			return false;
		}
	}
}
////////------------------------------------------------------------------------------

function callfrm(dest){
	document.frmConsole.target = "_self";
	document.frmConsole.action = dest;
	document.frmConsole.method = "POST";
	document.frmConsole.submit();
}
function	callFormSubmit(formId,goTopath){
	document.formId.target = "_self";
	document.formId.method = "POST";
	document.formId.action = goTopath;
	document.formId.submit();
}
function callfrm2(dest)
{
	document.frmConsole.target = "_blank";
	document.frmConsole.action = dest;
	document.frmConsole.method = "POST";
	document.frmConsole.submit();
}	
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	//return (((sign)?'':'-') + '$' + num + '.' + cents);
	return (((sign)?'':'-') + num);
}

function CheckBoxChageColor(c_id,ctmp_id,id,activecolor){
	var f = document.frmConsole;
	var a=c_id + '['+ id +']';
	var b='tr_';
	var c=ctmp_id;
	cb = eval( 'f.' + a);
	cb2 = eval(b + '' + id );
	cb3 = eval( 'f.' + c + '' + id );
	if(cb.checked==true){
		if(cb3.value==1)
			cb2.style.backgroundColor=activecolor;
		else
			cb2.style.backgroundColor="#f9fbcb";
	}else{
		if(cb3.value==0)
			cb2.style.backgroundColor=activecolor;
		else{
			cb2.style.backgroundColor="#D5E2F0";
		}
	}
}
function checkboxNum(form,chk) {
	var total = 0;
	var max = eval('form.' + chk + '.length');
	for (var idx = 0; idx < max; idx++) {
		if (eval('document.frmConsole.'+ chk +'[' + idx + '].checked') == true) {
			total += 1;
		}
	}
	return total;
}

function changerow(row){
	var b='tr_upload';
	for(i=0;i<50;i++){
		cb2 = eval(b + '' + i );
		if(i<row){
			cb2.style.display='';
		}else{			
			cb2.style.display='none';
		}
	}
}

function popupfrmPrint(dest,popname,width,height){
	popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=1,scrollbars=yes,location=no,alwaysRaised=yes,toolbar=yes");
	popup.focus()
}

function openNew(dest,popname,width,height){
	popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=0,scrollbars=yes,location=no,alwaysRaised=yes");
	popup.focus()
}

function popupPic(dest,popname,width,height){
		popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=0,scrollbars=no,location=no,alwaysRaised=yes");
		popup.focus()
}

function DigitOnly(e,obj) {
	var keyCode = e.keyCode || e.which;
	var keyChar = String.fromCharCode(keyCode);
	var CharShow="";
	var isThai=false;

	if (keyChar == "1" || keyChar == "2" || keyChar == "3" || keyChar == "4" || keyChar == "5" || keyChar == "6" || keyChar== "7" || keyChar == "8" 
		|| keyChar == "9" || keyChar == "0" || keyCode==8 || keyCode==9){
		return true;
	}else{
		for(i=0;i<obj.value.length;i++){
			if (obj.value.charAt(i) == "1" || obj.value.charAt(i) == "2" || obj.value.charAt(i) == "3" || obj.value.charAt(i) == "4" 
			|| obj.value.charAt(i) == "5" || obj.value.charAt(i) == "6" || obj.value.charAt(i) == "7" || obj.value.charAt(i) == "8" 
			|| obj.value.charAt(i) == "9" || obj.value.charAt(i) == "0"){		
				CharShow += obj.value.charAt(i);
			}
		}

		obj.value = CharShow;
		return false;
	}
}

function roll_over(img_name, img_src){
	document[img_name].src = img_src;
}

function hasWhiteSpace(s) 
{
	 reWhiteSpace = new RegExp(/\s/); 
	 if (reWhiteSpace.test(s)) {
		  return false;
	 }
	return true;
}

function EngOnly(e,obj){
	var keyCode = e.keyCode || e.which;
	var keyChar = String.fromCharCode(keyCode);
	var CharShow="";
	var isThai=false;

	if(keyChar >= '~'){
		return false;
	}

	for(i=0;i<obj.value.length;i++){
		if(obj.value.charAt(i) >= '~') {
			isThai = true;
		}else{
			CharShow += obj.value.charAt(i);
		}
	}

	obj.value = CharShow;
	if(isThai == true){
		return false;
	}else{
		return true;	
	}
}

function EngOnly2(e){
	var isThai=false;
	var keyCode = e.keyCode || e.which;
	var keyChar = String.fromCharCode(keyCode);
	var keyblock = new Array(33,64,35,36,37,94,38,42,40,41,95,43,61,92,123,125,91,93,58,59,34,39,60,62,44,46,63,47,91,93,123,125);
	var CharShow = "";

	for(var k=0 ; k<keyblock.length ; k++){
		if(keyCode == keyblock[k]){
			return false;
		}
	}
	if(keyChar >= '~'){
		return false;
	}

	for(i=0;i<document.frmConsole.reg_free_domain.value.length;i++){
		if(document.frmConsole.reg_free_domain.value.charAt(i) >= '~') {
			isThai = true;
		}else{
			CharShow += document.frmConsole.reg_free_domain.value.charAt(i);
		}
	}

	document.frmConsole.reg_free_domain.value = CharShow;
	if(isThai == true){
		return false;
	}else{
		return true;	
	}
}

function EngOnly3(e){
	var isThai=false;
	var keyCode = e.keyCode || e.which;
	var keyChar = String.fromCharCode(keyCode);
	var keyblock = new Array(33,64,35,36,37,94,38,42,40,41,95,43,61,92,123,125,91,93,58,59,34,39,60,62,44,46,63,47);
	var CharShow = "";

	for(var k=0 ; k<keyblock.length ; k++){
		if(keyCode == keyblock[k]){
			return false;
		}
	}
	if(keyChar >= '~'){
		return false;
	}

	for(i=0;i<document.getElementById('d_name_new').value.length;i++){
		if(document.getElementById('d_name_new').value.charAt(i) >= '~') {
			isThai = true;
		}else{
			CharShow += document.getElementById('d_name_new').value.charAt(i);
		}
	}

	document.getElementById('d_name_new').value = CharShow;
	if(isThai == true){
		return false;
	}else{
		return true;	
	}
}

function EngOnly5(e){
	var isThai=false;
	var keyCode = e.keyCode || e.which;
	var keyChar = String.fromCharCode(keyCode);
	var keyblock = new Array(33,64,35,36,37,94,38,42,40,41,95,43,61,92,123,125,91,93,58,59,34,39,60,62,44,63,47);
	var CharShow = "";

	for(var k=0 ; k<keyblock.length ; k++){
		if(keyCode == keyblock[k]){
			return false;
		}
	}
	if(keyChar >= '~'){
		return false;
	}

	for(i=0;i<document.getElementById('d_name_transfer').value.length;i++){
		if(document.getElementById('d_name_transfer').value.charAt(i) >= '~') {
			isThai = true;
		}else{
			CharShow += document.getElementById('d_name_transfer').value.charAt(i);
		}
	}

	document.getElementById('d_name_transfer').value = CharShow;
	if(isThai == true){
		return false;
	}else{
		return true;	
	}
}

function CloseWindows(){
	window.close();
}

function OnMouseBG(obj,color){ //เปลี่ยน bgcolor
	obj.style.background=color;
}

function OnMouseBG1(obj,color,text,img_name,img_src,i){ //เปลี่ยน bgcolor
	obj.style.background=color;
	obj.style.color=text;
	document.chk_mside[i].src = img_src;
}


function OnMouseText(obj,color){	//เปลี่ยน textcolor
	obj.style.color=color;
}

function formatNumber(num, decplaces) {
	num = parseFloat(num);
	if (!isNaN(num)) {
		var str = "" + Math.round (eval(num) * Math.pow(10,decplaces));
		if (str.indexOf("e") != -1) {
			return "Out of Range";
		}
		while (str.length <= decplaces) {
			str = "0" + str;
		}

		var decpoint = str.length - decplaces;
		var tmpNum = str.substring(0,decpoint);
		//---------------Add Commas--------------------------
		var numRet = tmpNum.toString();
		var re = /(-?\d+)(\d{3})/;
		while (re.test(numRet)) {
			numRet = numRet.replace(re, "$1,$2");
		}
		return numRet + "." + str.substring(decpoint,str.length);
	//	return numRet;
	} else {
		return "0.00";
	}
} 

function formatNumber2(num, decplaces) {
	num = parseFloat(num);
	if (!isNaN(num)) {
		var str = "" + Math.round (eval(num) * Math.pow(10,decplaces));
		if (str.indexOf("e") != -1) {
			return "Out of Range";
		}
		while (str.length <= decplaces) {
			str = "0" + str;
		}

		var decpoint = str.length - decplaces;
		var tmpNum = str.substring(0,decpoint);
		//---------------Add Commas--------------------------
		var numRet = tmpNum.toString();
		var re = /(-?\d+)(\d{3})/;
		while (re.test(numRet)) {
			numRet = numRet.replace(re, "$1,$2");
		}
		return numRet + "" + str.substring(decpoint,str.length);
	//	return numRet;
	} else {
		return "0.00";
	}
} 

function CheckEnter(callFunction,valueFunction){
	var cChr;
	cChr = e.keyCode || e.which;
	if (cChr == 13)
	{
		callFunction(valueFunction);
	}
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
	  return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
	  return "";
	}
	else{
	  return TRIM_VALUE;
	}
}

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
	  return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
	  if(VALUE.charAt(iTemp) == w_space){
	  }
	  else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
			 }
	  iTemp = iTemp-1;

	} //End While
		   return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
	  if(VALUE.charAt(iTemp) == w_space){
	  }
	  else{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	  }
	  iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function


//--------start title box--------------------------------------------------------------

/***********************************************
* Fixed ToolTip script- ? Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
		
var tipwidth='150px' //default tooltip width
var tipbgcolor='lightyellow'  //tooltip bgcolor
var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="0px" //horizontal offset of tooltip from anchor link
var horizontal_offset="-3px" //horizontal offset of tooltip from anchor link

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, tipwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function fixedtooltip(menucontents, obj, e, tipwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidetip()
dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv
dropmenuobj.innerHTML=menucontents

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", tipwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
}

function hidetip(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidetip(){
if (ie4||ns6)
delayhide=setTimeout("hidetip()",disappeardelay)
}

function clearhidetip(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
//--------end title box--------------------------------------------------------------

function checkEmail(inputvalue){	
	var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	if(pattern.test(inputvalue)){         
		return true;
	}else{   
		return false;
	}
}

function EngOnly4(e){
	var isThai=false;
	var keyCode = e.keyCode || e.which;
	var keyChar = String.fromCharCode(keyCode);
	var keyblock = new Array(33,64,35,36,37,94,38,42,40,41,95,43,61,92,123,125,91,93,58,59,34,39,60,62,44,46,63,47);
	var CharShow = "";
 
	for(var k=0 ; k<keyblock.length ; k++){
		if(keyCode == keyblock[k]){
			return false;
		}
	}
	if(keyChar >= '~'){
		return false;
	}
 
	for(i=0;i<document.frmConsole.d_name_new2.value.length;i++){
		if(document.frmConsole.d_name_new2.value.charAt(i) >= '~') {
			isThai = true;
		}else{
			CharShow += document.frmConsole.d_name_new2.value.charAt(i);
		}
	}
 
	document.frmConsole.d_name_new2.value = CharShow;
	if(isThai == true){
		return false;
	}else{
		return true;	
	}
}

function checkDomainDot2(e,type){
		var Domain = Trim(document.frmConsole.d_name_new2.value);
		if(Domain.value == "" || document.frmConsole.d_name_new2.value.replace(/[ ]/g,"")==""){
			alert("กรุณากรอก โดเมน ที่ท่านต้องการด้วยค่ะ");
			document.frmConsole.d_name_new2.style.backgroundColor = "#FBB1B1";
			document.frmConsole.d_name_new2.focus(); 
		}else if(Domain.length < 3){
			alert("กรุณากรอก โดเมน ให้มีความยาวมากกว่า 3 ตัวอักษรค่ะ");
			document.frmConsole.d_name_new2.style.backgroundColor = "#FBB1B1";
			document.frmConsole.d_name_new2.focus(); 
		}else{
			Ret = EngOnly4(e);
			if(Ret){ /*True คือผ่าน False คือไม่ผ่าน*/
				document.frmConsole.d_name_new2.style.backgroundColor = "#fdfd9b";
				document.frmConsole.in_status.value = 2;
				document.frmConsole.check_new_domain.value = 3;
				var tmp_domain = Trim(document.frmConsole.d_name_new2.value);
				document.frmConsole.d_name_home_search.value = tmp_domain;
				callfrm('quick/index.php?orderpage=check_domain');
			}else{
				alert("กรุณากรอก โดเมน ให้ถูกต้องด้วยค่ะ");
				document.frmConsole.d_name_new2.style.backgroundColor = "#FBB1B1";
				document.frmConsole.d_name_new2.focus(); 
				document.frmConsole.d_name_new2.value=''; 
			}
		}
	}
