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