//--------------------------------------------------------------
function click() {
	if (event.button==2) alert('Copyright eFinanceThai.com');
} 

//document.onmousedown=click
//--------------------------------------------------------------

function writetext(text)
{
	document.write(text);
}

function write_popup_index(name,filename,width,height)
{
	a ="<OBJECT codeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width='460' height='345' name='banner'><PARAM NAME='movie' VALUE='"+filename+"'>"
	a =a+"<PARAM NAME='quality' VALUE='high'><embed src='"+filename+"' quality='high' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='460' height='345'></embed></OBJECT>"
	writetext(a);
}


function OpenPopup(WindowName,text,height,width,top,left)
{
	var posleft=parseFloat(left);
	if((posleft+parseFloat(width)) > screen.width){posleft=screen.width-width;}
	
	OpenWindow=window.open("",WindowName, "height="+height+", width="+width+",top=0,left="+posleft+",toolbar=no,scrollbars="+scroll+",menubar=no");

	if(OpenWindow)
	{
		OpenWindow.document.write(text);
		OpenWindow.document.close()
		self.name="main"
		OpenWindow.location.reload() 
	}
}



function OpenNewPopup(WindowName,file,height,width,top,left)
{
	var posleft=parseFloat(left);
	if((posleft+parseFloat(width)) > screen.width){posleft=screen.width-width;}
	
	OpenWindow=window.open(file,WindowName, "height="+height+", width="+width+",top=0,left="+posleft+",toolbar=no,scrollbars="+scroll+",menubar=no");
}

function setImageSize() {
	//"Constansts"
	var thumbPrefix = "Banner_relate"; //What's before thumbnail's IDs
	var maxWidth = (screen.width-40)/2;	//, maxHeight = 360; //Max size of thumbnails
	alert("maxwidth = " & screen.width);
	//If we can access the images
	if (document.images) {
		//Loop for all images
		for (var loopCounter = 0; loopCounter < document.images.length; loopCounter++) {
		//If this one starts with thumbPrefix
		if (document.images[loopCounter].id.substring(0, thumbPrefix.length) == thumbPrefix) {
		//If this one is too wide, shrink it
			if (document.images[loopCounter].width > maxWidth)
				document.images[loopCounter].width = maxWidth;
				//document.images[loopCounter].style.display = 'block';
			////Same for height
			//if (document.images[loopCounter].height > maxHeight)
			//document.images[loopCounter].height = maxHeight;
			}
		}
	}
		
}

function clearForm(formIdent) 
{ 
  var form, elements, i, elm; 
  form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.elements;
		for( i=0, elm; elm=elements.item(i++); )
		{
			if ((elm.getAttribute('type') == "text")||(elm.getAttribute('type') == "textarea"))
			{	
				if(elm.name!='txt_BannerLocateRequire')
				{
					elm.value = '';
				}
				
			}				
		}
	}
}

function ChkRequire(formIdent)
{
	var flagReturn=true;
	var strFind='Require';
	var strCommentID;
	var form, elements, i, elm; 
	form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.elements;
		for( i=0, elm; elm=elements.item(i++); )
		{
			if ((elm.getAttribute('type') == "text")||(elm.getAttribute('type') == "textarea"))
			{	
				if ((elm.name).indexOf(strFind)!=-1)
				{
					strCommentID= (elm.name).replace(/txt/,"lbl");
					if((elm.name).indexOf("mail")!=-1)
					{
						if(ChkMail()==false){
							document.getElementById(strCommentID).style.color='red';
							flagReturn=false;
							break;
						}
					}
					else if(elm.value=='')
					{
						document.getElementById(strCommentID).style.color='red';
						flagReturn=false;
						break;
					}
					else{
						document.getElementById(strCommentID).style.color='white';
					}					
				}				
			}
		}
	}
	return flagReturn;
}

function ChkMail()
{
	var flagChk=false;
	var strMail=document.getElementById("txt_emailRequire").value;

	if((strMail.indexOf("@")!=-1)&&(strMail.indexOf(".")!=-1))
	{
		document.getElementById("lbl_emailRequire").style.color='white';
		flagChk=true;}
	else{
		document.getElementById("lbl_emailRequire").style.color='red';
		flagChk=false;
	}
	
	return flagChk;
}


function Open_popup(windowname,filename,height,width) { 
   var WindowName=windowname; 
 
   if (windowname.indexOf("1")!=-1) {
   	var left=screen.width-width;
   }
   else{
	var left=0;
   }
	var top=0;
     
   strFeatures = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left="+left+",top="+top+""; 

   frmpopup = window.open(filename, WindowName, strFeatures); 
   if (frmpopup){
   frmpopup.focus();} 
}


//*********************Create by kung***************************//
function bannedKey(evt,EngRight,ThaiRight,NumRight)
{
var allowedEng = EngRight; //Í¹Ø­ÒµãËé¤ÕÂìÍÑ§¡ÄÉ
var allowedThai = ThaiRight; //Í¹Ø­ÒµãËé¤ÕÂìä·Â
var allowedNum = NumRight; //Í¹Ø­ÒµãËé¤ÕÂìµÑÇàÅ¢

var k = evt.keyCode;

/* check Numeric 0-9 */
//if (k>=48 && k<=57) { return allowedNum; }
if (allowedNum == false){if (k>=48 && k<=57){return false;}}
if (allowedNum == true){if (k<48 || k>57){return false;}}
/* Check English Language a-z, A-Z */
//if ((k>=65 && k<=90) || (k>=97 && k<=122)) { return allowedEng; }
if (allowedEng == false){if ((k>=65 && k<=90) || (k>=97 && k<=122)){return false;}}
/* Check Thai Language non-unicode and unicode */
//if ((k>=161 && k<=255) || (k>=3585 && k<=3675)) { return allowedThai; }
if (allowedThai == false){if ((k>=161 && k<=255) || (k>=3585 && k<=3675)){return false;}}
}


function IsNumeric(sText)
{
var ValidChars = "0123456789.";
var IsNumber=true;
var Char;

for (i = 0; i < sText.length && IsNumber == true; i++){Char = sText.charAt(i);if (ValidChars.indexOf(Char) == -1){IsNumber = false;}}return IsNumber;}

var count;

function limiter(txtLen,textId){var tex = document.getElementById(textId).value;var len = tex.length;count = txtLen;
if(len > count){tex = tex.substring(0,count);document.getElementById(textId).value =tex;return false;}}
	
function  PBMS_CreateControl(DivID,CodeBase,ClassID,Width,Height,URL,LINK,PLAY)
{

		
	var d = document.getElementById(DivID);
	if (LINK != '')
	{
		//alert('Link');
		d.innerHTML ='<OBJECT onmousedown="window.open(\''+LINK+'\');"   codeBase='+CodeBase+' classid='+ClassID+' width='+Width+' height='+Height+'><PARAM NAME="WMode" VALUE="transparent"><PARAM NAME="movie" VALUE='+URL+'><PARAM NAME="play" VALUE= '+PLAY+'><embed src='+URL+' quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width='+Width+' height='+Height+'></embed></OBJECT>';
	}
	else
	{
		//alert('No Link');
		d.innerHTML ='<OBJECT  codeBase='+CodeBase+' classid='+ClassID+' width='+Width+' height='+Height+'><PARAM NAME="movie" VALUE='+URL+'><PARAM NAME="play" VALUE= '+PLAY+'><embed src='+URL+' quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width='+Width+' height='+Height+'></embed></OBJECT>';
	}
	//document.write(d.innerHtml);

}	


