initial commit
[home-automation.git] / index.php
1 <? include("includes.php"); 
2    include("xml2array.php");
3 ?>
4 <html>
5 <head>
6
7 <script type="text/javascript" src="/include/java/prototype.js"></script>
8 <script type="text/javascript" src="/include/java/scriptaculous.js?load=effects"></script>
9 <script type="text/javascript" src="/include/java/lightbox.js"></script>
10
11 <link rel="stylesheet" href="/include/css/lightbox.css" type="text/css" media="screen" />
12
13 <script type="text/javascript">
14
15 /***********************************************
16 * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
17 * This notice MUST stay intact for legal use
18 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
19 ***********************************************/
20
21 var bustcachevar=0 //bust potential caching of external pages after initial request? (1=yes, 0=no)
22 var loadedobjects=""
23 var rootdomain="http://"+window.location.hostname
24 var bustcacheparameter=""
25
26 function ajaxpage(url, containerid){
27   //alert("updating page");
28   var page_request = false
29   if (window.XMLHttpRequest) // if Mozilla, Safari etc
30     page_request = new XMLHttpRequest()
31   else if (window.ActiveXObject){ // if IE
32     try {
33       page_request = new ActiveXObject("Msxml2.XMLHTTP")
34     } 
35     catch (e){
36       try{
37         page_request = new ActiveXObject("Microsoft.XMLHTTP")
38       }
39     catch (e){}
40     }
41   }
42   else
43     return false
44   page_request.onreadystatechange=function(){
45     loadpage(page_request, containerid)
46   }
47   if (bustcachevar) //if bust caching of external page
48     bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
49   page_request.open('GET', url+bustcacheparameter, true)
50   page_request.send(null)
51 }
52
53 function resize(which, max) {
54   var elem = document.getElementById(which);
55   if (elem == undefined || elem == null) return false;
56   if (max == undefined) max = 100;
57   if (elem.width > elem.height) {
58     if (elem.width > max) elem.width = max;
59   } else {
60     if (elem.height > max) elem.height = max;
61   }
62 }
63
64
65 function getPixelsFromTop(obj){
66         objFromTop = obj.offsetTop;
67         while(obj.offsetParent!=null) {
68                 objParent = obj.offsetParent;
69                 objFromTop += objParent.offsetTop;
70                 obj = objParent;
71         }
72         return objFromTop;
73 }
74
75
76 function resizeheight(height,width) {
77   screen_title=parseInt(title.offsetHeight);
78   screen_menubar=150;
79   full_height=parseInt(fullheight.offsetHeight);
80   screen_height=screen_title+screen_menubar+parseInt(height);
81   if (screen_height>full_height) {
82     //newheight=(full_height-(screen_title+screen_menubar));
83     contentTopDiv = document.getElementById("contenttop")
84     contentBotDiv = document.getElementById("contentbottom")
85     contentTop = getPixelsFromTop(contentTopDiv);
86     contentBottom = getPixelsFromTop(contentBotDiv);
87     contentHeight = contentBottom - contentTop;
88
89     //alert("The cell height is " + contentHeight);
90
91     newheight=contentHeight;
92
93     percentage=newheight/height;
94     newwidth=parseInt(width*percentage);
95     var security = document.getElementById('security');
96     security.style.width=newheight+"px";
97     security.style.height=newwidth+"px";
98     //security.style.width=newheight;
99     //security.style.height=newwidth;
100     //alert(newwidth+" "+newheight);
101   } else {
102     //alert("not resizing height");
103   //  return(height);
104   }
105 }
106
107
108 function insteon(url) {
109   var page_request = false
110   if (window.XMLHttpRequest) // if Mozilla, Safari etc
111     page_request = new XMLHttpRequest()
112   else if (window.ActiveXObject){ // if IE
113     try {
114       page_request = new ActiveXObject("Msxml2.XMLHTTP")
115     }
116     catch (e){
117       try{
118         page_request = new ActiveXObject("Microsoft.XMLHTTP")
119       }
120     catch (e){}
121     }
122   }
123   else
124     return false
125   if (bustcachevar) //if bust caching of external page
126     bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
127   page_request.open('GET', url+bustcacheparameter, true)
128   page_request.send(null)
129
130 }
131
132 function sillytimeout() {
133   ajaxpage('check_isy99i_status.php', 'contentarea');
134 }
135
136 function update_isy99() {
137   var t=setTimeout("sillytimeout()", 10000);
138 }
139
140 function loadpage(page_request, containerid){
141   if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
142   document.getElementById(containerid).innerHTML=page_request.responseText;
143 }
144
145 function loadobjs(){
146   if (!document.getElementById)
147     return
148   for (i=0; i<arguments.length; i++){
149     var file=arguments[i]
150     var fileref=""
151     if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
152       if (file.indexOf(".js")!=-1){ //If object is a js file
153         fileref=document.createElement('script')
154         fileref.setAttribute("type","text/javascript");
155         fileref.setAttribute("src", file);
156       }
157       else if (file.indexOf(".css")!=-1){ //If object is a css file
158         fileref=document.createElement("link")
159         fileref.setAttribute("rel", "stylesheet");
160         fileref.setAttribute("type", "text/css");
161         fileref.setAttribute("href", file);
162       }
163     }
164     if (fileref!=""){
165       document.getElementsByTagName("head").item(0).appendChild(fileref)
166       loadedobjects+=file+" " //Remember this object as being already added to page
167     }
168   }
169 }
170
171 function chkObject(theVal) {
172     if (document.getElementById(theVal) != null) {
173       return true;
174     } else {
175       return false;
176     }
177 }
178
179 function title_status() {
180   ajaxpage("title_status.php","title_status");
181   setTimeout("title_status()", 60000);
182 }
183
184 function alert_status() {
185   ajaxpage("alert_status.php","alert_status");
186   setTimeout("alert_status()", 1000);
187 }
188
189 function securityStatus() {
190   ajaxpage('check_isy99i_occupancy_status.php','contentarea');
191   t=setTimeout('securityStatus()', 10000);
192 }
193
194 function lightingStatus() {
195   ajaxpage('check_isy99i_status.php', 'contentarea');
196   t=setTimeout('lightingStatus()', 10000);
197 }
198
199 var weatherpages=new Array();
200   weatherpages[0]="weather1.php";
201   weatherpages[1]="weather2.php";
202   weatherpages[2]="weather3.php";
203   weatherpages[3]="weather4.php";
204   weatherpages[4]="weather5.php";
205   weatherpages[5]="weather6.php";
206
207 var i=0;
208 var t;
209
210 function weatherpageChange() {
211   ajaxpage(weatherpages[i],'contentarea');
212   i++;
213   if (i==weatherpages.length) {
214     i=0;
215   }
216   t=setTimeout("weatherpageChange()",10000);
217 }
218
219 function imageHeaderChange(imgUrl) {
220   var div1 = document.getElementById('imgHeader');
221   div1.innerHTML='<img src=" '+imgUrl + ' ">'
222 }
223
224 function stopchanges(t) {
225   clearTimeout(t);
226   i=0;
227 }
228
229 function changeIcon(icon) {
230   var icons=new Array();
231   icons[0]="home";
232   icons[1]="weather";
233   icons[2]="lighting";
234   icons[3]="music";
235   icons[4]="cameras";
236   icons[5]="security";
237   icons[6]="climate";
238   icons[7]="news";
239   icons[8]="receipes";
240   icons[9]="groceries";
241   icons[10]="traffic";
242   icons[11]="power";
243   for ( var i=icons.length-1; i>=0; --i ){
244     if (icons[i] == icon) {
245       document.getElementById(icon).src = "images/"+icon+"-on.png";
246     } else {
247       document.getElementById(icons[i]).src = "images/"+icons[i]+"-off.png";
248     }
249   }
250 }
251
252 var securitypages=new Array();
253   securitypages[0]="security1.html";
254   securitypages[1]="security2.html";
255   securitypages[2]="security3.html";
256   securitypages[3]="security4.html";
257   securitypages[4]="security5.html";
258   securitypages[5]="security6.html";
259
260 function securitypageChange() {
261   ajaxpage(securitypages[i],'contentarea');
262   i++;
263   if (i==securitypages.length) {
264     i=0;
265   }
266   t=setTimeout("securitypageChange()",10000);
267 }
268
269 function mediacenterSelect(ip) {
270   ajaxpage("jukebox.php?ip="+ip, 'contentarea');
271 }
272
273 function thermostatMode(modeId) {
274   alert(modeId);
275 }
276
277 function thermostatFan(fanId) {
278   alert(fanId);
279 }
280
281 </script>
282
283 <style>
284 body {overflow-y:hidden;
285       height:100%;
286       background-color: #000000;
287       background-image: url('images/bg.jpg');
288       background-repeat:repeat-x;
289       color: white;}
290
291 #menubar {font-family:arial, helvetica; font-size:12px; font-weight:bold;}
292
293 #fullheight{height: 100%;}
294
295 #fullimage{  
296   width: 100%;
297   height: 100%;
298 }
299
300 #imgHeader {
301   float: center;
302   vertical-align:text-top;
303 }
304
305 </style>
306 </head>
307 <body>
308 <table border="0" width=100% id="fullheight">
309 <tr><td>
310
311 <table border=0 align=center cellspacing=0 cellpadding=0 width=100%>
312 <tr style="background-image: url('images/header-repeater.png'); background-repeat: repeat-x;">
313 <td width="40%">
314 <canvas id="canvas3" height="62" width="420"> </canvas>
315 <script language="JavaScript">
316 function testDrawText3(canvas)
317 {
318   var context=canvas.getContext('2d');
319   context.lineWidth=1;
320   context.strokeStyle="#3c3c3c";
321   context.shadowOffsetX=2;
322   context.shadowOffsetY=-2;
323   context.shadowColor="#3c3c3c";
324
325   context.font="22pt ariel";
326   context.fillStyle="#aaaaaa";
327   context.shadowOffsetX=5;
328   context.shadowOffsetY=5;
329   context.shadowBlur=10;
330   context.fillText("HANDORF HOUSE", 10, 35);
331   context.strokeText("HANDORF HOUSE", 10, 35);
332 }
333 testDrawText3(document.getElementById('canvas3'));
334 </script>
335 <!-- <img align="left" src="images/header.png"> -->
336 </td><td><div id="alert_status" style="font-family: Arial;position: relative; top: -6px;">
337 <script language="javascript">
338 alert_status();
339 </script></td><td align="right">
340 <div id="title_status" style="font-family: Arial;position: relative; top: -6px;">
341 <script language="javascript">
342 title_status();
343 </script>
344 </td>
345 <td width=20% align="right" valign="middle">
346 <div id="js_clock" style="font-size:x-large;font-family: Arial;position: relative; top: -6px;">
347 <script language="javascript">function js_clock(){var clock_time = new Date();var clock_hours = clock_time.getHours();var clock_minutes = clock_time.getMinutes();var clock_seconds = clock_time.getSeconds();var clock_suffix = "AM&nbsp;";if (clock_hours > 11){clock_suffix = "PM&nbsp;";clock_hours = clock_hours - 12;}if (clock_hours == 0){clock_hours = 12;}if (clock_hours < 10){clock_hours = "0" + clock_hours;}if (clock_minutes < 10){clock_minutes = "0" + clock_minutes;}if (clock_seconds < 10){clock_seconds = "0" + clock_seconds;}var clock_div = document.getElementById('js_clock');clock_div.innerHTML = clock_hours + ":" + clock_minutes + ":" + clock_seconds + " " + clock_suffix;setTimeout("js_clock()", 1000);}js_clock();</script>
348 </div>
349 </td>
350 </tr>
351 </table>
352
353
354
355 </td></tr>
356 <tr height="100%" valign="top"><td>
357 <div id="contenttop"></div>
358 <table align=center>
359 <tr><td>
360 <div id="imgHeader" align="center"></div>
361 </td></tr>
362 <tr><td>
363 <div id="contentarea" align="center">
364
365 Middle
366
367 </div>
368 </td></tr>
369 </table>
370 <div id="contentbottom"></div>
371 </td></tr>
372 <tr><td>
373
374 <div name="menubar">
375 <table border=0 ALIGN=center cellpadding=0 cellspacing =0 width=100%>
376 <tr style="background-image: url('images/bottom-controls-repeatablebar.jpg'); background-repeat: repeat-x;">
377 <td ALIGN=center>
378 <table border=0 align=center cellpadding=0 cellspacing=0>
379 <tr style="background-image: url('images/bottom-controls-repeatablebar.jpg'); background-repeat: repeat-x;">
380 <td ALIGN=center>
381 <a href="javascript:stopchanges(t);weatherpageChange();imageHeaderChange('images/header-weather.png');changeIcon('weather');"><img src="./images/weather-off.png" onMouseover="" border=0 id="weather"></a>
382 </td>
383 <td ALIGN=center>
384 <a href="javascript:stopchanges(t);lightingStatus();imageHeaderChange('images/header-lighting.png');changeIcon('lighting');"><img src="./images/lighting-off.png" onMouseover="" border=0 id="lighting"></a>
385 </td>
386 <td ALIGN=center>
387 <a href="javascript:stopchanges(t);ajaxpage('jukebox.php', 'contentarea');imageHeaderChange('images/header-thejukebox.png');changeIcon('music');"><img src="./images/music-off.png" onMouseover="" border=0 id="music"></a>
388 </td>
389 <td ALIGN=center>
390 <a href="javascript:stopchanges(t);securitypageChange();imageHeaderChange('images/header-camera.png');changeIcon('cameras');"><img src="./images/cameras-off.png" onMouseover="" border=0 id="cameras"></a>
391 </td>
392 <td ALIGN=center>
393 <a href="javascript:stopchanges(t);securityStatus();imageHeaderChange('images/header-security.png');changeIcon('security');"><img src="./images/security-off.png" onMouseover="" border=0 id="security"></a>
394 </td>
395 <td ALIGN=center>
396 <a href="javascript:stopchanges(t);ajaxpage('check_climate_status.php', 'contentarea');imageHeaderChange('images/header-climate.png');changeIcon('climate');"><img src="./images/climate-off.png" onMouseover="" border=0 id="climate"></a>
397 </td>
398 <td ALIGN=center>
399 <a href="javascript:stopchanges(t);ajaxpage('news.php', 'contentarea');imageHeaderChange('images/header-news.png');changeIcon('news');"><img src="./images/news-off.png" onMouseover="" border=0 id="news"></a>
400 </td>
401 <td ALIGN=center>
402 <a href="javascript:stopchanges(t);weatherpageChange();imageHeaderChange('images/header-recipes.png');changeIcon('receipes');"><img src="./images/receipes-off.png" onMouseover="" border=0 id="receipes"></a>
403 </td>
404 <td ALIGN=center>
405 <a href="javascript:stopchanges(t);ajaxpage('groceries.html', 'contentarea');imageHeaderChange('images/header-groceries.png');changeIcon('groceries');"><img src="./images/groceries-off.png" onMouseover="" border=0 id="groceries"></a>
406 </td>
407 <td ALIGN=center>
408 <a href="javascript:stopchanges(t);;ajaxpage('traffic.html', 'contentarea');imageHeaderChange('images/header-traffic.png');changeIcon('traffic');"><img src="./images/traffic-off.png" onMouseover="" border=0 id="traffic"></a>
409 </td>
410 <td ALIGN=center>
411 <a href="javascript:stopchanges(t);ajaxpage('check_power_status.php', 'contentarea');imageHeaderChange('images/header-power.png');changeIcon('power');"><img src="./images/power-off.png" onMouseover="" border=0 id="power"></a>
412 </td>
413 </tr>
414 <!--
415 <tr>
416 <td ALIGN=center>
417 Weather&nbsp;
418 </td>
419 <td ALIGN=center>
420 Lighting&nbsp;
421 </td>
422 <td ALIGN=center>
423 Music&nbsp;
424 </td>
425 <td ALIGN=center>
426 Cameras&nbsp;
427 </td>
428 <td ALIGN=center>
429 Security&nbsp;
430 </td>
431 <td ALIGN=center>
432 Climate&nbsp;
433 </td>
434 <td ALIGN=center>
435 News&nbsp;
436 </td>
437 <td ALIGN=center>
438 Receipes&nbsp;
439 </td>
440 <td ALIGN=center>
441 Groceries&nbsp;
442 </td>
443 <td ALIGN=center>
444 Traffic&nbsp;
445 </td>
446 <td ALIGN=center>
447 Power&nbsp;
448 </td>
449
450 </tr>
451 -->
452
453 </td></tr></table>
454 </table>
455
456 </div>
457
458 </td></tr>
459 </table>
460
461
462
463
464
465 </body>
466 </html>