	/*********************************************************

	Teleweb schedule script

	Developed by: Raymond Ko, AP ibm.com Production Services

	Date: 12-02-2004

	version: 1.0

	**********************************************************/

	//****EDITOR CHECKLIST*******/

	//1. Check call centre status

	//2. Please select one time zone only

	//3. Update CallMeSchedule using local time.

	//4. Update holidays schedule

	/**************************************************/

	//CHOOSE ONE ONLY !!

	var status = true; // turn call centre on

	//var status = false;// turn call centre off

	/***************************************************/

	var days = 10;

	var holidays = new Array(days);

	holidays[0] = new Date(Date.parse("Jan 30,2006"));

	holidays[1] = new Date(Date.parse("Jan 31,2006"));

	holidays[2] = new Date(Date.parse("Feb 1,2006"));

	holidays[3] = new Date(Date.parse("Feb 2,2006"));

	holidays[4] = new Date(Date.parse("Feb 28,2006"));

	holidays[5] = new Date(Date.parse("May 31,2006"));

	holidays[6] = new Date(Date.parse("Oct 6,2005"));

	holidays[7] = new Date(Date.parse("Oct 10,2005"));

	/***************************************************/

	//CHOOSE ONE ONLY !!

	//var timezone = 10; //AU WINTER - GMT + 10

	//var timezone = 11; //AU SUMMWE - GMT + 11

	var timezone = 8; //ASEAN,HK,CN and TW - GMT + 8

	//var timezone =  9 //KR and JP - CMT + 9

	/***************************************************/

	//CallCenter URL

	var callmeURL = "https://www-07.ibm.com/tw/BT/IBM_TEN_CallMeNowWrn_tw.html"; //<- Callmeback URL

	var callmeURLlater = "https://www-07.ibm.com/tw/BT/IBM_TEN_CallMeLaterWrn_tw.html"; //<- Callmelater URL

	var texchatURL = "https://www-07.ibm.com/tw/BT/IBM_TEN_TextChatWrn_tw.html"; //<- TexChat URL

	/**************************************************/

	var CallMeSchedule = new Array();

    CallMeSchedule[0] = new Array(7);

    for (var i = 0; i < 7; i++)

    {

     CallMeSchedule[0][i] = new Array(2);

     }

     CallMeSchedule[0][0][0] = "1:00"; //Sunday start time

     CallMeSchedule[0][0][1] = "1:00"; //Sunday end time

     CallMeSchedule[0][1][0] = "9:00";//Monday start time

     CallMeSchedule[0][1][1] = "17:00";//Monday end time

     CallMeSchedule[0][2][0] = "9:00";//Tuesday start time

     CallMeSchedule[0][2][1] = "17:00";//Tuesday end time

     CallMeSchedule[0][3][0] = "9:00";//Wednesday start time

     CallMeSchedule[0][3][1] = "17:00";//Wednesday end time

     CallMeSchedule[0][4][0] = "9:00";//Thursday start time

     CallMeSchedule[0][4][1] = "17:00";//Thursday end time

     CallMeSchedule[0][5][0] = "9:00";//Friday start time

     CallMeSchedule[0][5][1] = "17:00";//Friday end time

     CallMeSchedule[0][6][0] = "1:00";//Saturday start time

     CallMeSchedule[0][6][1] = "1:00";//Saturday end time

/*************************************************************/

// Return the hour component of the time given in HH:MM format.

function get_hour( time )

{

   var end = time.indexOf( ":" );

   var hours = time.substring( 0, end );

   return hours;

}



// Return the minutes component of the time given in HH:MM format.

function get_minutes( time )

{

   var start = time.indexOf( ":" ) + 1;

   var end = time.length;

   var minutes = time.substring( start, end );

   return minutes;

}

function Check_Time( schedule )

{

   var visible = false;

   var date_obj = new Date();

   var dow = date_obj.getDay();



   var start_time = schedule[0][dow][0];

   var stop_time = schedule[0][dow][1];

   var avail = CheckVdnOpen( date_obj, start_time, stop_time );

   visible = (visible || avail);

  

   return visible;

}



function CheckVdnOpen( date, start, end )

{

   var available = false;

   var current_time = date.getTime();

   var offset = date.getTimezoneOffset();

   var isdayoff = false;



   // extract hour & minutes components of start & stop times

   var start_hour = get_hour( start );

   var start_min = get_minutes( start );

   var stop_hour = get_hour( end );

   var stop_min = get_minutes( end );



   // convert hours & minutes from String to Integer

   start_hour = parseInt( start_hour );

   start_min = parseInt( start_min );

   stop_hour = parseInt( stop_hour );

   stop_min = parseInt( stop_min );

    

    // convert hours & minutes into date object.

	

	var time_start = new Date();

	var time_end = new Date();

	time_start.setUTCHours(start_hour-timezone);

	time_start.setUTCMinutes(start_min,00);

	time_end.setUTCHours(stop_hour - timezone);

	time_end.setUTCMinutes(stop_min,00);

	

	var start_time = time_start.getTime();

	var end_time = time_end.getTime();

	for(var i = 0; i < days; i++){

		var hdate = new Date(holidays[i]);	

		if(date.getMonth() == hdate.getMonth() && date.getDate() == hdate.getDate()) {

		isdayoff = true;

		}

	}

  

  //check if the schedule is available

  if (status == true){

  	if(isdayoff == false){

		if ( end_time > start_time ) {

      		if ( current_time >= start_time && current_time <= end_time ) available = true;

  		}

	}

  }



   return available;

}