﻿// JScript File

//Multiple Select in Gridview.
 function SelectAllCheckboxes(spanChk){

   // Added as ASPX uses SPAN for checkbox
   var oItem = spanChk.children;
   var theBox= (spanChk.type=="checkbox") ? 
        spanChk : spanChk.children.item[0];
   xState=theBox.checked;
   elm=theBox.form.elements;

   for(i=0;i<elm.length;i++)
     if(elm[i].type=="checkbox" && 
              elm[i].id!=theBox.id)
     {
       //elm[i].click();
       if(elm[i].checked!=xState)
         elm[i].click();
       //elm[i].checked=xState;
     }
 }

function RefreshPage()
{
	window.location.href = window.location.href ;
}
function RedirectPage(url)
{
	window.location.href = url ;
}
function PopupForm(url){
	var newWindow;
	
	newWindow = showModalDialog(url,'','dialogWidth=600px,dialogHeight=500px,help=no;status=no,scrollbar=no')
	RefreshPage();
	//newWindow = window.open(urlstring,'','height=166,width=257,toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=no')
}
function OpenWindow(url){
	var newWindow;
	
	newWindow = window.open(url,'','height=600,width=750,toolbar=no,minimize=no,resizable=yes,status=no,memubar=no,location=no,scrollbars=yes')
	RefreshPage();
	//newWindow = window.open(urlstring,'','height=166,width=257,toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=no')
}
function CloseWindow(){
    window.close();
}
function PopupWin(url,w,h){
///Parameters url=page to open, w=width, h=height
window.open(url, "external", "width=" + w +",height=" + h + ",resizable=no,scrollbars=no,status=no,location=no,toolbar=no,menubar=no");
}

function highlight(which,color){
if (document.all||document.getElementById)
which.style.backgroundColor=color
}

function log_out()
{
	ht = document.getElementsByTagName("html");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
//return confirm('คุณแน่ใจหรือไม่ ที่จะออกจากระบบ?')
	if (confirm('คุณแน่ใจหรือไม่ ที่จะออกจากระบบ?'))
	{
		return true;
	}
	else
	{
		ht[0].style.filter = "";
		return false;
	}
}

//Generating Pop-up Print Preview pagefunction 
function getPrint(print_area)
{ 
//Creating new page
var pp = window.open();
//Adding HTML opening tag with <HEAD> … </HEAD> portion 
pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')
pp.document.writeln('<LINK href=Styles.css type="text/css" rel="stylesheet">')
pp.document.writeln('<LINK href=PrintStyle.css type="text/css" rel="stylesheet" media="print">')
pp.document.writeln('<base target="_self"></HEAD>')
//Adding Body Tag
pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');
pp.document.writeln(' leftMargin="0" topMargin="0" rightMargin="0">');
//Adding form Tag
pp.document.writeln('<form method="post">');
//Creating two buttons Print and Close within a HTML table
pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');
pp.document.writeln('<INPUT ID="PRINT" type="button" value="Print" ');
pp.document.writeln('onclick="javascript:location.reload(true);window.print();">');
pp.document.writeln('<INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();">');
pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');
//Writing print area of the calling page
pp.document.writeln(document.getElementById(print_area).innerHTML);
//Ending Tag of </form>, </body> and </HTML>
pp.document.writeln('</form></body></HTML>'); 
} 

//<!-- Begin of Swap Image Buton -->
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
