// Copyright 2007 InGenius Software Inc.

function IsTelephonyDivVisible(){var tel_div=FgetElementById("TelephonyDiv");return!(tel_div.style.left=="3000"||tel_div.style.left=="3000px"||tel_div.style.left=="");}
function IsDivVisible(div_id){var div=document.getElementById(div_id);return!(div.style.visibility=="hidden"||div.style.visibility=="");}
function SetDivVisibility(div_id,visibility){document.getElementById(div_id).style.visibility=visibility;}
function SetTelephonyDivLabels(label_1,label_2,label_3,label_12,label_13,label_14){FgetElementById("SK74").innerHTML=label_1;FgetElementById("SK75").innerHTML=label_12;FgetElementById("SK76").innerHTML=label_2;FgetElementById("SK77").innerHTML=label_13;FgetElementById("SK78").innerHTML=label_3;FgetElementById("SK79").innerHTML=label_14;}
function TelephonyDivShow(){FgetElementById("TelephonyDiv").style.left="0px";SetTelephonyDivLabels("Phonebook","","Music On","","Redial","Messaging");F.HideOrRestoreEverythingUnderneath(true, F.UnderneathTelephonyDiv);}
function TelephonyDivHide(){FgetElementById("TelephonyDiv").style.left="3000px";FgetElementById("TextDisplay").innerHTML="";F.HideOrRestoreEverythingUnderneath(false, F.UnderneathTelephonyDiv);}
function TelephonyDivToggle(){SetDivVisibility("Lamp","hidden");if(IsTelephonyDivVisible()){TelephonyDivHide();}else{TelephonyDivShow();}}
function SetHandsetOffHook(set_off_hook){if(set_off_hook==-1)
set_off_hook=(document.getElementById("P").src.indexOf("5340-phone.gif")!=-1&&!IsTelephonyDivVisible());document.getElementById("P").src=(set_off_hook)?"Demo_Images/5340-phone-off.gif":"Demo_Images/5340-phone.gif";document.getElementById("AreaHookswitch").title=(set_off_hook)?"Hang up":"Answer";}
var simulate_answer=false;function TelephonyDivOffHookToggle(handset_click){if(simulate_answer){SetHandsetOffHook(true);SetTelephonyDivLabels("","","","","Trans/Conf","Hang-up");SetDivVisibility("Lamp","hidden");simulate_answer=false;return;}else{SetHandsetOffHook((handset_click?-1:false));}
SetDivVisibility("Lamp","hidden");SetDivVisibility("Sound",(IsDivVisible("Sound"))?"hidden":"visible");if(!IsDivVisible("Sound")){TelephonyDivHide();}else{TelephonyDivShow();}
SetTelephonyDivLabels("","","","","Redial","Hang-up");}
function TelephonyDivOnHook(){SetDivVisibility("Lamp","hidden");SetDivVisibility("Sound","hidden");SetHandsetOffHook(false);TelephonyDivHide();}
function TelephonyDivIncoming(sim_answ){if(document.getElementById("P").src.indexOf("Demo_Images/5340-phone.gif")!=-1){simulate_answer=sim_answ;TelephonyDivShow();FgetElementById("TextDisplay").innerHTML="1907 NICHOLAS COHEN";SetTelephonyDivLabels("","","","","","");SetDivVisibility("Sound","visible");SetDivVisibility("Lamp","visible");}else{alert("You have to hang up first :)");}}
function DialMockUp(number)
{TelephonyDivShow();SetDivVisibility("Sound","visible");SetDivVisibility("Lamp","visible");FgetElementById("TextDisplay").innerHTML=number;SetTelephonyDivLabels("Call Me Back","","Leave A Msg","","","Hang-up");}
function displayTime()
{var TimerDIV=document.getElementById("TimeDisplay");var CurrentTime=new Date();if(TimerDIV){var Minutes=new String(CurrentTime.getMinutes());if(Minutes.length<2)
Minutes="0"+Minutes;TimerDIV.innerHTML=CurrentTime.getHours()+":"+Minutes;}}
function displayDate()
{var DateDIV=document.getElementById("DateDisplay");var CurrentTime=new Date();var num_month=(CurrentTime.getMonth()+1);var abbrev_month="";switch(num_month){case 1:abbrev_month="JAN";break;case 2:abbrev_month="FEB";break;case 3:abbrev_month="MAR";break;case 4:abbrev_month="APR";break;case 5:abbrev_month="MAY";break;case 6:abbrev_month="JUN";break;case 7:abbrev_month="JUL";break;case 8:abbrev_month="AUG";break;case 9:abbrev_month="SEP";break;case 10:abbrev_month="OCT";break;case 11:abbrev_month="NOV";break;case 12:abbrev_month="DEC";break;}
if(DateDIV){DateDIV.innerHTML=CurrentTime.getDate()+"-"+abbrev_month+"-"+CurrentTime.getFullYear();}}