﻿<!--
/***********************************************
* Auto Maximize Window Script- ? Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for this script and 100's more.
***********************************************/
function maximizeWindow(){
	top.window.moveTo(0,0);
	if (document.all) {
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers||document.getElementById) {
		if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
}
//-->

function popup_window(width,height,location,window_name){
	child=window.open(location,window_name,'height='+ height +',width=' + width + ',menubar=no,status=no,toolbar=no,scrollbars=no');
	child.moveTo(screen.availWidth/2-(width/2),screen.availHeight/2-(height/2));
	child.focus();
}

function popup_window_scrollbar(width,height,location,window_name){
	child=window.open(location,window_name,'height='+ height +',width=' + width + ',menubar=yes,status=no,toolbar=no,scrollbars=yes');
	child.moveTo(screen.availWidth/2-(width/2),screen.availHeight/2-(height/2));
	child.focus();
}


function callParentUpdateCaseViewFrame(tran_no,page_action,frame_id,tab_index){
    	window.parent.updateCaseViewFrame(tran_no,page_action,frame_id,tab_index);
}

function updateCaseViewFrame(tran_no,page_action,frame_id,tab_index){
    	document.getElementById(frame_id).src=page_action+"?mode=edit&tran_no=" + tran_no;
        Chk_Tab.value = tab_index;
        mcTabs.displayTab('T'+tab_index,'D'+tab_index);
        //document.getElementById('case_view').innerHTML=" View Case ID <font style='color=#0000FF;'>" + case_id + "</font>";
        //document.getElementById('select_case').value=document.getElementById('select_case').value + case_id + ',' + tran_no + "|" ;
    }

function validateFrmChangePassword(){
    	var current_password=frm_change_password.current_password;
        var new_password=frm_change_password.new_password;
        var renew_password=frm_change_password.renew_password;
        var result=true;

        if(current_password.value==""){
            current_password.style.backgroundColor='FFFF66';
            current_password.focus();
            result=false;
        } else current_password.style.backgroundColor='FFFFFF';

        if(new_password.value==""){
            new_password.style.backgroundColor='FFFF66';
            if(result==true) new_password.focus();
            result=false;
        } else new_password.style.backgroundColor='FFFFFF';

        if(renew_password.value==""){
            renew_password.style.backgroundColor='FFFF66';
            if(result==true) renew_password.focus();
            result=false;
        } else renew_password.style.backgroundColor='FFFFFF';

        if(result==false){
        	alert("Please correct the incomplete fileds !");
        }

        if(result==true){
        	if((new_password.value!=renew_password.value)){
	            new_password.style.backgroundColor='FFFF66';
	            renew_password.style.backgroundColor='FFFF66';
                new_password.focus();
                alert("Please correct the incomplete fileds !");
	            result=false;
	        }
	        else if(new_password.value==renew_password.value) {
	            new_password.style.backgroundColor='FFFFFF'
	            renew_password.style.backgroundColor='FFFFFF'
	        }
        }

        return result;
    }

 function closeWindow(){

    window.opener=self;

    window.open('','_parent','');

    window.close();

}

function clearText(thisControl){
	if(thisControl.value=="0.00")thisControl.value="";
}
function setDefaultValue(thisControl){
    if(thisControl.value=="")thisControl.value="0.00";
}

//Hilighting data row========================================
/*
function clickRow(thisRow){
	if(thisRow.className=='selectRow')
    	thisRow.className='unselectRow';
    else
		thisRow.className='selectRow';
}
function mouseoverRow(thisRow){
    if(thisRow.className!='selectRow')
    	thisRow.style.backgroundColor='#DAE6E5';
}
function mouseoutRow(thisRow){
    if(thisRow.className!='selectRow')
    	thisRow.style.backgroundColor='#FFFFFF';
}
*/



function clickRow(thisRow){
	if(thisRow.className=='selectRow')
    	thisRow.className='unselectRow';
    else
		thisRow.className='selectRow';
}
function mouseoverRow(thisRow,color_get){

    if(thisRow.className!='selectRow'){
    	thisRow.style.backgroundColor=color_get;
	}
}
function mouseoutRow(thisRow,color_get){

    if(thisRow.className!='selectRow'){
    	thisRow.style.backgroundColor=color_get;
	}
}








/*
	//Hilighting data row 2
function mouseoverRow2(thisRow,user_id){

var status_id = "status"+user_id;
var status = document.getElementById(status_id);
var con_status_id = "constatus"+user_id;
var con_status = document.getElementById(con_status_id);
var row_id ="row"+user_id;
var row_var =document.getElementById(row_id);

	if(status.innerHTML == 'disable' && con_status.innerHTML != 'terminated') thisRow.style.backgroundColor='#F0E68C';
	else if(con_status.innerHTML == 'terminated') thisRow.style.backgroundColor='#FA8072';
	else{
		if(thisRow.className!='selectRow')
		thisRow.style.backgroundColor='#DAE6E5';
	}
}

function mouseoutRow2(thisRow,user_id){

	var status_id = "status"+user_id;
	var status = document.getElementById(status_id);
	var con_status_id = "constatus"+user_id;
	var con_status = document.getElementById(con_status_id);
	var row_id ="row"+user_id;
	var row_var =document.getElementById(row_id);

		if(status.innerHTML == 'disable' && con_status.innerHTML != 'terminated') thisRow.style.backgroundColor='#F2EFD9';
		else if(con_status.innerHTML == 'terminated') thisRow.style.backgroundColor='#F2D7D5';
		else{
			if(thisRow.className!='selectRow')
			thisRow.style.backgroundColor='#FFFFFF';
		}

}
*/


/*
  	Author:		Robert Hashemian (http://www.hashemian.com/)
  	Modified by:	Munsifali Rashid (http://www.munit.co.uk/)
  	Modified by:	Tilesh Khatri
  */

  
function return_to_reservation(){


                    timeout = 1; 
                    window.onload = setTimeout(myRedirect, timeout); // ensure we load the whole page
                    function myRedirect() {
								window.location='reservation_report.php';
                               window.parent.document.getElementById('frame_reservation_report').src='reservation_report.php';
                               window.parent.Chk_Tab.value = '6';
                               window.parent.mcTabs.displayTab('T6','D6');
                               
                    }
					

}
  
function StartCountDown(myDiv,myTargetDate)
  {
    var dthen	= new Date(myTargetDate);
    var dnow	= new Date();
    ddiff		= new Date(dthen-dnow);
    gsecs		= Math.floor(ddiff.valueOf()/1000);
    CountBack(myDiv,gsecs);
  }

function Calcage(secs, num1, num2)
  {
    s = ((Math.floor(secs/num1))%num2).toString();
    if (s.length < 2)
    {
      s = "0" + s;
    }
    return (s);
  }

function CountBack(myDiv, secs)
  {
    var DisplayStr;
    var DisplayFormat = "%%D%% Days %%H%%:%%M%%:%%S%%";
    DisplayStr = DisplayFormat.replace(/%%D%%/g,	Calcage(secs,86400,100000));
    DisplayStr = DisplayStr.replace(/%%H%%/g,		Calcage(secs,3600,24));
    DisplayStr = DisplayStr.replace(/%%M%%/g,		Calcage(secs,60,60));
    DisplayStr = DisplayStr.replace(/%%S%%/g,		Calcage(secs,1,60));
    if(secs > 0)
    {
      document.getElementById(myDiv).innerHTML = DisplayStr;
      setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
    }
    else
    {
      document.getElementById(myDiv).innerHTML = "Accountหมดอายุแล้ว !";
    }
  }

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val) {
  var strPass = val.value;
  var strLength = strPass.length;
  var lchar = val.value.charAt((strLength) - 1);
  var cCode = CalcKeyCode(lchar);

  /* Check if the keyed in character is a number
     do you want alphabetic UPPERCASE only ?
     or lower case only just check their respective
     codes and replace the 48 and 57 */

  if (cCode < 48 || cCode > 57 ) {
    var myNumber = val.value.substring(0, (strLength) - 1);
    val.value = myNumber;
  }
  return false;
}

/*
	Popup Updating value into Parent Window
*/

function AddParentActiveUserField(selected_user){
	var given_users=window.opener.document.getElementById('given_users');
	var user_check=window.document.getElementById(selected_user);
	var indexof;
	if(user_check.checked){
		if(given_users.value != "") {
			given_users.value= given_users.value + "," +selected_user;
		}
		else{
			given_users.value=selected_user;
		}
	}
	else{
		//alert(given_users.value.search(","));
		indexOf=given_users.value.search(selected_user)-1;
		if(indexOf<=0){
			if(given_users.value.search(",")!=-1){
				given_users.value=given_users.value.replace(selected_user + ",","");
			}
			else{
				given_users.value=given_users.value.replace(selected_user,"");
			}
		}
		else{
			given_users.value=given_users.value.replace("," + selected_user,"");
		}

	}
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function show_hide_all_div(id){

	if (id != ""){
		var status_id = document.getElementById(id).style.display;
	
		if (status_id == "none"){
			document.getElementById(id).style.display= "block";
		}
		else{
			document.getElementById(id).style.display= "none";
		}
		
	}

}




